mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-04-26 12:01:43 +00:00
Only send respawn info for macro objects when they are altered
This commit is contained in:
parent
d17aa69052
commit
84ab07bde6
4 changed files with 22 additions and 12 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue