fixed a bug where sync objects could be duplicated (#35)

this would happen if the sync object was spawned before the other players in the level's area sync was valid
This commit is contained in:
Isaac0-dev 2024-05-10 19:32:50 +10:00 committed by GitHub
parent 533404ca10
commit 8845b3ef0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 0 deletions

View File

@ -158,6 +158,21 @@ void network_receive_spawn_objects(struct Packet* p) {
id = gNetworkSystem->get_id_str(p->localIndex);
name = gNetworkPlayers[p->localIndex].name;
}
// Don't overwrite existing sync objects
{
u32 syncID = data.rawData[0x04]; // o->oSyncID
struct SyncObject *so = sync_object_get(syncID);
if (so && so->o) {
if (so->o->behavior == get_behavior_from_id(data.behaviorId)) {
LOG_ERROR("recieved duplicate sync object with id %d from %s (%s)", syncID, name, id);
} else {
LOG_ERROR("recieved duplicate sync object with id %d with different behavior %s from %s (%s)", syncID, get_behavior_name_from_id(data.behaviorId), name, id);
}
continue;
}
}
LOG_INFO("rx spawn object %s from %s (%s)", get_behavior_name_from_id(data.behaviorId), name, id);
LOG_CONSOLE("rx spawn object %s from %s\\#dcdcdc\\ (%s)", get_behavior_name_from_id(data.behaviorId), name, id);
snprintf(gLastRemoteBhv, 256, "%s %s (%s)", get_behavior_name_from_id(data.behaviorId), name, id);