add option to allow $quest without $debug for certain quests
This commit is contained in:
+17
-6
@@ -298,18 +298,29 @@ static void server_command_debug(shared_ptr<Client> c, const std::string&) {
|
||||
}
|
||||
|
||||
static void server_command_quest(shared_ptr<Client> c, const std::string& args) {
|
||||
check_debug_enabled(c);
|
||||
|
||||
Version effective_version = is_ep3(c->version()) ? Version::GC_V3 : c->version();
|
||||
|
||||
auto s = c->require_server_state();
|
||||
auto l = c->require_lobby();
|
||||
if (!l->is_game()) {
|
||||
throw precondition_failed("$C6Quests cannot be\nstarted from the\nlobby");
|
||||
}
|
||||
|
||||
Version effective_version = is_ep3(c->version()) ? Version::GC_V3 : c->version();
|
||||
auto q = s->quest_index(effective_version)->get(stoul(args));
|
||||
if (!q) {
|
||||
send_text_message(c, "$C6Quest not found");
|
||||
} else {
|
||||
set_lobby_quest(c->require_lobby(), q, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) {
|
||||
if (l->count_clients() > 1) {
|
||||
throw precondition_failed("$C6This command can only\nbe used with no\nother players present");
|
||||
}
|
||||
if (!q->allow_start_from_chat_command) {
|
||||
throw precondition_failed("$C6This quest cannot\nbe started with the\n%squest command");
|
||||
}
|
||||
}
|
||||
|
||||
set_lobby_quest(c->require_lobby(), q, true);
|
||||
}
|
||||
|
||||
static void server_command_qcheck(shared_ptr<Client> c, const std::string& args) {
|
||||
|
||||
@@ -206,11 +206,13 @@ VersionedQuest::VersionedQuest(
|
||||
ssize_t challenge_template_index,
|
||||
std::shared_ptr<const IntegralExpression> available_expression,
|
||||
std::shared_ptr<const IntegralExpression> enabled_expression,
|
||||
bool allow_start_from_chat_command,
|
||||
bool force_joinable,
|
||||
int16_t lock_status_register)
|
||||
: quest_number(quest_number),
|
||||
category_id(category_id),
|
||||
episode(Episode::NONE),
|
||||
allow_start_from_chat_command(allow_start_from_chat_command),
|
||||
joinable(force_joinable),
|
||||
lock_status_register(lock_status_register),
|
||||
version(version),
|
||||
@@ -384,6 +386,7 @@ Quest::Quest(shared_ptr<const VersionedQuest> initial_version)
|
||||
: quest_number(initial_version->quest_number),
|
||||
category_id(initial_version->category_id),
|
||||
episode(initial_version->episode),
|
||||
allow_start_from_chat_command(initial_version->allow_start_from_chat_command),
|
||||
joinable(initial_version->joinable),
|
||||
lock_status_register(initial_version->lock_status_register),
|
||||
name(initial_version->name),
|
||||
@@ -408,6 +411,9 @@ void Quest::add_version(shared_ptr<const VersionedQuest> vq) {
|
||||
if (this->episode != vq->episode) {
|
||||
throw runtime_error("quest version is in a different episode");
|
||||
}
|
||||
if (this->allow_start_from_chat_command != vq->allow_start_from_chat_command) {
|
||||
throw runtime_error("quest version has a different allow_start_from_chat_command state");
|
||||
}
|
||||
if (this->joinable != vq->joinable) {
|
||||
throw runtime_error("quest version has a different joinability state");
|
||||
}
|
||||
@@ -676,6 +682,7 @@ QuestIndex::QuestIndex(
|
||||
ssize_t challenge_template_index = -1;
|
||||
shared_ptr<const IntegralExpression> available_expression;
|
||||
shared_ptr<const IntegralExpression> enabled_expression;
|
||||
bool allow_start_from_chat_command = false;
|
||||
bool force_joinable = false;
|
||||
int16_t lock_status_register = -1;
|
||||
try {
|
||||
@@ -708,6 +715,10 @@ QuestIndex::QuestIndex(
|
||||
enabled_expression = make_shared<IntegralExpression>(metadata_json.get_string("EnabledIf"));
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
try {
|
||||
allow_start_from_chat_command = metadata_json.get_bool("AllowStartFromChatCommand");
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
try {
|
||||
force_joinable = metadata_json.get_bool("Joinable");
|
||||
} catch (const out_of_range&) {
|
||||
@@ -730,6 +741,7 @@ QuestIndex::QuestIndex(
|
||||
challenge_template_index,
|
||||
available_expression,
|
||||
enabled_expression,
|
||||
allow_start_from_chat_command,
|
||||
force_joinable,
|
||||
lock_status_register);
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ struct VersionedQuest {
|
||||
uint32_t quest_number;
|
||||
uint32_t category_id;
|
||||
Episode episode;
|
||||
bool allow_start_from_chat_command;
|
||||
bool joinable;
|
||||
int16_t lock_status_register;
|
||||
std::string name;
|
||||
@@ -92,6 +93,7 @@ struct VersionedQuest {
|
||||
ssize_t challenge_template_index = -1,
|
||||
std::shared_ptr<const IntegralExpression> available_expression = nullptr,
|
||||
std::shared_ptr<const IntegralExpression> enabled_expression = nullptr,
|
||||
bool allow_start_from_chat_command = false,
|
||||
bool force_joinable = false,
|
||||
int16_t lock_status_register = -1);
|
||||
|
||||
@@ -123,6 +125,7 @@ public:
|
||||
uint32_t quest_number;
|
||||
uint32_t category_id;
|
||||
Episode episode;
|
||||
bool allow_start_from_chat_command;
|
||||
bool joinable;
|
||||
int16_t lock_status_register;
|
||||
std::string name;
|
||||
|
||||
@@ -2055,6 +2055,7 @@ void set_lobby_quest(shared_ptr<Lobby> l, shared_ptr<const Quest> q, bool substi
|
||||
lc->should_disconnect = true;
|
||||
break;
|
||||
}
|
||||
lc->log.info("Sending %c version of quest \"%s\"", char_for_language_code(vq->language), vq->name.c_str());
|
||||
|
||||
string bin_filename = vq->bin_filename();
|
||||
string dat_filename = vq->dat_filename();
|
||||
|
||||
Reference in New Issue
Block a user