fix next item ID set incorrectly when joining a persistent game
This commit is contained in:
+3
-11
@@ -480,11 +480,7 @@ void Lobby::add_client(shared_ptr<Client> c, ssize_t required_client_id) {
|
|||||||
this->next_game_item_id = m.reassign_all_item_ids(this->next_game_item_id);
|
this->next_game_item_id = m.reassign_all_item_ids(this->next_game_item_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// On DC NTE and 11/2000, the game assigns item IDs immediately when a
|
this->assign_inventory_and_bank_item_ids(c);
|
||||||
// player joins a game, then assigns them again after the 6x6D equivalent is
|
|
||||||
// received. For this reason, we consume item IDs here only if the client is
|
|
||||||
// NTE or 11/2000.
|
|
||||||
this->assign_inventory_and_bank_item_ids(c, is_pre_v1(c->version()));
|
|
||||||
// On BB, we send artificial flag state to fix an Episode 2 bug where the
|
// On BB, we send artificial flag state to fix an Episode 2 bug where the
|
||||||
// CCA door lock state is overwritten by quests.
|
// CCA door lock state is overwritten by quests.
|
||||||
if (c->version() == Version::BB_V4) {
|
if (c->version() == Version::BB_V4) {
|
||||||
@@ -711,16 +707,12 @@ void Lobby::on_item_id_generated_externally(uint32_t item_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lobby::assign_inventory_and_bank_item_ids(shared_ptr<Client> c, bool consume_ids) {
|
void Lobby::assign_inventory_and_bank_item_ids(shared_ptr<Client> c) {
|
||||||
auto p = c->character();
|
auto p = c->character();
|
||||||
uint32_t start_item_id = this->next_item_id_for_client[c->lobby_client_id];
|
|
||||||
for (size_t z = 0; z < p->inventory.num_items; z++) {
|
for (size_t z = 0; z < p->inventory.num_items; z++) {
|
||||||
p->inventory.items[z].data.id = this->generate_item_id(c->lobby_client_id);
|
p->inventory.items[z].data.id = this->generate_item_id(c->lobby_client_id);
|
||||||
}
|
}
|
||||||
if (!consume_ids) {
|
if (c->log.info("Assigned inventory item IDs")) {
|
||||||
this->next_item_id_for_client[c->lobby_client_id] = start_item_id;
|
|
||||||
}
|
|
||||||
if (c->log.info("Assigned inventory item IDs%s", consume_ids ? "" : " but did not mark IDs as used")) {
|
|
||||||
p->print_inventory(stderr, c->version(), c->require_server_state()->item_name_index);
|
p->print_inventory(stderr, c->version(), c->require_server_state()->item_name_index);
|
||||||
if (p->bank.num_items) {
|
if (p->bank.num_items) {
|
||||||
p->bank.assign_ids(0x99000000 + (c->lobby_client_id << 20));
|
p->bank.assign_ids(0x99000000 + (c->lobby_client_id << 20));
|
||||||
|
|||||||
+1
-1
@@ -233,7 +233,7 @@ struct Lobby : public std::enable_shared_from_this<Lobby> {
|
|||||||
|
|
||||||
uint32_t generate_item_id(uint8_t client_id);
|
uint32_t generate_item_id(uint8_t client_id);
|
||||||
void on_item_id_generated_externally(uint32_t item_id);
|
void on_item_id_generated_externally(uint32_t item_id);
|
||||||
void assign_inventory_and_bank_item_ids(std::shared_ptr<Client> c, bool consume_ids);
|
void assign_inventory_and_bank_item_ids(std::shared_ptr<Client> c);
|
||||||
|
|
||||||
QuestIndex::IncludeCondition quest_include_condition() const;
|
QuestIndex::IncludeCondition quest_include_condition() const;
|
||||||
|
|
||||||
|
|||||||
@@ -1957,7 +1957,7 @@ static void on_quest_loaded(shared_ptr<Lobby> l) {
|
|||||||
lc->use_default_bank();
|
lc->use_default_bank();
|
||||||
lc->create_challenge_overlay(lc->version(), l->quest->challenge_template_index, s->level_table);
|
lc->create_challenge_overlay(lc->version(), l->quest->challenge_template_index, s->level_table);
|
||||||
lc->log.info("Created challenge overlay");
|
lc->log.info("Created challenge overlay");
|
||||||
l->assign_inventory_and_bank_item_ids(lc, true);
|
l->assign_inventory_and_bank_item_ids(lc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3536,7 +3536,7 @@ static void on_DF_BB(shared_ptr<Client> c, uint16_t command, uint32_t, string& d
|
|||||||
lc->use_default_bank();
|
lc->use_default_bank();
|
||||||
lc->create_challenge_overlay(lc->version(), l->quest->challenge_template_index, s->level_table);
|
lc->create_challenge_overlay(lc->version(), l->quest->challenge_template_index, s->level_table);
|
||||||
lc->log.info("Created challenge overlay");
|
lc->log.info("Created challenge overlay");
|
||||||
l->assign_inventory_and_bank_item_ids(lc, true);
|
l->assign_inventory_and_bank_item_ids(lc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4270,10 +4270,6 @@ static void on_6F(shared_ptr<Client> c, uint16_t command, uint32_t, string& data
|
|||||||
}
|
}
|
||||||
c->config.clear_flag(Client::Flag::LOADING);
|
c->config.clear_flag(Client::Flag::LOADING);
|
||||||
|
|
||||||
if (command == 0x006F) {
|
|
||||||
l->assign_inventory_and_bank_item_ids(c, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
send_server_time(c);
|
send_server_time(c);
|
||||||
if (l->base_version == Version::BB_V4) {
|
if (l->base_version == Version::BB_V4) {
|
||||||
send_set_exp_multiplier(l);
|
send_set_exp_multiplier(l);
|
||||||
|
|||||||
@@ -904,12 +904,13 @@ static void on_set_player_visible(shared_ptr<Client> c, uint8_t command, uint8_t
|
|||||||
static void on_change_floor_6x1F(shared_ptr<Client> c, uint8_t command, uint8_t flag, void* data, size_t size) {
|
static void on_change_floor_6x1F(shared_ptr<Client> c, uint8_t command, uint8_t flag, void* data, size_t size) {
|
||||||
if (is_pre_v1(c->version())) {
|
if (is_pre_v1(c->version())) {
|
||||||
check_size_t<G_SetPlayerFloor_DCNTE_6x1F>(data, size);
|
check_size_t<G_SetPlayerFloor_DCNTE_6x1F>(data, size);
|
||||||
// DC NTE and 11/2000 don't send 6F when they're done loading, so we do the
|
// DC NTE and 11/2000 don't send 6F when they're done loading, so we clear
|
||||||
// relevant things 6F would do here instead.
|
// the loading flag here instead. On these versions, it also seems to be
|
||||||
|
// necessary to assign item IDs again here.
|
||||||
if (c->config.check_flag(Client::Flag::LOADING)) {
|
if (c->config.check_flag(Client::Flag::LOADING)) {
|
||||||
c->config.clear_flag(Client::Flag::LOADING);
|
c->config.clear_flag(Client::Flag::LOADING);
|
||||||
auto l = c->require_lobby();
|
auto l = c->require_lobby();
|
||||||
l->assign_inventory_and_bank_item_ids(c, true);
|
l->assign_inventory_and_bank_item_ids(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user