fix BB bank withdraw conditions
This commit is contained in:
@@ -5487,11 +5487,11 @@ struct G_WordSelectDuringBattle_GC_Ep3_6xBD {
|
|||||||
|
|
||||||
struct G_BankAction_BB_6xBD {
|
struct G_BankAction_BB_6xBD {
|
||||||
G_UnusedHeader header;
|
G_UnusedHeader header;
|
||||||
le_uint32_t item_id = 0; // 0xFFFFFFFF = meseta; anything else = item
|
le_uint32_t item_id = 0;
|
||||||
le_uint32_t meseta_amount = 0;
|
le_uint32_t meseta_amount = 0;
|
||||||
uint8_t action = 0; // 0 = deposit, 1 = take, 3 = done (close bank window)
|
uint8_t action = 0; // 0 = deposit, 1 = take, 3 = done (close bank window)
|
||||||
uint8_t item_amount = 0;
|
uint8_t item_amount = 0;
|
||||||
le_uint16_t unused2 = 0;
|
le_uint16_t item_index = 0; // 0xFFFF = meseta
|
||||||
} __packed__;
|
} __packed__;
|
||||||
|
|
||||||
// 6xBE: Sound chat (Episode 3; not Trial Edition)
|
// 6xBE: Sound chat (Episode 3; not Trial Edition)
|
||||||
|
|||||||
@@ -486,22 +486,10 @@ void PlayerBank::add_item(const ItemData& item) {
|
|||||||
this->num_items++;
|
this->num_items++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemData PlayerBank::remove_item(uint32_t item_id, uint32_t amount) {
|
ItemData PlayerBank::remove_item_by_index(size_t index, uint32_t amount) {
|
||||||
ItemData ret;
|
|
||||||
|
|
||||||
if (item_id == 0xFFFFFFFF) {
|
|
||||||
if (amount > this->meseta) {
|
|
||||||
throw out_of_range("player does not have enough meseta");
|
|
||||||
}
|
|
||||||
ret.data1[0] = 0x04;
|
|
||||||
ret.data2d = amount;
|
|
||||||
this->meseta -= amount;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t index = this->find_item(item_id);
|
|
||||||
auto& bank_item = this->items[index];
|
auto& bank_item = this->items[index];
|
||||||
|
|
||||||
|
ItemData ret;
|
||||||
if (amount && (bank_item.data.stack_size() > 1) && (amount < bank_item.data.data1[5])) {
|
if (amount && (bank_item.data.stack_size() > 1) && (amount < bank_item.data.data1[5])) {
|
||||||
ret = bank_item.data;
|
ret = bank_item.data;
|
||||||
ret.data1[5] = amount;
|
ret.data1[5] = amount;
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ struct PlayerBank {
|
|||||||
/* 12C8 */
|
/* 12C8 */
|
||||||
|
|
||||||
void add_item(const ItemData& item);
|
void add_item(const ItemData& item);
|
||||||
ItemData remove_item(uint32_t item_id, uint32_t amount);
|
ItemData remove_item_by_index(size_t index, uint32_t amount);
|
||||||
size_t find_item(uint32_t item_id);
|
size_t find_item(uint32_t item_id);
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
|||||||
@@ -1480,7 +1480,7 @@ static void on_ep3_private_word_select_bb_bank_action(shared_ptr<Client> c, uint
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (cmd.action == 1) { // Take
|
} else if (cmd.action == 1) { // Take
|
||||||
if (cmd.item_id == 0xFFFFFFFF) { // Take Meseta
|
if (cmd.item_index == 0xFFFF) { // Take Meseta
|
||||||
if (cmd.meseta_amount > p->bank.meseta) {
|
if (cmd.meseta_amount > p->bank.meseta) {
|
||||||
l->log.info("Player %hu attempted to withdraw %" PRIu32 " Meseta from the bank, but has only %" PRIu32 " Meseta in the bank",
|
l->log.info("Player %hu attempted to withdraw %" PRIu32 " Meseta from the bank, but has only %" PRIu32 " Meseta in the bank",
|
||||||
c->lobby_client_id, cmd.meseta_amount.load(), p->bank.meseta.load());
|
c->lobby_client_id, cmd.meseta_amount.load(), p->bank.meseta.load());
|
||||||
@@ -1495,14 +1495,14 @@ static void on_ep3_private_word_select_bb_bank_action(shared_ptr<Client> c, uint
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else { // Take item
|
} else { // Take item
|
||||||
auto item = p->bank.remove_item(cmd.item_id, cmd.item_amount);
|
auto item = p->bank.remove_item_by_index(cmd.item_index, cmd.item_amount);
|
||||||
item.id = l->generate_item_id(c->lobby_client_id);
|
item.id = l->generate_item_id(c->lobby_client_id);
|
||||||
p->add_item(item);
|
p->add_item(item);
|
||||||
send_create_inventory_item(c, item);
|
send_create_inventory_item(c, item);
|
||||||
|
|
||||||
string name = s->item_name_index->describe_item(Version::BB_V4, item);
|
string name = s->item_name_index->describe_item(Version::BB_V4, item);
|
||||||
l->log.info("Player %hu withdrew item %08" PRIX32 " (x%hhu) (%s) from the bank",
|
l->log.info("Player %hu withdrew item %08" PRIX32 " (x%hhu) (%s) from the bank",
|
||||||
c->lobby_client_id, cmd.item_id.load(), cmd.item_amount, name.c_str());
|
c->lobby_client_id, item.id.load(), cmd.item_amount, name.c_str());
|
||||||
c->game_data.character()->print_inventory(stderr, c->version(), s->item_name_index);
|
c->game_data.character()->print_inventory(stderr, c->version(), s->item_name_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -215,7 +215,7 @@ TeamIndex::Reward::Reward(uint32_t menu_item_id, const JSON& def_json)
|
|||||||
} catch (const out_of_range&) {
|
} catch (const out_of_range&) {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this->reward_item = ItemData::from_data(def_json.get_string("RewardItem"));
|
this->reward_item = ItemData::from_data(parse_data_string(def_json.get_string("RewardItem")));
|
||||||
} catch (const out_of_range&) {
|
} catch (const out_of_range&) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user