bring back the $ln command

This commit is contained in:
Martin Michelsen
2023-09-05 00:08:44 -07:00
parent 013a19885f
commit 3b69d3484d
11 changed files with 38 additions and 34 deletions
+16 -12
View File
@@ -528,24 +528,28 @@ static void server_command_lobby_event_all(shared_ptr<ServerState> s, shared_ptr
static void server_command_lobby_type(shared_ptr<ServerState>, shared_ptr<Lobby> l,
shared_ptr<Client> c, const std::u16string& args) {
check_is_game(l, false);
check_privileges(c, Privilege::CHANGE_EVENT);
uint8_t new_type = lobby_type_for_name(args);
uint8_t new_type = args.empty() ? 0 : lobby_type_for_name(args);
if (new_type == 0x80) {
send_text_message(c, u"$C6No such lobby type.");
send_text_message(c, u"$C6No such lobby type");
return;
}
l->type = new_type;
if (l->type < (l->is_ep3() ? 20 : 15)) {
l->type = l->block - 1;
uint8_t max_standard_type = ((c->flags & Client::Flag::IS_EPISODE_3) ? 20 : 15);
c->options.override_lobby_number = (new_type < max_standard_type) ? -1 : new_type;
send_join_lobby(c, l);
}
static void proxy_command_lobby_type(shared_ptr<ServerState>,
ProxyServer::LinkedSession& session, const std::u16string& args) {
uint8_t new_type = args.empty() ? 0 : lobby_type_for_name(args);
if (new_type == 0x80) {
send_text_message(session.client_channel, u"$C6No such lobby type");
return;
}
for (size_t x = 0; x < l->max_clients; x++) {
if (l->clients[x]) {
send_join_lobby(l->clients[x], l);
}
}
uint8_t max_standard_type = ((session.newserv_client_config.cfg.flags & Client::Flag::IS_EPISODE_3) ? 20 : 15);
session.options.override_lobby_number = (new_type < max_standard_type) ? -1 : new_type;
}
static void server_command_saverec(shared_ptr<ServerState>, shared_ptr<Lobby> l,
@@ -1317,6 +1321,7 @@ static const unordered_map<u16string, ChatCommandDefinition> chat_commands({
{u"$i", {server_command_item, proxy_command_item}},
{u"$kick", {server_command_kick, nullptr}},
{u"$li", {server_command_lobby_info, proxy_command_lobby_info}},
{u"$ln", {server_command_lobby_type, proxy_command_lobby_type}},
{u"$ep3battledebug", {server_command_enable_ep3_battle_debug_menu, nullptr}},
{u"$maxlevel", {server_command_max_level, nullptr}},
{u"$minlevel", {server_command_min_level, nullptr}},
@@ -1335,7 +1340,6 @@ static const unordered_map<u16string, ChatCommandDefinition> chat_commands({
{u"$ss", {nullptr, proxy_command_send_server}},
{u"$surrender", {server_command_surrender, nullptr}},
{u"$swa", {server_command_switch_assist, proxy_command_switch_assist}},
{u"$type", {server_command_lobby_type, nullptr}},
{u"$warp", {server_command_warpme, proxy_command_warpme}},
{u"$warpme", {server_command_warpme, proxy_command_warpme}},
{u"$warpall", {server_command_warpall, proxy_command_warpall}},
+3 -3
View File
@@ -26,9 +26,9 @@ struct ClientOptions {
bool infinite_hp;
bool infinite_tp;
bool debug;
int16_t override_section_id;
int16_t override_lobby_event;
int16_t override_lobby_number;
int16_t override_section_id; // -1 = no override
int16_t override_lobby_event; // -1 = no override
int16_t override_lobby_number; // -1 = no override
int64_t override_random_seed;
// Options used only on proxy server
+1 -1
View File
@@ -103,7 +103,7 @@ public:
// This table specifies how many areas each weapon subtype appears in. For
// example, if Sword (subtype 02, which is index 1 in this table and the
// table above) has a subtype base of -2 and a subtype area lneght of 4,
// table above) has a subtype base of -2 and a subtype area length of 4,
// then Sword items can be found when area - 1 is 2, 3, 4, or 5 (Cave 1
// through Mine 1), and Gigush (the next sword subtype) can be found in Mine
// 1 through Ruins 3.
+1 -1
View File
@@ -862,7 +862,7 @@ struct MapDefinition { // .mnmd format; also the format of (decompressed) quests
// 0D = (Castor/Pollux map) ("REAL BOSS")
// 0E = Dolor Odor ("STOMACH")
// 0F = Ravum Aedes Sacra ("SACRAMENT")
// 10 = (Amplum Umbla map) ("RUIN")
// 10 = (Amplum Umbra map) ("RUIN")
// 11 = Via Tubus ("METRO")
// 12 = Morgue ("NORMAL MORGUE")
// Environment numbers above 12 are replaced with 0B (Cyber) if specified in
-1
View File
@@ -25,7 +25,6 @@ Lobby::Lobby(uint32_t id)
random_seed(random_object<uint32_t>()),
event(0),
block(0),
type(0),
leader_id(0),
max_clients(12),
flags(0) {
-1
View File
@@ -100,7 +100,6 @@ struct Lobby : public std::enable_shared_from_this<Lobby> {
// Lobby stuff
uint8_t event;
uint8_t block;
uint8_t type; // number to give to PSO for the lobby number
uint8_t leader_id;
uint8_t max_clients;
uint32_t flags;
+5 -3
View File
@@ -1638,16 +1638,18 @@ void send_join_lobby_t(shared_ptr<Client> c, shared_ptr<Lobby> l,
send_player_records_t<RecordsT>(c, l, joining_client);
}
uint8_t lobby_type = (l->type > 14) ? (l->block - 1) : l->type;
uint8_t lobby_type = (c->options.override_lobby_number >= 0)
? c->options.override_lobby_number
: l->block - 1;
// Allow non-canonical lobby types on GC. They may work on other versions too,
// but I haven't verified which values don't crash on each version.
if (c->version() == GameVersion::GC) {
if (c->flags & Client::Flag::IS_EPISODE_3) {
if ((l->type > 0x14) && (l->type < 0xE9)) {
if ((lobby_type > 0x14) && (lobby_type < 0xE9)) {
lobby_type = l->block - 1;
}
} else {
if ((l->type > 0x11) && (l->type != 0x67) && (l->type != 0xD4) && (l->type < 0xFC)) {
if ((lobby_type > 0x11) && (lobby_type != 0x67) && (lobby_type != 0xD4) && (lobby_type < 0xFC)) {
lobby_type = l->block - 1;
}
}
-1
View File
@@ -55,7 +55,6 @@ ServerState::ServerState(const char* config_filename, bool is_replay)
Lobby::Flag::PERSISTENT |
(is_non_v1_only ? Lobby::Flag::NON_V1_ONLY : 0);
l->block = x + 1;
l->type = x;
l->name = lobby_name;
l->max_clients = 12;
if (is_ep3_only) {
+9 -9
View File
@@ -153,13 +153,13 @@ const unordered_map<uint8_t, string> lobby_type_to_name({
{0xF1, "windpower"},
{0xF2, "overview"},
{0xF3, "seaside"},
{0xF4, "some?"},
{0xF4, "fons"},
{0xF5, "dmorgue"},
{0xF6, "caelum"},
{0xF8, "digital"},
{0xF8, "cyber"},
{0xF9, "boss1"},
{0xFA, "boss2"},
{0xFB, "boss3"},
{0xFB, "dolor"},
{0xFC, "dragon"},
{0xFD, "derolle"},
{0xFE, "volopt"},
@@ -186,14 +186,14 @@ const unordered_map<string, uint8_t> name_to_lobby_type({
{"windpower", 0xF1},
{"overview", 0xF2},
{"seaside", 0xF3},
{"some?", 0xF4},
{"fons", 0xF4},
{"dmorgue", 0xF5},
{"caelum", 0xF6},
{"digital", 0xF8},
{"cyber", 0xF8},
{"boss1", 0xF9},
{"boss2", 0xFA},
{"boss3", 0xFB},
{"knight", 0xFC},
{"dolor", 0xFB},
{"ravum", 0xFC},
{"sky", 0xFE},
{"morgue", 0xFF},
});
@@ -289,8 +289,8 @@ uint8_t lobby_type_for_name(const string& name) {
} catch (const out_of_range&) {
}
try {
uint64_t x = stoul(name);
if (x < lobby_type_to_name.size()) {
uint64_t x = stoul(name, nullptr, 0);
if (lobby_type_to_name.count(x)) {
return x;
}
} catch (const invalid_argument&) {