Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/heli_rotor_speed
Browse files Browse the repository at this point in the history
  • Loading branch information
FileEX committed Sep 2, 2024
2 parents e4c4c18 + b404523 commit d95dce1
Show file tree
Hide file tree
Showing 103 changed files with 2,300 additions and 2,263 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/dockerimage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ on:
- 'Dockerfile.i386'
- 'Dockerfile.armhf'
- 'Dockerfile.arm64'
- 'Dockerfile.osx-x64'
- 'Dockerfile.osx-arm64'

jobs:
build:
Expand All @@ -28,10 +26,6 @@ jobs:
dockerfile: Dockerfile.armhf
- tag: arm64
dockerfile: Dockerfile.arm64
- tag: osx-x64
dockerfile: Dockerfile.osx-x64
- tag: osx-arm64
dockerfile: Dockerfile.osx-arm64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
5 changes: 5 additions & 0 deletions Client/core/CChat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,11 @@ void CChat::SetCharacterLimit(int charLimit)
m_iCharacterLimit = charLimit;
}

float CChat::GetChatBottomPosition() const noexcept
{
return m_vecBackgroundSize.fY;
}

CChatLine::CChatLine()
{
m_bActive = false;
Expand Down
2 changes: 2 additions & 0 deletions Client/core/CChat.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ class CChat
constexpr int GetDefaultCharacterLimit() const { return m_iDefaultCharacterLimit; }
constexpr int GetMaxCharacterLimit() const { return m_iMaxCharacterLimit; }

float GetChatBottomPosition() const noexcept;

private:
void LoadCVars();

Expand Down
11 changes: 9 additions & 2 deletions Client/core/CCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool

// Grab the command
tagCOMMANDENTRY* pEntry = Get(szCommand);
bool wasHandled = false;
if (pEntry)
{
// If its a core command, or if its enabled
Expand All @@ -133,13 +134,16 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
// Execute it
if (!bIsScriptedBind || pEntry->bAllowScriptedBind)
ExecuteHandler(pEntry->pfnCmdFunc, szParameters);

wasHandled = true;
}
}

// Recompose the original command text
std::string val = std::string(szCommand) + " " + std::string(szParameters ? szParameters : "");

