mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-31 02:35:46 +01:00
Rename HOOK_TYPE and its members
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user