forked from rosebudai/OpenRCT2-Web
Rename HOOK_TYPE and its members
This commit is contained in:
12 files changed
+90
-90
No files matched your search
@@ -417,7 +417,7 @@ void GameNotifyMapChange()
|
||||
|
||||
auto& scriptEngine = GetContext()->GetScriptEngine();
|
||||
auto& hookEngine = scriptEngine.GetHookEngine();
|
||||
hookEngine.Call(HOOK_TYPE::MAP_CHANGE, false);
|
||||
hookEngine.Call(HookType::mapChange, false);
|
||||
_mapChangedExpected = true;
|
||||
#endif
|
||||
}
|
||||
@@ -429,7 +429,7 @@ void GameNotifyMapChanged()
|
||||
|
||||
auto& scriptEngine = GetContext()->GetScriptEngine();
|
||||
auto& hookEngine = scriptEngine.GetHookEngine();
|
||||
hookEngine.Call(HOOK_TYPE::MAP_CHANGED, false);
|
||||
hookEngine.Call(HookType::mapChanged, false);
|
||||
_mapChangedExpected = false;
|
||||
#endif
|
||||
}
|
||||
@@ -757,9 +757,9 @@ void PrepareMapForSave()
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
auto& scriptEngine = GetContext()->GetScriptEngine();
|
||||
auto& hookEngine = scriptEngine.GetHookEngine();
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::MAP_SAVE))
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::mapSave))
|
||||
{
|
||||
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::MAP_SAVE, false);
|
||||
hookEngine.Call(OpenRCT2::Scripting::HookType::mapSave, false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -351,11 +351,11 @@ namespace OpenRCT2
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
|
||||
hookEngine.Call(HOOK_TYPE::INTERVAL_TICK, true);
|
||||
hookEngine.Call(HookType::intervalTick, true);
|
||||
|
||||
if (day != gameState.date.GetDay())
|
||||
{
|
||||
hookEngine.Call(HOOK_TYPE::INTERVAL_DAY, true);
|
||||
hookEngine.Call(HookType::intervalDay, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -479,7 +479,7 @@ bool GameAction::LocationValid(const CoordsXY& coords) const
|
||||
return false;
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::ACTION_LOCATION))
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::actionLocation))
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
|
||||
@@ -496,7 +496,7 @@ bool GameAction::LocationValid(const CoordsXY& coords) const
|
||||
|
||||
// Call the subscriptions
|
||||
auto e = obj.Take();
|
||||
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::ACTION_LOCATION, e, true);
|
||||
hookEngine.Call(OpenRCT2::Scripting::HookType::actionLocation, e, true);
|
||||
|
||||
auto scriptResult = OpenRCT2::Scripting::AsOrDefault(e["result"], true);
|
||||
|
||||
|
||||
@@ -7311,7 +7311,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords)
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
auto& hookEngine = OpenRCT2::GetContext()->GetScriptEngine().GetHookEngine();
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::GUEST_GENERATION))
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::guestGeneration))
|
||||
{
|
||||
auto ctx = OpenRCT2::GetContext()->GetScriptEngine().GetContext();
|
||||
|
||||
@@ -7321,7 +7321,7 @@ Guest* Guest::Generate(const CoordsXYZ& coords)
|
||||
|
||||
// Call the subscriptions
|
||||
auto e = obj.Take();
|
||||
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::GUEST_GENERATION, e, true);
|
||||
hookEngine.Call(OpenRCT2::Scripting::HookType::guestGeneration, e, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1823,7 +1823,7 @@ static bool ProcessPlayerAuthenticatePluginHooks(
|
||||
using namespace OpenRCT2::Scripting;
|
||||
|
||||
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_AUTHENTICATE))
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::networkAuthenticate))
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
|
||||
@@ -1836,7 +1836,7 @@ static bool ProcessPlayerAuthenticatePluginHooks(
|
||||
auto e = eObj.Take();
|
||||
|
||||
// Call the subscriptions
|
||||
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_AUTHENTICATE, e, false);
|
||||
hookEngine.Call(OpenRCT2::Scripting::HookType::networkAuthenticate, e, false);
|
||||
|
||||
// Check if any hook has cancelled the join
|
||||
if (AsOrDefault(e["cancel"], false))
|
||||
@@ -1854,7 +1854,7 @@ static void ProcessPlayerJoinedPluginHooks(uint8_t playerId)
|
||||
using namespace OpenRCT2::Scripting;
|
||||
|
||||
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_JOIN))
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::networkJoin))
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
|
||||
@@ -1864,7 +1864,7 @@ static void ProcessPlayerJoinedPluginHooks(uint8_t playerId)
|
||||
auto e = eObj.Take();
|
||||
|
||||
// Call the subscriptions
|
||||
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_JOIN, e, false);
|
||||
hookEngine.Call(OpenRCT2::Scripting::HookType::networkJoin, e, false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1875,7 +1875,7 @@ static void ProcessPlayerLeftPluginHooks(uint8_t playerId)
|
||||
using namespace OpenRCT2::Scripting;
|
||||
|
||||
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_LEAVE))
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::networkLeave))
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
|
||||
@@ -1885,7 +1885,7 @@ static void ProcessPlayerLeftPluginHooks(uint8_t playerId)
|
||||
auto e = eObj.Take();
|
||||
|
||||
// Call the subscriptions
|
||||
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_LEAVE, e, false);
|
||||
hookEngine.Call(OpenRCT2::Scripting::HookType::networkLeave, e, false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -2898,7 +2898,7 @@ static bool ProcessChatMessagePluginHooks(uint8_t playerId, std::string& text)
|
||||
{
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_CHAT))
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::networkChat))
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
|
||||
@@ -2911,7 +2911,7 @@ static bool ProcessChatMessagePluginHooks(uint8_t playerId, std::string& text)
|
||||
auto e = DukValue::take_from_stack(ctx);
|
||||
|
||||
// Call the subscriptions
|
||||
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::NETWORK_CHAT, e, false);
|
||||
hookEngine.Call(OpenRCT2::Scripting::HookType::networkChat, e, false);
|
||||
|
||||
// Update text from object if subscriptions changed it
|
||||
if (e["message"].type() != DukValue::Type::STRING)
|
||||
|
||||
@@ -1069,7 +1069,7 @@ static void RideRatingsCalculate(RideRatingUpdateState& state, Ride& ride)
|
||||
if (ride.lifecycleFlags & RIDE_LIFECYCLE_TESTED)
|
||||
{
|
||||
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
|
||||
if (hookEngine.HasSubscriptions(HOOK_TYPE::RIDE_RATINGS_CALCULATE))
|
||||
if (hookEngine.HasSubscriptions(HookType::rideRatingsCalculate))
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
auto originalRatings = ride.ratings;
|
||||
@@ -1083,7 +1083,7 @@ static void RideRatingsCalculate(RideRatingUpdateState& state, Ride& ride)
|
||||
|
||||
// Call the subscriptions
|
||||
auto e = obj.Take();
|
||||
hookEngine.Call(HOOK_TYPE::RIDE_RATINGS_CALCULATE, e, true);
|
||||
hookEngine.Call(HookType::rideRatingsCalculate, e, true);
|
||||
|
||||
auto scriptExcitement = AsOrDefault(e["excitement"], static_cast<int32_t>(originalRatings.excitement));
|
||||
auto scriptIntensity = AsOrDefault(e["intensity"], static_cast<int32_t>(originalRatings.intensity));
|
||||
|
||||
@@ -469,7 +469,7 @@ bool EntityBase::Is<Vehicle>() const
|
||||
static void InvokeVehicleCrashHook(const EntityId vehicleId, const std::string_view crashId)
|
||||
{
|
||||
auto& hookEngine = OpenRCT2::GetContext()->GetScriptEngine().GetHookEngine();
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HOOK_TYPE::VEHICLE_CRASH))
|
||||
if (hookEngine.HasSubscriptions(OpenRCT2::Scripting::HookType::vehicleCrash))
|
||||
{
|
||||
auto ctx = OpenRCT2::GetContext()->GetScriptEngine().GetContext();
|
||||
|
||||
@@ -480,7 +480,7 @@ static void InvokeVehicleCrashHook(const EntityId vehicleId, const std::string_v
|
||||
|
||||
// Call the subscriptions
|
||||
auto e = obj.Take();
|
||||
hookEngine.Call(OpenRCT2::Scripting::HOOK_TYPE::VEHICLE_CRASH, e, true);
|
||||
hookEngine.Call(OpenRCT2::Scripting::HookType::vehicleCrash, e, true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -18,42 +18,42 @@
|
||||
|
||||
using namespace OpenRCT2::Scripting;
|
||||
|
||||
static const EnumMap<HOOK_TYPE> HooksLookupTable({
|
||||
{ "action.query", HOOK_TYPE::ACTION_QUERY },
|
||||
{ "action.execute", HOOK_TYPE::ACTION_EXECUTE },
|
||||
{ "interval.tick", HOOK_TYPE::INTERVAL_TICK },
|
||||
{ "interval.day", HOOK_TYPE::INTERVAL_DAY },
|
||||
{ "network.chat", HOOK_TYPE::NETWORK_CHAT },
|
||||
{ "network.authenticate", HOOK_TYPE::NETWORK_AUTHENTICATE },
|
||||
{ "network.join", HOOK_TYPE::NETWORK_JOIN },
|
||||
{ "network.leave", HOOK_TYPE::NETWORK_LEAVE },
|
||||
{ "ride.ratings.calculate", HOOK_TYPE::RIDE_RATINGS_CALCULATE },
|
||||
{ "action.location", HOOK_TYPE::ACTION_LOCATION },
|
||||
{ "guest.generation", HOOK_TYPE::GUEST_GENERATION },
|
||||
{ "vehicle.crash", HOOK_TYPE::VEHICLE_CRASH },
|
||||
{ "map.change", HOOK_TYPE::MAP_CHANGE },
|
||||
{ "map.changed", HOOK_TYPE::MAP_CHANGED },
|
||||
{ "map.save", HOOK_TYPE::MAP_SAVE },
|
||||
{ "park.guest.softcap.calculate", HOOK_TYPE::PARK_CALCULATE_GUEST_CAP },
|
||||
static const EnumMap<HookType> HooksLookupTable({
|
||||
{ "action.query", HookType::actionQuery },
|
||||
{ "action.execute", HookType::actionExecute },
|
||||
{ "interval.tick", HookType::intervalTick },
|
||||
{ "interval.day", HookType::intervalDay },
|
||||
{ "network.chat", HookType::networkChat },
|
||||
{ "network.authenticate", HookType::networkAuthenticate },
|
||||
{ "network.join", HookType::networkJoin },
|
||||
{ "network.leave", HookType::networkLeave },
|
||||
{ "ride.ratings.calculate", HookType::rideRatingsCalculate },
|
||||
{ "action.location", HookType::actionLocation },
|
||||
{ "guest.generation", HookType::guestGeneration },
|
||||
{ "vehicle.crash", HookType::vehicleCrash },
|
||||
{ "map.change", HookType::mapChange },
|
||||
{ "map.changed", HookType::mapChanged },
|
||||
{ "map.save", HookType::mapSave },
|
||||
{ "park.guest.softcap.calculate", HookType::parkCalculateGuestCap },
|
||||
});
|
||||
|
||||
HOOK_TYPE OpenRCT2::Scripting::GetHookType(const std::string& name)
|
||||
HookType OpenRCT2::Scripting::GetHookType(const std::string& name)
|
||||
{
|
||||
auto result = HooksLookupTable.find(name);
|
||||
return (result != HooksLookupTable.end()) ? result->second : HOOK_TYPE::UNDEFINED;
|
||||
return (result != HooksLookupTable.end()) ? result->second : HookType::notDefined;
|
||||
}
|
||||
|
||||
HookEngine::HookEngine(ScriptEngine& scriptEngine)
|
||||
: _scriptEngine(scriptEngine)
|
||||
{
|
||||
_hookMap.resize(NUM_HOOK_TYPES);
|
||||
for (size_t i = 0; i < NUM_HOOK_TYPES; i++)
|
||||
_hookMap.resize(NUM_HookTypeS);
|
||||
for (size_t i = 0; i < NUM_HookTypeS; i++)
|
||||
{
|
||||
_hookMap[i].Type = static_cast<HOOK_TYPE>(i);
|
||||
_hookMap[i].Type = static_cast<HookType>(i);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t HookEngine::Subscribe(HOOK_TYPE type, std::shared_ptr<Plugin> owner, const DukValue& function)
|
||||
uint32_t HookEngine::Subscribe(HookType type, std::shared_ptr<Plugin> owner, const DukValue& function)
|
||||
{
|
||||
auto& hookList = GetHookList(type);
|
||||
auto cookie = _nextCookie++;
|
||||
@@ -61,7 +61,7 @@ uint32_t HookEngine::Subscribe(HOOK_TYPE type, std::shared_ptr<Plugin> owner, co
|
||||
return cookie;
|
||||
}
|
||||
|
||||
void HookEngine::Unsubscribe(HOOK_TYPE type, uint32_t cookie)
|
||||
void HookEngine::Unsubscribe(HookType type, uint32_t cookie)
|
||||
{
|
||||
auto& hookList = GetHookList(type);
|
||||
auto& hooks = hookList.Hooks;
|
||||
@@ -94,22 +94,22 @@ void HookEngine::UnsubscribeAll()
|
||||
}
|
||||
}
|
||||
|
||||
bool HookEngine::HasSubscriptions(HOOK_TYPE type) const
|
||||
bool HookEngine::HasSubscriptions(HookType type) const
|
||||
{
|
||||
auto& hookList = GetHookList(type);
|
||||
return !hookList.Hooks.empty();
|
||||
}
|
||||
|
||||
bool HookEngine::IsValidHookForPlugin(HOOK_TYPE type, Plugin& plugin) const
|
||||
bool HookEngine::IsValidHookForPlugin(HookType type, Plugin& plugin) const
|
||||
{
|
||||
if (type == HOOK_TYPE::MAP_CHANGED && plugin.GetMetadata().Type != PluginType::Intransient)
|
||||
if (type == HookType::mapChanged && plugin.GetMetadata().Type != PluginType::Intransient)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void HookEngine::Call(HOOK_TYPE type, bool isGameStateMutable)
|
||||
void HookEngine::Call(HookType type, bool isGameStateMutable)
|
||||
{
|
||||
auto& hookList = GetHookList(type);
|
||||
for (auto& hook : hookList.Hooks)
|
||||
@@ -118,7 +118,7 @@ void HookEngine::Call(HOOK_TYPE type, bool isGameStateMutable)
|
||||
}
|
||||
}
|
||||
|
||||
void HookEngine::Call(HOOK_TYPE type, const DukValue& arg, bool isGameStateMutable)
|
||||
void HookEngine::Call(HookType type, const DukValue& arg, bool isGameStateMutable)
|
||||
{
|
||||
auto& hookList = GetHookList(type);
|
||||
for (auto& hook : hookList.Hooks)
|
||||
@@ -128,7 +128,7 @@ void HookEngine::Call(HOOK_TYPE type, const DukValue& arg, bool isGameStateMutab
|
||||
}
|
||||
|
||||
void HookEngine::Call(
|
||||
HOOK_TYPE type, const std::initializer_list<std::pair<std::string_view, std::any>>& args, bool isGameStateMutable)
|
||||
HookType type, const std::initializer_list<std::pair<std::string_view, std::any>>& args, bool isGameStateMutable)
|
||||
{
|
||||
auto& hookList = GetHookList(type);
|
||||
for (auto& hook : hookList.Hooks)
|
||||
@@ -162,13 +162,13 @@ void HookEngine::Call(
|
||||
}
|
||||
}
|
||||
|
||||
HookList& HookEngine::GetHookList(HOOK_TYPE type)
|
||||
HookList& HookEngine::GetHookList(HookType type)
|
||||
{
|
||||
auto index = static_cast<size_t>(type);
|
||||
return _hookMap[index];
|
||||
}
|
||||
|
||||
const HookList& HookEngine::GetHookList(HOOK_TYPE type) const
|
||||
const HookList& HookEngine::GetHookList(HookType type) const
|
||||
{
|
||||
auto index = static_cast<size_t>(type);
|
||||
return _hookMap[index];
|
||||
|
||||
@@ -25,29 +25,29 @@ namespace OpenRCT2::Scripting
|
||||
class ScriptExecutionInfo;
|
||||
class Plugin;
|
||||
|
||||
enum class HOOK_TYPE
|
||||
enum class HookType
|
||||
{
|
||||
ACTION_QUERY,
|
||||
ACTION_EXECUTE,
|
||||
INTERVAL_TICK,
|
||||
INTERVAL_DAY,
|
||||
NETWORK_CHAT,
|
||||
NETWORK_AUTHENTICATE,
|
||||
NETWORK_JOIN,
|
||||
NETWORK_LEAVE,
|
||||
RIDE_RATINGS_CALCULATE,
|
||||
ACTION_LOCATION,
|
||||
GUEST_GENERATION,
|
||||
VEHICLE_CRASH,
|
||||
MAP_CHANGE,
|
||||
MAP_CHANGED,
|
||||
MAP_SAVE,
|
||||
PARK_CALCULATE_GUEST_CAP,
|
||||
COUNT,
|
||||
UNDEFINED = -1,
|
||||
actionQuery,
|
||||
actionExecute,
|
||||
intervalTick,
|
||||
intervalDay,
|
||||
networkChat,
|
||||
networkAuthenticate,
|
||||
networkJoin,
|
||||
networkLeave,
|
||||
rideRatingsCalculate,
|
||||
actionLocation,
|
||||
guestGeneration,
|
||||
vehicleCrash,
|
||||
mapChange,
|
||||
mapChanged,
|
||||
mapSave,
|
||||
parkCalculateGuestCap,
|
||||
count,
|
||||
notDefined = -1,
|
||||
};
|
||||
constexpr size_t NUM_HOOK_TYPES = static_cast<size_t>(HOOK_TYPE::COUNT);
|
||||
HOOK_TYPE GetHookType(const std::string& name);
|
||||
constexpr size_t NUM_HookTypeS = static_cast<size_t>(HookType::count);
|
||||
HookType GetHookType(const std::string& name);
|
||||
|
||||
struct Hook
|
||||
{
|
||||
@@ -66,7 +66,7 @@ namespace OpenRCT2::Scripting
|
||||
|
||||
struct HookList
|
||||
{
|
||||
HOOK_TYPE Type{};
|
||||
HookType Type{};
|
||||
std::vector<Hook> Hooks;
|
||||
|
||||
HookList() = default;
|
||||
@@ -84,20 +84,20 @@ namespace OpenRCT2::Scripting
|
||||
public:
|
||||
HookEngine(ScriptEngine& scriptEngine);
|
||||
HookEngine(const HookEngine&) = delete;
|
||||
uint32_t Subscribe(HOOK_TYPE type, std::shared_ptr<Plugin> owner, const DukValue& function);
|
||||
void Unsubscribe(HOOK_TYPE type, uint32_t cookie);
|
||||
uint32_t Subscribe(HookType type, std::shared_ptr<Plugin> owner, const DukValue& function);
|
||||
void Unsubscribe(HookType type, uint32_t cookie);
|
||||
void UnsubscribeAll(std::shared_ptr<const Plugin> owner);
|
||||
void UnsubscribeAll();
|
||||
bool HasSubscriptions(HOOK_TYPE type) const;
|
||||
bool IsValidHookForPlugin(HOOK_TYPE type, Plugin& plugin) const;
|
||||
void Call(HOOK_TYPE type, bool isGameStateMutable);
|
||||
void Call(HOOK_TYPE type, const DukValue& arg, bool isGameStateMutable);
|
||||
bool HasSubscriptions(HookType type) const;
|
||||
bool IsValidHookForPlugin(HookType type, Plugin& plugin) const;
|
||||
void Call(HookType type, bool isGameStateMutable);
|
||||
void Call(HookType type, const DukValue& arg, bool isGameStateMutable);
|
||||
void Call(
|
||||
HOOK_TYPE type, const std::initializer_list<std::pair<std::string_view, std::any>>& args, bool isGameStateMutable);
|
||||
HookType type, const std::initializer_list<std::pair<std::string_view, std::any>>& args, bool isGameStateMutable);
|
||||
|
||||
private:
|
||||
HookList& GetHookList(HOOK_TYPE type);
|
||||
const HookList& GetHookList(HOOK_TYPE type) const;
|
||||
HookList& GetHookList(HookType type);
|
||||
const HookList& GetHookList(HookType type) const;
|
||||
};
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
|
||||
@@ -1460,7 +1460,7 @@ void ScriptEngine::RunGameActionHooks(const GameAction& action, GameActions::Res
|
||||
{
|
||||
DukStackFrame frame(_context);
|
||||
|
||||
auto hookType = isExecute ? HOOK_TYPE::ACTION_EXECUTE : HOOK_TYPE::ACTION_QUERY;
|
||||
auto hookType = isExecute ? HookType::actionExecute : HookType::actionQuery;
|
||||
if (_hookEngine.HasSubscriptions(hookType))
|
||||
{
|
||||
DukObject obj(_context);
|
||||
|
||||
@@ -273,7 +273,7 @@ namespace OpenRCT2::Scripting
|
||||
__declspec(noinline)
|
||||
#endif
|
||||
std::shared_ptr<ScDisposable>
|
||||
CreateSubscription(HOOK_TYPE hookType, const DukValue& callback)
|
||||
CreateSubscription(HookType hookType, const DukValue& callback)
|
||||
{
|
||||
auto owner = _execInfo.GetCurrentPlugin();
|
||||
auto cookie = _hookEngine.Subscribe(hookType, owner, callback);
|
||||
@@ -286,7 +286,7 @@ namespace OpenRCT2::Scripting
|
||||
auto ctx = scriptEngine.GetContext();
|
||||
|
||||
auto hookType = GetHookType(hook);
|
||||
if (hookType == HOOK_TYPE::UNDEFINED)
|
||||
if (hookType == HookType::notDefined)
|
||||
{
|
||||
duk_error(ctx, DUK_ERR_ERROR, "Unknown hook type");
|
||||
}
|
||||
|
||||
@@ -160,13 +160,13 @@ namespace OpenRCT2::Park
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine();
|
||||
if (hookEngine.HasSubscriptions(HOOK_TYPE::PARK_CALCULATE_GUEST_CAP))
|
||||
if (hookEngine.HasSubscriptions(HookType::parkCalculateGuestCap))
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
auto obj = DukObject(ctx);
|
||||
obj.Set("suggestedGuestMaximum", suggestedMaxGuests);
|
||||
auto e = obj.Take();
|
||||
hookEngine.Call(HOOK_TYPE::PARK_CALCULATE_GUEST_CAP, e, true);
|
||||
hookEngine.Call(HookType::parkCalculateGuestCap, e, true);
|
||||
|
||||
suggestedMaxGuests = AsOrDefault(e["suggestedGuestMaximum"], static_cast<int32_t>(suggestedMaxGuests));
|
||||
suggestedMaxGuests = std::clamp<uint16_t>(suggestedMaxGuests, 0, UINT16_MAX);
|
||||
|
||||
Reference in new issue
Block a user