disable $bank when character overlay is present

This commit is contained in:
Martin Michelsen
2023-12-09 10:38:48 -08:00
parent 0ded423c84
commit bb3d4ac847
4 changed files with 16 additions and 1 deletions
+3
View File
@@ -1001,6 +1001,9 @@ static void server_command_change_bank(shared_ptr<Client> c, const std::string&
if (c->config.check_flag(Client::Flag::AT_BANK_COUNTER)) {
throw runtime_error("cannot change banks while at the bank counter");
}
if (c->has_overlay()) {
throw runtime_error("cannot change banks while Battle or Challenge is in progress");
}
ssize_t new_char_index = args.empty() ? (c->bb_character_index + 1) : stol(args, nullptr, 0);
+9 -1
View File
@@ -926,13 +926,21 @@ void Client::use_default_bank() {
bool Client::use_shared_bank() {
this->use_default_bank();
string filename = this->shared_bank_filename();
if (isfile(filename)) {
auto files_manager = this->require_server_state()->player_files_manager;
this->external_bank = files_manager->get_bank(filename);
if (this->external_bank) {
player_data_log.info("Using loaded shared bank %s", filename.c_str());
return true;
} else if (isfile(filename)) {
this->external_bank = make_shared<PlayerBank>(load_object_file<PlayerBank>(filename));
files_manager->set_bank(filename, this->external_bank);
player_data_log.info("Loaded shared bank %s", filename.c_str());
return true;
} else {
this->external_bank = make_shared<PlayerBank>();
files_manager->set_bank(filename, this->external_bank);
player_data_log.info("Created shared bank for %s", filename.c_str());
return false;
}
+3
View File
@@ -1896,9 +1896,11 @@ static void on_quest_loaded(shared_ptr<Lobby> l) {
if (l->base_version != Version::BB_V4) {
lc->delete_overlay();
if (l->quest->battle_rules) {
lc->use_default_bank();
lc->create_battle_overlay(l->quest->battle_rules, s->level_table);
lc->log.info("Created battle overlay");
} else if (l->quest->challenge_template_index >= 0) {
lc->use_default_bank();
lc->create_challenge_overlay(lc->version(), l->quest->challenge_template_index, s->level_table);
lc->log.info("Created challenge overlay");
l->assign_inventory_and_bank_item_ids(lc);
@@ -3463,6 +3465,7 @@ static void on_DF_BB(shared_ptr<Client> c, uint16_t command, uint32_t, string& d
for (auto lc : l->clients) {
if (lc) {
lc->use_default_bank();
lc->create_challenge_overlay(lc->version(), l->quest->challenge_template_index, s->level_table);
lc->log.info("Created challenge overlay");
l->assign_inventory_and_bank_item_ids(lc);
+1
View File
@@ -2440,6 +2440,7 @@ static void on_battle_restart_bb(shared_ptr<Client> c, uint8_t, uint8_t, const v
for (auto& lc : l->clients) {
if (lc) {
lc->delete_overlay();
lc->use_default_bank();
lc->create_battle_overlay(new_rules, s->level_table);
}
}