update for string_printf and log format warnings
This commit is contained in:
+2
-1
@@ -410,7 +410,8 @@ static void command_lobby_info(shared_ptr<ServerState>, shared_ptr<Lobby> l,
|
|||||||
static void command_ax(shared_ptr<ServerState>, shared_ptr<Lobby>,
|
static void command_ax(shared_ptr<ServerState>, shared_ptr<Lobby>,
|
||||||
shared_ptr<Client> c, const char16_t* args) {
|
shared_ptr<Client> c, const char16_t* args) {
|
||||||
check_privileges(c, Privilege::Announce);
|
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<ServerState> s, shared_ptr<Lobby>,
|
static void command_announce(shared_ptr<ServerState> s, shared_ptr<Lobby>,
|
||||||
|
|||||||
+3
-2
@@ -96,8 +96,9 @@ void Lobby::remove_client(shared_ptr<Client> c) {
|
|||||||
if (this->clients[c->lobby_client_id] != c) {
|
if (this->clients[c->lobby_client_id] != c) {
|
||||||
auto other_c = this->clients[c->lobby_client_id].get();
|
auto other_c = this->clients[c->lobby_client_id].get();
|
||||||
throw logic_error(string_printf(
|
throw logic_error(string_printf(
|
||||||
"client\'s lobby client id (%hhu) does not match client list (%hhu)",
|
"client\'s lobby client id (%hhu) does not match client list (%u)",
|
||||||
c->lobby_client_id, other_c ? other_c->lobby_client_id : 0xFF));
|
c->lobby_client_id,
|
||||||
|
static_cast<uint8_t>(other_c ? other_c->lobby_client_id : 0xFF)));
|
||||||
}
|
}
|
||||||
|
|
||||||
this->clients[c->lobby_client_id] = NULL;
|
this->clients[c->lobby_client_id] = NULL;
|
||||||
|
|||||||
+2
-2
@@ -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) {
|
string filename_for_player_bb(const string& username, uint8_t player_index) {
|
||||||
return string_printf("system/players/player_%s_%ld.nsc", username.c_str(),
|
return string_printf("system/players/player_%s_%hhu.nsc", username.c_str(),
|
||||||
player_index + 1);
|
static_cast<uint8_t>(player_index + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
string filename_for_bank_bb(const string& username, const char* bank_name) {
|
string filename_for_bank_bb(const string& username, const char* bank_name) {
|
||||||
|
|||||||
+4
-3
@@ -392,12 +392,13 @@ string Quest::decode_gci(const string& filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string data_to_decompress = compressed_data_with_header.substr(sizeof(DecryptedHeader));
|
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(
|
throw runtime_error(string_printf(
|
||||||
"GCI decompressed data is smaller than expected size (have 0x%zX bytes, expected 0x%zX bytes)",
|
"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()
|
// The caller expects to get PRS-compressed data when calling bin_contents()
|
||||||
|
|||||||
@@ -1013,7 +1013,7 @@ void process_player_data(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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->pending_bb_save_username.c_str(), c->pending_bb_save_player_index + 1);
|
||||||
c->player.bank.save(filename);
|
c->player.bank.save(filename);
|
||||||
} catch (const exception& e) {
|
} catch (const exception& e) {
|
||||||
|
|||||||
@@ -33,14 +33,16 @@ struct ItemSubcommand {
|
|||||||
|
|
||||||
void check_size(uint16_t size, uint16_t min_size, uint16_t max_size) {
|
void check_size(uint16_t size, uint16_t min_size, uint16_t max_size) {
|
||||||
if (size < min_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));
|
min_size, size));
|
||||||
}
|
}
|
||||||
if (max_size == 0) {
|
if (max_size == 0) {
|
||||||
max_size = min_size;
|
max_size = min_size;
|
||||||
}
|
}
|
||||||
if (size > max_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));
|
max_size, size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -872,10 +874,10 @@ static void process_subcommand_invalid(shared_ptr<ServerState>,
|
|||||||
shared_ptr<Lobby>, shared_ptr<Client>, uint8_t command, uint8_t flag,
|
shared_ptr<Lobby>, shared_ptr<Client>, uint8_t command, uint8_t flag,
|
||||||
const PSOSubcommand* p, size_t count) {
|
const PSOSubcommand* p, size_t count) {
|
||||||
if (command_is_private(command)) {
|
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);
|
p->byte[0], count, flag);
|
||||||
} else {
|
} else {
|
||||||
log(WARNING, "invalid subcommand: %02X (%d of them) (public)",
|
log(WARNING, "invalid subcommand: %02hhX (%zu of them) (public)",
|
||||||
p->byte[0], count);
|
p->byte[0], count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -885,10 +887,10 @@ static void process_subcommand_unimplemented(shared_ptr<ServerState>,
|
|||||||
shared_ptr<Lobby>, shared_ptr<Client>, uint8_t command, uint8_t flag,
|
shared_ptr<Lobby>, shared_ptr<Client>, uint8_t command, uint8_t flag,
|
||||||
const PSOSubcommand* p, size_t count) {
|
const PSOSubcommand* p, size_t count) {
|
||||||
if (command_is_private(command)) {
|
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);
|
p->byte[0], count, flag);
|
||||||
} else {
|
} else {
|
||||||
log(WARNING, "unknown subcommand: %02X (%d of them) (public)",
|
log(WARNING, "unknown subcommand: %02hhX (%zu of them) (public)",
|
||||||
p->byte[0], count);
|
p->byte[0], count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
#include "SendCommands.hh"
|
#include "SendCommands.hh"
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -2060,7 +2061,7 @@ void send_ep3_map_list(shared_ptr<Lobby> l) {
|
|||||||
|
|
||||||
// sends the map data for the chosen map to all players in the game
|
// sends the map data for the chosen map to all players in the game
|
||||||
void send_ep3_map_data(shared_ptr<Lobby> l, uint32_t map_id) {
|
void send_ep3_map_data(shared_ptr<Lobby> 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);
|
auto file_data = file_cache.get(filename);
|
||||||
|
|
||||||
string data(12, '\0');
|
string data(12, '\0');
|
||||||
|
|||||||
Reference in New Issue
Block a user