From 2af926b46165ee96034849412593bb34c08ad887 Mon Sep 17 00:00:00 2001 From: nolrinale Date: Sat, 23 Dec 2023 02:07:14 +0100 Subject: [PATCH 1/6] Coren labo area client function adjustments --- .gitignore | 1 + .../area-pioneer2/map_labo_on_e.txt | 18 +++++++++--------- notes/psobb/usbb-resources/map_labo_on_e.bin | Bin 52228 -> 52260 bytes 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 4c478abd..91cf872f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ cmake_install.cmake CMakeCache.txt CMakeFiles CTestTestFile.cmake +CTestTestfile.cmake install_manifest.txt Makefile Testing diff --git a/notes/psobb/localized-assets/area-pioneer2/map_labo_on_e.txt b/notes/psobb/localized-assets/area-pioneer2/map_labo_on_e.txt index 7a200e97..7d795cd7 100755 --- a/notes/psobb/localized-assets/area-pioneer2/map_labo_on_e.txt +++ b/notes/psobb/localized-assets/area-pioneer2/map_labo_on_e.txt @@ -1482,9 +1482,9 @@ label02D3@0x02D3: mesend ret -label0370@0x0370: +label0370@0x03D4: // Could not determine data type; disassembling as code - arg_pushl 0x00000418 + arg_pushl 0x00000426 arg_pushs "I am Coren Tsu, a wandering merchant,\nyou could say." message ... arg_pushs "Please take some time to look at\nthe rare and wonderous goods\nI have been collecting." @@ -1503,7 +1503,7 @@ label0370@0x0370: label0371@0x0371: bb_get_number_in_pack r100 jmpi_eq r100, 0x0000001E, label0373 /* 1984 */ - arg_pushl 0x00000418 + arg_pushl 0x00000426 arg_pushs "You may win,\nyou may lose." message ... arg_pushs "But if you don't win,\ndon't take it out on me." @@ -1522,7 +1522,7 @@ label0371@0x0371: ret label0372@0x0372: - arg_pushl 0x00000418 + arg_pushl 0x00000426 arg_pushs "Huh?" message ... arg_pushs "That's too bad..." @@ -1537,7 +1537,7 @@ label0372@0x0372: ret label0373@0x0373: - arg_pushl 0x00000418 + arg_pushl 0x00000426 arg_pushs "It seems you have\ntoo many items." message ... arg_pushs "First, go and\norganize your items," @@ -1569,7 +1569,7 @@ label0376@0x0376: ret label0377@0x0377: - arg_pushl 0x00000418 + arg_pushl 0x00000426 arg_pushs "What?" message ... arg_pushs "You said you'd try,\nthen you said no." @@ -1580,7 +1580,7 @@ label0377@0x0377: ret label0378@0x0378: - arg_pushl 0x00000418 + arg_pushl 0x00000426 arg_pushs "What the...?" message ... arg_pushs "You don't have the\nmeseta to pay me?" @@ -1597,7 +1597,7 @@ label0379@0x0379: clear r105 take_slot_meseta r103-r104, r105 jmpi_eq r105, 0x00000000, label0378 /* 1AA3 */ - arg_pushl 0x00000418 + arg_pushl 0x00000426 arg_pushs "You better pray..." message ... arg_pushs "for something good..." @@ -1649,7 +1649,7 @@ label037C@0x037C: window_msg ... winend sync - arg_pushl 0x00000418 + arg_pushl 0x00000426 arg_pushs "Look here!\nTake it!" message ... arg_pushs "Even if you had bad luck,\nsomething good will come out of it." diff --git a/notes/psobb/usbb-resources/map_labo_on_e.bin b/notes/psobb/usbb-resources/map_labo_on_e.bin index d791d79a4a55d2cad89d5df2de602bb9c986de83..fb5486913ca70f4879633c8bfe1a9449abf240b1 100755 GIT binary patch delta 91 zcmZpf!MtP!Gv^Fu28IiJ7#LJGa&BG5sJ40kvKNd%YQ+j|CLncXl?#X`xrP-;O_pD~ o4oIF`dk-kIcAXnY=F9pyQj-<-vTUAms(^8_;9i-@6Hc)J0PfZz;{X5v delta 83 zcmZ27gSlk}Gv^Fu28IiJ7#LVKa&BG5D6x6}vKNd%YQ+j|CLncXl?#X`xrP-;O_pD~ f4oIF`dk-kIcAXnY=F9pyQj- Date: Sat, 23 Dec 2023 02:15:20 +0100 Subject: [PATCH 2/6] Added Map files to spawn Coren --- notes/psobb/map-files/map_city00_00e.dat | Bin 0 -> 1584 bytes notes/psobb/map-files/map_city02_00_00e.dat | Bin 0 -> 1584 bytes notes/psobb/map-files/map_labo00_00e.dat | Bin 0 -> 1512 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 notes/psobb/map-files/map_city00_00e.dat create mode 100644 notes/psobb/map-files/map_city02_00_00e.dat create mode 100644 notes/psobb/map-files/map_labo00_00e.dat diff --git a/notes/psobb/map-files/map_city00_00e.dat b/notes/psobb/map-files/map_city00_00e.dat new file mode 100644 index 0000000000000000000000000000000000000000..8f3b6c7486e9c6af409c8a27d2ec2600efa2383c GIT binary patch literal 1584 zcmZ{kO-NKx6oAkCdHor4d)s%a4gHJc@;FRmsX1Az2DYhQV?h`DkrO6YSaEjYCUM%sV`Y7nabO(l2~wP~q>Bi0 zA`}o&ob?uPq-j1BWsWU>0miKs`?51u738?DWnHu&r-Gs?6ek1?OVads%XP>#L=rhA z`(tLTN|gktxz7MR$4?X|I(9rQImrk2nDfPT{d|Ab0PBGZ#OX<=L=8IR7a*rNcM4N!+1F%2 zXU^K+9B{B6`yAJEDkTK&v+NBZ8uRzZsI=*P?TrPKT&v89K)!hH=C~DxXjcFOj4fRp z!nKxyr{YOkQM`WC0brUl%OC!`KVW9DmMc_GKAA#J5cX02zL?KRx_xPBYTNy|NUlwi zI6rrb_1IZUzy_cDSDwQ<3ag79<#3cMUi=B-L0&nOqB$cthdh_Ycjm;%8!P2-9pG_# zRJu|$7{&Y5P5)#3(8WRQtDd~|B^(ZSe(rcYm97-c9I=96pOFS*M;8g?Xynxt=gr<} z?gtWctFk0%Xz-UoQ@RTQ~yu=cOGEYyXPl)&G`|fE7k+oi6gCl E0H%ewoB#j- literal 0 HcmV?d00001 diff --git a/notes/psobb/map-files/map_city02_00_00e.dat b/notes/psobb/map-files/map_city02_00_00e.dat new file mode 100644 index 0000000000000000000000000000000000000000..a22886b4981a8fc490fb084052ecfea2dde4bc30 GIT binary patch literal 1584 zcmZ|PPe@cj7y$5ZcV~6gr#^SRRBGGBtV4Au2oig)3q=u0DgB{?mjn-m1s$rb2JFy5 z!b4$DBTGaW2?=@-!g_5&9;HA!NId8ibnuuEy}tRrdGpr(EI2be-#0(MdHe0QLlVr( ztv8E&qFB+(vp`Ci8^!=l#y^-P3B0rvyYe4?37Ia{N88< z{w*}-3;L{kU5OfWxT2(W7NL!tm*Ekr3j#i!hV|Hy+9{J0l$6+tN{Z4_)|m@0kt1Q~ z9fgd;ni>7u=&Vz{fmC7(I)XyNIva4AoNiJ2<6hO$9dweE7u;2%5uG%J)7JUi0lwZ^ zOgZdG{SGj1CB7HvdyVqF?kUlMP7P(%SSJO!_j>E;*U+cX2#x4eJs(dy(FhCA~V`g>$TDd-YtDny@I}=K@qm!ZijCHQ|j?ww=gG>CJ`y(fwvl9CUPT?Ow z@IZ++bm}Nv=XRL1FRObh!^53kamVQjZRJg%YRY=L4^Oi5NC^iW?&EsvK>w?ri|CAA zdBINA`DmGyH_|K8>3P zshu+2Kk$`+L=yP-wADHQ-IYndbIu<0>?&U5$FP6Sp@sD<>F-zkihkz-=FIo}0MF$( NCtjfg7s%0jzX7?yz{&ss literal 0 HcmV?d00001 diff --git a/notes/psobb/map-files/map_labo00_00e.dat b/notes/psobb/map-files/map_labo00_00e.dat new file mode 100644 index 0000000000000000000000000000000000000000..d0de079d7b91f465236be073651350fdc2d6b4ed GIT binary patch literal 1512 zcmZ{k&ubGw6vtn4SZYw|WfXJ*H9DisP)( z9*4bAur(Fwr?m5m`{gb0!1u1GQ;(WjSOgMx6kF6f*Um8Ol^yjAI z{H+jh$M?h60&QPr>oEsO9yZR9CHT36} z;}p#woO=~HY9it+y;>I?t(TXqp8fmNwf70>8g=EHef%@n9@V?xOdz0Y5r^pA98q_J zzlYaF;GA}Ps^&L1HQ`Lgob0^id}J0|PCUCX*5iZYJ3V#X1!od@YAV68I_Nd)Vl(2? zE&!+G^k}ogQEv(L^z9w zpOzM&lk)WaHcU+Gcl*hbwN+Vat```wV)^C^jy*Zz?l(FBj$u$m%m|q&9N@x zJr;tKb)0Kv6PyNelumG1PlB_5UI|tJj^{XwdJ7yaoY|Q3g7t)k?}yY+<;4Ezrvc}L z<1CrK;BY5c&z!tIqC6SfTpQa#oEFZ#;5c`3zc|g~r!!|h*0aiWq0brHXN`D|wVv~N gJ#d`69lXaPi|^q#=D^O&6G+P>?F{rh6b=Ia0awen(EtDd literal 0 HcmV?d00001 From 2ee6119c9398ea1b82ba690655d55bdb99b36805 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Fri, 22 Dec 2023 18:26:14 -0800 Subject: [PATCH 3/6] fix kap and ktp Ep3 env stat expr tokens --- src/Episode3/CardSpecial.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Episode3/CardSpecial.cc b/src/Episode3/CardSpecial.cc index 1a99aab6..cb2eae5b 100644 --- a/src/Episode3/CardSpecial.cc +++ b/src/Episode3/CardSpecial.cc @@ -789,13 +789,16 @@ CardSpecial::AttackEnvStats CardSpecial::compute_attack_env_stats( ast.card_cost = ce->def.self_cost; ast.defined_max_hp = ast.max_hp; - size_t z; + size_t z = 0; + + uint16_t z_ref = pa.attacker_card_ref; // Note: The (z < 9) conditions in these two loops are not present in the // original code. for (z = 0; - ((target_card_ref != pa.attacker_card_ref) && (z < 9) && (pa.action_card_refs[z] != 0xFFFF)); + ((target_card_ref != z_ref) && (z < 9) && ((z_ref = pa.action_card_refs[z]) != 0xFFFF)); z++) { } + ast.action_cards_ap = 0; ast.action_cards_tp = 0; for (; (z < 9) && (pa.action_card_refs[z] != 0xFFFF); z++) { From fa9b4d7f61cb4afb31c8168337be20dbf50b951c Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Fri, 22 Dec 2023 20:21:43 -0800 Subject: [PATCH 4/6] implement $ping on proxy server --- README.md | 2 +- src/ChatCommands.cc | 11 ++++++++++- src/ProxyCommands.cc | 37 ++++++++++++++++++++++++++++--------- src/ProxyServer.hh | 2 ++ 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1dc21f4b..34647008 100644 --- a/README.md +++ b/README.md @@ -283,7 +283,7 @@ Some commands only work on the game server and not on the proxy server. The chat * Information commands * `$li`: Shows basic information about the lobby or game you're in. If you're on the proxy server, shows information about your connection instead (remote Guild Card number, client ID, etc.). - * `$ping` (game server only): Shows round-trip ping time from the server to you. + * `$ping`: Shows round-trip ping time from the server to you. On the proxy server, shows the ping time from you to the proxy and from the proxy to the server. * `$matcount` (game server only): Shows how many of each type of material you've used. * `$what` (game server only): Shows the type, name, and stats of the nearest item on the ground. * `$where` (game server only): Shows your current floor number and coordinates. Mainly useful for debugging. diff --git a/src/ChatCommands.cc b/src/ChatCommands.cc index 08dee740..1c2d1b3f 100644 --- a/src/ChatCommands.cc +++ b/src/ChatCommands.cc @@ -168,6 +168,15 @@ static void server_command_ping(shared_ptr c, const std::string&) { send_command(c, 0x1D, 0x00); } +static void proxy_command_ping(shared_ptr ses, const std::string&) { + ses->client_ping_start_time = now(); + ses->server_ping_start_time = now(); + + C_GuildCardSearch_40 cmd = {0x00010000, ses->remote_guild_card_number, ses->remote_guild_card_number}; + ses->client_channel.send(0x1D, 0x00); + ses->server_channel.send(0x40, 0x00, &cmd, sizeof(cmd)); +} + static void proxy_command_lobby_info(shared_ptr ses, const std::string&) { string msg; // On non-masked-GC sessions (BB), there is no remote Guild Card number, so we @@ -1883,7 +1892,7 @@ static const unordered_map chat_commands({ {"$password", {server_command_password, nullptr}}, {"$patch", {server_command_patch, proxy_command_patch}}, {"$persist", {server_command_persist, nullptr}}, - {"$ping", {server_command_ping, nullptr}}, + {"$ping", {server_command_ping, proxy_command_ping}}, {"$playrec", {server_command_playrec, nullptr}}, {"$qcall", {server_command_qcall, proxy_command_qcall}}, {"$qcheck", {server_command_qcheck, nullptr}}, diff --git a/src/ProxyCommands.cc b/src/ProxyCommands.cc index 970c5644..69bd0d4c 100644 --- a/src/ProxyCommands.cc +++ b/src/ProxyCommands.cc @@ -119,6 +119,12 @@ static HandlerResult C_05(shared_ptr ses, uint16_t, } static HandlerResult C_1D(shared_ptr ses, uint16_t, uint32_t, string&) { + if (ses->client_ping_start_time) { + uint64_t ping_usecs = now() - ses->client_ping_start_time; + ses->client_ping_start_time = 0; + double ping_ms = static_cast(ping_usecs) / 1000.0; + send_text_message_printf(ses->client_channel, "To proxy: %gms", ping_ms); + } return ses->config.check_flag(Client::Flag::PROXY_SUPPRESS_CLIENT_PINGS) ? HandlerResult::Type::SUPPRESS : HandlerResult::Type::FORWARD; @@ -566,19 +572,32 @@ static HandlerResult S_V123_06(shared_ptr ses, uint1 template static HandlerResult S_41(shared_ptr ses, uint16_t, uint32_t, string& data) { - bool modified = false; if (ses->license) { auto& cmd = check_size_t(data); - if (cmd.searcher_guild_card_number == ses->remote_guild_card_number) { - cmd.searcher_guild_card_number = ses->license->serial_number; - modified = true; - } - if (cmd.result_guild_card_number == ses->remote_guild_card_number) { - cmd.result_guild_card_number = ses->license->serial_number; - modified = true; + if ((cmd.searcher_guild_card_number == ses->remote_guild_card_number) && + (cmd.result_guild_card_number == ses->remote_guild_card_number) && + ses->server_ping_start_time) { + uint64_t ping_usecs = now() - ses->server_ping_start_time; + ses->server_ping_start_time = 0; + double ping_ms = static_cast(ping_usecs) / 1000.0; + send_text_message_printf(ses->client_channel, "To server: %gms", ping_ms); + return HandlerResult::Type::SUPPRESS; + + } else { + bool modified = false; + if (cmd.searcher_guild_card_number == ses->remote_guild_card_number) { + cmd.searcher_guild_card_number = ses->license->serial_number; + modified = true; + } + if (cmd.result_guild_card_number == ses->remote_guild_card_number) { + cmd.result_guild_card_number = ses->license->serial_number; + modified = true; + } + return modified ? HandlerResult::Type::MODIFIED : HandlerResult::Type::FORWARD; } + } else { + return HandlerResult::Type::FORWARD; } - return modified ? HandlerResult::Type::MODIFIED : HandlerResult::Type::FORWARD; } constexpr on_command_t S_DGX_41 = &S_41; diff --git a/src/ProxyServer.hh b/src/ProxyServer.hh index 62dbcbad..b74e7e42 100644 --- a/src/ProxyServer.hh +++ b/src/ProxyServer.hh @@ -91,6 +91,8 @@ public: bool is_in_game; bool is_in_quest; uint8_t difficulty; + uint64_t client_ping_start_time = 0; + uint64_t server_ping_start_time = 0; std::shared_ptr detector_crypt; From 4de23561b0f4afa5961b98b218e5025cbf84e5e4 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Fri, 22 Dec 2023 21:52:51 -0800 Subject: [PATCH 5/6] add option to unmask Ep3 whispers on proxy server, and prevent this from working on newserv --- src/Client.hh | 1 + src/Menu.hh | 1 + src/ProxyCommands.cc | 27 ++++++++++++++++++-- src/ReceiveCommands.cc | 11 ++++++++- src/ReceiveSubcommands.cc | 52 ++++++++++++++++++++++++++++++++++++++- src/Text.hh | 7 ++++++ 6 files changed, 95 insertions(+), 4 deletions(-) diff --git a/src/Client.hh b/src/Client.hh index 11ccaafd..16442fe2 100644 --- a/src/Client.hh +++ b/src/Client.hh @@ -79,6 +79,7 @@ public: PROXY_RED_NAME_ENABLED = 0x0000200000000000, PROXY_BLANK_NAME_ENABLED = 0x0000400000000000, PROXY_BLOCK_FUNCTION_CALLS = 0x0000800000000000, + PROXY_EP3_UNMASK_WHISPERS = 0x0008000000000000, // clang-format on }; diff --git a/src/Menu.hh b/src/Menu.hh index 7bfb68c0..33468a60 100644 --- a/src/Menu.hh +++ b/src/Menu.hh @@ -75,6 +75,7 @@ constexpr uint32_t SUPPRESS_LOGIN = 0xAA0D0DAA; constexpr uint32_t SKIP_CARD = 0xAA0E0EAA; constexpr uint32_t EP3_INFINITE_MESETA = 0xAA0F0FAA; constexpr uint32_t EP3_INFINITE_TIME = 0xAA1010AA; +constexpr uint32_t EP3_UNMASK_WHISPERS = 0xAA1111AA; } // namespace ProxyOptionsMenuItemID namespace TeamRewardMenuItemID { diff --git a/src/ProxyCommands.cc b/src/ProxyCommands.cc index 69bd0d4c..2fc6cb55 100644 --- a/src/ProxyCommands.cc +++ b/src/ProxyCommands.cc @@ -560,14 +560,28 @@ static HandlerResult S_V123_04(shared_ptr ses, uint1 } static HandlerResult S_V123_06(shared_ptr ses, uint16_t, uint32_t, string& data) { + bool modified = false; if (ses->license) { auto& cmd = check_size_t(data, 0xFFFF); if (cmd.guild_card_number == ses->remote_guild_card_number) { cmd.guild_card_number = ses->license->serial_number; - return HandlerResult::Type::MODIFIED; + modified = true; } } - return HandlerResult::Type::FORWARD; + + // If the session is Ep3, and Unmask Whispers is on, and there's enough data, + // and the message has private_flags, and the private_flags say that you + // shouldn't see the message, then change the private_flags + if (is_ep3(ses->version()) && + ses->config.check_flag(Client::Flag::PROXY_EP3_UNMASK_WHISPERS) && + (data.size() >= 12) && + (data[sizeof(SC_TextHeader_01_06_11_B0_EE)] != '\t') && + (data[sizeof(SC_TextHeader_01_06_11_B0_EE)] & (1 << ses->lobby_client_id))) { + data[sizeof(SC_TextHeader_01_06_11_B0_EE)] &= ~(1 << ses->lobby_client_id); + modified = true; + } + + return modified ? HandlerResult::Type::MODIFIED : HandlerResult::Type::FORWARD; } template @@ -1031,6 +1045,15 @@ static HandlerResult S_6x(shared_ptr ses, uint16_t, return HandlerResult::Type::SUPPRESS; } } + + } else if ((static_cast(data[0]) == 0xBD) && + ses->config.check_flag(Client::Flag::PROXY_EP3_UNMASK_WHISPERS) && + is_ep3(ses->version())) { + auto& cmd = check_size_t(data); + if (cmd.private_flags & (1 << ses->lobby_client_id)) { + cmd.private_flags &= ~(1 << ses->lobby_client_id); + modified = true; + } } } diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index a18e27ca..44aa022e 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -69,6 +69,8 @@ static shared_ptr proxy_options_menu_for_client(shared_ptrconfig.override_lobby_event != 0xFF), @@ -2229,6 +2231,9 @@ static void on_10(shared_ptr c, uint16_t, uint32_t, string& data) { case ProxyOptionsMenuItemID::EP3_INFINITE_TIME: c->config.toggle_flag(Client::Flag::PROXY_EP3_INFINITE_TIME_ENABLED); goto resend_proxy_options_menu; + case ProxyOptionsMenuItemID::EP3_UNMASK_WHISPERS: + c->config.toggle_flag(Client::Flag::PROXY_EP3_UNMASK_WHISPERS); + goto resend_proxy_options_menu; case ProxyOptionsMenuItemID::BLOCK_EVENTS: c->config.override_lobby_event = (c->config.override_lobby_event == 0xFF) ? 0x00 : 0xFF; goto resend_proxy_options_menu; @@ -3172,7 +3177,11 @@ static void on_06(shared_ptr c, uint16_t, uint32_t, string& data) { } for (size_t x = 0; x < l->max_clients; x++) { if (l->clients[x]) { - send_chat_message(l->clients[x], c->license->serial_number, from_name, text, private_flags); + if (private_flags & (1 << x)) { + send_chat_message(l->clients[x], c->license->serial_number, from_name, "(whisper)", private_flags); + } else { + send_chat_message(l->clients[x], c->license->serial_number, from_name, text, private_flags); + } } } for (const auto& watcher_l : l->watcher_lobbies) { diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index 74a84cf3..bbaafdaa 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -1637,7 +1637,57 @@ static void on_ep3_private_word_select_bb_bank_action(shared_ptr c, uint } } else if (is_ep3(c->version())) { - forward_subcommand(c, command, flag, data, size); + + const auto& cmd = check_size_t(data, size); + G_WordSelectDuringBattle_GC_Ep3_6xBD masked_cmd = { + {0xBD, sizeof(G_WordSelectDuringBattle_GC_Ep3_6xBD) >> 2, cmd.header.client_id}, + 0x0001, + 0x0001, + // "Please use the Whispers function." + {0x00C1, 0x02C7, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF}, + 0x0000, + 0x0000, + cmd.private_flags, + {0, 0, 0}}; + + auto send_to_client = [&](shared_ptr lc) -> void { + if (cmd.private_flags & (1 << lc->lobby_client_id)) { + send_command_t(lc, command, flag, masked_cmd); + } else { + send_command_t(lc, command, flag, cmd); + } + }; + + if (command_is_private(command)) { + if (flag >= l->max_clients) { + return; + } + auto target = l->clients[flag]; + if (target) { + send_to_client(target); + } + } else { + for (auto& lc : l->clients) { + if (lc && (lc != c) && is_ep3(lc->version())) { + send_to_client(lc); + } + } + } + + for (const auto& watcher_lobby : l->watcher_lobbies) { + for (auto& target : watcher_lobby->clients) { + if (target && is_ep3(target->version())) { + send_command(target, command, flag, data, size); + } + } + } + + if (l->battle_record && l->battle_record->battle_in_progress()) { + auto type = ((command & 0xF0) == 0xC0) + ? Episode3::BattleRecord::Event::Type::EP3_GAME_COMMAND + : Episode3::BattleRecord::Event::Type::GAME_COMMAND; + l->battle_record->add_command(type, data, size); + } } } diff --git a/src/Text.hh b/src/Text.hh index 1ce75692..0b1d2834 100644 --- a/src/Text.hh +++ b/src/Text.hh @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -58,6 +59,12 @@ struct parray { parray(ItemT v) { this->clear(v); } + parray(std::initializer_list init_items) { + for (size_t z = 0; z < init_items.size(); z++) { + this->items[z] = std::data(init_items)[z]; + } + this->clear_after(init_items.size()); + } template requires(std::is_arithmetic_v || is_converted_endian_sc_v) parray() { From cf7c4674d6e23f347398c23f4b49c6f2069e6746 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Fri, 22 Dec 2023 21:54:59 -0800 Subject: [PATCH 6/6] add decode-sjis action --- src/Main.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Main.cc b/src/Main.cc index 86ecc09b..7306a94a 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -1142,6 +1142,13 @@ Action a_extract_bml("extract-bml", "\ PC/BB format.\n", a_extract_archive_fn); +Action a_decode_sjis( + "decode-sjis", nullptr, +[](Arguments& args) { + string data = read_input_data(args); + string result = tt_sjis_to_utf8(data); + write_output_data(args, result.data(), result.size(), "txt"); + }); + Action a_decode_text_archive( "decode-text-archive", nullptr, +[](Arguments& args) { string data = read_input_data(args);