diff --git a/src/ChatCommands.cc b/src/ChatCommands.cc index c36712d0..6aaa4c4b 100644 --- a/src/ChatCommands.cc +++ b/src/ChatCommands.cc @@ -410,7 +410,8 @@ static void command_lobby_info(shared_ptr, shared_ptr l, static void command_ax(shared_ptr, shared_ptr, shared_ptr c, const char16_t* args) { check_privileges(c, Privilege::Announce); - log(INFO, "[$ax from %010u] %S\n", c->license->serial_number, args); + string message = encode_sjis(args); + log(INFO, "[$ax from %010u] %s\n", c->license->serial_number, message.c_str()); } static void command_announce(shared_ptr s, shared_ptr, diff --git a/src/Lobby.cc b/src/Lobby.cc index f8fc55cb..c262a0e4 100644 --- a/src/Lobby.cc +++ b/src/Lobby.cc @@ -96,8 +96,9 @@ void Lobby::remove_client(shared_ptr c) { if (this->clients[c->lobby_client_id] != c) { auto other_c = this->clients[c->lobby_client_id].get(); throw logic_error(string_printf( - "client\'s lobby client id (%hhu) does not match client list (%hhu)", - c->lobby_client_id, other_c ? other_c->lobby_client_id : 0xFF)); + "client\'s lobby client id (%hhu) does not match client list (%u)", + c->lobby_client_id, + static_cast(other_c ? other_c->lobby_client_id : 0xFF))); } this->clients[c->lobby_client_id] = NULL; diff --git a/src/Player.cc b/src/Player.cc index 06e97fb7..7524b266 100644 --- a/src/Player.cc +++ b/src/Player.cc @@ -656,8 +656,8 @@ size_t PlayerBank::find_item(uint32_t item_id) { } string filename_for_player_bb(const string& username, uint8_t player_index) { - return string_printf("system/players/player_%s_%ld.nsc", username.c_str(), - player_index + 1); + return string_printf("system/players/player_%s_%hhu.nsc", username.c_str(), + static_cast(player_index + 1)); } string filename_for_bank_bb(const string& username, const char* bank_name) { diff --git a/src/Quest.cc b/src/Quest.cc index 1ad8b471..dd8d90ea 100644 --- a/src/Quest.cc +++ b/src/Quest.cc @@ -392,12 +392,13 @@ string Quest::decode_gci(const string& filename) { } string data_to_decompress = compressed_data_with_header.substr(sizeof(DecryptedHeader)); - string decompressed_data = prs_decompress(data_to_decompress); + size_t decompressed_bytes = prs_decompress_size(data_to_decompress); - if (decompressed_data.size() < dh->decompressed_size - 8) { + size_t expected_decompressed_bytes = dh->decompressed_size - 8; + if (decompressed_bytes < expected_decompressed_bytes) { throw runtime_error(string_printf( "GCI decompressed data is smaller than expected size (have 0x%zX bytes, expected 0x%zX bytes)", - decompressed_data.size(), dh->decompressed_size - 8)); + decompressed_bytes, expected_decompressed_bytes)); } // The caller expects to get PRS-compressed data when calling bin_contents() diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index 5564f59e..771aa323 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -1013,7 +1013,7 @@ void process_player_data(shared_ptr s, shared_ptr c, } try { - string filename = string_printf("system/players/player_%s_player%ld.nsb", + string filename = string_printf("system/players/player_%s_player%d.nsb", c->pending_bb_save_username.c_str(), c->pending_bb_save_player_index + 1); c->player.bank.save(filename); } catch (const exception& e) { diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index eb697624..5d8d6465 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -33,14 +33,16 @@ struct ItemSubcommand { void check_size(uint16_t size, uint16_t min_size, uint16_t max_size) { if (size < min_size) { - throw runtime_error(string_printf("command too small (expected at least %zX bytes, got %zX bytes)", + throw runtime_error(string_printf( + "command too small (expected at least 0x%hX bytes, got 0x%hX bytes)", min_size, size)); } if (max_size == 0) { max_size = min_size; } if (size > max_size) { - throw runtime_error(string_printf("command too large (expected at most %zX bytes, got %zX bytes)", + throw runtime_error(string_printf( + "command too large (expected at most 0x%hX bytes, got 0x%hX bytes)", max_size, size)); } } @@ -872,10 +874,10 @@ static void process_subcommand_invalid(shared_ptr, shared_ptr, shared_ptr, uint8_t command, uint8_t flag, const PSOSubcommand* p, size_t count) { if (command_is_private(command)) { - log(WARNING, "invalid subcommand: %02X (%d of them) (private to player %d)", + log(WARNING, "invalid subcommand: %02hhX (%zu of them) (private to player %hhu)", p->byte[0], count, flag); } else { - log(WARNING, "invalid subcommand: %02X (%d of them) (public)", + log(WARNING, "invalid subcommand: %02hhX (%zu of them) (public)", p->byte[0], count); } } @@ -885,10 +887,10 @@ static void process_subcommand_unimplemented(shared_ptr, shared_ptr, shared_ptr, uint8_t command, uint8_t flag, const PSOSubcommand* p, size_t count) { if (command_is_private(command)) { - log(WARNING, "unknown subcommand: %02X (%d of them) (private to player %d)", + log(WARNING, "unknown subcommand: %02hhX (%zu of them) (private to player %hhu)", p->byte[0], count, flag); } else { - log(WARNING, "unknown subcommand: %02X (%d of them) (public)", + log(WARNING, "unknown subcommand: %02hhX (%zu of them) (public)", p->byte[0], count); } } diff --git a/src/SendCommands.cc b/src/SendCommands.cc index 4e664a06..c5a7ef12 100644 --- a/src/SendCommands.cc +++ b/src/SendCommands.cc @@ -1,5 +1,6 @@ #include "SendCommands.hh" +#include #include #include @@ -2060,7 +2061,7 @@ void send_ep3_map_list(shared_ptr l) { // sends the map data for the chosen map to all players in the game void send_ep3_map_data(shared_ptr l, uint32_t map_id) { - string filename = string_printf("system/ep3/map%08lX.mnm", map_id); + string filename = string_printf("system/ep3/map%08" PRIX32 ".mnm", map_id); auto file_data = file_cache.get(filename); string data(12, '\0');