From 5a98b48521455216ff07ff0ba4bfb52942cc0aff Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Fri, 8 Dec 2023 10:01:01 -0800 Subject: [PATCH] don't set floor if it's negative --- src/CommandFormats.hh | 18 +++++++++--------- src/ReceiveSubcommands.cc | 10 +++++++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/CommandFormats.hh b/src/CommandFormats.hh index 343d6d05..da861b84 100644 --- a/src/CommandFormats.hh +++ b/src/CommandFormats.hh @@ -3936,9 +3936,9 @@ struct G_DestroyNPC_6x1C { // 6x1F: Set player floor -struct G_SetPlayerArea_6x1F { +struct G_SetPlayerFloor_6x1F { G_ClientIDHeader header; - le_uint32_t floor = 0; + le_int32_t floor = 0; } __packed__; // 6x20: Set position @@ -3947,7 +3947,7 @@ struct G_SetPlayerArea_6x1F { struct G_SetPosition_6x20 { G_ClientIDHeader header; - le_uint32_t floor = 0; + le_int32_t floor = 0; le_float x = 0.0f; le_float y = 0.0f; le_float z = 0.0f; @@ -3958,7 +3958,7 @@ struct G_SetPosition_6x20 { struct G_InterLevelWarp_6x21 { G_ClientIDHeader header; - le_uint32_t floor = 0; + le_int32_t floor = 0; } __packed__; // 6x22: Set player invisible @@ -4164,9 +4164,9 @@ struct G_Unknown_6x3B { struct G_StopAtPosition_6x3E { G_ClientIDHeader header; le_uint16_t unknown_a1 = 0; - le_uint16_t unknown_a2 = 0; - le_uint16_t floor = 0; - le_uint16_t unknown_a3 = 0; + le_uint16_t angle = 0; + le_int16_t floor = 0; + le_int16_t room = 0; le_float x = 0.0f; le_float y = 0.0f; le_float z = 0.0f; @@ -4178,8 +4178,8 @@ struct G_SetPosition_6x3F { G_ClientIDHeader header; le_uint16_t unknown_a1 = 0; le_uint16_t angle = 0; - le_uint16_t floor = 0; - le_uint16_t room = 0; + le_int16_t floor = 0; + le_int16_t room = 0; le_float x = 0.0f; le_float y = 0.0f; le_float z = 0.0f; diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index 7e0cde7b..0e03c0fd 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -704,7 +704,9 @@ static void on_set_player_visible(shared_ptr c, uint8_t command, uint8_t template static void on_change_floor(shared_ptr c, uint8_t command, uint8_t flag, const void* data, size_t size) { const auto& cmd = check_size_t(data, size); - c->floor = cmd.floor; + if (cmd.floor >= 0) { + c->floor = cmd.floor; + } forward_subcommand(c, command, flag, data, size, DCNTESubcommand, DC112000ProtoSubcommand); } @@ -838,7 +840,9 @@ void on_movement_with_floor(shared_ptr c, uint8_t command, uint8_t flag, c->x = cmd.x; c->z = cmd.z; - c->floor = cmd.floor; + if (cmd.floor >= 0) { + c->floor = cmd.floor; + } forward_subcommand(c, command, flag, data, size, DCNTESubcommand, DC112000ProtoSubcommand); } @@ -2862,7 +2866,7 @@ SubcommandDefinition subcommand_definitions[0x100] = { /* 6x1C */ {0x00, 0x00, 0x1C, on_forward_check_size_game}, /* 6x1D */ {0x00, 0x00, 0x1D, nullptr}, /* 6x1E */ {0x00, 0x00, 0x1E, nullptr}, - /* 6x1F */ {0x1B, 0x1D, 0x1F, on_change_floor}, + /* 6x1F */ {0x1B, 0x1D, 0x1F, on_change_floor}, /* 6x20 */ {0x1C, 0x1E, 0x20, on_movement_with_floor}, /* 6x21 */ {0x1D, 0x1F, 0x21, on_change_floor}, /* 6x22 */ {0x1E, 0x20, 0x22, on_set_player_invisible},