Skip to content

Commit 7138e73

Browse files
authored
Merge branch 'master' into feature/panelstates_flyingComponent
2 parents d357a43 + b51e111 commit 7138e73

File tree

166 files changed

+3199
-2326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+3199
-2326
lines changed

.github/workflows/dockerimage.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ on:
1212
- 'Dockerfile.i386'
1313
- 'Dockerfile.armhf'
1414
- 'Dockerfile.arm64'
15-
- 'Dockerfile.osx-x64'
16-
- 'Dockerfile.osx-arm64'
1715

1816
jobs:
1917
build:
@@ -28,10 +26,6 @@ jobs:
2826
dockerfile: Dockerfile.armhf
2927
- tag: arm64
3028
dockerfile: Dockerfile.arm64
31-
- tag: osx-x64
32-
dockerfile: Dockerfile.osx-x64
33-
- tag: osx-arm64
34-
dockerfile: Dockerfile.osx-arm64
3529
runs-on: ubuntu-latest
3630
steps:
3731
- uses: actions/checkout@v4

Client/core/CChat.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,11 @@ void CChat::SetCharacterLimit(int charLimit)
11171117
m_iCharacterLimit = charLimit;
11181118
}
11191119

1120+
float CChat::GetChatBottomPosition() const noexcept
1121+
{
1122+
return m_vecBackgroundSize.fY;
1123+
}
1124+
11201125
CChatLine::CChatLine()
11211126
{
11221127
m_bActive = false;

Client/core/CChat.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ class CChat
207207
constexpr int GetDefaultCharacterLimit() const { return m_iDefaultCharacterLimit; }
208208
constexpr int GetMaxCharacterLimit() const { return m_iMaxCharacterLimit; }
209209

210+
float GetChatBottomPosition() const noexcept;
211+
210212
private:
211213
void LoadCVars();
212214

Client/core/CCommands.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
125125

126126
// Grab the command
127127
tagCOMMANDENTRY* pEntry = Get(szCommand);
128+
bool wasHandled = false;
128129
if (pEntry)
129130
{
130131
// If its a core command, or if its enabled
@@ -133,13 +134,16 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
133134
// Execute it
134135
if (!bIsScriptedBind || pEntry->bAllowScriptedBind)
135136
ExecuteHandler(pEntry->pfnCmdFunc, szParameters);
137+
138+
wasHandled = true;
136139
}
137140
}
138141

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

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