// Is it a cvar? (syntax: cvar[ = value])
if (!wasHandled)
{
// Check to see if '=' exists
unsigned int nOpIndex = val.find('=');
Expand Down Expand Up @@ -187,7 +191,7 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool

// HACK: if its a 'nick' command, save it here
bool bIsNickCommand = !stricmp(szCommand, "nick");
if (bIsNickCommand && szParameters && !bIsScriptedBind)
if (!wasHandled && bIsNickCommand && szParameters && !bIsScriptedBind)
{
if (CCore::GetSingleton().IsValidNick(szParameters))
{
Expand All @@ -208,10 +212,13 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
if (m_pfnExecuteHandler)
{
bool bAllowScriptedBind = (!pEntry || pEntry->bAllowScriptedBind);
if (m_pfnExecuteHandler(szCommand, szParameters, bHandleRemotely, (pEntry != NULL), bIsScriptedBind, bAllowScriptedBind))
if (m_pfnExecuteHandler(szCommand, szParameters, bHandleRemotely, wasHandled, bIsScriptedBind, bAllowScriptedBind))
return true;
}

if (wasHandled)
return true;

// Unknown command
val = _("Unknown command or cvar: ") + szCommand;
if (!bIsScriptedBind && !bIsNickCommand && pEntry == nullptr)
Expand Down
5 changes: 0 additions & 5 deletions Client/core/CCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2181,11 +2181,6 @@ CModelCacheManager* CCore::GetModelCacheManager()
return m_pModelCacheManager;
}

void CCore::AddModelToPersistentCache(ushort usModelId)
{
return GetModelCacheManager()->AddModelToPersistentCache(usModelId);
}

void CCore::StaticIdleHandler()
{
g_pCore->IdleHandler();
Expand Down
1 change: 0 additions & 1 deletion Client/core/CCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
EDiagnosticDebugType GetDiagnosticDebug();
void SetDiagnosticDebug(EDiagnosticDebugType value);
CModelCacheManager* GetModelCacheManager();
void AddModelToPersistentCache(ushort usModelId);

static void StaticIdleHandler();
void IdleHandler();
Expand Down
5 changes: 5 additions & 0 deletions Client/core/CGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ CChat* CLocalGUI::GetChat()
return m_pChat;
}

float CLocalGUI::GetChatBottomPosition() const noexcept
{
return m_pChat->GetChatBottomPosition();
}

CDebugView* CLocalGUI::GetDebugView()
{
return m_pDebugView;
Expand Down
1 change: 1 addition & 0 deletions Client/core/CGUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class CLocalGUI : public CSingleton<CLocalGUI>
bool IsMainMenuVisible();

CChat* GetChat();
float GetChatBottomPosition() const noexcept;
void SetChatBoxVisible(bool bVisible, bool bInputBlocked = true);
bool IsChatBoxVisible();
bool IsChatBoxInputBlocked();
Expand Down
48 changes: 28 additions & 20 deletions Client/core/CGraphStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

namespace
{
#define GRAPHSTAT_HISTORY_SIZE 256

struct SGraphStatLine
{
TIMEUS prevData;
Expand Down Expand Up @@ -113,6 +111,11 @@ void CGraphStats::AddTimingPoint(const char* szName)
if (!IsEnabled())
return;

CGraphicsInterface* pGraphics = g_pCore->GetGraphics();

std::uint32_t viewportWidth = pGraphics->GetViewportWidth();
std::uint32_t sizeX = viewportWidth / 4; // one quarter of screen width

// Start of next frame?
if (szName[0] == 0)
{
Expand All @@ -133,7 +136,7 @@ void CGraphStats::AddTimingPoint(const char* szName)
for (int i = 0; i < Dups; i++)
{
pLine->iDataPos++;
if (pLine->iDataPos > GRAPHSTAT_HISTORY_SIZE - 1)
if (pLine->iDataPos > sizeX - 1)
pLine->iDataPos = 0;
pLine->dataHistory[pLine->iDataPos] = Data;
}
Expand All @@ -153,7 +156,7 @@ void CGraphStats::AddTimingPoint(const char* szName)
// Add new line
MapSet(m_LineList, szName, SGraphStatLine());
pLine = MapFind(m_LineList, szName);
pLine->dataHistory.resize(GRAPHSTAT_HISTORY_SIZE);
pLine->dataHistory.resize(sizeX);
memset(&pLine->dataHistory[0], 0, pLine->dataHistory.size());
pLine->iDataPos = 0;
pLine->prevData = 0;
Expand All @@ -179,7 +182,7 @@ void CGraphStats::AddTimingPoint(const char* szName)

// Inc position
pLine->iDataPos++;
if (pLine->iDataPos > GRAPHSTAT_HISTORY_SIZE - 1)
if (pLine->iDataPos > sizeX - 1)
pLine->iDataPos = 0;

// Insert data point
Expand All @@ -199,44 +202,49 @@ void CGraphStats::Draw()
return;

CGraphicsInterface* pGraphics = g_pCore->GetGraphics();
CLocalGUI* pLocalGUI = g_pCore->GetLocalGUI();

std::uint32_t viewportWidth = pGraphics->GetViewportWidth(); // get width of current resolution
std::uint32_t viewportHeight = pGraphics->GetViewportHeight(); // get height of current resolution
std::uint32_t originX = 10; // offset the graph by 10 pixels from left side of screen
std::uint32_t originY = pLocalGUI->GetChatBottomPosition(); // get chat bottom screen position
std::uint32_t sizeX = viewportWidth / 4; // set the width of graph to 1/4 of current resolution
std::uint32_t sizeY = viewportHeight / 4; // set the height of graph to 1/4 of current resolution
std::uint32_t rangeY = 100; // 100ms

originY = originY + sizeY + 30; // add graph height plus a little gap to the overall Y position

uint uiViewportHeight = pGraphics->GetViewportHeight();
uint uiOriginX = 10;
uint uiOriginY = std::min<int>(500, uiViewportHeight - 10);
uint uiSizeX = GRAPHSTAT_HISTORY_SIZE;
uint uiSizeY = 150;
uint uiRangeY = 100; // 100ms
float fLineScale = 1 / 1000.f / uiRangeY * uiSizeY;
float fLineScale = 1 / 1000.f / rangeY * sizeY;
float fLineHeight = pGraphics->GetDXFontHeight();

// Backgroung box
pGraphics->DrawRectQueued(uiOriginX, uiOriginY - uiSizeY, uiSizeX, uiSizeY, SColorRGBA(0, 0, 0, 128), true);
pGraphics->DrawRectQueued(originX, originY - sizeY, sizeX, sizeY, SColorRGBA(0, 0, 0, 128), true);

// Draw data lines
float fLabelX = uiOriginX + uiSizeX + 22;
float fLabelY = uiOriginY - m_LineList.size() * fLineHeight;
float fLabelX = originX + sizeX + 22;
float fLabelY = originY - m_LineList.size() * fLineHeight;
for (const auto& dataLine : m_LineList)
{
const SGraphStatLine& line = dataLine.second;
int iDataPos = line.iDataPos;
int iDataPosPrev = iDataPos;

for (int i = uiSizeX - 1; i > 0; i--)
for (int i = sizeX - 1; i > 0; i--)
{
float fY0 = line.dataHistory[iDataPos] * fLineScale;
float fY1 = line.dataHistory[iDataPosPrev] * fLineScale;

iDataPosPrev = iDataPos;
iDataPos--;
if (iDataPos == -1)
iDataPos = GRAPHSTAT_HISTORY_SIZE - 1;
iDataPos = sizeX - 1;

pGraphics->DrawLineQueued(uiOriginX + i - 1, uiOriginY - fY0, uiOriginX + i, uiOriginY - fY1, 1, line.color, true);
pGraphics->DrawLineQueued(originX + i - 1, originY - fY0, originX + i, originY - fY1, 1, line.color, true);

if (i == uiSizeX - 1)
if (i == sizeX - 1)
{
// Line from graph to label
pGraphics->DrawLineQueued(uiOriginX + i - 1, uiOriginY - fY0, fLabelX - 2, fLabelY + fLineHeight / 2, 1, line.color, true);
pGraphics->DrawLineQueued(originX + i - 1, originY - fY0, fLabelX - 2, fLabelY + fLineHeight / 2, 1, line.color, true);
}
}

Expand Down
3 changes: 2 additions & 1 deletion Client/core/CKeyBinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,8 @@ CCommandBind* CKeyBinds::FindCommandMatch(const char* szKey, const char* szComma
NullEmptyStrings(szKey, szArguments, szResource, szOriginalScriptKey);

std::string arguments = szArguments ? szArguments : "";
szArguments = SharedUtil::Trim(arguments.data());
if (!arguments.empty())
szArguments = SharedUtil::Trim(arguments.data());

for (KeyBindPtr& bind : m_binds)
{
Expand Down
28 changes: 1 addition & 27 deletions Client/core/CModelCacheManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class CModelCacheManagerImpl : public CModelCacheManager
virtual void OnClientClose();
virtual void UpdatePedModelCaching(const std::map<ushort, float>& newNeedCacheList);
virtual void UpdateVehicleModelCaching(const std::map<ushort, float>& newNeedCacheList);
virtual void AddModelToPersistentCache(ushort usModelId);
virtual void SetCustomLimits(std::optional<size_t> numVehicles, std::optional<size_t> numPeds);

// CModelCacheManagerImpl methods
Expand All @@ -72,7 +71,6 @@ class CModelCacheManagerImpl : public CModelCacheManager
bool m_IsUsingCustomVehicleCacheLimit{}; //< If `true` the value is set by the scripter, otherwise is calculated in `DoPulse()`
std::map<ushort, SModelCacheInfo> m_PedModelCacheInfoMap{};
std::map<ushort, SModelCacheInfo> m_VehicleModelCacheInfoMap{};
std::set<ushort> m_PermoLoadedModels{};
};

///////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -266,22 +264,6 @@ void CModelCacheManagerImpl::DoPulse()
}
}

///////////////////////////////////////////////////////////////
//
// CModelCacheManagerImpl::AddModelToPersistentCache
//
// Keep this model around 4 evar now
//
///////////////////////////////////////////////////////////////
void CModelCacheManagerImpl::AddModelToPersistentCache(ushort usModelId)
{
if (!MapContains(m_PermoLoadedModels, usModelId))
{
AddModelRefCount(usModelId);
MapInsert(m_PermoLoadedModels, usModelId);
}
}

///////////////////////////////////////////////////////////////
//
// CModelCacheManagerImpl::UpdatePedModelCaching
Expand Down Expand Up @@ -542,13 +524,5 @@ void CModelCacheManagerImpl::OnRestreamModel(ushort usModelId)
OutputDebugLine(SString("[Cache] End caching model %d (OnRestreamModel)", usModelId));
}
}
}

// Also check the permo list
if (MapContains(m_PermoLoadedModels, usModelId))
{
SubModelRefCount(usModelId);
MapRemove(m_PermoLoadedModels, usModelId);
OutputDebugLine(SString("[Cache] End permo-caching model %d (OnRestreamModel)", usModelId));
}
}
}
1 change: 0 additions & 1 deletion Client/core/CModelCacheManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class CModelCacheManager
virtual void OnClientClose() = 0;
virtual void UpdatePedModelCaching(const std::map<ushort, float>& newNeedCacheList) = 0;
virtual void UpdateVehicleModelCaching(const std::map<ushort, float>& newNeedCacheList) = 0;
virtual void AddModelToPersistentCache(ushort usModelId) = 0;
virtual void SetCustomLimits(std::optional<size_t> numVehicles, std::optional<size_t> numPeds) = 0;
};

