Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Client/game_sa/CWeatherSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,24 @@ bool CWeatherSA::ResetRainbow()
MemCpy((LPVOID)(0x72BF59 + 2), &originalCodes, 3);
return true;
}

bool CWeatherSA::SetTimerCycle(bool value) noexcept
{
if (value)
{
MemSet((void*)0x53BFBD, 0x90, 5);
}
else
{
MemCpy((void*)0x53BFBD, "\xE8\x4E\x0F\xFF\xFF", 5);
}
m_bTimeCycleFrozen = value;
return true;
}

bool CWeatherSA::ResetTimerCycle() noexcept
{
SetTimerCycle(0);
m_bTimeCycleFrozen = false;
return true;
}
5 changes: 5 additions & 0 deletions Client/game_sa/CWeatherSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,15 @@ class CWeatherSA : public CWeather
bool SetRainbow(float fAmount);
bool ResetRainbow();

bool SetTimerCycle(bool value) noexcept;
bool GetTimerCycleEnabled() const noexcept { return m_bTimeCycleFrozen; };
bool ResetTimerCycle() noexcept;

private:
static unsigned char* VAR_CWeather__ForcedWeatherType;
static unsigned char* VAR_CWeather__OldWeatherType;
static unsigned char* VAR_CWeather__NewWeatherType;
static float* VAR_CWeather__Rain;
bool m_bTimeCycleFrozen;

};
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3418,6 +3418,7 @@ void CClientGame::Event_OnIngame()

g_pGame->GetBuildingRemoval()->ClearRemovedBuildingLists();
g_pGame->GetWorld()->SetOcclusionsEnabled(true);
g_pGame->GetWeather()->ResetTimerCycle();

g_pGame->ResetModelLodDistances();
g_pGame->ResetModelFlags();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ ADD_ENUM(WEATHER_RAIN_FOG, "RainFog")
ADD_ENUM(WEATHER_WATER_FOG, "WaterFog")
ADD_ENUM(WEATHER_SANDSTORM, "Sandstorm")
ADD_ENUM(WEATHER_RAINBOW, "Rainbow")
ADD_ENUM(TIME_CYCLE, "FreezeTimeCycle")
IMPLEMENT_ENUM_END("world-property")

//
Expand Down
25 changes: 24 additions & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2128,14 +2128,33 @@ std::variant<bool, float, CLuaMultiReturn<float, float, float>> CLuaWorldDefs::G
return g_pGame->GetWeather()->GetSandstorm();
case eWorldProperty::WEATHER_RAINBOW:
return g_pGame->GetWeather()->GetRainbow();
case eWorldProperty::TIME_CYCLE:
return g_pGame->GetWeather()->GetTimerCycleEnabled();
}
return false;
}

bool CLuaWorldDefs::SetWorldProperty(eWorldProperty property, float arg1, std::optional<float> arg2, std::optional<float> arg3)
bool CLuaWorldDefs::SetWorldProperty(eWorldProperty property, std::variant<bool, float> argVariant, std::optional<float> arg2, std::optional<float> arg3)
{
float arg1;
bool argBool;

if (std::holds_alternative<float>(argVariant))
{
arg1 = std::get<float>(argVariant);
}
else if (std::holds_alternative<bool>(argVariant))
{
argBool = std::get<bool>(argVariant);
}
else
{
return false; //in case the type is invalid
}

if (arg2.has_value() && arg3.has_value())
{

switch (property)
{
case eWorldProperty::AMBIENT_COLOR:
Expand Down Expand Up @@ -2183,6 +2202,8 @@ bool CLuaWorldDefs::SetWorldProperty(eWorldProperty property, float arg1, std::o
return g_pGame->GetWeather()->SetSandstorm(arg1);
case eWorldProperty::WEATHER_RAINBOW:
return g_pGame->GetWeather()->SetRainbow(arg1);
case eWorldProperty::TIME_CYCLE:
return g_pGame->GetWeather()->SetTimerCycle(argBool);
}
return false;
}
Expand Down Expand Up @@ -2231,6 +2252,8 @@ bool CLuaWorldDefs::ResetWorldProperty(eWorldProperty property)
return g_pGame->GetWeather()->ResetSandstorm();
case eWorldProperty::WEATHER_RAINBOW:
return g_pGame->GetWeather()->ResetRainbow();
case eWorldProperty::TIME_CYCLE:
return g_pGame->GetWeather()->ResetTimerCycle();
}
return false;
}
3 changes: 2 additions & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class CLuaWorldDefs : public CLuaDefs
static bool ResetCoronaReflectionsEnabled();

static std::variant<bool, float, CLuaMultiReturn<float, float, float>> GetWorldProperty(eWorldProperty property);
static bool SetWorldProperty(eWorldProperty property, float arg1, std::optional<float> arg2, std::optional<float> arg3);
static bool SetWorldProperty(eWorldProperty property, std::variant<bool, float> argVariant, std::optional<float> arg2, std::optional<float> arg3);
static bool ResetWorldProperty(eWorldProperty property);
};

4 changes: 4 additions & 0 deletions Client/sdk/game/CWeather.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ class CWeather
virtual float GetRainbow() const = 0;
virtual bool SetRainbow(float fAmount) = 0;
virtual bool ResetRainbow() = 0;

virtual bool SetTimerCycle(bool value) noexcept = 0;
virtual bool GetTimerCycleEnabled() const noexcept = 0;
virtual bool ResetTimerCycle() noexcept = 0;
};
1 change: 1 addition & 0 deletions Client/sdk/game/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1643,4 +1643,5 @@ enum eWorldProperty
WEATHER_WATER_FOG,
WEATHER_SANDSTORM,
WEATHER_RAINBOW,
TIME_CYCLE,
};