implement $next on proxy server
This commit is contained in:
+18
-3
@@ -758,8 +758,13 @@ static void server_command_warp(shared_ptr<ServerState>, shared_ptr<Lobby> l,
|
||||
|
||||
static void proxy_command_warp(shared_ptr<ServerState>,
|
||||
ProxyServer::LinkedSession& session, const std::u16string& args) {
|
||||
if (!session.is_in_game) {
|
||||
send_text_message(session.client_channel, u"$C6You must be in a\ngame to use this\ncommand");
|
||||
return;
|
||||
}
|
||||
uint32_t area = stoul(encode_sjis(args), nullptr, 0);
|
||||
send_warp(session.client_channel, session.lobby_client_id, area);
|
||||
session.area = area;
|
||||
}
|
||||
|
||||
static void server_command_next(shared_ptr<ServerState>, shared_ptr<Lobby> l,
|
||||
@@ -768,7 +773,7 @@ static void server_command_next(shared_ptr<ServerState>, shared_ptr<Lobby> l,
|
||||
check_cheats_enabled(l);
|
||||
|
||||
if (!l->episode || (l->episode > 3)) {
|
||||
return;
|
||||
throw runtime_error("invalid episode number");
|
||||
}
|
||||
|
||||
uint8_t new_area = c->area + 1;
|
||||
@@ -781,6 +786,17 @@ static void server_command_next(shared_ptr<ServerState>, shared_ptr<Lobby> l,
|
||||
send_warp(c, new_area);
|
||||
}
|
||||
|
||||
static void proxy_command_next(shared_ptr<ServerState>,
|
||||
ProxyServer::LinkedSession& session, const std::u16string&) {
|
||||
if (!session.is_in_game) {
|
||||
send_text_message(session.client_channel, u"$C6You must be in a\ngame to use this\ncommand");
|
||||
return;
|
||||
}
|
||||
|
||||
session.area++;
|
||||
send_warp(session.client_channel, session.lobby_client_id, session.area);
|
||||
}
|
||||
|
||||
static void server_command_what(shared_ptr<ServerState>, shared_ptr<Lobby> l,
|
||||
shared_ptr<Client> c, const std::u16string&) {
|
||||
check_is_game(l, true);
|
||||
@@ -972,8 +988,7 @@ static const unordered_map<u16string, ChatCommandDefinition> chat_commands({
|
||||
{u"$li", {server_command_lobby_info, proxy_command_lobby_info, u"Usage:\nli"}},
|
||||
{u"$maxlevel", {server_command_max_level, nullptr, u"Usage:\nmax_level <level>"}},
|
||||
{u"$minlevel", {server_command_min_level, nullptr, u"Usage:\nmin_level <level>"}},
|
||||
// TODO: implement this on proxy server
|
||||
{u"$next", {server_command_next, nullptr, u"Usage:\nnext"}},
|
||||
{u"$next", {server_command_next, proxy_command_next, u"Usage:\nnext"}},
|
||||
{u"$password", {server_command_password, nullptr, u"Usage:\nlock [password]\nomit password to\nunlock game"}},
|
||||
{u"$persist", {server_command_persist, nullptr, u"Usage:\npersist"}},
|
||||
{u"$proxygc", {server_command_proxygc, proxy_command_proxygc, u"Usage:\nproxygc <gc#>"}},
|
||||
|
||||
@@ -1045,6 +1045,7 @@ static HandlerResult S_65_67_68(shared_ptr<ServerState>,
|
||||
if (command == 0x67) {
|
||||
session.clear_lobby_players(12);
|
||||
session.is_in_game = false;
|
||||
session.area = 0x0F;
|
||||
|
||||
// This command can cause the client to no longer send D6 responses when
|
||||
// 1A/D5 large message boxes are closed. newserv keeps track of this
|
||||
@@ -1117,6 +1118,7 @@ static HandlerResult S_64(shared_ptr<ServerState>,
|
||||
}
|
||||
|
||||
session.clear_lobby_players(4);
|
||||
session.area = 0;
|
||||
session.is_in_game = true;
|
||||
|
||||
bool modified = false;
|
||||
@@ -1181,6 +1183,7 @@ static HandlerResult S_66_69(shared_ptr<ServerState>,
|
||||
|
||||
static HandlerResult C_98(shared_ptr<ServerState>,
|
||||
ProxyServer::LinkedSession& session, uint16_t, uint32_t, string&) {
|
||||
session.area = 0x0F;
|
||||
session.is_in_game = false;
|
||||
return HandlerResult::Type::FORWARD;
|
||||
}
|
||||
@@ -1281,7 +1284,11 @@ static HandlerResult C_6x(shared_ptr<ServerState> s,
|
||||
}
|
||||
|
||||
if (!data.empty()) {
|
||||
if (data[0] == 0x2F || data[0] == 0x4B || data[0] == 0x4C) {
|
||||
if (data[0] == 0x21) {
|
||||
const auto& cmd = check_size_t<G_InterLevelWarp_6x21>(data);
|
||||
session.area = cmd.area;
|
||||
|
||||
} else if (data[0] == 0x2F || data[0] == 0x4B || data[0] == 0x4C) {
|
||||
if (session.infinite_hp) {
|
||||
send_player_stats_change(session.client_channel,
|
||||
session.lobby_client_id, PlayerStatsChange::ADD_HP, 2550);
|
||||
|
||||
@@ -86,6 +86,7 @@ public:
|
||||
std::vector<LobbyPlayer> lobby_players;
|
||||
size_t lobby_client_id;
|
||||
size_t leader_client_id;
|
||||
uint16_t area;
|
||||
bool is_in_game;
|
||||
|
||||
std::shared_ptr<PSOBBMultiKeyDetectorEncryption> detector_crypt;
|
||||
|
||||
Reference in New Issue
Block a user