Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions Client/game_sa/CClockSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,19 @@ void CClockSA::Get(BYTE* bHour, BYTE* bMinute)
*bMinute = *(BYTE*)VAR_TimeMinutes;
*bHour = *(BYTE*)VAR_TimeHours;
}

bool CClockSA::SetTimeFrozen(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 CClockSA::ResetTimeFrozen() noexcept
{
return SetTimeFrozen(false);
}
7 changes: 7 additions & 0 deletions Client/game_sa/CClockSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ class CClockSA : public CClock
public:
void Set(BYTE bHour, BYTE bMinute);
void Get(BYTE* bHour, BYTE* bMinute);

bool SetTimeFrozen(bool value) noexcept;
bool IsTimeFrozen() const noexcept { return m_bTimeCycleFrozen; };
bool ResetTimeFrozen() noexcept;

private:
bool m_bTimeCycleFrozen;
};
1 change: 0 additions & 1 deletion Client/game_sa/CWeatherSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,4 @@ class CWeatherSA : public CWeather
static unsigned char* VAR_CWeather__OldWeatherType;
static unsigned char* VAR_CWeather__NewWeatherType;
static float* VAR_CWeather__Rain;

};
5 changes: 5 additions & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <game/CWeather.h>
#include <game/Task.h>
#include <game/CBuildingRemoval.h>
#include "game/CClock.h"
#include <windowsx.h>
#include "CServerInfo.h"

Expand Down Expand Up @@ -5408,6 +5409,7 @@ void CClientGame::ResetMapInfo()

// Hud
g_pGame->GetHud()->SetComponentVisible(HUD_ALL, true);

// Disable area names as they are on load until camera unfades
g_pGame->GetHud()->SetComponentVisible(HUD_AREA_NAME, false);
g_pGame->GetHud()->SetComponentVisible(HUD_VITAL_STATS, false);
Expand Down Expand Up @@ -5548,6 +5550,9 @@ void CClientGame::ResetMapInfo()
// Disable the change of any player stats
g_pMultiplayer->SetLocalStatsStatic(true);

// Reset Frozen Time
g_pGame->GetClock()->ResetTimeFrozen();

// Close all garages
CGarage* pGarage = NULL;
CGarages* pGarages = g_pCore->GetGame()->GetGarages();
Expand Down
21 changes: 20 additions & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <game/CWeather.h>
#include <game/CColPoint.h>
#include <game/CCoronas.h>
#include <game/CClock.h>
#include "lua/CLuaFunctionParser.h"

void CLuaWorldDefs::LoadFunctions()
Expand Down Expand Up @@ -103,6 +104,7 @@ void CLuaWorldDefs::LoadFunctions()
{"removeWorldModel", RemoveWorldBuilding},
{"restoreAllWorldModels", RestoreWorldBuildings},
{"restoreWorldModel", RestoreWorldBuilding},
{"setTimeFrozen", ArgumentParser<SetTimeFrozen>},

// World create funcs
{"createSWATRope", CreateSWATRope},
Expand All @@ -125,13 +127,15 @@ void CLuaWorldDefs::LoadFunctions()
{"resetMoonSize", ResetMoonSize},
{"resetBlurLevel", ResetBlurLevel},
{"resetWorldProperty", ArgumentParserWarn<false, ResetWorldProperty>},
{"resetTimeFrozen", ArgumentParser<ResetTimeFrozen>},

// World check funcs
{"areTrafficLightsLocked", AreTrafficLightsLocked},
{"isPedTargetingMarkerEnabled", IsPedTargetingMarkerEnabled},
{"isLineOfSightClear", IsLineOfSightClear},
{"isWorldSpecialPropertyEnabled", ArgumentParserWarn<false, IsWorldSpecialPropertyEnabled>},
{"isGarageOpen", IsGarageOpen}};
{"isGarageOpen", IsGarageOpen},
{"isTimeFrozen", ArgumentParser<IsTimeFrozen>}};

// Add functions
for (const auto& [name, func] : functions)
Expand Down Expand Up @@ -2234,3 +2238,18 @@ bool CLuaWorldDefs::ResetWorldProperty(eWorldProperty property)
}
return false;
}

bool CLuaWorldDefs::SetTimeFrozen(bool value) noexcept
{
return g_pGame->GetClock()->SetTimeFrozen(value);
}

bool CLuaWorldDefs::IsTimeFrozen() noexcept
{
return g_pGame->GetClock()->IsTimeFrozen();
}

bool CLuaWorldDefs::ResetTimeFrozen() noexcept
{
return g_pGame->GetClock()->ResetTimeFrozen();
}
7 changes: 6 additions & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaWorldDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,9 @@ class CLuaWorldDefs : public CLuaDefs
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 ResetWorldProperty(eWorldProperty property);
};

static bool SetTimeFrozen(bool value) noexcept;
static bool IsTimeFrozen() noexcept;
static bool ResetTimeFrozen() noexcept;
};

4 changes: 4 additions & 0 deletions Client/sdk/game/CClock.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ class CClock
public:
virtual void Set(BYTE bHour, BYTE bMinute) = 0;
virtual void Get(BYTE* bHour, BYTE* bMinute) = 0;

virtual bool SetTimeFrozen(bool value) noexcept = 0;
virtual bool IsTimeFrozen() const noexcept = 0;
virtual bool ResetTimeFrozen() noexcept = 0;
};