move patch server message to config file

This commit is contained in:
Martin Michelsen
2022-08-02 20:52:41 -07:00
parent 09f0d1f3de
commit 293cc86092
4 changed files with 25 additions and 19 deletions
+6 -17
View File
@@ -2372,7 +2372,7 @@ void process_encryption_ok_patch(shared_ptr<ServerState>, shared_ptr<Client> c,
send_command(c, 0x04, 0x00); // This requests the user's login information
}
void process_login_patch(shared_ptr<ServerState>, shared_ptr<Client> c,
void process_login_patch(shared_ptr<ServerState> s, shared_ptr<Client> c,
uint16_t, uint32_t, const string& data) {
const auto& cmd = check_size_t<C_Login_Patch_04>(data);
@@ -2382,24 +2382,13 @@ void process_login_patch(shared_ptr<ServerState>, shared_ptr<Client> c,
// On BB we can use colors and newlines should be \n; on PC we can't use
// colors, the text is auto-word-wrapped, and newlines should be \r\n.
u16string message;
if (c->flags & Client::Flag::BB_PATCH) {
message = u"\
$C7newserv patch server\n\
\n\
This server is not affiliated with, sponsored by, or in any\n\
other way connected to SEGA or Sonic Team, and is owned\n\
and operated completely independently.";
} else {
message = u"\
newserv patch server\r\n\
\r\n\
This server is not affiliated with, sponsored by, or in any other way \
connected to SEGA or Sonic Team, and is owned and operated completely \
independently.";
const u16string& message = (c->flags & Client::Flag::BB_PATCH)
? s->bb_patch_server_message : s->pc_patch_server_message;
if (!message.empty()) {
send_message_box(c, message.c_str());
}
send_message_box(c, message.c_str());
// TODO: Implement patch serving for realz.
send_enter_directory_patch(c, ".");
send_enter_directory_patch(c, "data");
send_enter_directory_patch(c, "scene");
+6
View File
@@ -389,4 +389,10 @@ void ServerState::create_menus(shared_ptr<const JSONObject> config_json) {
try {
this->welcome_message = decode_sjis(d.at("WelcomeMessage")->as_string());
} catch (const out_of_range&) { }
try {
this->pc_patch_server_message = decode_sjis(d.at("PCPatchServerMessage")->as_string());
} catch (const out_of_range&) { }
try {
this->bb_patch_server_message = decode_sjis(d.at("BBPatchServerMessage")->as_string());
} catch (const out_of_range&) { }
}
+3 -1
View File
@@ -20,7 +20,7 @@
// Forwawrd declarations due to reference cycles
// Forward declarations due to reference cycles
class ProxyServer;
class Server;
@@ -73,6 +73,8 @@ struct ServerState {
std::pair<std::string, uint16_t> proxy_destination_patch;
std::pair<std::string, uint16_t> proxy_destination_bb;
std::u16string welcome_message;
std::u16string pc_patch_server_message;
std::u16string bb_patch_server_message;
std::map<int64_t, std::shared_ptr<Lobby>> id_to_lobby;
std::vector<std::shared_ptr<Lobby>> public_lobby_search_order;