implement ss shell command on game server
This commit is contained in:
@@ -4081,3 +4081,32 @@ void on_command(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||
on_unimplemented_command(s, c, command, flag, data);
|
||||
}
|
||||
}
|
||||
|
||||
void on_command_with_header(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||
string& data) {
|
||||
switch (c->version()) {
|
||||
case GameVersion::DC:
|
||||
case GameVersion::GC:
|
||||
case GameVersion::XB: {
|
||||
auto& header = check_size_t<PSOCommandHeaderDCV3>(data,
|
||||
sizeof(PSOCommandHeaderDCV3), 0xFFFF);
|
||||
on_command(s, c, header.command, header.flag, data.substr(sizeof(header)));
|
||||
break;
|
||||
}
|
||||
case GameVersion::PC:
|
||||
case GameVersion::PATCH: {
|
||||
auto& header = check_size_t<PSOCommandHeaderPC>(data,
|
||||
sizeof(PSOCommandHeaderPC), 0xFFFF);
|
||||
on_command(s, c, header.command, header.flag, data.substr(sizeof(header)));
|
||||
break;
|
||||
}
|
||||
case GameVersion::BB: {
|
||||
auto& header = check_size_t<PSOCommandHeaderBB>(data,
|
||||
sizeof(PSOCommandHeaderBB), 0xFFFF);
|
||||
on_command(s, c, header.command, header.flag, data.substr(sizeof(header)));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw logic_error("unimplemented game version in on_command_with_header");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,3 +22,5 @@ void on_disconnect(std::shared_ptr<ServerState> s,
|
||||
std::shared_ptr<Client> c);
|
||||
void on_command(std::shared_ptr<ServerState> s, std::shared_ptr<Client> c,
|
||||
uint16_t command, uint32_t flag, const std::string& data);
|
||||
void on_command_with_header(std::shared_ptr<ServerState> s,
|
||||
std::shared_ptr<Client> c, std::string& data);
|
||||
|
||||
+6
-5
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <phosg/Strings.hh>
|
||||
|
||||
#include "ReceiveCommands.hh"
|
||||
#include "ServerState.hh"
|
||||
#include "SendCommands.hh"
|
||||
#include "StaticGameData.hh"
|
||||
@@ -508,10 +509,6 @@ session with ID 17205AE4, run the command `on 17205AE4 sc 1D 00 04 00`.\n\
|
||||
}
|
||||
|
||||
} else {
|
||||
if (command_name [1] == 's') {
|
||||
throw runtime_error("cannot send to server in non-proxy session");
|
||||
}
|
||||
|
||||
shared_ptr<Client> c;
|
||||
if (session_name.empty()) {
|
||||
c = this->state->game_server->get_client();
|
||||
@@ -528,7 +525,11 @@ session with ID 17205AE4, run the command `on 17205AE4 sc 1D 00 04 00`.\n\
|
||||
}
|
||||
|
||||
if (c) {
|
||||
send_command_with_header(c->channel, data.data(), data.size());
|
||||
if (command_name[1] == 's') {
|
||||
on_command_with_header(this->state, c, data);
|
||||
} else {
|
||||
send_command_with_header(c->channel, data.data(), data.size());
|
||||
}
|
||||
} else {
|
||||
throw runtime_error("no client available");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user