fix event lookups in quest availability expressions

This commit is contained in:
Martin Michelsen
2024-03-03 23:15:57 -08:00
parent 6d6a8621bb
commit 7cd5aa1c2d
5 changed files with 4 additions and 19 deletions
-13
View File
@@ -767,19 +767,6 @@ Lobby::JoinError Lobby::join_error_for_client(std::shared_ptr<Client> c, const s
return JoinError::ALLOWED;
}
uint8_t Lobby::game_event_for_lobby_event(uint8_t lobby_event) {
if (lobby_event > 7) {
return 0;
}
if (lobby_event == 7) {
return 2;
}
if (lobby_event == 2) {
return 0;
}
return lobby_event;
}
bool Lobby::item_exists(uint8_t floor, uint32_t item_id) const {
if (floor >= this->floor_item_managers.size()) {
return false;
-2
View File
@@ -294,8 +294,6 @@ struct Lobby : public std::enable_shared_from_this<Lobby> {
QuestIndex::IncludeCondition quest_include_condition() const;
static uint8_t game_event_for_lobby_event(uint8_t lobby_event);
std::unordered_map<uint32_t, std::shared_ptr<Client>> clients_by_serial_number() const;
static void dispatch_on_idle_timeout(evutil_socket_t, short, void* ctx);
+2 -2
View File
@@ -252,14 +252,14 @@ bool QuestAvailabilityExpression::EventLookupNode::operator==(const Node& other)
}
int64_t QuestAvailabilityExpression::EventLookupNode::evaluate(const Env& env) const {
return env.num_players;
return env.event;
}
string QuestAvailabilityExpression::EventLookupNode::str() const {
return "V_Event";
}
QuestAvailabilityExpression::ConstantNode::ConstantNode(bool value)
QuestAvailabilityExpression::ConstantNode::ConstantNode(int64_t value)
: value(value) {}
bool QuestAvailabilityExpression::ConstantNode::operator==(const Node& other) const {
+1 -1
View File
@@ -162,7 +162,7 @@ protected:
class ConstantNode : public Node {
public:
ConstantNode(bool value);
ConstantNode(int64_t value);
virtual ~ConstantNode() = default;
virtual bool operator==(const Node& other) const;
virtual int64_t evaluate(const Env& env) const;
+1 -1
View File
@@ -4233,7 +4233,7 @@ shared_ptr<Lobby> create_game_generic(
throw logic_error("invalid quest script version");
}
game->event = Lobby::game_event_for_lobby_event(current_lobby->event);
game->event = current_lobby->event;
game->block = 0xFF;
game->max_clients = game->check_flag(Lobby::Flag::IS_SPECTATOR_TEAM) ? 12 : 4;
game->min_level = min_level;