Skip to content

Commit ff757de

Browse files
committed
add new functions
1 parent 5e7b39c commit ff757de

File tree

4 files changed

+26
-29
lines changed

4 files changed

+26
-29
lines changed

Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,6 @@ ADD_ENUM(WEATHER_RAIN_FOG, "RainFog")
894894
ADD_ENUM(WEATHER_WATER_FOG, "WaterFog")
895895
ADD_ENUM(WEATHER_SANDSTORM, "Sandstorm")
896896
ADD_ENUM(WEATHER_RAINBOW, "Rainbow")
897-
ADD_ENUM(TIME_CYCLE, "FreezeTimeCycle")
898897
IMPLEMENT_ENUM_END("world-property")
899898

900899
//

Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ void CLuaWorldDefs::LoadFunctions()
104104
{"removeWorldModel", RemoveWorldBuilding},
105105
{"restoreAllWorldModels", RestoreWorldBuildings},
106106
{"restoreWorldModel", RestoreWorldBuilding},
107+
{"setTimeFrozen", ArgumentParser<SetTimeFrozen>},
107108

108109
// World create funcs
109110
{"createSWATRope", CreateSWATRope},
@@ -126,13 +127,15 @@ void CLuaWorldDefs::LoadFunctions()
126127
{"resetMoonSize", ResetMoonSize},
127128
{"resetBlurLevel", ResetBlurLevel},
128129
{"resetWorldProperty", ArgumentParserWarn<false, ResetWorldProperty>},
130+
{"resetTimeFrozen", ArgumentParser<ResetTimeFrozen>},
129131

130132
// World check funcs
131133
{"areTrafficLightsLocked", AreTrafficLightsLocked},
132134
{"isPedTargetingMarkerEnabled", IsPedTargetingMarkerEnabled},
133135
{"isLineOfSightClear", IsLineOfSightClear},
134136
{"isWorldSpecialPropertyEnabled", ArgumentParserWarn<false, IsWorldSpecialPropertyEnabled>},
135-
{"isGarageOpen", IsGarageOpen}};
137+
{"isGarageOpen", IsGarageOpen},
138+
{"isTimeFrozen", ArgumentParser<IsTimeFrozen>}};
136139

137140
// Add functions
138141
for (const auto& [name, func] : functions)
@@ -2129,33 +2132,14 @@ std::variant<bool, float, CLuaMultiReturn<float, float, float>> CLuaWorldDefs::G
21292132
return g_pGame->GetWeather()->GetSandstorm();
21302133
case eWorldProperty::WEATHER_RAINBOW:
21312134
return g_pGame->GetWeather()->GetRainbow();
2132-
case eWorldProperty::TIME_CYCLE:
2133-
return g_pGame->GetClock()->GetTimerCycleEnabled();
21342135
}
21352136
return false;
21362137
}
21372138

2138-
bool CLuaWorldDefs::SetWorldProperty(eWorldProperty property, std::variant<bool, float> argVariant, std::optional<float> arg2, std::optional<float> arg3)
2139+
bool CLuaWorldDefs::SetWorldProperty(eWorldProperty property, float arg1, std::optional<float> arg2, std::optional<float> arg3)
21392140
{
2140-
float arg1;
2141-
bool argBool;
2142-
2143-
if (std::holds_alternative<float>(argVariant))
2144-
{
2145-
arg1 = std::get<float>(argVariant);
2146-
}
2147-
else if (std::holds_alternative<bool>(argVariant))
2148-
{
2149-
argBool = std::get<bool>(argVariant);
2150-
}
2151-
else
2152-
{
2153-
return false; //in case the type is invalid
2154-
}
2155-
21562141
if (arg2.has_value() && arg3.has_value())
21572142
{
2158-
21592143
switch (property)
21602144
{
21612145
case eWorldProperty::AMBIENT_COLOR:
@@ -2203,8 +2187,6 @@ bool CLuaWorldDefs::SetWorldProperty(eWorldProperty property, std::variant<bool,
22032187
return g_pGame->GetWeather()->SetSandstorm(arg1);
22042188
case eWorldProperty::WEATHER_RAINBOW:
22052189
return g_pGame->GetWeather()->SetRainbow(arg1);
2206-
case eWorldProperty::TIME_CYCLE:
2207-
return g_pGame->GetClock()->SetTimerCycle(argBool);
22082190
}
22092191
return false;
22102192
}
@@ -2253,8 +2235,21 @@ bool CLuaWorldDefs::ResetWorldProperty(eWorldProperty property)
22532235
return g_pGame->GetWeather()->ResetSandstorm();
22542236
case eWorldProperty::WEATHER_RAINBOW:
22552237
return g_pGame->GetWeather()->ResetRainbow();
2256-
case eWorldProperty::TIME_CYCLE:
2257-
return g_pGame->GetClock()->ResetTimerCycle();
22582238
}
22592239
return false;
22602240
}
2241+
2242+
bool CLuaWorldDefs::SetTimeFrozen(bool value) noexcept
2243+
{
2244+
return g_pGame->GetClock()->SetTimerCycle(value);
2245+
}
2246+
2247+
bool CLuaWorldDefs::IsTimeFrozen() noexcept
2248+
{
2249+
return g_pGame->GetClock()->GetTimerCycleEnabled();
2250+
}
2251+
2252+
bool CLuaWorldDefs::ResetTimeFrozen() noexcept
2253+
{
2254+
return g_pGame->GetClock()->ResetTimerCycle();
2255+
}

Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ class CLuaWorldDefs : public CLuaDefs
128128
static bool ResetCoronaReflectionsEnabled();
129129

130130
static std::variant<bool, float, CLuaMultiReturn<float, float, float>> GetWorldProperty(eWorldProperty property);
131-
static bool SetWorldProperty(eWorldProperty property, std::variant<bool, float> argVariant, std::optional<float> arg2, std::optional<float> arg3);
131+
static bool SetWorldProperty(eWorldProperty property, float arg1, std::optional<float> arg2, std::optional<float> arg3);
132132
static bool ResetWorldProperty(eWorldProperty property);
133-
};
133+
134+
static bool SetTimeFrozen(bool value) noexcept;
135+
static bool IsTimeFrozen() noexcept;
136+
static bool ResetTimeFrozen() noexcept;
137+
};
134138

Client/sdk/game/Common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,5 +1643,4 @@ enum eWorldProperty
16431643
WEATHER_WATER_FOG,
16441644
WEATHER_SANDSTORM,
16451645
WEATHER_RAINBOW,
1646-
TIME_CYCLE,
16471646
};

0 commit comments

Comments
 (0)