implement simple mail on pc
This commit is contained in:
@@ -1031,14 +1031,18 @@ struct S_Unknown_PC_V3_80 {
|
|||||||
// uninitialized data for security reasons before forwarding and things seem to
|
// uninitialized data for security reasons before forwarding and things seem to
|
||||||
// work fine.
|
// work fine.
|
||||||
|
|
||||||
struct SC_SimpleMail_V3_81 {
|
template <typename CharT>
|
||||||
|
struct SC_SimpleMail_81 {
|
||||||
le_uint32_t player_tag;
|
le_uint32_t player_tag;
|
||||||
le_uint32_t from_guild_card_number;
|
le_uint32_t from_guild_card_number;
|
||||||
ptext<char, 0x10> from_name;
|
ptext<CharT, 0x10> from_name;
|
||||||
le_uint32_t to_guild_card_number;
|
le_uint32_t to_guild_card_number;
|
||||||
ptext<char, 0x200> text;
|
ptext<CharT, 0x200> text;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SC_SimpleMail_PC_81 : SC_SimpleMail_81<char16_t> { };
|
||||||
|
struct SC_SimpleMail_V3_81 : SC_SimpleMail_81<char> { };
|
||||||
|
|
||||||
// 82: Invalid command
|
// 82: Invalid command
|
||||||
|
|
||||||
// 83 (S->C): Lobby menu
|
// 83 (S->C): Lobby menu
|
||||||
|
|||||||
+20
-7
@@ -1724,15 +1724,25 @@ void process_choice_search(shared_ptr<ServerState>, shared_ptr<Client> c,
|
|||||||
|
|
||||||
void process_simple_mail(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
void process_simple_mail(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||||
uint16_t, uint32_t, const string& data) { // 81
|
uint16_t, uint32_t, const string& data) { // 81
|
||||||
if ((c->version != GameVersion::GC) && (c->version != GameVersion::XB)) {
|
u16string message;
|
||||||
// TODO: implement this for non-V3
|
uint32_t to_guild_card_number;
|
||||||
|
if ((c->version == GameVersion::GC) || (c->version == GameVersion::XB)) {
|
||||||
|
const auto& cmd = check_size_t<SC_SimpleMail_V3_81>(data);
|
||||||
|
to_guild_card_number = cmd.to_guild_card_number;
|
||||||
|
message = decode_sjis(cmd.text);
|
||||||
|
|
||||||
|
} else if (c->version == GameVersion::PC) {
|
||||||
|
const auto& cmd = check_size_t<SC_SimpleMail_PC_81>(data);
|
||||||
|
to_guild_card_number = cmd.to_guild_card_number;
|
||||||
|
message = cmd.text;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// TODO
|
||||||
send_text_message(c, u"$C6Simple Mail is not\nsupported yet on\nthis platform.");
|
send_text_message(c, u"$C6Simple Mail is not\nsupported yet on\nthis platform.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& cmd = check_size_t<SC_SimpleMail_V3_81>(data);
|
auto target = s->find_client(nullptr, to_guild_card_number);
|
||||||
|
|
||||||
auto target = s->find_client(nullptr, cmd.to_guild_card_number);
|
|
||||||
|
|
||||||
// If the sender is blocked, don't forward the mail
|
// If the sender is blocked, don't forward the mail
|
||||||
for (size_t y = 0; y < 30; y++) {
|
for (size_t y = 0; y < 30; y++) {
|
||||||
@@ -1749,8 +1759,11 @@ void process_simple_mail(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Forward the message
|
// Forward the message
|
||||||
u16string msg = decode_sjis(cmd.text);
|
send_simple_mail(
|
||||||
send_simple_mail(target, c->license->serial_number, c->game_data.player()->disp.name, msg);
|
target,
|
||||||
|
c->license->serial_number,
|
||||||
|
c->game_data.player()->disp.name,
|
||||||
|
message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+12
-4
@@ -556,9 +556,13 @@ void send_chat_message(shared_ptr<Client> c, uint32_t from_guild_card_number,
|
|||||||
send_header_text(c->channel, 0x06, from_guild_card_number, data, false);
|
send_header_text(c->channel, 0x06, from_guild_card_number, data, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_simple_mail_v3(shared_ptr<Client> c, uint32_t from_guild_card_number,
|
template <typename CmdT>
|
||||||
const u16string& from_name, const u16string& text) {
|
void send_simple_mail_t(
|
||||||
SC_SimpleMail_V3_81 cmd;
|
shared_ptr<Client> c,
|
||||||
|
uint32_t from_guild_card_number,
|
||||||
|
const u16string& from_name,
|
||||||
|
const u16string& text) {
|
||||||
|
CmdT cmd;
|
||||||
cmd.player_tag = 0x00010000;
|
cmd.player_tag = 0x00010000;
|
||||||
cmd.from_guild_card_number = from_guild_card_number;
|
cmd.from_guild_card_number = from_guild_card_number;
|
||||||
cmd.from_name = from_name;
|
cmd.from_name = from_name;
|
||||||
@@ -570,7 +574,11 @@ void send_simple_mail_v3(shared_ptr<Client> c, uint32_t from_guild_card_number,
|
|||||||
void send_simple_mail(shared_ptr<Client> c, uint32_t from_guild_card_number,
|
void send_simple_mail(shared_ptr<Client> c, uint32_t from_guild_card_number,
|
||||||
const u16string& from_name, const u16string& text) {
|
const u16string& from_name, const u16string& text) {
|
||||||
if ((c->version == GameVersion::GC) || (c->version == GameVersion::XB)) {
|
if ((c->version == GameVersion::GC) || (c->version == GameVersion::XB)) {
|
||||||
send_simple_mail_v3(c, from_guild_card_number, from_name, text);
|
send_simple_mail_t<SC_SimpleMail_V3_81>(
|
||||||
|
c, from_guild_card_number, from_name, text);
|
||||||
|
} else if (c->version == GameVersion::PC) {
|
||||||
|
send_simple_mail_t<SC_SimpleMail_PC_81>(
|
||||||
|
c, from_guild_card_number, from_name, text);
|
||||||
} else {
|
} else {
|
||||||
throw logic_error("unimplemented versioned command");
|
throw logic_error("unimplemented versioned command");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user