Skip to content

Commit 0da17db

Browse files
committed
Misc coding guidelines conformance fixes (from my recent commits + extended)
1 parent 5ac6e3b commit 0da17db

File tree

5 files changed

+51
-51
lines changed

5 files changed

+51
-51
lines changed

Client/core/CAdditionalVertexStreamManager.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "StdInc.h"
1313
#include "CAdditionalVertexStreamManager.h"
1414

15-
CAdditionalVertexStreamManager* CAdditionalVertexStreamManager::ms_Singleton = NULL;
15+
CAdditionalVertexStreamManager* CAdditionalVertexStreamManager::ms_Singleton = nullptr;
1616

1717
namespace
1818
{
@@ -69,15 +69,15 @@ CAdditionalVertexStreamManager::~CAdditionalVertexStreamManager()
6969
{
7070
SAFE_RELEASE(m_pOldVertexDeclaration);
7171

72-
for (std::map<void*, SAdditionalStreamInfo>::iterator iter = m_AdditionalStreamInfoMap.begin(); iter != m_AdditionalStreamInfoMap.end(); ++iter)
72+
for (auto iter = m_AdditionalStreamInfoMap.begin(); iter != m_AdditionalStreamInfoMap.end(); ++iter)
7373
{
7474
SAdditionalStreamInfo& info = iter->second;
7575
SAFE_RELEASE(info.pStreamData);
7676
SAFE_RELEASE(info.pVertexDeclaration);
7777
}
7878

7979
m_AdditionalStreamInfoMap.clear();
80-
m_pDevice = NULL;
80+
m_pDevice = nullptr;
8181
}
8282

8383
///////////////////////////////////////////////////////////////
@@ -94,7 +94,7 @@ CAdditionalVertexStreamManager* CAdditionalVertexStreamManager::GetSingleton()
9494
return ms_Singleton;
9595
}
9696

97-
CAdditionalVertexStreamManager* CAdditionalVertexStreamManager::GetExistingSingleton()
97+
CAdditionalVertexStreamManager* const& CAdditionalVertexStreamManager::GetExistingSingleton() noexcept
9898
{
9999
return ms_Singleton;
100100
}
@@ -104,7 +104,7 @@ void CAdditionalVertexStreamManager::DestroySingleton()
104104
if (ms_Singleton)
105105
{
106106
delete ms_Singleton;
107-
ms_Singleton = NULL;
107+
ms_Singleton = nullptr;
108108
}
109109
}
110110

@@ -227,7 +227,7 @@ void CAdditionalVertexStreamManager::MaybeUnsetAdditionalVertexStream()
227227
SAFE_RELEASE(m_pOldVertexDeclaration);
228228

229229
// Unset additional stream
230-
hr = m_pDevice->SetStreamSource(2, NULL, 0, 0);
230+
hr = m_pDevice->SetStreamSource(2, nullptr, 0, 0);
231231
}
232232
}
233233

