add $variations command

This commit is contained in:
Martin Michelsen
2024-03-03 17:28:35 -08:00
parent 4faad54872
commit 7f71b87b9b
3 changed files with 24 additions and 3 deletions
+17
View File
@@ -954,6 +954,22 @@ static void proxy_command_secid(shared_ptr<ProxyServer::LinkedSession> ses, cons
}
}
static void server_command_variations(shared_ptr<Client> c, const std::string& args) {
// Note: This command is intentionally undocumented, since it's primarily used
// for testing. If we ever make it public, we should add some kind of user
// feedback (currently it sends no message when it runs).
auto s = c->require_server_state();
auto l = c->require_lobby();
check_is_game(l, false);
check_cheats_allowed(s, c);
c->override_variations = make_unique<parray<le_uint32_t, 0x20>>();
c->override_variations->clear(0);
for (size_t z = 0; z < min<size_t>(c->override_variations->size(), args.size()); z++) {
c->override_variations->at(z) = args[z] - '0';
}
}
static void server_command_rand(shared_ptr<Client> c, const std::string& args) {
auto s = c->require_server_state();
auto l = c->require_lobby();
@@ -2185,6 +2201,7 @@ static const unordered_map<string, ChatCommandDefinition> chat_commands({
{"$surrender", {server_command_surrender, nullptr}},
{"$swa", {server_command_switch_assist, proxy_command_switch_assist}},
{"$unset", {server_command_ep3_unset_field_character, nullptr}},
{"$variations", {server_command_variations, nullptr}},
{"$warp", {server_command_warpme, proxy_command_warpme}},
{"$warpme", {server_command_warpme, proxy_command_warpme}},
{"$warpall", {server_command_warpall, proxy_command_warpall}},
+1
View File
@@ -198,6 +198,7 @@ public:
// Lobby/positioning
Config config;
Config synced_config;
std::unique_ptr<parray<le_uint32_t, 0x20>> override_variations;
int32_t sub_version;
float x;
float z;
+6 -3
View File
@@ -4217,11 +4217,14 @@ shared_ptr<Lobby> create_game_generic(
if (game->episode != Episode::EP3) {
// GC NTE ignores the passed-in variations and always uses all zeroes
if (game->base_version != Version::GC_NTE) {
if (game->base_version == Version::GC_NTE) {
game->variations.clear(0);
} else if (c->override_variations) {
game->variations = *c->override_variations;
c->override_variations.reset();
} else {
auto sdt = s->set_data_table(game->base_version, game->episode, game->mode, game->difficulty);
game->variations = sdt->generate_variations(game->episode, is_solo, game->opt_rand_crypt);
} else {
game->variations.clear(0);
}
game->load_maps();
} else {