diff --git a/src/ChatCommands.cc b/src/ChatCommands.cc index 87665fad..77a86457 100644 --- a/src/ChatCommands.cc +++ b/src/ChatCommands.cc @@ -708,7 +708,8 @@ static void command_silence(shared_ptr s, shared_ptr l, } target->can_chat = !target->can_chat; - send_text_message_printf(l, "$C6%s %ssilenced", target->player.disp.name, + string target_name_sjis = encode_sjis(target->player.disp.name); + send_text_message_printf(l, "$C6%s %ssilenced", target_name_sjis.c_str(), target->can_chat ? "un" : ""); } @@ -730,7 +731,8 @@ static void command_kick(shared_ptr s, shared_ptr l, send_message_box(target, u"$C6You were kicked off by a moderator."); target->should_disconnect = true; - send_text_message_printf(l, "$C6%s kicked off", target->player.disp.name); + string target_name_sjis = encode_sjis(target->player.disp.name); + send_text_message_printf(l, "$C6%s kicked off", target_name_sjis.c_str()); } static void command_ban(shared_ptr s, shared_ptr l, diff --git a/src/Client.cc b/src/Client.cc index 3c917bc4..ae0f21e2 100644 --- a/src/Client.cc +++ b/src/Client.cc @@ -45,7 +45,6 @@ Client::Client( this->is_virtual_connection = false; get_socket_addresses(fd, &this->local_addr, &this->remote_addr); } - memset(this->name, 0, sizeof(this->name)); memset(&this->next_connection_addr, 0, sizeof(this->next_connection_addr)); } diff --git a/src/Client.hh b/src/Client.hh index f4dcd21d..0f902c64 100644 --- a/src/Client.hh +++ b/src/Client.hh @@ -35,7 +35,6 @@ struct ClientConfigBB { struct Client { // License & account std::shared_ptr license; - char16_t name[0x20]; ClientConfigBB config; GameVersion version; uint16_t flags; diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index bd028e8d..9f5aa04d 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -1018,7 +1018,8 @@ void process_player_data(shared_ptr s, shared_ptr c, if (!failure) { send_text_message_printf(c, "$C6PSOBB player data saved\nas player %hhu for user\n%s", - c->pending_bb_save_player_index + 1, c->pending_bb_save_username.c_str()); + static_cast(c->pending_bb_save_player_index + 1), + c->pending_bb_save_username.c_str()); } c->pending_bb_save_username.clear(); @@ -2168,8 +2169,12 @@ void process_command(shared_ptr s, shared_ptr c, uint16_t command, uint32_t flag, uint16_t size, const void* data) { // TODO: this is slow; make it better somehow { - log(INFO, "Received version=%d size=%04hX command=%04hX flag=%08X", - static_cast(c->version), size, command, flag); + string name_token; + if (c->player.disp.name[0]) { + name_token = " from " + remove_language_marker(encode_sjis(c->player.disp.name)); + } + log(INFO, "Received%s version=%d size=%04hX command=%04hX flag=%08X", + name_token.c_str(), static_cast(c->version), size, command, flag); string data_to_print; if (c->version == GameVersion::BB) { diff --git a/src/SendCommands.cc b/src/SendCommands.cc index 85f1f711..8b426d8e 100644 --- a/src/SendCommands.cc +++ b/src/SendCommands.cc @@ -74,7 +74,12 @@ void send_command(shared_ptr c, uint16_t command, uint32_t flag, throw logic_error("unimplemented game version in send_command"); } - log(INFO, "Sending command"); + string name_token; + if (c->player.disp.name[0]) { + name_token = " to " + remove_language_marker(encode_sjis(c->player.disp.name)); + } + log(INFO, "Sending%s version=%d size=%04zX command=%04hX flag=%08X", + name_token.c_str(), static_cast(c->version), size, command, flag); print_data(stderr, send_data.data(), send_data.size()); c->send(move(send_data)); diff --git a/src/SendCommands.hh b/src/SendCommands.hh index d8fd4161..c66c641f 100644 --- a/src/SendCommands.hh +++ b/src/SendCommands.hh @@ -109,7 +109,8 @@ void send_simple_mail(std::shared_ptr c, uint32_t from_serial_number, const char16_t* from_name, const char16_t* text); template -void send_text_message_printf(std::shared_ptr t, const char* format, ...) { +__attribute__((format(printf, 2, 3))) void send_text_message_printf( + std::shared_ptr t, const char* format, ...) { va_list va; va_start(va, format); std::string buf = string_vprintf(format, va);