split Ep3 and Ep1&2 quest indexes
This commit is contained in:
+16
-13
@@ -1462,10 +1462,11 @@ static void on_09(shared_ptr<Client> c, uint16_t, uint32_t, const string& data)
|
||||
break;
|
||||
case MenuID::QUEST: {
|
||||
bool is_download_quest = !c->lobby.lock();
|
||||
if (!s->quest_index) {
|
||||
auto quest_index = s->quest_index_for_client(c);
|
||||
if (!quest_index) {
|
||||
send_quest_info(c, u"$C6Quests are not available.", is_download_quest);
|
||||
} else {
|
||||
auto q = s->quest_index->get(cmd.item_id);
|
||||
auto q = quest_index->get(cmd.item_id);
|
||||
if (!q) {
|
||||
send_quest_info(c, u"$C4Quest does not\nexist.", is_download_quest);
|
||||
} else {
|
||||
@@ -1716,8 +1717,13 @@ static void on_10(shared_ptr<Client> c, uint16_t, uint32_t, const string& data)
|
||||
}
|
||||
}
|
||||
if (num_ep3_categories == 1) {
|
||||
auto quests = s->quest_index->filter(ep3_category_id, c->quest_version(), c->language());
|
||||
send_quest_menu(c, MenuID::QUEST, quests, true);
|
||||
auto quest_index = s->quest_index_for_client(c);
|
||||
if (quest_index) {
|
||||
auto quests = quest_index->filter(ep3_category_id, c->quest_version(), c->language());
|
||||
send_quest_menu(c, MenuID::QUEST, quests, true);
|
||||
} else {
|
||||
send_lobby_message_box(c, u"$C6Quests are not available.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1962,12 +1968,13 @@ static void on_10(shared_ptr<Client> c, uint16_t, uint32_t, const string& data)
|
||||
|
||||
case MenuID::QUEST_FILTER: {
|
||||
auto s = c->require_server_state();
|
||||
if (!s->quest_index) {
|
||||
auto quest_index = s->quest_index_for_client(c);
|
||||
if (!quest_index) {
|
||||
send_lobby_message_box(c, u"$C6Quests are not available.");
|
||||
break;
|
||||
}
|
||||
shared_ptr<Lobby> l = c->lobby.lock();
|
||||
auto quests = s->quest_index->filter(item_id, c->quest_version(), c->language());
|
||||
auto quests = quest_index->filter(item_id, c->quest_version(), c->language());
|
||||
|
||||
// Hack: Assume the menu to be sent is the download quest menu if the
|
||||
// client is not in any lobby
|
||||
@@ -1977,11 +1984,12 @@ static void on_10(shared_ptr<Client> c, uint16_t, uint32_t, const string& data)
|
||||
|
||||
case MenuID::QUEST: {
|
||||
auto s = c->require_server_state();
|
||||
if (!s->quest_index) {
|
||||
auto quest_index = s->quest_index_for_client(c);
|
||||
if (!quest_index) {
|
||||
send_lobby_message_box(c, u"$C6Quests are not\navailable.");
|
||||
break;
|
||||
}
|
||||
auto q = s->quest_index->get(item_id);
|
||||
auto q = quest_index->get(item_id);
|
||||
if (!q) {
|
||||
send_lobby_message_box(c, u"$C6Quest does not exist.");
|
||||
break;
|
||||
@@ -2328,11 +2336,6 @@ static void on_A2(shared_ptr<Client> c, uint16_t, uint32_t flag, const string& d
|
||||
check_size_v(data.size(), 0);
|
||||
auto s = c->require_server_state();
|
||||
|
||||
if (!s->quest_index) {
|
||||
send_lobby_message_box(c, u"$C6Quests are not available.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto l = c->lobby.lock();
|
||||
if (!l || !l->is_game()) {
|
||||
send_lobby_message_box(c, u"$C6Quests are not available\nin lobbies.");
|
||||
|
||||
+2
-2
@@ -116,8 +116,8 @@ Server commands:\n\
|
||||
battle-params - reload the enemy stats files\n\
|
||||
level-table - reload the level-up tables\n\
|
||||
item-tables - reload the item generation tables\n\
|
||||
ep3 - reload the Episode 3 card definitions and maps\n\
|
||||
quests - reindex all quests\n\
|
||||
ep3 - reload Episode 3 card definitions and maps (not download quests)\n\
|
||||
quests - reindex all quests (including Episode 3 download quests)\n\
|
||||
functions - recompile all client-side functions\n\
|
||||
dol-files - reindex all DOL files\n\
|
||||
config - reload most fields from config.json\n\
|
||||
|
||||
+14
-6
@@ -310,7 +310,7 @@ shared_ptr<Client> ServerState::find_client(const std::u16string* identifier,
|
||||
throw out_of_range("client not found");
|
||||
}
|
||||
|
||||
uint32_t ServerState::connect_address_for_client(std::shared_ptr<Client> c) {
|
||||
uint32_t ServerState::connect_address_for_client(std::shared_ptr<Client> c) const {
|
||||
if (c->channel.is_virtual_connection) {
|
||||
if (c->channel.remote_addr.ss_family != AF_INET) {
|
||||
throw logic_error("virtual connection is missing remote IPv4 address");
|
||||
@@ -329,7 +329,7 @@ uint32_t ServerState::connect_address_for_client(std::shared_ptr<Client> c) {
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<const Menu> ServerState::information_menu_for_version(GameVersion version) {
|
||||
std::shared_ptr<const Menu> ServerState::information_menu_for_version(GameVersion version) const {
|
||||
if ((version == GameVersion::DC) || (version == GameVersion::PC)) {
|
||||
return this->information_menu_v2;
|
||||
} else if ((version == GameVersion::GC) || (version == GameVersion::XB)) {
|
||||
@@ -338,7 +338,7 @@ std::shared_ptr<const Menu> ServerState::information_menu_for_version(GameVersio
|
||||
throw out_of_range("no information menu exists for this version");
|
||||
}
|
||||
|
||||
shared_ptr<const Menu> ServerState::proxy_destinations_menu_for_version(GameVersion version) {
|
||||
shared_ptr<const Menu> ServerState::proxy_destinations_menu_for_version(GameVersion version) const {
|
||||
switch (version) {
|
||||
case GameVersion::DC:
|
||||
return this->proxy_destinations_menu_dc;
|
||||
@@ -353,7 +353,7 @@ shared_ptr<const Menu> ServerState::proxy_destinations_menu_for_version(GameVers
|
||||
}
|
||||
}
|
||||
|
||||
const vector<pair<string, uint16_t>>& ServerState::proxy_destinations_for_version(GameVersion version) {
|
||||
const vector<pair<string, uint16_t>>& ServerState::proxy_destinations_for_version(GameVersion version) const {
|
||||
switch (version) {
|
||||
case GameVersion::DC:
|
||||
return this->proxy_destinations_dc;
|
||||
@@ -979,8 +979,10 @@ void ServerState::resolve_ep3_card_names() {
|
||||
}
|
||||
|
||||
void ServerState::load_quest_index() {
|
||||
config_log.info("Collecting quest metadata");
|
||||
this->quest_index.reset(new QuestIndex("system/quests", this->quest_category_index));
|
||||
config_log.info("Collecting quests");
|
||||
this->default_quest_index.reset(new QuestIndex("system/quests", this->quest_category_index));
|
||||
config_log.info("Collecting Episode 3 download quests");
|
||||
this->ep3_download_quest_index.reset(new QuestIndex("system/ep3/maps-download", this->quest_category_index));
|
||||
}
|
||||
|
||||
void ServerState::compile_functions() {
|
||||
@@ -992,3 +994,9 @@ void ServerState::load_dol_files() {
|
||||
config_log.info("Loading DOL files");
|
||||
this->dol_file_index.reset(new DOLFileIndex("system/dol"));
|
||||
}
|
||||
|
||||
shared_ptr<const QuestIndex> ServerState::quest_index_for_client(shared_ptr<Client> c) const {
|
||||
return (c->flags & Client::Flag::IS_EPISODE_3)
|
||||
? this->ep3_download_quest_index
|
||||
: this->default_quest_index;
|
||||
}
|
||||
|
||||
+9
-7
@@ -84,7 +84,8 @@ struct ServerState : public std::enable_shared_from_this<ServerState> {
|
||||
std::shared_ptr<const G_SetEXResultValues_GC_Ep3_6xB4x4B> ep3_tournament_ex_values;
|
||||
std::shared_ptr<const G_SetEXResultValues_GC_Ep3_6xB4x4B> ep3_tournament_final_round_ex_values;
|
||||
std::shared_ptr<const QuestCategoryIndex> quest_category_index;
|
||||
std::shared_ptr<const QuestIndex> quest_index;
|
||||
std::shared_ptr<const QuestIndex> default_quest_index;
|
||||
std::shared_ptr<const QuestIndex> ep3_download_quest_index;
|
||||
std::shared_ptr<const LevelTable> level_table;
|
||||
std::shared_ptr<const BattleParamsIndex> battle_params;
|
||||
std::shared_ptr<const GSLArchive> bb_data_gsl;
|
||||
@@ -185,14 +186,15 @@ struct ServerState : public std::enable_shared_from_this<ServerState> {
|
||||
uint64_t serial_number = 0,
|
||||
std::shared_ptr<Lobby> l = nullptr);
|
||||
|
||||
uint32_t connect_address_for_client(std::shared_ptr<Client> c);
|
||||
uint32_t connect_address_for_client(std::shared_ptr<Client> c) const;
|
||||
|
||||
std::shared_ptr<const Menu> information_menu_for_version(GameVersion version);
|
||||
std::shared_ptr<const Menu> proxy_destinations_menu_for_version(GameVersion version);
|
||||
const std::vector<std::pair<std::string, uint16_t>>& proxy_destinations_for_version(GameVersion version);
|
||||
std::shared_ptr<const Menu> information_menu_for_version(GameVersion version) const;
|
||||
std::shared_ptr<const Menu> proxy_destinations_menu_for_version(GameVersion version) const;
|
||||
const std::vector<std::pair<std::string, uint16_t>>& proxy_destinations_for_version(GameVersion version) const;
|
||||
|
||||
void set_port_configuration(
|
||||
const std::vector<PortConfiguration>& port_configs);
|
||||
std::shared_ptr<const QuestIndex> quest_index_for_client(std::shared_ptr<Client> c) const;
|
||||
|
||||
void set_port_configuration(const std::vector<PortConfiguration>& port_configs);
|
||||
|
||||
std::shared_ptr<const std::string> load_bb_file(
|
||||
const std::string& patch_index_filename,
|
||||
|
||||
Reference in New Issue
Block a user