allow $edit to change a few things even if cheat mode is disabled

This commit is contained in:
Martin Michelsen
2023-12-29 16:25:03 -08:00
parent 4f2432cbac
commit 7ee7af0b0f
2 changed files with 14 additions and 18 deletions
+1 -2
View File
@@ -323,8 +323,7 @@ Some commands only work on the game server and not on the proxy server. The chat
* `$savechar <slot>`: Saves your current character data on the server in the specified slot (each serial number has 4 slots, numbered 1-4). These slots are separate from BB character slots; using this command does not affect BB characters.
* `$loadchar <slot>` (v1 and v2 only): Loads your character data from the specified slot. The changes will be undone if you join a game - to save your changes, disconnect from the lobby.
* `$bbchar <username> <password> <slot>`: Use this command when playing on a non-BB version of PSO. If the username and password are correct, this command converts your current character to BB format and saves it on the server in the given slot (1-4). Any character already in that slot is overwritten. (This command is similar to `$savechar`, except it overwrites a BB character slot, and can transfer characters across accounts.) Note that the character's chat data, quick menu config, and bank contents are not copied, since there is no way for the server to request those types of data.
* `$edit <stat> <value>`: Modifies your character data. If you are on V3 (GameCube/Xbox), or if the server does not allow cheat mode anywhere (that is, "CheatModeBehavior" is "Off" in config.json), this command does nothing. If you are on V1 or V2 (DC or PC, not BB), your changes will be undone if you join a game - to save your changes, disconnect from the lobby.
* `$edit <stat> <value>`: Modifies your character data. If you are on V3 (GameCube/Xbox), this command does nothing. If you are on V1 or V2 (DC or PC, not BB), your changes will be undone if you join a game - to save your changes, disconnect from the lobby. If cheats are allowed on the server, `<stat>` can be any of `atp`, `mst`, `evp`, `hp`, `dfp`, `ata`, `lck`, `meseta`, `exp`, `level`, `namecolor`, `secid`, `name`, `npc`, or `tech`. If cheats are not allowed, only `namecolor`, `name`, and `npc` can be used.
* Blue Burst player commands (game server only)
* `$bank [number]`: Switches your current bank, so you can access your other character's banks (if `number` is 1-4) or your shared account bank (if `number` is 0). If `number` is not given, switches back to your current character's bank.
* `$save`: Saves your character, system, and Guild Card data immediately. (By default, your character is saved every 60 seconds while online, and your account and Guild Card data are saved whenever they change.)
+13 -16
View File
@@ -1017,35 +1017,32 @@ static void server_command_edit(shared_ptr<Client> c, const std::string& args) {
throw precondition_failed("$C6This command cannot\nbe used for your\nversion of PSO.");
}
if ((s->cheat_mode_behavior == ServerState::BehaviorSwitch::OFF) && !(c->license->flags & License::Flag::CHEAT_ANYWHERE)) {
send_text_message(l, "$C6Cheats are disabled\non this server");
return;
}
bool cheats_allowed = ((s->cheat_mode_behavior != ServerState::BehaviorSwitch::OFF) || (c->license->flags & License::Flag::CHEAT_ANYWHERE));
string encoded_args = tolower(args);
vector<string> tokens = split(encoded_args, ' ');
try {
auto p = c->character();
if (tokens.at(0) == "atp") {
if (tokens.at(0) == "atp" && cheats_allowed) {
p->disp.stats.char_stats.atp = stoul(tokens.at(1));
} else if (tokens.at(0) == "mst") {
} else if (tokens.at(0) == "mst" && cheats_allowed) {
p->disp.stats.char_stats.mst = stoul(tokens.at(1));
} else if (tokens.at(0) == "evp") {
} else if (tokens.at(0) == "evp" && cheats_allowed) {
p->disp.stats.char_stats.evp = stoul(tokens.at(1));
} else if (tokens.at(0) == "hp") {
} else if (tokens.at(0) == "hp" && cheats_allowed) {
p->disp.stats.char_stats.hp = stoul(tokens.at(1));
} else if (tokens.at(0) == "dfp") {
} else if (tokens.at(0) == "dfp" && cheats_allowed) {
p->disp.stats.char_stats.dfp = stoul(tokens.at(1));
} else if (tokens.at(0) == "ata") {
} else if (tokens.at(0) == "ata" && cheats_allowed) {
p->disp.stats.char_stats.ata = stoul(tokens.at(1));
} else if (tokens.at(0) == "lck") {
} else if (tokens.at(0) == "lck" && cheats_allowed) {
p->disp.stats.char_stats.lck = stoul(tokens.at(1));
} else if (tokens.at(0) == "meseta") {
} else if (tokens.at(0) == "meseta" && cheats_allowed) {
p->disp.stats.meseta = stoul(tokens.at(1));
} else if (tokens.at(0) == "exp") {
} else if (tokens.at(0) == "exp" && cheats_allowed) {
p->disp.stats.experience = stoul(tokens.at(1));
} else if (tokens.at(0) == "level") {
} else if (tokens.at(0) == "level" && cheats_allowed) {
uint32_t level = stoul(tokens.at(1)) - 1;
p->disp.stats.reset_to_base(p->disp.visual.char_class, s->level_table);
p->disp.stats.advance_to_level(p->disp.visual.char_class, level, s->level_table);
@@ -1053,7 +1050,7 @@ static void server_command_edit(shared_ptr<Client> c, const std::string& args) {
uint32_t new_color;
sscanf(tokens.at(1).c_str(), "%8X", &new_color);
p->disp.visual.name_color = new_color;
} else if (tokens.at(0) == "secid") {
} else if (tokens.at(0) == "secid" && cheats_allowed) {
uint8_t secid = section_id_for_name(tokens.at(1));
if (secid == 0xFF) {
send_text_message(c, "$C6No such section ID");
@@ -1079,7 +1076,7 @@ static void server_command_edit(shared_ptr<Client> c, const std::string& args) {
p->disp.visual.extra_model = npc;
p->disp.visual.validation_flags |= 0x02;
}
} else if (tokens.at(0) == "tech") {
} else if (tokens.at(0) == "tech" && cheats_allowed) {
uint8_t level = stoul(tokens.at(2)) - 1;
if (tokens.at(1) == "all") {
for (size_t x = 0; x < 0x14; x++) {