From bfe8391cc9a4c53c0e5bb4b380219fdcac460d98 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Wed, 14 Jun 2023 09:11:44 -0700 Subject: [PATCH] update some debug messages --- src/CommandFormats.hh | 2 ++ src/ReceiveSubcommands.cc | 35 +++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/CommandFormats.hh b/src/CommandFormats.hh index d87859ef..c76c60aa 100644 --- a/src/CommandFormats.hh +++ b/src/CommandFormats.hh @@ -4283,6 +4283,7 @@ struct G_SyncEnemyState_6x6B_Entry_Decompressed { // Decompressed format is a list of these struct G_SyncObjectState_6x6C_Entry_Decompressed { + // TODO: Verify this format on DC and PC. It appears correct for GC and BB. le_uint16_t flags; le_uint16_t object_index; } __packed__; @@ -4322,6 +4323,7 @@ struct G_SyncItemState_6x6D_Decompressed { // Compressed format is the same as 6x6B. struct G_SyncFlagState_6x6E_Decompressed { + // TODO: Verify this format on DC and PC. It appears correct for GC and BB. // The three unknowns here are the sizes (in bytes) of three fields // immediately following this structure. It is currently unknown what these // fields represent. The three unknown fields always sum to the size field. diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index c5cac538..9f185295 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -183,6 +183,13 @@ static void on_forward_sync_game_state(shared_ptr, throw runtime_error("compressed end offset is beyond end of command"); } + if (c->options.debug) { + string decompressed = bc0_decompress(cmd.data, cmd.compressed_size); + c->log.info("Decompressed sync data (%" PRIX32 " -> %zX bytes; expected %" PRIX32 "):", + cmd.compressed_size.load(), decompressed.size(), cmd.decompressed_size.load()); + print_data(stderr, decompressed); + } + forward_subcommand(l, c, command, flag, data); } @@ -495,7 +502,7 @@ static void on_player_drop_item(shared_ptr, cmd.area.load(), cmd.x.load(), cmd.z.load()); if (c->options.debug) { string name = item.data.name(true); - send_text_message_printf(c, "$C5Items: drop %08" PRIX32 "\n%s", + send_text_message_printf(c, "$C5DROP %08" PRIX32 "\n%s", cmd.item_id.load(), name.c_str()); } c->game_data.player()->print_inventory(stderr); @@ -531,7 +538,7 @@ static void on_create_inventory_item(shared_ptr, cmd.header.client_id.load(), cmd.item.id.load(), name.c_str()); if (c->options.debug) { string name = item.data.name(true); - send_text_message_printf(c, "$C5Items: create %08" PRIX32 "\n%s", + send_text_message_printf(c, "$C5CREATE %08" PRIX32 "\n%s", cmd.item.id.load(), name.c_str()); } c->game_data.player()->print_inventory(stderr); @@ -569,7 +576,7 @@ static void on_drop_partial_stack(shared_ptr, cmd.area.load(), cmd.x.load(), cmd.z.load()); if (c->options.debug) { string name = item.data.name(true); - send_text_message_printf(c, "$C5Items: split %08" PRIX32 "\n%s", + send_text_message_printf(c, "$C5SPLIT %08" PRIX32 "\n%s", item.data.id.load(), name.c_str()); } c->game_data.player()->print_inventory(stderr); @@ -614,7 +621,7 @@ static void on_drop_partial_stack_bb(shared_ptr, cmd.area.load(), cmd.x.load(), cmd.z.load()); if (c->options.debug) { string name = item.data.name(true); - send_text_message_printf(c, "$C5Items: split/BB %08" PRIX32 "\n%s", + send_text_message_printf(c, "$C5SPLIT/BB %08" PRIX32 "\n%s", cmd.item_id.load(), name.c_str()); } c->game_data.player()->print_inventory(stderr); @@ -650,7 +657,7 @@ static void on_buy_shop_item(shared_ptr, cmd.header.client_id.load(), item.data.id.load(), name.c_str()); if (c->options.debug) { string name = item.data.name(true); - send_text_message_printf(c, "$C5Items: buy %08" PRIX32 "\n%s", + send_text_message_printf(c, "$C5BUY %08" PRIX32 "\n%s", item.data.id.load(), name.c_str()); } c->game_data.player()->print_inventory(stderr); @@ -684,7 +691,7 @@ static void on_box_or_enemy_item_drop(shared_ptr, item.data.id.load(), name.c_str(), cmd.area, cmd.x.load(), cmd.z.load()); if (c->options.debug) { string name = item.data.name(true); - send_text_message_printf(c, "$C5Items: drop %08" PRIX32 "\n%s", + send_text_message_printf(c, "$C5DROP %08" PRIX32 "\n%s", item.data.id.load(), name.c_str()); } } @@ -719,7 +726,7 @@ static void on_pick_up_item(shared_ptr, cmd.header.client_id.load(), cmd.item_id.load(), name.c_str()); if (c->options.debug) { string name = item.data.name(true); - send_text_message_printf(c, "$C5Items: pick %08" PRIX32 "\n%s", + send_text_message_printf(c, "$C5PICK %08" PRIX32 "\n%s", cmd.item_id.load(), name.c_str()); } effective_c->game_data.player()->print_inventory(stderr); @@ -751,7 +758,7 @@ static void on_pick_up_item_request(shared_ptr, cmd.header.client_id.load(), cmd.item_id.load(), name.c_str()); if (c->options.debug) { string name = item.data.name(true); - send_text_message_printf(c, "$C5Items: pick/BB %08" PRIX32 "\n%s", + send_text_message_printf(c, "$C5PICK/BB %08" PRIX32 "\n%s", cmd.item_id.load(), name.c_str()); } c->game_data.player()->print_inventory(stderr); @@ -816,7 +823,7 @@ static void on_use_item( l->log.info("Player used item %hu:%08" PRIX32 " (%s)", cmd.header.client_id.load(), cmd.item_id.load(), name.c_str()); if (c->options.debug) { - send_text_message_printf(c, "$C5Items: use %08" PRIX32 "\n%s", + send_text_message_printf(c, "$C5USE %08" PRIX32 "\n%s", cmd.item_id.load(), colored_name.c_str()); } c->game_data.player()->print_inventory(stderr); @@ -866,7 +873,7 @@ static void on_feed_mag( cmd.header.client_id.load(), cmd.fed_item_id.load(), fed_name.c_str(), cmd.header.client_id.load(), cmd.mag_item_id.load(), mag_name.c_str()); if (c->options.debug) { - send_text_message_printf(c, "$C5Items: feed %08" PRIX32 "\n%s\n...to %08" PRIX32 "\n%s", + send_text_message_printf(c, "$C5FEED %08" PRIX32 "\n%s\n...TO %08" PRIX32 "\n%s", cmd.fed_item_id.load(), fed_colored_name.c_str(), cmd.mag_item_id.load(), mag_colored_name.c_str()); } @@ -1249,7 +1256,7 @@ static void on_destroy_inventory_item(shared_ptr, cmd.header.client_id.load(), cmd.item_id.load(), name.c_str()); if (c->options.debug) { string name = item.data.name(true); - send_text_message_printf(c, "$C5Items: destroy %08" PRIX32 "\n%s", + send_text_message_printf(c, "$C5DESTROY %08" PRIX32 "\n%s", cmd.item_id.load(), name.c_str()); } c->game_data.player()->print_inventory(stderr); @@ -1271,7 +1278,7 @@ static void on_destroy_ground_item(shared_ptr, name.c_str()); if (c->options.debug) { string name = item.data.name(true); - send_text_message_printf(c, "$C5Items: destroy/ground %08" PRIX32 "\n%s", + send_text_message_printf(c, "$C5DESTROY/GND %08" PRIX32 "\n%s", cmd.item_id.load(), name.c_str()); } forward_subcommand(l, c, command, flag, data); @@ -1360,7 +1367,7 @@ static void on_sell_item_at_shop_bb(shared_ptr s, c->game_data.player()->print_inventory(stderr); if (c->options.debug) { string name = item.data.name(true); - send_text_message_printf(c, "$C5Items: destroy/sale %08" PRIX32 "\n+%zu Meseta\n%s", + send_text_message_printf(c, "$C5DESTROY/SELL %08" PRIX32 "\n+%zu Meseta\n%s", cmd.item_id.load(), price, name.c_str()); } @@ -1401,7 +1408,7 @@ static void on_buy_shop_item_bb(shared_ptr, c->game_data.player()->print_inventory(stderr); if (c->options.debug) { string name = item.data.name(true); - send_text_message_printf(c, "$C5Items: create/purchase %08" PRIX32 "\n-%zu Meseta\n%s", + send_text_message_printf(c, "$C5CREATE/BUY %08" PRIX32 "\n-%zu Meseta\n%s", cmd.inventory_item_id.load(), price, name.c_str()); } }