Force players who are held by an entity to own that entity

This commit is contained in:
MysterD 2020-08-31 22:36:07 -07:00
parent 2b70dcc255
commit cc9300f969
1 changed files with 6 additions and 0 deletions

View File

@ -327,6 +327,7 @@ void network_receive_object(struct Packet* p) {
if (so == NULL) { return; }
struct Object* o = so->o;
if (!network_sync_object_initialized(o)) { return; }
if (gMarioStates[0].heldByObj == o) { return; }
// make sure no one can update an object we're holding
if (gMarioStates[0].heldObj == o) { return; }
@ -344,6 +345,11 @@ void network_receive_object(struct Packet* p) {
}
bool should_own_object(struct SyncObject* so) {
if (gMarioStates[0].heldByObj == so->o) { return true; }
for (int i = 0; i < MAX_PLAYERS; i++) {
if (gMarioStates[i].heldByObj == so->o) { return false; }
}
if (so->o->oHeldState == HELD_HELD && so->o->heldByPlayerIndex == 0) { return true; }
if (player_distance(&gMarioStates[0], so->o) > player_distance(&gMarioStates[1], so->o)) { return false; }
if (so->o->oHeldState == HELD_HELD && so->o->heldByPlayerIndex != 0) { return false; }