add option to disable save_files globally

This commit is contained in:
Martin Michelsen
2022-12-13 23:53:06 -08:00
parent ae49ca0189
commit cf2f1ef529
6 changed files with 27 additions and 7 deletions
+6
View File
@@ -154,6 +154,12 @@ void populate_state_from_config(shared_ptr<ServerState> s,
s->catch_handler_exceptions = true;
}
try {
s->proxy_allow_save_files = d.at("ProxyAllowSaveFiles")->as_bool();
} catch (const out_of_range&) {
s->proxy_allow_save_files = true;
}
try {
s->ep3_behavior_flags = d.at("Episode3BehaviorFlags")->as_int();
} catch (const out_of_range&) {
+8 -6
View File
@@ -81,7 +81,7 @@ static const unordered_map<uint32_t, const char16_t*> proxy_options_menu_descrip
});
static vector<MenuItem> proxy_options_menu_for_client(
shared_ptr<const Client> c) {
shared_ptr<ServerState> s, shared_ptr<const Client> c) {
vector<MenuItem> ret;
// Note: The descriptions are instead in the map above, because this menu is
// dynamically created every time it's sent to the client. This is just one
@@ -100,8 +100,10 @@ static vector<MenuItem> proxy_options_menu_for_client(
c->proxy_block_events ? u"Block events ON" : u"Block events OFF", u"", 0);
ret.emplace_back(ProxyOptionsMenuItemID::BLOCK_PATCHES,
c->proxy_block_function_calls ? u"Block patches ON" : u"Block patches OFF", u"", 0);
ret.emplace_back(ProxyOptionsMenuItemID::SAVE_FILES,
c->proxy_save_files ? u"Save files ON" : u"Save files OFF", u"", 0);
if (s->proxy_allow_save_files) {
ret.emplace_back(ProxyOptionsMenuItemID::SAVE_FILES,
c->proxy_save_files ? u"Save files ON" : u"Save files OFF", u"", 0);
}
ret.emplace_back(ProxyOptionsMenuItemID::SUPPRESS_LOGIN,
c->proxy_suppress_remote_login ? u"Skip login ON" : u"Skip login OFF", u"", 0);
ret.emplace_back(ProxyOptionsMenuItemID::SKIP_CARD,
@@ -131,7 +133,7 @@ static void send_client_to_proxy_server(shared_ptr<ServerState> s, shared_ptr<Cl
session->infinite_hp = c->infinite_hp;
session->infinite_tp = c->infinite_tp;
session->switch_assist = c->switch_assist;
session->save_files = c->proxy_save_files;
session->save_files = s->proxy_allow_save_files && c->proxy_save_files;
session->suppress_remote_login = c->proxy_suppress_remote_login;
if (c->proxy_block_events) {
session->override_lobby_event = 0;
@@ -1682,7 +1684,7 @@ static void on_menu_selection(shared_ptr<ServerState> s, shared_ptr<Client> c,
c->proxy_zero_remote_guild_card = !c->proxy_zero_remote_guild_card;
resend_proxy_options_menu:
send_menu(c, s->name.c_str(), MenuID::PROXY_OPTIONS,
proxy_options_menu_for_client(c));
proxy_options_menu_for_client(s, c));
break;
default:
send_message_box(c, u"Incorrect menu item ID.");
@@ -1697,7 +1699,7 @@ static void on_menu_selection(shared_ptr<ServerState> s, shared_ptr<Client> c,
} else if (item_id == ProxyDestinationsMenuItemID::OPTIONS) {
send_menu(c, s->name.c_str(), MenuID::PROXY_OPTIONS,
proxy_options_menu_for_client(c));
proxy_options_menu_for_client(s, c));
} else {
const pair<string, uint16_t>* dest = nullptr;
+4 -1
View File
@@ -31,7 +31,10 @@ ServerState::ServerState()
ep3_card_auction_max_size(0),
next_lobby_id(1),
pre_lobby_event(0),
ep3_menu_song(-1) {
ep3_menu_song(-1),
local_address(0),
external_address(0),
proxy_allow_save_files(true) {
vector<shared_ptr<Lobby>> non_v1_only_lobbies;
vector<shared_ptr<Lobby>> ep3_only_lobbies;
+2
View File
@@ -110,6 +110,8 @@ struct ServerState {
uint32_t local_address;
uint32_t external_address;
bool proxy_allow_save_files;
std::shared_ptr<ProxyServer> proxy_server;
std::shared_ptr<Server> game_server;
std::shared_ptr<FileContentsCache> client_options_cache;