make BB proxy's Save Files option generate .psochar files

This commit is contained in:
Martin Michelsen
2025-03-18 20:54:20 -07:00
parent 02c3d35d78
commit 52d019a321
2 changed files with 8 additions and 5 deletions
+2 -2
View File
@@ -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. * **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 events**: disables holiday events sent by the remote server.
* **Block patches**: prevents any B2 (patch) commands from reaching the client. * **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) * Online quests and download quests (saved as .bin/.dat files)
* GBA games (saved as .gba files) * GBA games (saved as .gba files)
* Patches (saved as .bin files and disassembled as .txt 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 online quests and maps (saved as .mnmd files)
* Episode 3 download quests (saved as .mnm files) * Episode 3 download quests (saved as .mnm files)
* Episode 3 card definitions (saved as .mnr files) * Episode 3 card definitions (saved as .mnr files)
+6 -3
View File
@@ -836,10 +836,13 @@ static HandlerResult C_B3(shared_ptr<ProxyServer::LinkedSession> ses, uint16_t,
} }
} }
static HandlerResult S_B_E7(shared_ptr<ProxyServer::LinkedSession> ses, uint16_t, uint32_t, string& data) { static HandlerResult S_B_E7(shared_ptr<ProxyServer::LinkedSession> ses, uint16_t command, uint32_t flag, string& data) {
if (ses->config.check_flag(Client::Flag::PROXY_SAVE_FILES)) { if (ses->config.check_flag(Client::Flag::PROXY_SAVE_FILES)) {
string output_filename = phosg::string_printf("player.%" PRId64 ".bin", phosg::now()); string output_filename = phosg::string_printf("player.%" PRId64 ".psochar", phosg::now());
phosg::save_file(output_filename, data); 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()); ses->log.info("Wrote player data to file %s", output_filename.c_str());
} }
return HandlerResult::Type::FORWARD; return HandlerResult::Type::FORWARD;