set up map loading at quest load time
This commit is contained in:
+1
-1
@@ -103,7 +103,7 @@ struct Lobby : public std::enable_shared_from_this<Lobby> {
|
||||
uint8_t leader_id;
|
||||
uint8_t max_clients;
|
||||
uint32_t flags;
|
||||
std::shared_ptr<const Quest> loading_quest;
|
||||
std::shared_ptr<const Quest> quest;
|
||||
std::array<std::shared_ptr<Client>, 12> clients;
|
||||
// Keys in this map are client_id
|
||||
std::unordered_map<size_t, std::weak_ptr<Client>> clients_to_add;
|
||||
|
||||
+34
-7
@@ -1568,11 +1568,11 @@ static void on_09(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||
info += "$C4Locked$C7\n";
|
||||
}
|
||||
|
||||
if (game->loading_quest) {
|
||||
if (game->quest) {
|
||||
if (game->flags & Lobby::Flag::JOINABLE_QUEST_IN_PROGRESS) {
|
||||
info += "$C6Quest: " + encode_sjis(game->loading_quest->name);
|
||||
info += "$C6Quest: " + encode_sjis(game->quest->name);
|
||||
} else {
|
||||
info += "$C4Quest: " + encode_sjis(game->loading_quest->name);
|
||||
info += "$C4Quest: " + encode_sjis(game->quest->name);
|
||||
}
|
||||
} else if (game->flags & Lobby::Flag::JOINABLE_QUEST_IN_PROGRESS) {
|
||||
info += "$C6Quest in progress";
|
||||
@@ -2005,7 +2005,7 @@ static void on_10(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||
} else {
|
||||
l->flags |= Lobby::Flag::QUEST_IN_PROGRESS;
|
||||
}
|
||||
l->loading_quest = q;
|
||||
l->quest = q;
|
||||
for (size_t x = 0; x < l->max_clients; x++) {
|
||||
if (!l->clients[x]) {
|
||||
continue;
|
||||
@@ -2337,7 +2337,34 @@ static void on_AC_V3_BB(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||
}
|
||||
c->flags &= ~Client::Flag::LOADING_QUEST;
|
||||
|
||||
send_quest_barrier_if_all_clients_ready(s->find_lobby(c->lobby_id));
|
||||
auto l = s->find_lobby(c->lobby_id);
|
||||
if (!l->quest.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (send_quest_barrier_if_all_clients_ready(l) &&
|
||||
(l->version == GameVersion::BB)) {
|
||||
// TODO: We should replace the game enemies list here. It'll look something
|
||||
// like this (but the dat format may be different from the existing loader):
|
||||
// try {
|
||||
// auto dat_data = prs_decompress(l->quest->dat_contents());
|
||||
// game->enemies = parse_map(
|
||||
// s->battle_params,
|
||||
// l->flags & Lobby::Flag::SOLO_MODE,
|
||||
// l->episode,
|
||||
// l->difficulty,
|
||||
// dat_data,
|
||||
// false);
|
||||
// c->log.info("Replaced enemies list with quest layout (%zu entries)",
|
||||
// l->enemies.size());
|
||||
// for (size_t z = 0; z < l->enemies.size(); z++) {
|
||||
// string e_str = l->enemies[z].str();
|
||||
// l->log.info("(Entry %zX) %s", z, e_str.c_str());
|
||||
// }
|
||||
// } catch (const exception& e) {
|
||||
// c->log.info("Failed to load quest layout: %s", e.what());
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
static void on_AA(shared_ptr<ServerState> s,
|
||||
@@ -2349,8 +2376,8 @@ static void on_AA(shared_ptr<ServerState> s,
|
||||
}
|
||||
|
||||
auto l = s->find_lobby(c->lobby_id);
|
||||
if (!l || !l->is_game() || !l->loading_quest.get() ||
|
||||
(l->loading_quest->internal_id != cmd.quest_internal_id)) {
|
||||
if (!l || !l->is_game() || !l->quest.get() ||
|
||||
(l->quest->internal_id != cmd.quest_internal_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+6
-5
@@ -2435,9 +2435,9 @@ void send_open_quest_file(shared_ptr<Client> c, const string& quest_name,
|
||||
}
|
||||
}
|
||||
|
||||
void send_quest_barrier_if_all_clients_ready(shared_ptr<Lobby> l) {
|
||||
bool send_quest_barrier_if_all_clients_ready(shared_ptr<Lobby> l) {
|
||||
if (!l || !l->is_game()) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if any client is still loading
|
||||
@@ -2452,16 +2452,17 @@ void send_quest_barrier_if_all_clients_ready(shared_ptr<Lobby> l) {
|
||||
}
|
||||
|
||||
// If they're all done, start the quest
|
||||
if (x == l->max_clients) {
|
||||
send_command(l, 0xAC, 0x00);
|
||||
if (x != l->max_clients) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if any client is still loading
|
||||
send_command(l, 0xAC, 0x00);
|
||||
for (x = 0; x < l->max_clients; x++) {
|
||||
if (l->clients[x]) {
|
||||
l->clients[x]->disconnect_hooks.erase(QUEST_BARRIER_DISCONNECT_HOOK_NAME);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void send_card_auction_if_all_clients_ready(
|
||||
|
||||
+1
-1
@@ -381,7 +381,7 @@ void send_quest_file_chunk(
|
||||
const void* data,
|
||||
size_t size,
|
||||
bool is_download_quest);
|
||||
void send_quest_barrier_if_all_clients_ready(std::shared_ptr<Lobby> l);
|
||||
bool send_quest_barrier_if_all_clients_ready(std::shared_ptr<Lobby> l);
|
||||
|
||||
void send_card_auction_if_all_clients_ready(
|
||||
std::shared_ptr<ServerState> s, std::shared_ptr<Lobby> l);
|
||||
|
||||
Reference in New Issue
Block a user