From 0c459294bbd3f50ba866d2118caed22a79036974 Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 14 Jun 2021 21:06:07 -0700 Subject: [PATCH] Fixed the merry go round in BBH Fixed releasing of sync objects that otherwise don't sync their death events Fixed using/releasing reserved objects in an area that the server isn't in --- src/game/behaviors/boo.inc.c | 4 ++-- src/game/spawn_object.c | 13 +++++++++++-- src/pc/network/packets/packet_reservation_list.c | 4 +++- src/pc/network/packets/packet_reservation_release.c | 7 ++++--- src/pc/network/packets/packet_reservation_use.c | 7 ++++--- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/game/behaviors/boo.inc.c b/src/game/behaviors/boo.inc.c index d6f5c0399..a9be437d6 100644 --- a/src/game/behaviors/boo.inc.c +++ b/src/game/behaviors/boo.inc.c @@ -859,7 +859,7 @@ void bhv_merry_go_round_boo_manager_loop(void) { switch (o->oAction) { case 0: if (distanceToPlayer < 1000.0f) { - if (gNetworkType == NT_SERVER && o->oMerryGoRoundBooManagerNumBoosKilled < 5) { + if (player == gMarioObjects[0] && o->oMerryGoRoundBooManagerNumBoosKilled < 5) { if (o->oMerryGoRoundBooManagerNumBoosSpawned < 5) { if (o->oMerryGoRoundBooManagerNumBoosSpawned - o->oMerryGoRoundBooManagerNumBoosKilled < 2) { struct Object* boo = spawn_object(o, MODEL_BOO, bhvMerryGoRoundBoo); @@ -878,7 +878,7 @@ void bhv_merry_go_round_boo_manager_loop(void) { } if (o->oMerryGoRoundBooManagerNumBoosKilled > 4) { - if (gNetworkType == NT_SERVER) { + if (player == gMarioObjects[0]) { struct Object* boo = spawn_object(o, MODEL_BOO, bhvMerryGoRoundBigBoo); obj_copy_behavior_params(boo, o); diff --git a/src/game/spawn_object.c b/src/game/spawn_object.c index 9f4788a9f..b577d88fa 100644 --- a/src/game/spawn_object.c +++ b/src/game/spawn_object.c @@ -13,6 +13,7 @@ #include "spawn_object.h" #include "types.h" #include "pc/network/network.h" +#include "pc/network/reservation_area.h" /** * An unused linked list struct that seems to have been replaced by ObjectNode. @@ -198,8 +199,16 @@ void unload_object(struct Object *obj) { obj->header.gfx.node.flags &= ~GRAPH_RENDER_CYLBOARD; obj->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; - if (obj->oSyncID != 0 && gSyncObjects[obj->oSyncID].syncDeathEvent) { - network_send_object(obj); + if (obj->oSyncID != 0) { + if (gSyncObjects[obj->oSyncID].syncDeathEvent) { + network_send_object(obj); + } else { + if (gNetworkType == NT_SERVER) { + reservation_area_release(gNetworkPlayerLocal, obj->oSyncID); + } else { + network_send_reservation_release(obj->oSyncID); + } + } } deallocate_object(&gFreeObjectList, &obj->header); diff --git a/src/pc/network/packets/packet_reservation_list.c b/src/pc/network/packets/packet_reservation_list.c index 7a2bbff37..b4944e0ff 100644 --- a/src/pc/network/packets/packet_reservation_list.c +++ b/src/pc/network/packets/packet_reservation_list.c @@ -7,7 +7,7 @@ #include "course_table.h" #include "src/game/interaction.h" #include "src/engine/math_util.h" -#define DISABLE_MODULE_LOG 1 +//#define DISABLE_MODULE_LOG 1 #include "pc/debuglog.h" void network_send_reservation_list(struct NetworkPlayer* np, u8 syncIds[]) { @@ -26,10 +26,12 @@ void network_send_reservation_list(struct NetworkPlayer* np, u8 syncIds[]) { } network_send_to(np->localIndex, &p); + LOG_INFO("tx reservation list"); } void network_receive_reservation_list(struct Packet* p) { assert(gNetworkType == NT_CLIENT); + LOG_INFO("rx reservation list"); u8 courseNum, actNum, levelNum, areaIndex; packet_read(p, &courseNum, sizeof(u8)); diff --git a/src/pc/network/packets/packet_reservation_release.c b/src/pc/network/packets/packet_reservation_release.c index a4e86bfb0..fcc1fea73 100644 --- a/src/pc/network/packets/packet_reservation_release.c +++ b/src/pc/network/packets/packet_reservation_release.c @@ -7,7 +7,7 @@ #include "course_table.h" #include "src/game/interaction.h" #include "src/engine/math_util.h" -#define DISABLE_MODULE_LOG 1 +//#define DISABLE_MODULE_LOG 1 #include "pc/debuglog.h" void network_send_reservation_release(u8 syncId) { @@ -28,10 +28,12 @@ void network_send_reservation_release(u8 syncId) { packet_write(&p, &syncId, sizeof(u8)); network_send_to(gNetworkPlayerServer->localIndex, &p); + LOG_INFO("tx reservation release"); } void network_receive_reservation_release(struct Packet* p) { assert(gNetworkType == NT_SERVER); + LOG_INFO("rx reservation release"); struct NetworkPlayer* np = &gNetworkPlayers[p->localIndex]; if (np == NULL || np->localIndex == UNKNOWN_LOCAL_INDEX || !np->connected) { @@ -45,8 +47,7 @@ void network_receive_reservation_release(struct Packet* p) { packet_read(p, &levelNum, sizeof(u8)); packet_read(p, &areaIndex, sizeof(u8)); - extern s16 gCurrCourseNum, gCurrActStarNum, gCurrLevelNum, gCurrAreaIndex; - if (courseNum != gCurrCourseNum || actNum != gCurrActStarNum || levelNum != gCurrLevelNum || areaIndex != gCurrAreaIndex) { + if (courseNum != np->currCourseNum || actNum != np->currActNum || levelNum != np->currLevelNum || areaIndex != np->currAreaIndex) { LOG_ERROR("received an improper location"); return; } diff --git a/src/pc/network/packets/packet_reservation_use.c b/src/pc/network/packets/packet_reservation_use.c index d72232dd6..334f9b78d 100644 --- a/src/pc/network/packets/packet_reservation_use.c +++ b/src/pc/network/packets/packet_reservation_use.c @@ -7,7 +7,7 @@ #include "course_table.h" #include "src/game/interaction.h" #include "src/engine/math_util.h" -#define DISABLE_MODULE_LOG 1 +//#define DISABLE_MODULE_LOG 1 #include "pc/debuglog.h" void network_send_reservation_use(u8 syncId) { @@ -28,10 +28,12 @@ void network_send_reservation_use(u8 syncId) { packet_write(&p, &syncId, sizeof(u8)); network_send_to(gNetworkPlayerServer->localIndex, &p); + LOG_INFO("tx reservation use"); } void network_receive_reservation_use(struct Packet* p) { assert(gNetworkType == NT_SERVER); + LOG_INFO("rx reservation use"); struct NetworkPlayer* np = &gNetworkPlayers[p->localIndex]; if (np == NULL || np->localIndex == UNKNOWN_LOCAL_INDEX || !np->connected) { @@ -45,8 +47,7 @@ void network_receive_reservation_use(struct Packet* p) { packet_read(p, &levelNum, sizeof(u8)); packet_read(p, &areaIndex, sizeof(u8)); - extern s16 gCurrCourseNum, gCurrActStarNum, gCurrLevelNum, gCurrAreaIndex; - if (courseNum != gCurrCourseNum || actNum != gCurrActStarNum || levelNum != gCurrLevelNum || areaIndex != gCurrAreaIndex) { + if (courseNum != np->currCourseNum || actNum != np->currActNum|| levelNum != np->currLevelNum || areaIndex != np->currAreaIndex) { LOG_ERROR("received an improper location"); return; }