implement 6xD1 command for BB challenge mode
This commit is contained in:
@@ -5629,15 +5629,15 @@ struct G_BattleModeLevelUp_BB_6xD0 {
|
||||
le_uint32_t num_levels = 0;
|
||||
} __packed__;
|
||||
|
||||
// 6xD1: Challenge mode grave (BB; handled by server)
|
||||
// 6xD1: Request Challenge Mode grave recovery item (BB; handled by server)
|
||||
|
||||
struct G_ChallengeModeGrave_BB_6xD1 {
|
||||
struct G_ChallengeModeGraveRecoveryItemRequest_BB_6xD1 {
|
||||
G_ClientIDHeader header;
|
||||
le_uint16_t unknown_a1 = 0;
|
||||
le_uint16_t floor = 0;
|
||||
le_uint16_t unknown_a2 = 0;
|
||||
le_uint32_t unknown_a3 = 0;
|
||||
le_uint32_t unknown_a4 = 0;
|
||||
le_uint32_t unknown_a5 = 0;
|
||||
le_float x = 0;
|
||||
le_float z = 0;
|
||||
le_uint32_t item_type = 0; // Should be < 6
|
||||
} __packed__;
|
||||
|
||||
// 6xD2: Set quest global flag (BB)
|
||||
|
||||
@@ -18,6 +18,12 @@ ItemData::ItemData(const ItemData& other) {
|
||||
this->data2d = other.data2d;
|
||||
}
|
||||
|
||||
ItemData::ItemData(uint64_t first, uint64_t second) {
|
||||
*reinterpret_cast<be_uint64_t*>(&this->data1[0]) = first;
|
||||
this->data1d[2] = bswap32((second >> 32) & 0xFFFFFFFF);
|
||||
this->data2d = bswap32(second & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
ItemData& ItemData::operator=(const ItemData& other) {
|
||||
this->data1d = other.data1d;
|
||||
this->id = other.id;
|
||||
|
||||
@@ -122,6 +122,7 @@ struct ItemData { // 0x14 bytes
|
||||
|
||||
ItemData();
|
||||
ItemData(const ItemData& other);
|
||||
ItemData(uint64_t first, uint64_t second = 0);
|
||||
ItemData& operator=(const ItemData& other);
|
||||
|
||||
bool operator==(const ItemData& other) const;
|
||||
|
||||
@@ -2302,6 +2302,28 @@ static void on_battle_level_up_bb(shared_ptr<Client> c, uint8_t, uint8_t, const
|
||||
}
|
||||
}
|
||||
|
||||
static void on_request_challenge_grave_recovery_item_bb(shared_ptr<Client> c, uint8_t, uint8_t, const void* data, size_t size) {
|
||||
auto l = c->require_lobby();
|
||||
if (l->is_game() &&
|
||||
(l->base_version == GameVersion::BB) &&
|
||||
(l->mode == GameMode::CHALLENGE) &&
|
||||
l->check_flag(Lobby::Flag::QUEST_IN_PROGRESS)) {
|
||||
const auto& cmd = check_size_t<G_ChallengeModeGraveRecoveryItemRequest_BB_6xD1>(data, size);
|
||||
static const array<ItemData, 6> items = {
|
||||
ItemData(0x0300000000010000), // Monomate x1
|
||||
ItemData(0x0300010000010000), // Dimate x1
|
||||
ItemData(0x0300020000010000), // Trimate x1
|
||||
ItemData(0x0301000000010000), // Monofluid x1
|
||||
ItemData(0x0301010000010000), // Difluid x1
|
||||
ItemData(0x0301020000010000), // Trifluid x1
|
||||
};
|
||||
ItemData item = items.at(cmd.item_type);
|
||||
item.id = l->generate_item_id(0xFF);
|
||||
l->add_item(item, cmd.floor, cmd.x, cmd.z);
|
||||
send_drop_stacked_item(l, item, cmd.floor, cmd.x, cmd.z);
|
||||
}
|
||||
}
|
||||
|
||||
static void on_quest_exchange_item_bb(shared_ptr<Client> c, uint8_t, uint8_t, const void* data, size_t size) {
|
||||
auto l = c->require_lobby();
|
||||
if (l->is_game() &&
|
||||
@@ -2875,7 +2897,7 @@ subcommand_handler_t subcommand_handlers[0x100] = {
|
||||
/* 6xCE */ nullptr,
|
||||
/* 6xCF */ on_battle_restart_bb,
|
||||
/* 6xD0 */ on_battle_level_up_bb,
|
||||
/* 6xD1 */ nullptr,
|
||||
/* 6xD1 */ on_request_challenge_grave_recovery_item_bb,
|
||||
/* 6xD2 */ on_write_quest_global_flag_bb,
|
||||
/* 6xD3 */ nullptr,
|
||||
/* 6xD4 */ nullptr,
|
||||
|
||||
+2
-4
@@ -296,10 +296,8 @@ void send_drop_item(std::shared_ptr<ServerState> s, Channel& ch, const ItemData&
|
||||
bool from_enemy, uint8_t floor, float x, float z, uint16_t request_id);
|
||||
void send_drop_item(std::shared_ptr<Lobby> l, const ItemData& item,
|
||||
bool from_enemy, uint8_t floor, float x, float z, uint16_t request_id);
|
||||
void send_drop_stacked_item(std::shared_ptr<ServerState> s, Channel& ch, const ItemData& item,
|
||||
uint8_t floor, float x, float z);
|
||||
void send_drop_stacked_item(std::shared_ptr<Lobby> l, const ItemData& item,
|
||||
uint8_t floor, float x, float z);
|
||||
void send_drop_stacked_item(std::shared_ptr<ServerState> s, Channel& ch, const ItemData& item, uint8_t floor, float x, float z);
|
||||
void send_drop_stacked_item(std::shared_ptr<Lobby> l, const ItemData& item, uint8_t floor, float x, float z);
|
||||
void send_pick_up_item(std::shared_ptr<Client> c, uint32_t id, uint8_t floor);
|
||||
void send_create_inventory_item(std::shared_ptr<Client> c, const ItemData& item);
|
||||
void send_destroy_item(std::shared_ptr<Client> c, uint32_t item_id, uint32_t amount);
|
||||
|
||||
Reference in New Issue
Block a user