188192
// HACK: if its a 'nick' command, save it here
189193
bool bIsNickCommand = !stricmp(szCommand, "nick");
190-
if (bIsNickCommand && szParameters && !bIsScriptedBind)
194+
if (!wasHandled && bIsNickCommand && szParameters && !bIsScriptedBind)
191195
{
192196
if (CCore::GetSingleton().IsValidNick(szParameters))
193197
{
@@ -208,10 +212,13 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
208212
if (m_pfnExecuteHandler)
209213
{
210214
bool bAllowScriptedBind = (!pEntry || pEntry->bAllowScriptedBind);
211-
if (m_pfnExecuteHandler(szCommand, szParameters, bHandleRemotely, (pEntry != NULL), bIsScriptedBind, bAllowScriptedBind))
215+
if (m_pfnExecuteHandler(szCommand, szParameters, bHandleRemotely, wasHandled, bIsScriptedBind, bAllowScriptedBind))
212216
return true;
213217
}
214218

219+
if (wasHandled)
220+
return true;
221+
215222
// Unknown command
216223
val = _("Unknown command or cvar: ") + szCommand;
217224
if (!bIsScriptedBind && !bIsNickCommand && pEntry == nullptr)

Client/core/CCore.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,11 +2181,6 @@ CModelCacheManager* CCore::GetModelCacheManager()
21812181
return m_pModelCacheManager;
21822182
}
21832183

2184-
void CCore::AddModelToPersistentCache(ushort usModelId)
2185-
{
2186-
return GetModelCacheManager()->AddModelToPersistentCache(usModelId);
2187-
}
2188-
21892184
void CCore::StaticIdleHandler()
21902185
{
21912186
g_pCore->IdleHandler();

Client/core/CCore.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
253253
EDiagnosticDebugType GetDiagnosticDebug();
254254
void SetDiagnosticDebug(EDiagnosticDebugType value);
255255
CModelCacheManager* GetModelCacheManager();
256-
void AddModelToPersistentCache(ushort usModelId);
257256

258257
static void StaticIdleHandler();
259258
void IdleHandler();

Client/core/CGUI.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ CChat* CLocalGUI::GetChat()
449449
return m_pChat;
450450
}
451451

452+
float CLocalGUI::GetChatBottomPosition() const noexcept
453+
{
454+
return m_pChat->GetChatBottomPosition();
455+
}
456+
452457
CDebugView* CLocalGUI::GetDebugView()
453458
{
454459
return m_pDebugView;

Client/core/CGUI.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class CLocalGUI : public CSingleton<CLocalGUI>
6868
bool IsMainMenuVisible();
6969

7070
CChat* GetChat();
71+
float GetChatBottomPosition() const noexcept;
7172
void SetChatBoxVisible(bool bVisible, bool bInputBlocked = true);
7273
bool IsChatBoxVisible();
7374
bool IsChatBoxInputBlocked();

Client/core/CGraphStats.cpp

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
namespace
1414
{
15-
#define GRAPHSTAT_HISTORY_SIZE 256
16-
1715
struct SGraphStatLine
1816
{
1917
TIMEUS prevData;
@@ -113,6 +111,11 @@ void CGraphStats::AddTimingPoint(const char* szName)
113111
if (!IsEnabled())
114112
return;
115113

114+
CGraphicsInterface* pGraphics = g_pCore->GetGraphics();
115+
116+
std::uint32_t viewportWidth = pGraphics->GetViewportWidth();
117+
std::uint32_t sizeX = viewportWidth / 4; // one quarter of screen width
118+
116119
// Start of next frame?
117120
if (szName[0] == 0)
118121
{
@@ -133,7 +136,7 @@ void CGraphStats::AddTimingPoint(const char* szName)
133136
for (int i = 0; i < Dups; i++)
134137
{
135138
pLine->iDataPos++;
136-
if (pLine->iDataPos > GRAPHSTAT_HISTORY_SIZE - 1)
139+
if (pLine->iDataPos > sizeX - 1)
137140
pLine->iDataPos = 0;
138141
pLine->dataHistory[pLine->iDataPos] = Data;
139142
}
@@ -153,7 +156,7 @@ void CGraphStats::AddTimingPoint(const char* szName)
153156
// Add new line
154157
MapSet(m_LineList, szName, SGraphStatLine());
155158
pLine = MapFind(m_LineList, szName);
156-
pLine->dataHistory.resize(GRAPHSTAT_HISTORY_SIZE);
159+
pLine->dataHistory.resize(sizeX);
157160
memset(&pLine->dataHistory[0], 0, pLine->dataHistory.size());
158161
pLine->iDataPos = 0;
159162
pLine->prevData = 0;
@@ -179,7 +182,7 @@ void CGraphStats::AddTimingPoint(const char* szName)
179182

180183
// Inc position
181184
pLine->iDataPos++;
182-
if (pLine->iDataPos > GRAPHSTAT_HISTORY_SIZE - 1)
185+
if (pLine->iDataPos > sizeX - 1)
183186
pLine->iDataPos = 0;
184187

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

201204
CGraphicsInterface* pGraphics = g_pCore->GetGraphics();
205+
CLocalGUI* pLocalGUI = g_pCore->GetLocalGUI();
206+
207+
std::uint32_t viewportWidth = pGraphics->GetViewportWidth(); // get width of current resolution
208+
std::uint32_t viewportHeight = pGraphics->GetViewportHeight(); // get height of current resolution
209+
std::uint32_t originX = 10; // offset the graph by 10 pixels from left side of screen
210+
std::uint32_t originY = pLocalGUI->GetChatBottomPosition(); // get chat bottom screen position
211+
std::uint32_t sizeX = viewportWidth / 4; // set the width of graph to 1/4 of current resolution
212+
std::uint32_t sizeY = viewportHeight / 4; // set the height of graph to 1/4 of current resolution
213+
std::uint32_t rangeY = 100; // 100ms
214+
215+
originY = originY + sizeY + 30; // add graph height plus a little gap to the overall Y position
202216

203-
uint uiViewportHeight = pGraphics->GetViewportHeight();
204-
uint uiOriginX = 10;
205-
uint uiOriginY = std::min<int>(500, uiViewportHeight - 10);
206-
uint uiSizeX = GRAPHSTAT_HISTORY_SIZE;
207-
uint uiSizeY = 150;
208-
uint uiRangeY = 100; // 100ms
209-
float fLineScale = 1 / 1000.f / uiRangeY * uiSizeY;
217+
float fLineScale = 1 / 1000.f / rangeY * sizeY;
210218
float fLineHeight = pGraphics->GetDXFontHeight();
211219

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

215223
// Draw data lines
216-
float fLabelX = uiOriginX + uiSizeX + 22;
217-
float fLabelY = uiOriginY - m_LineList.size() * fLineHeight;
224+
float fLabelX = originX + sizeX + 22;
225+
float fLabelY = originY - m_LineList.size() * fLineHeight;
218226
for (const auto& dataLine : m_LineList)
219227
{
220228
const SGraphStatLine& line = dataLine.second;
221229
int iDataPos = line.iDataPos;
222230
int iDataPosPrev = iDataPos;
223231

224-
for (int i = uiSizeX - 1; i > 0; i--)
232+
for (int i = sizeX - 1; i > 0; i--)
225233
{
226234
float fY0 = line.dataHistory[iDataPos] * fLineScale;
227235
float fY1 = line.dataHistory[iDataPosPrev] * fLineScale;
228236

229237
iDataPosPrev = iDataPos;
230238
iDataPos--;
231239
if (iDataPos == -1)
232-
iDataPos = GRAPHSTAT_HISTORY_SIZE - 1;
240+
iDataPos = sizeX - 1;
233241

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

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

Client/core/CKeyBinds.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,8 @@ CCommandBind* CKeyBinds::FindCommandMatch(const char* szKey, const char* szComma
841841
NullEmptyStrings(szKey, szArguments, szResource, szOriginalScriptKey);
842842

843843
std::string arguments = szArguments ? szArguments : "";
844-
szArguments = SharedUtil::Trim(arguments.data());
844+
if (!arguments.empty())
845+
szArguments = SharedUtil::Trim(arguments.data());
845846

846847
for (KeyBindPtr& bind : m_binds)
847848
{

Client/core/CModelCacheManager.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class CModelCacheManagerImpl : public CModelCacheManager
4747
virtual void OnClientClose();
4848
virtual void UpdatePedModelCaching(const std::map<ushort, float>& newNeedCacheList);
4949
virtual void UpdateVehicleModelCaching(const std::map<ushort, float>& newNeedCacheList);
50-
virtual void AddModelToPersistentCache(ushort usModelId);
5150
virtual void SetCustomLimits(std::optional<size_t> numVehicles, std::optional<size_t> numPeds);
5251

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

7876
///////////////////////////////////////////////////////////////
@@ -266,22 +264,6 @@ void CModelCacheManagerImpl::DoPulse()
266264
}
267265
}
268266

269-
///////////////////////////////////////////////////////////////
270-
//
271-
// CModelCacheManagerImpl::AddModelToPersistentCache
272-
//
273-
// Keep this model around 4 evar now
274-
//
275-
///////////////////////////////////////////////////////////////
276-
void CModelCacheManagerImpl::AddModelToPersistentCache(ushort usModelId)
277-
{
278-
if (!MapContains(m_PermoLoadedModels, usModelId))
279-
{
280-
AddModelRefCount(usModelId);
281-
MapInsert(m_PermoLoadedModels, usModelId);
282-
}
283-
}
284-
285267
///////////////////////////////////////////////////////////////
286268
//
287269
// CModelCacheManagerImpl::UpdatePedModelCaching
@@ -542,13 +524,5 @@ void CModelCacheManagerImpl::OnRestreamModel(ushort usModelId)
542524
OutputDebugLine(SString("[Cache] End caching model %d (OnRestreamModel)", usModelId));
543525
}
544526
}
545-
}
546-
547-
// Also check the permo list
548-
if (MapContains(m_PermoLoadedModels, usModelId))
549-
{
550-
SubModelRefCount(usModelId);
551-
MapRemove(m_PermoLoadedModels, usModelId);
552-
OutputDebugLine(SString("[Cache] End permo-caching model %d (OnRestreamModel)", usModelId));
553-
}
527+
}
554528
}

Client/core/CModelCacheManager.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class CModelCacheManager
2424
virtual void OnClientClose() = 0;
2525
virtual void UpdatePedModelCaching(const std::map<ushort, float>& newNeedCacheList) = 0;
2626
virtual void UpdateVehicleModelCaching(const std::map<ushort, float>& newNeedCacheList) = 0;
27-
virtual void AddModelToPersistentCache(ushort usModelId) = 0;
2827
virtual void SetCustomLimits(std::optional<size_t> numVehicles, std::optional<size_t> numPeds) = 0;
2928
};
3029

Client/game_sa/CBuildingsPoolSA.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ void CBuildingsPoolSA::RemoveBuilding(CBuilding* pBuilding)
101101
// Remove plant
102102
pGame->GetPlantManager()->RemovePlant(pInterface);
103103

104-
RemoveBuildingFromWorld(pInterface);
104+
// Remove shadow
105+
pInterface->RemoveShadows();
106+
107+
// Remove building from world
108+
pGame->GetWorld()->Remove(pInterface, CBuildingPool_Destructor);
109+
110+
// Call virtual destructor
111+
((void*(__thiscall*)(void*, char))pInterface->vtbl->SCALAR_DELETING_DESTRUCTOR)(pInterface, 0);
105112

106113
// Remove col reference
107114
auto modelInfo = pGame->GetModelInfo(pBuilding->GetModelIndex());

Client/game_sa/CClockSA.cpp

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

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 SetTimeFrozen(bool value) noexcept;
27+
bool IsTimeFrozen() const noexcept { return m_bTimeCycleFrozen; };
28+
bool ResetTimeFrozen() noexcept;
29+
30+
private:
31+
bool m_bTimeCycleFrozen;
2532
};

0 commit comments

Comments
 (0)