diff --git a/README.md b/README.md index d9f3c89a..f4b49165 100644 --- a/README.md +++ b/README.md @@ -512,11 +512,11 @@ There are many options available when starting a proxy session. All options are * **Infinite Meseta** (Episode 3 only): gives you 1,000,000 Meseta, regardless of the value sent by the remote server. * **Block events**: disables holiday events sent by the remote server. * **Block patches**: prevents any B2 (patch) commands from reaching the client. -* **Save files**: saves copies of several kinds of files when they're sent by the remote server. The files are written to the current directory (which is usually the directory containing the system/ directory). These kinds of files can be saved: +* **Save files**: saves copies of several kinds of files when they're sent by the remote server. The files are written to the current directory (which is usually the directory containing the system/ directory). Saved files can then be used with newserv by just moving the file into the appropriate place in the system/ directory and renaming it appropriately. These kinds of files can be saved: * Online quests and download quests (saved as .bin/.dat files) * GBA games (saved as .gba files) * Patches (saved as .bin files and disassembled as .txt files) - * Player data from BB sessions (saved as .bin files, which are not the same format as .nsc or .psochar files) + * Player data from BB sessions (saved as .psochar files) * Episode 3 online quests and maps (saved as .mnmd files) * Episode 3 download quests (saved as .mnm files) * Episode 3 card definitions (saved as .mnr files) diff --git a/src/ProxyCommands.cc b/src/ProxyCommands.cc index 17728be9..e4b2eec8 100644 --- a/src/ProxyCommands.cc +++ b/src/ProxyCommands.cc @@ -836,10 +836,13 @@ static HandlerResult C_B3(shared_ptr ses, uint16_t, } } -static HandlerResult S_B_E7(shared_ptr ses, uint16_t, uint32_t, string& data) { +static HandlerResult S_B_E7(shared_ptr ses, uint16_t command, uint32_t flag, string& data) { if (ses->config.check_flag(Client::Flag::PROXY_SAVE_FILES)) { - string output_filename = phosg::string_printf("player.%" PRId64 ".bin", phosg::now()); - phosg::save_file(output_filename, data); + string output_filename = phosg::string_printf("player.%" PRId64 ".psochar", phosg::now()); + auto f = phosg::fopen_unique(output_filename, "wb"); + PSOCommandHeaderBB header = {data.size() + sizeof(PSOCommandHeaderBB), command, flag}; + phosg::fwritex(f.get(), &header, sizeof(header)); + phosg::fwritex(f.get(), data); ses->log.info("Wrote player data to file %s", output_filename.c_str()); } return HandlerResult::Type::FORWARD;