Skip to content

Commit d502388

Browse files
committed
review fixes for class
1 parent 7f65849 commit d502388

File tree

8 files changed

+34
-28
lines changed

8 files changed

+34
-28
lines changed

Client/game_sa/CClockSA.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,20 @@ void CClockSA::Get(BYTE* bHour, BYTE* bMinute)
3030
*bMinute = *(BYTE*)VAR_TimeMinutes;
3131
*bHour = *(BYTE*)VAR_TimeHours;
3232
}
33+
34+
35+
bool CClockSA::SetTimerCycle(bool value) noexcept
36+
{
37+
if (value)
38+
MemSet((void*)0x53BFBD, 0x90, 5);
39+
else
40+
MemCpy((void*)0x53BFBD, "\xE8\x4E\x0F\xFF\xFF", 5);
41+
42+
m_bTimeCycleFrozen = value;
43+
return true;
44+
}
45+
46+
bool CClockSA::ResetTimerCycle() noexcept
47+
{
48+
return SetTimerCycle(false);
49+
}

Client/game_sa/CClockSA.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,11 @@ class CClockSA : public CClock
2222
public:
2323
void Set(BYTE bHour, BYTE bMinute);
2424
void Get(BYTE* bHour, BYTE* bMinute);
25+
26+
bool SetTimerCycle(bool value) noexcept;
27+
bool GetTimerCycleEnabled() const noexcept { return m_bTimeCycleFrozen; };
28+
bool ResetTimerCycle() noexcept;
29+
30+
private:
31+
bool m_bTimeCycleFrozen;
2532
};

Client/game_sa/CWeatherSA.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,3 @@ bool CWeatherSA::ResetRainbow()
228228
MemCpy((LPVOID)(0x72BF59 + 2), &originalCodes, 3);
229229
return true;
230230
}
231-
232-
bool CWeatherSA::SetTimerCycle(bool value) noexcept
233-
{
234-
if (value)
235-
MemSet((void*)0x53BFBD, 0x90, 5);
236-
else
237-
MemCpy((void*)0x53BFBD, "\xE8\x4E\x0F\xFF\xFF", 5);
238-
239-
m_bTimeCycleFrozen = value;
240-
return true;
241-
}
242-
243-
bool CWeatherSA::ResetTimerCycle() noexcept
244-
{
245-
return SetTimerCycle(false);
246-
}

Client/game_sa/CWeatherSA.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ class CWeatherSA : public CWeather
5555
bool SetRainbow(float fAmount);
5656
bool ResetRainbow();
5757

58-
bool SetTimerCycle(bool value) noexcept;
59-
bool GetTimerCycleEnabled() const noexcept { return m_bTimeCycleFrozen; };
60-
bool ResetTimerCycle() noexcept;
61-
6258
private:
6359
static unsigned char* VAR_CWeather__ForcedWeatherType;
6460
static unsigned char* VAR_CWeather__OldWeatherType;

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <game/CBuildingRemoval.h>
3636
#include <windowsx.h>
3737
#include "CServerInfo.h"
38+
#include "game/CClock.h"
3839

3940
SString StringZeroPadout(const SString& strInput, uint uiPadoutSize)
4041
{
@@ -3418,7 +3419,6 @@ void CClientGame::Event_OnIngame()
34183419

34193420
g_pGame->GetBuildingRemoval()->ClearRemovedBuildingLists();
34203421
g_pGame->GetWorld()->SetOcclusionsEnabled(true);
3421-
g_pGame->GetWeather()->ResetTimerCycle();
34223422

34233423
g_pGame->ResetModelLodDistances();
34243424
g_pGame->ResetModelFlags();
@@ -5544,6 +5544,7 @@ void CClientGame::ResetMapInfo()
55445544
g_pGame->GetWeather()->ResetWaterFog();
55455545
g_pGame->GetWeather()->ResetSandstorm();
55465546
g_pGame->GetWeather()->ResetRainbow();
5547+
g_pGame->GetClock()->ResetTimerCycle();
55475548

55485549
// Disable the change of any player stats
55495550
g_pMultiplayer->SetLocalStatsStatic(true);

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <game/CWeather.h>
1313
#include <game/CColPoint.h>
1414
#include <game/CCoronas.h>
15+
#include <game/CClock.h>
1516
#include "lua/CLuaFunctionParser.h"
1617

1718
void CLuaWorldDefs::LoadFunctions()
@@ -2129,7 +2130,7 @@ std::variant<bool, float, CLuaMultiReturn<float, float, float>> CLuaWorldDefs::G
21292130
case eWorldProperty::WEATHER_RAINBOW:
21302131
return g_pGame->GetWeather()->GetRainbow();
21312132
case eWorldProperty::TIME_CYCLE:
2132-
return g_pGame->GetWeather()->GetTimerCycleEnabled();
2133+
return g_pGame->GetClock()->GetTimerCycleEnabled();
21332134
}
21342135
return false;
21352136
}
@@ -2203,7 +2204,7 @@ bool CLuaWorldDefs::SetWorldProperty(eWorldProperty property, std::variant<bool,
22032204
case eWorldProperty::WEATHER_RAINBOW:
22042205
return g_pGame->GetWeather()->SetRainbow(arg1);
22052206
case eWorldProperty::TIME_CYCLE:
2206-
return g_pGame->GetWeather()->SetTimerCycle(argBool);
2207+
return g_pGame->GetClock()->SetTimerCycle(argBool);
22072208
}
22082209
return false;
22092210
}
@@ -2253,7 +2254,7 @@ bool CLuaWorldDefs::ResetWorldProperty(eWorldProperty property)
22532254
case eWorldProperty::WEATHER_RAINBOW:
22542255
return g_pGame->GetWeather()->ResetRainbow();
22552256
case eWorldProperty::TIME_CYCLE:
2256-
return g_pGame->GetWeather()->ResetTimerCycle();
2257+
return g_pGame->GetClock()->ResetTimerCycle();
22572258
}
22582259
return false;
22592260
}

Client/sdk/game/CClock.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ class CClock
1616
public:
1717
virtual void Set(BYTE bHour, BYTE bMinute) = 0;
1818
virtual void Get(BYTE* bHour, BYTE* bMinute) = 0;
19+
20+
virtual bool SetTimerCycle(bool value) noexcept = 0;
21+
virtual bool GetTimerCycleEnabled() const noexcept = 0;
22+
virtual bool ResetTimerCycle() noexcept = 0;
1923
};

Client/sdk/game/CWeather.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,4 @@ class CWeather
5151
virtual float GetRainbow() const = 0;
5252
virtual bool SetRainbow(float fAmount) = 0;
5353
virtual bool ResetRainbow() = 0;
54-
55-
virtual bool SetTimerCycle(bool value) noexcept = 0;
56-
virtual bool GetTimerCycleEnabled() const noexcept = 0;
57-
virtual bool ResetTimerCycle() noexcept = 0;
5854
};

0 commit comments

Comments
 (0)