add card config backup
This commit is contained in:
+31
-5
@@ -41,7 +41,8 @@ static void flush_and_free_bufferevent(struct bufferevent* bev) {
|
|||||||
ProxyServer::ProxyServer(
|
ProxyServer::ProxyServer(
|
||||||
shared_ptr<struct event_base> base,
|
shared_ptr<struct event_base> base,
|
||||||
shared_ptr<ServerState> state)
|
shared_ptr<ServerState> state)
|
||||||
: base(base),
|
: save_quests(false),
|
||||||
|
base(base),
|
||||||
state(state) { }
|
state(state) { }
|
||||||
|
|
||||||
void ProxyServer::listen(uint16_t port, GameVersion version) {
|
void ProxyServer::listen(uint16_t port, GameVersion version) {
|
||||||
@@ -290,8 +291,7 @@ ProxyServer::LinkedSession::LinkedSession(
|
|||||||
local_port(local_port),
|
local_port(local_port),
|
||||||
version(version),
|
version(version),
|
||||||
sub_version(0), // This is set during resume()
|
sub_version(0), // This is set during resume()
|
||||||
guild_card_number(0),
|
guild_card_number(0) {
|
||||||
save_quests(false) {
|
|
||||||
memset(this->client_config_data, 0, 0x20);
|
memset(this->client_config_data, 0, 0x20);
|
||||||
memset(&this->next_destination, 0, sizeof(this->next_destination));
|
memset(&this->next_destination, 0, sizeof(this->next_destination));
|
||||||
struct sockaddr_in* dest_sin = reinterpret_cast<struct sockaddr_in*>(&this->next_destination);
|
struct sockaddr_in* dest_sin = reinterpret_cast<struct sockaddr_in*>(&this->next_destination);
|
||||||
@@ -653,7 +653,7 @@ void ProxyServer::LinkedSession::on_server_input() {
|
|||||||
|
|
||||||
case 0x44:
|
case 0x44:
|
||||||
case 0xA6: {
|
case 0xA6: {
|
||||||
if (!this->save_quests) {
|
if (!this->server->save_quests) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -693,7 +693,7 @@ void ProxyServer::LinkedSession::on_server_input() {
|
|||||||
|
|
||||||
case 0x13:
|
case 0x13:
|
||||||
case 0xA7: {
|
case 0xA7: {
|
||||||
if (!this->save_quests) {
|
if (!this->server->save_quests) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -744,6 +744,32 @@ void ProxyServer::LinkedSession::on_server_input() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 0xB8: {
|
||||||
|
if (!this->server->save_quests) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (data.size() < 4) {
|
||||||
|
log(WARNING, "[ProxyServer/%08" PRIX32 "] Card list data size is too small; skipping file",
|
||||||
|
this->license->serial_number);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringReader r(data);
|
||||||
|
size_t size = r.get_u32l();
|
||||||
|
if (r.remaining() < size) {
|
||||||
|
log(WARNING, "[ProxyServer/%08" PRIX32 "] Card list data size extends beyond end of command; skipping file",
|
||||||
|
this->license->serial_number);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
string output_filename = string_printf("cardupdate.mnr.%" PRIu64, now());
|
||||||
|
save_file(output_filename, r.read(size));
|
||||||
|
|
||||||
|
log(INFO, "[ProxyServer/%08" PRIX32 "] Wrote %zu bytes to %s",
|
||||||
|
this->license->serial_number, size, output_filename.c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_forward) {
|
if (should_forward) {
|
||||||
|
|||||||
+2
-1
@@ -62,7 +62,6 @@ public:
|
|||||||
const std::string& output_filename,
|
const std::string& output_filename,
|
||||||
uint32_t remaining_bytes);
|
uint32_t remaining_bytes);
|
||||||
};
|
};
|
||||||
bool save_quests;
|
|
||||||
std::unordered_map<std::string, SavingQuestFile> saving_quest_files;
|
std::unordered_map<std::string, SavingQuestFile> saving_quest_files;
|
||||||
|
|
||||||
LinkedSession(
|
LinkedSession(
|
||||||
@@ -100,6 +99,8 @@ public:
|
|||||||
std::shared_ptr<LinkedSession> get_session();
|
std::shared_ptr<LinkedSession> get_session();
|
||||||
void delete_session(uint32_t serial_number);
|
void delete_session(uint32_t serial_number);
|
||||||
|
|
||||||
|
bool save_quests;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ListeningSocket {
|
struct ListeningSocket {
|
||||||
ProxyServer* server;
|
ProxyServer* server;
|
||||||
|
|||||||
+5
-5
@@ -2102,12 +2102,12 @@ void send_give_experience(shared_ptr<Lobby> l, shared_ptr<Client> c,
|
|||||||
void send_ep3_card_list_update(shared_ptr<Client> c) {
|
void send_ep3_card_list_update(shared_ptr<Client> c) {
|
||||||
auto file_data = file_cache.get("system/ep3/cardupdate.mnr");
|
auto file_data = file_cache.get("system/ep3/cardupdate.mnr");
|
||||||
|
|
||||||
string data("\0\0\0\0", 4);
|
StringWriter w;
|
||||||
*reinterpret_cast<uint32_t*>(data.data()) = file_data->size();
|
w.put_u32l(file_data->size());
|
||||||
data += *file_data;
|
w.write(*file_data);
|
||||||
data.resize((data.size() + 3) & ~3);
|
w.str().resize((w.str().size() + 3) & (~3));
|
||||||
|
|
||||||
send_command(c, 0xB8, 0x00, data);
|
send_command(c, 0xB8, 0x00, w.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// sends the client a generic rank
|
// sends the client a generic rank
|
||||||
|
|||||||
+9
-7
@@ -303,14 +303,16 @@ Proxy commands (these will only work when exactly one client is connected):\n\
|
|||||||
session->send_to_end(data, true);
|
session->send_to_end(data, true);
|
||||||
|
|
||||||
} else if (command_name == "set-save-quests") {
|
} else if (command_name == "set-save-quests") {
|
||||||
auto session = this->get_proxy_session();
|
if (this->state->proxy_server.get()) {
|
||||||
|
if (command_args == "on") {
|
||||||
if (command_args == "on") {
|
this->state->proxy_server->save_quests = true;
|
||||||
session->save_quests = true;
|
} else if (command_args == "off") {
|
||||||
} else if (command_args == "off") {
|
this->state->proxy_server->save_quests = false;
|
||||||
session->save_quests = false;
|
} else {
|
||||||
|
throw invalid_argument("argument must be \"on\" or \"off\"");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw invalid_argument("argument must be \"on\" or \"off\"");
|
throw invalid_argument("proxy server is not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user