Expand Down
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;
};
8 changes: 2 additions & 6 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,18 +1005,14 @@ void CGameSA::GetShaderReplacementStats(SShaderReplacementStats& outStats)
m_pRenderWare->GetShaderReplacementStats(outStats);
}

void CGameSA::RemoveAllBuildings(bool clearBuildingRemoval)
void CGameSA::RemoveAllBuildings()
{
m_pIplStore->SetDynamicIplStreamingEnabled(false);

m_pPools->GetDummyPool().RemoveAllBuildingLods();
m_pPools->GetBuildingsPool().RemoveAllBuildings();

auto pBuildingRemoval = static_cast<CBuildingRemovalSA*>(m_pBuildingRemoval);
if (clearBuildingRemoval)
{
pBuildingRemoval->ClearRemovedBuildingLists();
}
pBuildingRemoval->DropCaches();

m_isBuildingsRemoved = true;
Expand All @@ -1036,7 +1032,7 @@ bool CGameSA::SetBuildingPoolSize(size_t size)
const bool shouldRemoveBuilding = !m_isBuildingsRemoved;
if (shouldRemoveBuilding)
{
RemoveAllBuildings(false);
RemoveAllBuildings();
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Client/game_sa/CGameSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class CGameSA : public CGame
PostWeaponFireHandler* m_pPostWeaponFireHandler;
TaskSimpleBeHitHandler* m_pTaskSimpleBeHitHandler;

void RemoveAllBuildings(bool clearBuildingRemoval = true);
void RemoveAllBuildings();
void RestoreGameBuildings();

bool SetBuildingPoolSize(size_t size);
Expand Down
Loading

0 comments on commit d95dce1

Please sign in to comment.