add warp command in proxy
This commit is contained in:
+14
-9
@@ -927,18 +927,19 @@ void ProxyServer::LinkedSession::on_server_input() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProxyServer::LinkedSession::send_to_end(const string& data, bool to_server) {
|
void ProxyServer::LinkedSession::send_to_end(
|
||||||
string name = string_printf("ProxySession:%08" PRIX32 ":shell:%s",
|
const void* data, size_t size, bool to_server) {
|
||||||
this->license->serial_number, to_server ? "server" : "client");
|
|
||||||
|
|
||||||
size_t header_size = PSOCommandHeader::header_size(this->version);
|
size_t header_size = PSOCommandHeader::header_size(this->version);
|
||||||
if (data.size() < header_size) {
|
if (size < header_size) {
|
||||||
throw runtime_error("command is too small for header");
|
throw runtime_error("command is too small for header");
|
||||||
}
|
}
|
||||||
if (data.size() & 3) {
|
if (size & 3) {
|
||||||
throw runtime_error("command size is not a multiple of 4");
|
throw runtime_error("command size is not a multiple of 4");
|
||||||
}
|
}
|
||||||
const auto* header = reinterpret_cast<const PSOCommandHeader*>(data.data());
|
const auto* header = reinterpret_cast<const PSOCommandHeader*>(data);
|
||||||
|
|
||||||
|
string name = string_printf("ProxySession:%08" PRIX32 ":shell:%s",
|
||||||
|
this->license->serial_number, to_server ? "server" : "client");
|
||||||
|
|
||||||
send_command(
|
send_command(
|
||||||
to_server ? this->server_bev.get() : this->client_bev.get(),
|
to_server ? this->server_bev.get() : this->client_bev.get(),
|
||||||
@@ -946,11 +947,15 @@ void ProxyServer::LinkedSession::send_to_end(const string& data, bool to_server)
|
|||||||
to_server ? this->server_output_crypt.get() : this->client_output_crypt.get(),
|
to_server ? this->server_output_crypt.get() : this->client_output_crypt.get(),
|
||||||
header->command(this->version),
|
header->command(this->version),
|
||||||
header->flag(this->version),
|
header->flag(this->version),
|
||||||
data.data() + header_size,
|
reinterpret_cast<const uint8_t*>(data) + header_size,
|
||||||
data.size() - header_size,
|
size - header_size,
|
||||||
name.c_str());
|
name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProxyServer::LinkedSession::send_to_end(const string& data, bool to_server) {
|
||||||
|
this->send_to_end(data.data(), data.size(), to_server);
|
||||||
|
}
|
||||||
|
|
||||||
shared_ptr<ProxyServer::LinkedSession> ProxyServer::get_session() {
|
shared_ptr<ProxyServer::LinkedSession> ProxyServer::get_session() {
|
||||||
if (this->serial_number_to_session.empty()) {
|
if (this->serial_number_to_session.empty()) {
|
||||||
throw runtime_error("no sessions exist");
|
throw runtime_error("no sessions exist");
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ public:
|
|||||||
void on_server_input();
|
void on_server_input();
|
||||||
void on_stream_error(short events, bool is_server_stream);
|
void on_stream_error(short events, bool is_server_stream);
|
||||||
|
|
||||||
|
void send_to_end(const void* data, size_t size, bool to_server);
|
||||||
void send_to_end(const std::string& data, bool to_server);
|
void send_to_end(const std::string& data, bool to_server);
|
||||||
|
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ Proxy commands (these will only work when exactly one client is connected):\n\
|
|||||||
Send a lobby marker message to the server.\n\
|
Send a lobby marker message to the server.\n\
|
||||||
event <event-id>\n\
|
event <event-id>\n\
|
||||||
Send a lobby event update to yourself.\n\
|
Send a lobby event update to yourself.\n\
|
||||||
|
warp <area-id>\n\
|
||||||
|
Send yourself to a specific area.\n\
|
||||||
ship\n\
|
ship\n\
|
||||||
Request the ship select menu from the server.\n\
|
Request the ship select menu from the server.\n\
|
||||||
");
|
");
|
||||||
@@ -279,6 +281,18 @@ Proxy commands (these will only work when exactly one client is connected):\n\
|
|||||||
|
|
||||||
session->send_to_end(data, false);
|
session->send_to_end(data, false);
|
||||||
|
|
||||||
|
} else if (command_name == "warp") {
|
||||||
|
auto session = this->get_proxy_session();
|
||||||
|
|
||||||
|
PSOSubcommand cmds[3];
|
||||||
|
cmds[0].dword = 0x000C0060; // header (60 00 0C 00)
|
||||||
|
cmds[1].word[0] = 0x0294;
|
||||||
|
cmds[1].word[1] = session->lobby_client_id;
|
||||||
|
cmds[2].dword = stoul(command_args);
|
||||||
|
|
||||||
|
session->send_to_end(&cmds, sizeof(cmds), false);
|
||||||
|
session->send_to_end(&cmds, sizeof(cmds), true);
|
||||||
|
|
||||||
} else if (command_name == "ship") {
|
} else if (command_name == "ship") {
|
||||||
auto session = this->get_proxy_session();
|
auto session = this->get_proxy_session();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user