From f8044a5639ff6acb96c1038b3ce0bdb1527f0c7b Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 7 Sep 2020 20:54:15 -0700 Subject: [PATCH] Make send_spawn_objects more reliable As noticed by anuserlol, stars would sometimes not spawn from breakable boxes on the remote. This was due to the box being destroyed before the star spawned, when the star tried to spawn it couldn't find the parent and gave up. Now if no parent is found the spawned object will be its own parent. This should make all spawned objects more reliable, but may cause weirdness somewhere. Fixes #34 --- src/pc/network/packets/packet_spawn_objects.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pc/network/packets/packet_spawn_objects.c b/src/pc/network/packets/packet_spawn_objects.c index ceb200503..3e906df0f 100644 --- a/src/pc/network/packets/packet_spawn_objects.c +++ b/src/pc/network/packets/packet_spawn_objects.c @@ -108,7 +108,13 @@ void network_receive_spawn_objects(struct Packet* p) { parentObj = (i == 0) ? gSyncObjects[data.parentId].o : spawned[data.parentId]; - if (parentObj == NULL) { continue; } + if (parentObj == NULL) { + // failed to find parent, make it it's own parent + // may cause issues, but we want it to spawn! + printf("ERROR: failed to find spawn object's parent (%d)!\n", data.parentId); + parentObj = gMarioStates[0].marioObj; + data.parentId = (u8)-1; + } } void* behavior = (void*)get_behavior_from_id(data.behaviorId);