Fix crash in packet_spawn_star

This commit is contained in:
MysterD 2023-05-17 17:48:54 -07:00
parent 521854e481
commit c2f591b930
1 changed files with 13 additions and 8 deletions

View File

@ -37,9 +37,12 @@ void network_receive_spawn_star(struct Packet* p) {
packet_read(p, &behParams, sizeof(u32)); packet_read(p, &behParams, sizeof(u32));
packet_read(p, &networkPlayerIndex, sizeof(u8)); packet_read(p, &networkPlayerIndex, sizeof(u8));
struct Object* oldObject = gCurrentObject;
struct Object* o = NULL;
gCurrentObject = gMarioStates[0].marioObj;
if (gCurrentObject) {
u32 oldBehParams = gCurrentObject->oBehParams; u32 oldBehParams = gCurrentObject->oBehParams;
gCurrentObject->oBehParams = behParams; gCurrentObject->oBehParams = behParams;
struct Object* o = NULL;
switch (starType) { switch (starType) {
case 0: o = spawn_default_star(x, y, z); break; case 0: o = spawn_default_star(x, y, z); break;
case 1: o = spawn_red_coin_cutscene_star(x, y, z); break; case 1: o = spawn_red_coin_cutscene_star(x, y, z); break;
@ -47,6 +50,8 @@ void network_receive_spawn_star(struct Packet* p) {
default: LOG_ERROR("UNKNOWN SPAWN STAR %d", starType); default: LOG_ERROR("UNKNOWN SPAWN STAR %d", starType);
} }
gCurrentObject->oBehParams = oldBehParams; gCurrentObject->oBehParams = oldBehParams;
}
gCurrentObject = oldObject;
if (o != NULL) { if (o != NULL) {
packet_read(p, &o->oPosX, sizeof(u32) * 3); packet_read(p, &o->oPosX, sizeof(u32) * 3);