Skip to content

Commit 29be4e4

Browse files
authored
Merge branch 'master' into 050824_Async-dbConnect
2 parents cbb0a81 + cd7dd1a commit 29be4e4

23 files changed

+140
-75
lines changed

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/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/game_sa/CHandlingManagerSA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9167,7 +9167,7 @@ void CHandlingManagerSA::CheckSuspensionChanges(CHandlingEntry* pEntry) noexcept
91679167

91689168
// Get Handling ID
91699169
const eHandlingTypes eHandling = static_cast<eHandlingTypes>(pEntry->GetVehicleID());
9170-
if (eHandling > HT_MAX)
9170+
if (eHandling >= HT_MAX)
91719171
return;
91729172

91739173
const CHandlingEntrySA* pOriginal = m_pOriginalEntries[eHandling];

Client/game_sa/CStreamingSA.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,3 +503,15 @@ void CStreamingSA::RemoveBigBuildings()
503503
{
504504
(reinterpret_cast<void(__cdecl*)()>(0x4093B0))();
505505
}
506+
507+
void CStreamingSA::LoadScene(const CVector* position)
508+
{
509+
auto CStreaming_LoadScene = (void(__cdecl*)(const CVector*))FUNC_CStreaming_LoadScene;
510+
CStreaming_LoadScene(position);
511+
}
512+
513+
void CStreamingSA::LoadSceneCollision(const CVector* position)
514+
{
515+
auto CStreaming_LoadSceneCollision = (void(__cdecl*)(const CVector*))FUNC_CStreaming_LoadSceneCollision;
516+
CStreaming_LoadSceneCollision(position);
517+
}

Client/game_sa/CStreamingSA.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#define FUNC_LoadAllRequestedModels 0x40EA10
2121
#define FUNC_CStreaming__HasVehicleUpgradeLoaded 0x407820
2222
#define FUNC_CStreaming_RequestSpecialModel 0x409d10
23+
#define FUNC_CStreaming_LoadScene 0x40EB70
24+
#define FUNC_CStreaming_LoadSceneCollision 0x40ED80
2325

2426
struct CArchiveInfo
2527
{
@@ -77,6 +79,9 @@ class CStreamingSA final : public CStreaming
7779
void MakeSpaceFor(std::uint32_t memoryToCleanInBytes) override;
7880
std::uint32_t GetMemoryUsed() const override;
7981

82+
void LoadScene(const CVector* position);
83+
void LoadSceneCollision(const CVector* position);
84+
8085
private:
8186
void AllocateArchive();
8287

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,47 +1247,44 @@ bool CStaticFunctionDefinitions::SetElementAngularVelocity(CClientEntity& Entity
12471247

12481248
bool CStaticFunctionDefinitions::SetElementParent(CClientEntity& Entity, CClientEntity& Parent, CLuaMain* pLuaMain)
12491249
{
1250-
if (&Entity != &Parent && !Entity.IsMyChild(&Parent, true))
1250+
if (&Entity == &Parent || Entity.IsMyChild(&Parent, true))
1251+
return false;
1252+
1253+
if (Entity.GetType() == CCLIENTCAMERA || Parent.GetType() == CCLIENTCAMERA)
1254+
return false;
1255+
1256+
if (Entity.GetType() == CCLIENTGUI)
12511257
{
1252-
if (Entity.GetType() == CCLIENTCAMERA || Parent.GetType() == CCLIENTCAMERA)
1253-
{
1258+
if (Parent.GetType() != CCLIENTGUI && &Parent != pLuaMain->GetResource()->GetResourceGUIEntity())
12541259
return false;
1255-
}
1256-
else if (Entity.GetType() == CCLIENTGUI)
1257-
{
1258-
if (Parent.GetType() == CCLIENTGUI || &Parent == pLuaMain->GetResource()->GetResourceGUIEntity())
1259-
{
1260-
CClientGUIElement& GUIElement = static_cast<CClientGUIElement&>(Entity);
12611260

1262-
GUIElement.SetParent(&Parent);
1263-
return true;
1264-
}
1265-
}
1266-
else
1267-
{
1268-
CClientEntity* pTemp = &Parent;
1269-
CClientEntity* pRoot = m_pRootEntity;
1270-
bool bValidParent = false;
1271-
while (pTemp != pRoot && pTemp != NULL)
1272-
{
1273-
const char* szTypeName = pTemp->GetTypeName();
1274-
if (szTypeName && strcmp(szTypeName, "map") == 0)
1275-
{
1276-
bValidParent = true; // parents must be a map
1277-
break;
1278-
}
1261+
CClientGUIElement& GUIElement = static_cast<CClientGUIElement&>(Entity);
12791262

1280-
pTemp = pTemp->GetParent();
1281-
}
1263+
GUIElement.SetParent(&Parent);
1264+
return true;
1265+
}
12821266

1283-
// Make sure the entity we move is a client entity or we get a problem
1284-
if (bValidParent && Entity.IsLocalEntity())
1285-
{
1286-
// Set the new parent
1287-
Entity.SetParent(&Parent);
1288-
return true;
1289-
}
1267+
CClientEntity* pTemp = &Parent;
1268+
CClientEntity* pRoot = m_pRootEntity;
1269+
bool bValidParent = false;
1270+
while (pTemp != pRoot && pTemp != NULL)
1271+
{
1272+
const char* szTypeName = pTemp->GetTypeName();
1273+
if (szTypeName && strcmp(szTypeName, "map") == 0)
1274+
{
1275+
bValidParent = true; // parents must be a map
1276+
break;
12901277
}
1278+
1279+
pTemp = pTemp->GetParent();
1280+
}
1281+
1282+
// Make sure the entity we move is a client entity or we get a problem
1283+
if (bValidParent && Entity.IsLocalEntity())
1284+
{
1285+
// Set the new parent
1286+
Entity.SetParent(&Parent);
1287+
return true;
12911288
}
12921289

12931290
return false;

Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,12 @@ ADD_ENUM(eModelLoadState::LOADSTATE_READING, "reading")
904904
ADD_ENUM(eModelLoadState::LOADSTATE_FINISHING, "finishing")
905905
IMPLEMENT_ENUM_CLASS_END("model-load-state")
906906

907+
IMPLEMENT_ENUM_CLASS_BEGIN(PreloadAreaOption)
908+
ADD_ENUM(PreloadAreaOption::MODELS, "models")
909+
ADD_ENUM(PreloadAreaOption::COLLISIONS, "collisions")
910+
ADD_ENUM(PreloadAreaOption::ALL, "all")
911+
IMPLEMENT_ENUM_CLASS_END("preload-area-option")
912+
907913
//
908914
// CResource from userdata
909915
//

0 commit comments

Comments
 (0)