@@ -254,7 +254,7 @@ bool CAdditionalVertexStreamManager::UpdateAdditionalStreamContent(SCurrentState
254254
sourceArray.resize(ReadSize);
255255
uchar* pSourceArrayBytes = &sourceArray[0];
256256
{
257-
void* pVertexBytesPT = NULL;
257+
void* pVertexBytesPT = nullptr;
258258
if (FAILED(pStreamDataPT->Lock(ReadOffsetStart, ReadSize, &pVertexBytesPT, D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY)))
259259
return false;
260260
memcpy(pSourceArrayBytes, pVertexBytesPT, ReadSize);
@@ -290,7 +290,7 @@ bool CAdditionalVertexStreamManager::UpdateAdditionalStreamContent(SCurrentState
290290
indexArray.resize(ReadSize);
291291
uchar* pIndexArrayBytes = &indexArray[0];
292292
{
293-
void* pIndexBytes = NULL;
293+
void* pIndexBytes = nullptr;
294294
if (FAILED(state.pIndexData->Lock(state.args.startIndex * 2, numIndices * 2, &pIndexBytes, D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY)))
295295
return false;
296296
memcpy(pIndexArrayBytes, pIndexBytes, numIndices * 2);
@@ -372,7 +372,7 @@ bool CAdditionalVertexStreamManager::UpdateAdditionalStreamContent(SCurrentState
372372

373373
// Set the dest bytes
374374
{
375-
void* pVertexBytesN = NULL;
375+
void* pVertexBytesN = nullptr;
376376
if (FAILED(pStreamDataN->Lock(WriteOffsetStart, WriteSize, &pVertexBytesN, D3DLOCK_NOSYSLOCK)))
377377
return false;
378378
memcpy(pVertexBytesN, pDestArrayBytes, WriteSize);
@@ -407,7 +407,7 @@ bool CAdditionalVertexStreamManager::UpdateCurrentStateInfo(SCurrentStateInfo& s
407407

408408
// Get vertex stream
409409
if (FAILED(m_pDevice->GetStreamSource(1, &state.stream1.pStreamData, &state.stream1.OffsetInBytes, &state.stream1.Stride)))
410-
return NULL;
410+
return false;
411411

412412
// Get vertex stream desc
413413
if (state.stream1.pStreamData)
@@ -505,7 +505,7 @@ SAdditionalStreamInfo* CAdditionalVertexStreamManager::CreateAdditionalStreamInf
505505
// Create new stream
506506
info.Stride = sizeof(float) * 3;
507507
UINT Size2 = ConvertPTSize(state.decl.VertexBufferDesc1.Size);
508-
if (FAILED(m_pDevice->CreateVertexBuffer(Size2, D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &info.pStreamData, NULL)))
508+
if (FAILED(m_pDevice->CreateVertexBuffer(Size2, D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &info.pStreamData, nullptr)))
509509
{
510510
SAFE_RELEASE(info.pVertexDeclaration);
511511
return nullptr;

Client/core/CAdditionalVertexStreamManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class CAdditionalVertexStreamManager
8484
void OnVertexBufferRangeInvalidated(IDirect3DVertexBuffer9* pStreamData, uint Offset, uint Size);
8585

8686
static CAdditionalVertexStreamManager* GetSingleton();
87-
static CAdditionalVertexStreamManager* GetExistingSingleton();
87+
static CAdditionalVertexStreamManager* const& GetExistingSingleton() noexcept;
8888
static void DestroySingleton();
8989

9090
protected:

Client/core/DXHook/CDirect3DEvents9.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ void CDirect3DEvents9::OnInvalidate(IDirect3DDevice9* pDevice)
9595
// Force completion of all GPU operations if a scene is currently active
9696
if (g_bInMTAScene || g_bInGTAScene)
9797
{
98-
const HRESULT hEndScene = pDevice->EndScene();
99-
if (SUCCEEDED(hEndScene))
98+
const HRESULT hrEndScene = pDevice->EndScene();
99+
if (SUCCEEDED(hrEndScene))
100100
{
101101
g_bInMTAScene = false;
102102
g_bInGTAScene = false;
103103
}
104104
else
105105
{
106-
WriteDebugEvent(SString("OnInvalidate: EndScene failed: %08x", hEndScene));
106+
WriteDebugEvent(SString("OnInvalidate: EndScene failed: %08x", hrEndScene));
107107
}
108108
}
109109

@@ -138,10 +138,10 @@ void CDirect3DEvents9::OnPresent(IDirect3DDevice9* pDevice)
138138
// Start a new scene. This isn't ideal and is not really recommended by MSDN.
139139
// I tried disabling EndScene from GTA and just end it after this code ourselves
140140
// before present, but that caused graphical issues randomly with the sky.
141-
const HRESULT hBeginScene = pDevice->BeginScene();
142-
if (FAILED(hBeginScene))
141+
const HRESULT hrBeginScene = pDevice->BeginScene();
142+
if (FAILED(hrBeginScene))
143143
{
144-
WriteDebugEvent(SString("OnPresent: BeginScene failed: %08x", hBeginScene));
144+
WriteDebugEvent(SString("OnPresent: BeginScene failed: %08x", hrBeginScene));
145145
g_bInMTAScene = false;
146146
return;
147147
}

Client/core/DXHook/CProxyDirect3DVertexBuffer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ CProxyDirect3DVertexBuffer::~CProxyDirect3DVertexBuffer()
6666
/////////////////////////////////////////////////////////////
6767
HRESULT CProxyDirect3DVertexBuffer::QueryInterface(REFIID riid, void** ppvObj)
6868
{
69-
*ppvObj = NULL;
69+
*ppvObj = nullptr;
7070

7171
// Looking for me?
7272
if (riid == CProxyDirect3DVertexBuffer_GUID)
@@ -113,11 +113,11 @@ HRESULT CProxyDirect3DVertexBuffer::Lock(UINT OffsetToLock, UINT SizeToLock, voi
113113
pBoundingBoxManager->OnVertexBufferRangeInvalidated(m_pOriginal, OffsetToLock, SizeToLock);
114114
}
115115

116-
*ppbData = NULL;
116+
*ppbData = nullptr;
117117
HRESULT hr = DoLock(OffsetToLock, SizeToLock, ppbData, Flags);
118118
HRESULT originalHr = hr;
119119

120-
if (SUCCEEDED(hr) && *ppbData == NULL)
120+
if (SUCCEEDED(hr) && *ppbData == nullptr)
121121
{
122122
hr = D3DERR_INVALIDCALL;
123123
}

0 commit comments

Comments
 (0)