show client player name in sent/received commands
This commit is contained in:
+4
-2
@@ -708,7 +708,8 @@ static void command_silence(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
|||||||
}
|
}
|
||||||
|
|
||||||
target->can_chat = !target->can_chat;
|
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" : "");
|
target->can_chat ? "un" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -730,7 +731,8 @@ static void command_kick(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
|||||||
|
|
||||||
send_message_box(target, u"$C6You were kicked off by a moderator.");
|
send_message_box(target, u"$C6You were kicked off by a moderator.");
|
||||||
target->should_disconnect = true;
|
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<ServerState> s, shared_ptr<Lobby> l,
|
static void command_ban(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ Client::Client(
|
|||||||
this->is_virtual_connection = false;
|
this->is_virtual_connection = false;
|
||||||
get_socket_addresses(fd, &this->local_addr, &this->remote_addr);
|
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));
|
memset(&this->next_connection_addr, 0, sizeof(this->next_connection_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ struct ClientConfigBB {
|
|||||||
struct Client {
|
struct Client {
|
||||||
// License & account
|
// License & account
|
||||||
std::shared_ptr<const License> license;
|
std::shared_ptr<const License> license;
|
||||||
char16_t name[0x20];
|
|
||||||
ClientConfigBB config;
|
ClientConfigBB config;
|
||||||
GameVersion version;
|
GameVersion version;
|
||||||
uint16_t flags;
|
uint16_t flags;
|
||||||
|
|||||||
@@ -1018,7 +1018,8 @@ void process_player_data(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
|||||||
if (!failure) {
|
if (!failure) {
|
||||||
send_text_message_printf(c,
|
send_text_message_printf(c,
|
||||||
"$C6PSOBB player data saved\nas player %hhu for user\n%s",
|
"$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<uint8_t>(c->pending_bb_save_player_index + 1),
|
||||||
|
c->pending_bb_save_username.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
c->pending_bb_save_username.clear();
|
c->pending_bb_save_username.clear();
|
||||||
@@ -2168,8 +2169,12 @@ void process_command(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
|||||||
uint16_t command, uint32_t flag, uint16_t size, const void* data) {
|
uint16_t command, uint32_t flag, uint16_t size, const void* data) {
|
||||||
// TODO: this is slow; make it better somehow
|
// TODO: this is slow; make it better somehow
|
||||||
{
|
{
|
||||||
log(INFO, "Received version=%d size=%04hX command=%04hX flag=%08X",
|
string name_token;
|
||||||
static_cast<int>(c->version), size, command, flag);
|
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<int>(c->version), size, command, flag);
|
||||||
|
|
||||||
string data_to_print;
|
string data_to_print;
|
||||||
if (c->version == GameVersion::BB) {
|
if (c->version == GameVersion::BB) {
|
||||||
|
|||||||
+6
-1
@@ -74,7 +74,12 @@ void send_command(shared_ptr<Client> c, uint16_t command, uint32_t flag,
|
|||||||
throw logic_error("unimplemented game version in send_command");
|
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<int>(c->version), size, command, flag);
|
||||||
print_data(stderr, send_data.data(), send_data.size());
|
print_data(stderr, send_data.data(), send_data.size());
|
||||||
|
|
||||||
c->send(move(send_data));
|
c->send(move(send_data));
|
||||||
|
|||||||
+2
-1
@@ -109,7 +109,8 @@ void send_simple_mail(std::shared_ptr<Client> c, uint32_t from_serial_number,
|
|||||||
const char16_t* from_name, const char16_t* text);
|
const char16_t* from_name, const char16_t* text);
|
||||||
|
|
||||||
template <typename TARGET>
|
template <typename TARGET>
|
||||||
void send_text_message_printf(std::shared_ptr<TARGET> t, const char* format, ...) {
|
__attribute__((format(printf, 2, 3))) void send_text_message_printf(
|
||||||
|
std::shared_ptr<TARGET> t, const char* format, ...) {
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, format);
|
va_start(va, format);
|
||||||
std::string buf = string_vprintf(format, va);
|
std::string buf = string_vprintf(format, va);
|
||||||
|
|||||||
Reference in New Issue
Block a user