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
|
||||
// work fine.
|
||||
|
||||
struct SC_SimpleMail_V3_81 {
|
||||
template <typename CharT>
|
||||
struct SC_SimpleMail_81 {
|
||||
le_uint32_t player_tag;
|
||||
le_uint32_t from_guild_card_number;
|
||||
ptext<char, 0x10> from_name;
|
||||
ptext<CharT, 0x10> from_name;
|
||||
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
|
||||
|
||||
// 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,
|
||||
uint16_t, uint32_t, const string& data) { // 81
|
||||
if ((c->version != GameVersion::GC) && (c->version != GameVersion::XB)) {
|
||||
// TODO: implement this for non-V3
|
||||
u16string message;
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& cmd = check_size_t<SC_SimpleMail_V3_81>(data);
|
||||
|
||||
auto target = s->find_client(nullptr, cmd.to_guild_card_number);
|
||||
auto target = s->find_client(nullptr, to_guild_card_number);
|
||||
|
||||
// If the sender is blocked, don't forward the mail
|
||||
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
|
||||
u16string msg = decode_sjis(cmd.text);
|
||||
send_simple_mail(target, c->license->serial_number, c->game_data.player()->disp.name, msg);
|
||||
send_simple_mail(
|
||||
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);
|
||||
}
|
||||
|
||||
void send_simple_mail_v3(shared_ptr<Client> c, uint32_t from_guild_card_number,
|
||||
const u16string& from_name, const u16string& text) {
|
||||
SC_SimpleMail_V3_81 cmd;
|
||||
template <typename CmdT>
|
||||
void send_simple_mail_t(
|
||||
shared_ptr<Client> c,
|
||||
uint32_t from_guild_card_number,
|
||||
const u16string& from_name,
|
||||
const u16string& text) {
|
||||
CmdT cmd;
|
||||
cmd.player_tag = 0x00010000;
|
||||
cmd.from_guild_card_number = from_guild_card_number;
|
||||
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,
|
||||
const u16string& from_name, const u16string& text) {
|
||||
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 {
|
||||
throw logic_error("unimplemented versioned command");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user