load quest enemies when starting BB quest

This commit is contained in:
Martin Michelsen
2023-06-19 18:33:19 -07:00
parent 8db058871f
commit 9a6c0b6c9a
3 changed files with 35 additions and 0 deletions
+26
View File
@@ -480,6 +480,32 @@ void Map::add_enemies_from_map_data(
}
}
void Map::add_enemies_from_quest_data(
Episode episode,
uint8_t difficulty,
uint8_t event,
const void* data,
size_t size) {
StringReader r(data, size);
while (!r.eof()) {
const auto& header = r.get<Quest::DATSectionHeader>();
if (header.type == 0 && header.section_size == 0) {
break;
}
if (header.section_size < sizeof(header)) {
throw runtime_error(string_printf("quest layout has invalid section header at offset 0x%zX", r.where() - sizeof(header)));
}
if (header.type == 2) {
if (header.data_size % sizeof(EnemyEntry)) {
throw runtime_error("quest layout enemy section size is not a multiple of enemy entry size");
}
this->add_enemies_from_map_data(episode, difficulty, event, r.getv(header.data_size), header.data_size);
} else {
r.skip(header.section_size - sizeof(header));
}
}
}
SetDataTable::SetDataTable(shared_ptr<const string> data, bool big_endian) {
if (big_endian) {
this->load_table_t<true>(data);
+7
View File
@@ -45,6 +45,13 @@ struct QuestCategoryIndex {
class Quest {
public:
struct DATSectionHeader {
le_uint32_t type; // 1 = objects, 2 = enemies. There are other types too
le_uint32_t section_size; // Includes this header
le_uint32_t area;
le_uint32_t data_size;
} __attribute__((packed));
enum class FileFormat {
BIN_DAT = 0,
BIN_DAT_UNCOMPRESSED,
+2
View File
@@ -12,6 +12,7 @@
#include <phosg/Time.hh>
#include "ChatCommands.hh"
#include "Compression.hh"
#include "Episode3/Tournament.hh"
#include "FileContentsCache.hh"
#include "ItemCreator.hh"
@@ -1973,6 +1974,7 @@ static void on_10(shared_ptr<ServerState> s, shared_ptr<Client> c,
l->flags |= Lobby::Flag::QUEST_IN_PROGRESS;
}
l->quest = q;
l->episode = q->episode;
for (size_t x = 0; x < l->max_clients; x++) {
if (!l->clients[x]) {
continue;