diff --git a/src/engine/level_script.c b/src/engine/level_script.c index 4f1a77018..83fce25ba 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -643,6 +643,9 @@ static void level_cmd_set_macro_objects(void) { } gAreas[sCurrAreaIndex].macroObjects = alloc_only_pool_alloc(sLevelPool, len * sizeof(MacroObject)); memcpy(gAreas[sCurrAreaIndex].macroObjects, data, len * sizeof(MacroObject)); + + gAreas[sCurrAreaIndex].macroObjectsAltered = alloc_only_pool_alloc(sLevelPool, len * sizeof(u8)); + memset(gAreas[sCurrAreaIndex].macroObjectsAltered, 0, len); } sCurrentCmd = CMD_NEXT; } diff --git a/src/game/area.h b/src/game/area.h index 357c50cd1..cf2827b38 100644 --- a/src/game/area.h +++ b/src/game/area.h @@ -82,6 +82,7 @@ struct Area /*????*/ u8 cachedBehaviors[256]; /*????*/ Vec3f cachedPositions[256]; /*????*/ u32 localAreaTimer; + /*????*/ u8 *macroObjectsAltered; }; // All the transition data to be used in screen_transition.c diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index 4f8bbb26f..8e93ad4a4 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -454,6 +454,10 @@ void set_object_respawn_info_bits(struct Object *obj, u8 bits) { } if (newRespawnInfoBits != oldRespawnInfoBits) { + if (obj->respawnInfoType == RESPAWN_INFO_TYPE_16) { + u16 index = ((s16*)obj->respawnInfo) - gCurrentArea->macroObjects; + gCurrentArea->macroObjectsAltered[index] = 1; + } network_send_level_respawn_info(obj, newRespawnInfoBits); } } diff --git a/src/pc/network/packets/packet_level_macro.c b/src/pc/network/packets/packet_level_macro.c index 04898be0b..0a5643040 100644 --- a/src/pc/network/packets/packet_level_macro.c +++ b/src/pc/network/packets/packet_level_macro.c @@ -87,12 +87,12 @@ static void network_send_level_macro_area(struct NetworkPlayer* destNp, u8 areaI s16* respawnInfo = macroObjList++; // check for special cases - if (*respawnInfo != 0) { + u16 index = respawnInfo - area->macroObjects; + if (area->macroObjectsAltered[index] != 0) { *macroSpecialCount = *macroSpecialCount + 1; - u16 offset = respawnInfo - area->macroObjects; - packet_write(&p, &offset, sizeof(u16)); + packet_write(&p, &index, sizeof(u16)); packet_write(&p, respawnInfo, sizeof(s16)); - LOG_INFO("tx macro special: offset %d, respawnInfo %d", offset, *respawnInfo); + LOG_INFO("tx macro special: index %d, respawnInfo %d", index, *respawnInfo); } } @@ -148,13 +148,14 @@ void network_receive_level_macro(struct Packet* p) { LOG_INFO("rx macro (count %d)", macroDeletionCount); while (macroDeletionCount-- > 0) { - u16 offset; - packet_read(p, &offset, sizeof(u16)); - LOG_INFO("rx macro deletion: offset %d", offset); + u16 index; + packet_read(p, &index, sizeof(u16)); + LOG_INFO("rx macro deletion: index %d", index); // mark respawninfo as dont respawn - s16* respawnInfo = gAreaData[thisAreaIndex].macroObjects + offset; + s16* respawnInfo = gAreaData[thisAreaIndex].macroObjects + index; *respawnInfo |= RESPAWN_INFO_DONT_RESPAWN << 8; + gAreaData[thisAreaIndex].macroObjectsAltered[index] = true; struct Object* o = get_object_matching_respawn_info(respawnInfo); if (o != NULL) { @@ -174,12 +175,13 @@ void network_receive_level_macro(struct Packet* p) { u8 macroSpecialCount; packet_read(p, ¯oSpecialCount, sizeof(u8)); while (macroSpecialCount-- > 0) { - u16 offset; - packet_read(p, &offset, sizeof(u16)); + u16 index; + packet_read(p, &index, sizeof(u16)); - s16* respawnInfo = gAreaData[thisAreaIndex].macroObjects + offset; + s16* respawnInfo = gAreaData[thisAreaIndex].macroObjects + index; packet_read(p, respawnInfo, sizeof(s16)); - LOG_INFO("rx macro special: offset %d, respawnInfo %d", offset, *respawnInfo); + LOG_INFO("rx macro special: index %d, respawnInfo %d", index, *respawnInfo); + gAreaData[thisAreaIndex].macroObjectsAltered[index] = true; s32 presetID = (*(respawnInfo - 4) & 0x1FF) - 31; const BehaviorScript* behavior = MacroObjectPresets[presetID].behavior;