implement infinite hp/tp on proxy server

This commit is contained in:
Martin Michelsen
2022-05-23 00:10:41 -07:00
parent a50500a67d
commit 5a3a55b233
4 changed files with 49 additions and 4 deletions
+33 -4
View File
@@ -751,10 +751,39 @@ static bool process_client_81(shared_ptr<ServerState>,
template <typename SendGuildCardCmdT>
static bool process_client_60_62_6C_6D_C9_CB(shared_ptr<ServerState> s,
ProxyServer::LinkedSession& session, uint16_t command, uint32_t flag, string& data) {
if (session.license && !data.empty() && (data[0] == 0x06)) {
auto& cmd = check_size_t<SendGuildCardCmdT>(data);
if (cmd.guild_card_number == session.license->serial_number) {
cmd.guild_card_number = session.remote_guild_card_number;
if (session.license && !data.empty()) {
if (data[0] == 0x06) {
auto& cmd = check_size_t<SendGuildCardCmdT>(data);
if (cmd.guild_card_number == session.license->serial_number) {
cmd.guild_card_number = session.remote_guild_card_number;
}
} else if (data[0] == 0x2F || data[0] == 0x4C) {
if (session.infinite_hp) {
vector<PSOSubcommand> subs;
for (size_t amount = 1020; amount > 0;) {
auto& sub1 = subs.emplace_back();
sub1.word[0] = 0x029A;
sub1.byte[2] = session.lobby_client_id;
sub1.byte[3] = 0x00;
auto& sub2 = subs.emplace_back();
sub2.word[0] = 0x0000;
sub2.byte[2] = PlayerStatsChange::ADD_HP;
sub2.byte[3] = (amount > 0xFF) ? 0xFF : amount;
amount -= sub2.byte[3];
}
session.send_to_end(false, 0x60, 0x00, subs.data(), subs.size() * sizeof(PSOSubcommand));
}
} else if (data[0] == 0x48) {
if (session.infinite_tp) {
PSOSubcommand subs[2];
subs[0].word[0] = 0x029A;
subs[0].byte[2] = session.lobby_client_id;
subs[0].byte[3] = 0x00;
subs[1].word[0] = 0x0000;
subs[1].byte[2] = PlayerStatsChange::ADD_TP;
subs[1].byte[3] = 0xFF;
session.send_to_end(false, 0x60, 0x00, &subs[0], sizeof(subs));
}
}
}
return process_client_60_62_6C_6D_C9_CB<void>(s, session, command, flag, data);
+2
View File
@@ -436,6 +436,8 @@ ProxyServer::LinkedSession::LinkedSession(
suppress_newserv_commands(true),
enable_chat_filter(true),
enable_switch_assist(false),
infinite_hp(false),
infinite_tp(false),
save_files(false),
function_call_return_value(-1),
override_section_id(-1),
+2
View File
@@ -61,6 +61,8 @@ public:
bool suppress_newserv_commands;
bool enable_chat_filter;
bool enable_switch_assist;
bool infinite_hp;
bool infinite_tp;
bool save_files;
int64_t function_call_return_value; // -1 = don't block function calls
G_SwitchStateChanged_6x05 last_switch_enabled_command;
+12
View File
@@ -130,6 +130,10 @@ Proxy commands (these will only work when exactly one client is connected):\n\
all chat messages that begin with a $ are not sent to the remote server.\n\
This can prevent embarrassing situations if the remote server isn\'t a\n\
newserv instance and you have newserv commands in your chat shortcuts.\n\
set-infinite-hp <on|off>\n\
set-infinite-tp <on|off>\n\
Enable or disable infinite HP or TP. When infinite HP is enabled, attacks\n\
that would kill you in one hit will still do so.\n\
set-switch-assist <on|off>\n\
Enable or disable switch assist. When switch assist is on, the proxy will\n\
remember the last \"enable switch\" command that you send, and will send it\n\
@@ -384,6 +388,14 @@ Proxy commands (these will only work when exactly one client is connected):\n\
auto session = this->get_proxy_session();
set_boolean(&session->suppress_newserv_commands, command_args);
} else if (command_name == "set-infinite-hp") {
auto session = this->get_proxy_session();
set_boolean(&session->infinite_hp, command_args);
} else if (command_name == "set-infinite-tp") {
auto session = this->get_proxy_session();
set_boolean(&session->infinite_tp, command_args);
} else if (command_name == "set-switch-assist") {
auto session = this->get_proxy_session();
set_boolean(&session->enable_switch_assist, command_args);