enable $quest to load v3 quests on ep3
This commit is contained in:
+8
-2
@@ -257,10 +257,16 @@ static void server_command_quest(shared_ptr<Client> c, const std::string& args)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Version effective_version = is_ep3(c->version()) ? Version::GC_V3 : c->version();
|
||||||
|
|
||||||
auto s = c->require_server_state();
|
auto s = c->require_server_state();
|
||||||
auto l = c->require_lobby();
|
auto l = c->require_lobby();
|
||||||
auto q = s->quest_index_for_client(c)->get(stoul(args));
|
auto q = s->quest_index_for_version(effective_version)->get(stoul(args));
|
||||||
set_lobby_quest(c->require_lobby(), q);
|
if (!q) {
|
||||||
|
send_text_message(c, "$C6Quest not found");
|
||||||
|
} else {
|
||||||
|
set_lobby_quest(c->require_lobby(), q, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void server_command_qcheck(shared_ptr<Client> c, const std::string& args) {
|
static void server_command_qcheck(shared_ptr<Client> c, const std::string& args) {
|
||||||
|
|||||||
+11
-7
@@ -1670,7 +1670,7 @@ static void on_09(shared_ptr<Client> c, uint16_t, uint32_t, string& data) {
|
|||||||
break;
|
break;
|
||||||
case MenuID::QUEST: {
|
case MenuID::QUEST: {
|
||||||
bool is_download_quest = !c->lobby.lock();
|
bool is_download_quest = !c->lobby.lock();
|
||||||
auto quest_index = s->quest_index_for_client(c);
|
auto quest_index = s->quest_index_for_version(c->version());
|
||||||
if (!quest_index) {
|
if (!quest_index) {
|
||||||
send_quest_info(c, "$C6Quests are not available.", is_download_quest);
|
send_quest_info(c, "$C6Quests are not available.", is_download_quest);
|
||||||
} else {
|
} else {
|
||||||
@@ -1909,7 +1909,7 @@ static void on_quest_loaded(shared_ptr<Lobby> l) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_lobby_quest(shared_ptr<Lobby> l, shared_ptr<const Quest> q) {
|
void set_lobby_quest(shared_ptr<Lobby> l, shared_ptr<const Quest> q, bool substitute_v3_for_ep3) {
|
||||||
if (!l->is_game()) {
|
if (!l->is_game()) {
|
||||||
throw logic_error("non-game lobby cannot accept a quest");
|
throw logic_error("non-game lobby cannot accept a quest");
|
||||||
}
|
}
|
||||||
@@ -1926,7 +1926,9 @@ void set_lobby_quest(shared_ptr<Lobby> l, shared_ptr<const Quest> q) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
l->quest = q;
|
l->quest = q;
|
||||||
l->episode = q->episode;
|
if (!is_ep3(l->base_version)) {
|
||||||
|
l->episode = q->episode;
|
||||||
|
}
|
||||||
if (l->item_creator) {
|
if (l->item_creator) {
|
||||||
l->create_item_creator();
|
l->create_item_creator();
|
||||||
}
|
}
|
||||||
@@ -1959,7 +1961,9 @@ void set_lobby_quest(shared_ptr<Lobby> l, shared_ptr<const Quest> q) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto vq = q->version(lc->version(), lc->language());
|
Version effective_version = (substitute_v3_for_ep3 && is_ep3(lc->version())) ? Version::GC_V3 : lc->version();
|
||||||
|
|
||||||
|
auto vq = q->version(effective_version, lc->language());
|
||||||
if (!vq) {
|
if (!vq) {
|
||||||
send_lobby_message_box(lc, "$C6Quest does not exist\nfor this game version.");
|
send_lobby_message_box(lc, "$C6Quest does not exist\nfor this game version.");
|
||||||
lc->should_disconnect = true;
|
lc->should_disconnect = true;
|
||||||
@@ -2063,7 +2067,7 @@ static void on_10(shared_ptr<Client> c, uint16_t, uint32_t, string& data) {
|
|||||||
// always the download quest menu. (Episode 3 does actually have
|
// always the download quest menu. (Episode 3 does actually have
|
||||||
// online quests, but they're served via a server data request
|
// online quests, but they're served via a server data request
|
||||||
// instead of the file download paradigm that other versions use.)
|
// instead of the file download paradigm that other versions use.)
|
||||||
auto quest_index = s->quest_index_for_client(c);
|
auto quest_index = s->quest_index_for_version(c->version());
|
||||||
const auto& categories = quest_index->categories(menu_type, Episode::EP3, c->version());
|
const auto& categories = quest_index->categories(menu_type, Episode::EP3, c->version());
|
||||||
if (categories.size() == 1) {
|
if (categories.size() == 1) {
|
||||||
auto quests = quest_index->filter(menu_type, Episode::EP3, c->version(), categories[0]->category_id);
|
auto quests = quest_index->filter(menu_type, Episode::EP3, c->version(), categories[0]->category_id);
|
||||||
@@ -2306,7 +2310,7 @@ static void on_10(shared_ptr<Client> c, uint16_t, uint32_t, string& data) {
|
|||||||
|
|
||||||
case MenuID::QUEST_CATEGORIES: {
|
case MenuID::QUEST_CATEGORIES: {
|
||||||
auto s = c->require_server_state();
|
auto s = c->require_server_state();
|
||||||
auto quest_index = s->quest_index_for_client(c);
|
auto quest_index = s->quest_index_for_version(c->version());
|
||||||
if (!quest_index) {
|
if (!quest_index) {
|
||||||
send_lobby_message_box(c, "$C6Quests are not available.");
|
send_lobby_message_box(c, "$C6Quests are not available.");
|
||||||
break;
|
break;
|
||||||
@@ -2346,7 +2350,7 @@ static void on_10(shared_ptr<Client> c, uint16_t, uint32_t, string& data) {
|
|||||||
|
|
||||||
case MenuID::QUEST: {
|
case MenuID::QUEST: {
|
||||||
auto s = c->require_server_state();
|
auto s = c->require_server_state();
|
||||||
auto quest_index = s->quest_index_for_client(c);
|
auto quest_index = s->quest_index_for_version(c->version());
|
||||||
if (!quest_index) {
|
if (!quest_index) {
|
||||||
send_lobby_message_box(c, "$C6Quests are not\navailable.");
|
send_lobby_message_box(c, "$C6Quests are not\navailable.");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ std::shared_ptr<Lobby> create_game_generic(
|
|||||||
bool allow_v1 = false,
|
bool allow_v1 = false,
|
||||||
std::shared_ptr<Lobby> watched_lobby = nullptr,
|
std::shared_ptr<Lobby> watched_lobby = nullptr,
|
||||||
std::shared_ptr<Episode3::BattleRecordPlayer> battle_player = nullptr);
|
std::shared_ptr<Episode3::BattleRecordPlayer> battle_player = nullptr);
|
||||||
void set_lobby_quest(std::shared_ptr<Lobby> l, std::shared_ptr<const Quest> q);
|
void set_lobby_quest(std::shared_ptr<Lobby> l, std::shared_ptr<const Quest> q, bool substitute_v3_for_ep3 = false);
|
||||||
|
|
||||||
void on_connect(std::shared_ptr<Client> c);
|
void on_connect(std::shared_ptr<Client> c);
|
||||||
void on_disconnect(std::shared_ptr<Client> c);
|
void on_disconnect(std::shared_ptr<Client> c);
|
||||||
|
|||||||
+2
-2
@@ -1209,6 +1209,6 @@ shared_ptr<const vector<string>> ServerState::information_contents_for_client(sh
|
|||||||
return is_v1_or_v2(c->version()) ? this->information_contents_v2 : this->information_contents_v3;
|
return is_v1_or_v2(c->version()) ? this->information_contents_v2 : this->information_contents_v3;
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<const QuestIndex> ServerState::quest_index_for_client(shared_ptr<const Client> c) const {
|
shared_ptr<const QuestIndex> ServerState::quest_index_for_version(Version version) const {
|
||||||
return is_ep3(c->version()) ? this->ep3_download_quest_index : this->default_quest_index;
|
return is_ep3(version) ? this->ep3_download_quest_index : this->default_quest_index;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -227,7 +227,7 @@ struct ServerState : public std::enable_shared_from_this<ServerState> {
|
|||||||
std::string describe_item(Version version, const ItemData& item, bool include_color_codes) const;
|
std::string describe_item(Version version, const ItemData& item, bool include_color_codes) const;
|
||||||
|
|
||||||
std::shared_ptr<const std::vector<std::string>> information_contents_for_client(std::shared_ptr<const Client> c) const;
|
std::shared_ptr<const std::vector<std::string>> information_contents_for_client(std::shared_ptr<const Client> c) const;
|
||||||
std::shared_ptr<const QuestIndex> quest_index_for_client(std::shared_ptr<const Client> c) const;
|
std::shared_ptr<const QuestIndex> quest_index_for_version(Version version) const;
|
||||||
|
|
||||||
void set_port_configuration(const std::vector<PortConfiguration>& port_configs);
|
void set_port_configuration(const std::vector<PortConfiguration>& port_configs);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user