diff --git a/src/CommandFormats.hh b/src/CommandFormats.hh index 4caed01c..0520023a 100644 --- a/src/CommandFormats.hh +++ b/src/CommandFormats.hh @@ -4559,7 +4559,7 @@ struct G_CreateTelepipe_6x68 { struct G_NPCControl_6x69 { G_UnusedHeader header; le_uint16_t state = 0; - le_uint16_t npc_client_id = 0; + le_uint16_t npc_entity_id = 0; le_uint16_t command = 0; // 0 = create follower NPC, 1 = stop acting, 2 = start acting, 3 = create attacker NPC le_uint16_t npc_template_index = 0; // Specifies which NPC to create if command == 0 or 3; unused otherwise } __packed__; @@ -4673,8 +4673,6 @@ struct G_SetQuestFlags_6x6F { // 6x70: Sync player disp data and inventory (used while loading into game) // Annoyingly, they didn't use the same format as the 65/67/68 commands here, // and instead rearranged a bunch of things. -// Episode 3 does not send this command, since the relevant data is sent to the -// joining player in the 64 command instead. struct Telepipe { /* 00 */ le_uint16_t client_id; diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index 231fd9b2..40bcece2 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -451,12 +451,11 @@ static void on_sync_joining_player_disp_and_inventory( break; case Version::GC_NTE: case Version::GC_V3: + case Version::GC_EP3_TRIAL_EDITION: + case Version::GC_EP3: gc_cmd = &check_size_t(data, size); base = &gc_cmd->base; break; - case Version::GC_EP3_TRIAL_EDITION: - case Version::GC_EP3: - throw runtime_error("Episode 3 should not send 6x70 commands"); case Version::XB_V3: xb_cmd = &check_size_t(data, size); base = &xb_cmd->base; @@ -1018,10 +1017,7 @@ static void on_npc_control(shared_ptr c, uint8_t command, uint8_t flag, if (!l->is_game()) { throw runtime_error("cannot create NPCs in the lobby"); } - if (cmd.npc_client_id >= 4) { - throw runtime_error("NPC client ID is not valid"); - } - if (l->clients[cmd.npc_client_id]) { + if ((cmd.npc_entity_id < 4) && l->clients[cmd.npc_entity_id]) { throw runtime_error("cannot overwrite existing player with NPC"); } forward_subcommand(c, command, flag, data, size); diff --git a/src/Text.hh b/src/Text.hh index e70a7fe4..1ce75692 100644 --- a/src/Text.hh +++ b/src/Text.hh @@ -427,7 +427,7 @@ struct pstring { return std::string(reinterpret_cast(&this->data[0]), this->used_chars_8()); case TextEncoding::CHALLENGE16: { std::string decrypted(reinterpret_cast(&this->data[0]), this->used_chars_16() * 2); - decrypt_challenge_rank_text_t(decrypted.data(), decrypted.size()); + decrypt_challenge_rank_text_t(decrypted.data(), decrypted.size() / 2); return tt_utf16_to_utf8(decrypted.data(), decrypted.size()); } case TextEncoding::MARKED: { diff --git a/system/ppc/Episode3USAQuestBufferOverflow.s b/system/ppc/Episode3USAQuestBufferOverflow.s index 89ed28e8..e444291b 100644 --- a/system/ppc/Episode3USAQuestBufferOverflow.s +++ b/system/ppc/Episode3USAQuestBufferOverflow.s @@ -148,7 +148,7 @@ handle_B2: stw [r1 + 0x44], r0 # Arguments: - # r3 = PSONetworkContext* ctx (we use this to call the send function) + # r3 = TProtocol* proto (we use this to call the send function) # r4 = void* data # Returns: void @@ -244,7 +244,7 @@ handle_B2_skip_code: mtctr r4 addi r4, r1, 0x08 li r5, 0x0C - bctrl # PSONetworkContext::send_command(ctx, &reply_data, 0x0C) + bctrl # TProtocol::send_command(ctx, &reply_data, 0x0C) # Clean up stack and return lwz r0, [r1 + 0x44]