Skip to content

Commit 8a36b95

Browse files
committed
Pass CStringName by ref
1 parent 95cd9a9 commit 8a36b95

16 files changed

+56
-56
lines changed

Client/mods/deathmatch/logic/CClientEntity.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ void CClientEntity::SetID(ElementID ID)
279279
}
280280
}
281281

282-
CLuaArgument* CClientEntity::GetCustomData(CStringName name, bool bInheritData, bool* pbIsSynced)
282+
CLuaArgument* CClientEntity::GetCustomData(const CStringName& name, bool bInheritData, bool* pbIsSynced)
283283
{
284284
assert(name);
285285

@@ -315,7 +315,7 @@ CLuaArguments* CClientEntity::GetAllCustomData(CLuaArguments* table)
315315
return table;
316316
}
317317

318-
bool CClientEntity::GetCustomDataString(CStringName name, SString& strOut, bool bInheritData)
318+
bool CClientEntity::GetCustomDataString(const CStringName& name, SString& strOut, bool bInheritData)
319319
{
320320
// Grab the custom data variable
321321
CLuaArgument* pData = GetCustomData(name, bInheritData);
@@ -350,7 +350,7 @@ bool CClientEntity::GetCustomDataString(CStringName name, SString& strOut, bool
350350
return false;
351351
}
352352

353-
bool CClientEntity::GetCustomDataInt(CStringName name, int& iOut, bool bInheritData)
353+
bool CClientEntity::GetCustomDataInt(const CStringName& name, int& iOut, bool bInheritData)
354354
{
355355
// Grab the custom data variable
356356
CLuaArgument* pData = GetCustomData(name, bInheritData);
@@ -388,7 +388,7 @@ bool CClientEntity::GetCustomDataInt(CStringName name, int& iOut, bool bInheritD
388388
return false;
389389
}
390390

391-
bool CClientEntity::GetCustomDataFloat(CStringName name, float& fOut, bool bInheritData)
391+
bool CClientEntity::GetCustomDataFloat(const CStringName& name, float& fOut, bool bInheritData)
392392
{
393393
// Grab the custom data variable
394394
CLuaArgument* pData = GetCustomData(name, bInheritData);
@@ -415,7 +415,7 @@ bool CClientEntity::GetCustomDataFloat(CStringName name, float& fOut, bool bInhe
415415
return false;
416416
}
417417

418-
bool CClientEntity::GetCustomDataBool(CStringName name, bool& bOut, bool bInheritData)
418+
bool CClientEntity::GetCustomDataBool(const CStringName& name, bool& bOut, bool bInheritData)
419419
{
420420
// Grab the custom data variable
421421
CLuaArgument* pData = GetCustomData(name, bInheritData);
@@ -470,7 +470,7 @@ bool CClientEntity::GetCustomDataBool(CStringName name, bool& bOut, bool bInheri
470470
return false;
471471
}
472472

473-
void CClientEntity::SetCustomData(CStringName name, const CLuaArgument& Variable, bool bSynchronized)
473+
void CClientEntity::SetCustomData(const CStringName& name, const CLuaArgument& Variable, bool bSynchronized)
474474
{
475475
assert(name);
476476
if (name->length() > MAX_CUSTOMDATA_NAME_LENGTH)
@@ -499,7 +499,7 @@ void CClientEntity::SetCustomData(CStringName name, const CLuaArgument& Variable
499499
CallEvent("onClientElementDataChange", Arguments, true);
500500
}
501501

502-
void CClientEntity::DeleteCustomData(CStringName name)
502+
void CClientEntity::DeleteCustomData(const CStringName& name)
503503
{
504504
// Grab the old variable
505505
SCustomData* pData = m_pCustomData->Get(name);

Client/mods/deathmatch/logic/CClientEntity.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@ class CClientEntity : public CClientEntityBase
202202
void SetID(ElementID ID);
203203

204204
CCustomData* GetCustomDataPointer() { return m_pCustomData; }
205-
CLuaArgument* GetCustomData(CStringName name, bool bInheritData, bool* pbIsSynced = nullptr);
205+
CLuaArgument* GetCustomData(const CStringName& name, bool bInheritData, bool* pbIsSynced = nullptr);
206206
CLuaArguments* GetAllCustomData(CLuaArguments* table);
207-
bool GetCustomDataString(CStringName name, SString& strOut, bool bInheritData);
208-
bool GetCustomDataFloat(CStringName name, float& fOut, bool bInheritData);
209-
bool GetCustomDataInt(CStringName name, int& iOut, bool bInheritData);
210-
bool GetCustomDataBool(CStringName name, bool& bOut, bool bInheritData);
211-
void SetCustomData(CStringName name, const CLuaArgument& Variable, bool bSynchronized = true);
212-
void DeleteCustomData(CStringName name);
207+
bool GetCustomDataString(const CStringName& name, SString& strOut, bool bInheritData);
208+
bool GetCustomDataFloat(const CStringName& name, float& fOut, bool bInheritData);
209+
bool GetCustomDataInt(const CStringName& name, int& iOut, bool bInheritData);
210+
bool GetCustomDataBool(const CStringName& name, bool& bOut, bool bInheritData);
211+
void SetCustomData(const CStringName& name, const CLuaArgument& Variable, bool bSynchronized = true);
212+
void DeleteCustomData(const CStringName& name);
213213

214214
virtual bool GetMatrix(CMatrix& matrix) const;
215215
virtual bool SetMatrix(const CMatrix& matrix);

Client/mods/deathmatch/logic/CCustomData.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void CCustomData::Copy(CCustomData* pCustomData)
2121
}
2222
}
2323

24-
SCustomData* CCustomData::Get(CStringName name)
24+
SCustomData* CCustomData::Get(const CStringName& name)
2525
{
2626
assert(name);
2727

@@ -32,7 +32,7 @@ SCustomData* CCustomData::Get(CStringName name)
3232
return NULL;
3333
}
3434

35-
void CCustomData::Set(CStringName name, const CLuaArgument& Variable, bool bSynchronized)
35+
void CCustomData::Set(const CStringName& name, const CLuaArgument& Variable, bool bSynchronized)
3636
{
3737
assert(name);
3838

@@ -54,7 +54,7 @@ void CCustomData::Set(CStringName name, const CLuaArgument& Variable, bool bSync
5454
}
5555
}
5656

57-
bool CCustomData::Delete(CStringName name)
57+
bool CCustomData::Delete(const CStringName& name)
5858
{
5959
// Find the item and delete it
6060
auto it = m_Data.find(name);

Client/mods/deathmatch/logic/CCustomData.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class CCustomData
2626
public:
2727
void Copy(CCustomData* pCustomData);
2828

29-
SCustomData* Get(CStringName name);
30-
void Set(CStringName name, const CLuaArgument& Variable, bool bSynchronized = true);
29+
SCustomData* Get(const CStringName& name);
30+
void Set(const CStringName& name, const CLuaArgument& Variable, bool bSynchronized = true);
3131

32-
bool Delete(CStringName name);
32+
bool Delete(const CStringName& name);
3333

3434
std::unordered_map<CStringName, SCustomData>::const_iterator IterBegin() { return m_Data.begin(); }
3535
std::unordered_map<CStringName, SCustomData>::const_iterator IterEnd() { return m_Data.end(); }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ void CLuaArgument::ReadString(const std::string_view& string)
334334
m_strString = std::string{string};
335335
}
336336

337-
void CLuaArgument::ReadString(CStringName string)
337+
void CLuaArgument::ReadString(const CStringName& string)
338338
{
339339
m_iType = LUA_TSTRING;
340340
DeleteTableData();

Client/mods/deathmatch/logic/lua/CLuaArgument.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CLuaArgument
4343
void ReadNumber(double dNumber);
4444
void ReadString(const std::string& string);
4545
void ReadString(const std::string_view& string);
46-
void ReadString(CStringName string);
46+
void ReadString(const CStringName& string);
4747
void ReadString(const char* string);
4848
void ReadElement(CClientEntity* pElement);
4949
void ReadScriptID(uint uiScriptID);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ CLuaArgument* CLuaArguments::PushString(const std::string_view& string)
351351
return arg;
352352
}
353353

354-
CLuaArgument* CLuaArguments::PushString(CStringName string)
354+
CLuaArgument* CLuaArguments::PushString(const CStringName& string)
355355
{
356356
CLuaArgument* arg = new CLuaArgument();
357357
arg->ReadString(string);

Client/mods/deathmatch/logic/lua/CLuaArguments.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CLuaArguments
5757
CLuaArgument* PushNumber(double dNumber);
5858
CLuaArgument* PushString(const std::string& string);
5959
CLuaArgument* PushString(const std::string_view& string);
60-
CLuaArgument* PushString(CStringName string);
60+
CLuaArgument* PushString(const CStringName& string);
6161
CLuaArgument* PushString(const char* string);
6262
CLuaArgument* PushElement(CClientEntity* pElement);
6363
CLuaArgument* PushArgument(const CLuaArgument& argument);

Server/mods/deathmatch/logic/CCustomData.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void CCustomData::Copy(CCustomData* pCustomData)
2121
}
2222
}
2323

24-
SCustomData* CCustomData::Get(CStringName name) const
24+
SCustomData* CCustomData::Get(const CStringName& name) const
2525
{
2626
assert(name);
2727

@@ -32,7 +32,7 @@ SCustomData* CCustomData::Get(CStringName name) const
3232
return NULL;
3333
}
3434

35-
SCustomData* CCustomData::GetSynced(CStringName name)
35+
SCustomData* CCustomData::GetSynced(const CStringName& name)
3636
{
3737
assert(name);
3838

@@ -43,7 +43,7 @@ SCustomData* CCustomData::GetSynced(CStringName name)
4343
return NULL;
4444
}
4545

46-
bool CCustomData::DeleteSynced(CStringName name)
46+
bool CCustomData::DeleteSynced(const CStringName& name)
4747
{
4848
// Find the item and delete it
4949
auto iter = m_SyncedData.find(name);
@@ -57,7 +57,7 @@ bool CCustomData::DeleteSynced(CStringName name)
5757
return false;
5858
}
5959

60-
void CCustomData::UpdateSynced(CStringName name, const CLuaArgument& Variable, ESyncType syncType)
60+
void CCustomData::UpdateSynced(const CStringName& name, const CLuaArgument& Variable, ESyncType syncType)
6161
{
6262
if (syncType == ESyncType::BROADCAST)
6363
{
@@ -81,7 +81,7 @@ void CCustomData::UpdateSynced(CStringName name, const CLuaArgument& Variable, E
8181
}
8282
}
8383

84-
void CCustomData::Set(CStringName name, const CLuaArgument& Variable, ESyncType syncType)
84+
void CCustomData::Set(const CStringName& name, const CLuaArgument& Variable, ESyncType syncType)
8585
{
8686
assert(name);
8787

@@ -106,7 +106,7 @@ void CCustomData::Set(CStringName name, const CLuaArgument& Variable, ESyncType
106106
}
107107
}
108108

109-
bool CCustomData::Delete(CStringName name)
109+
bool CCustomData::Delete(const CStringName& name)
110110
{
111111
// Find the item and delete it
112112
auto it = m_Data.find(name);
@@ -121,7 +121,7 @@ bool CCustomData::Delete(CStringName name)
121121
return false;
122122
}
123123

124-
void CCustomData::SetClientChangesMode(CStringName name, eCustomDataClientTrust mode)
124+
void CCustomData::SetClientChangesMode(const CStringName& name, eCustomDataClientTrust mode)
125125
{
126126
SCustomData& pData = m_Data[name];
127127
pData.clientChangesMode = mode;

Server/mods/deathmatch/logic/CCustomData.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ class CCustomData
4444
public:
4545
void Copy(CCustomData* pCustomData);
4646

47-
SCustomData* Get(CStringName name) const;
48-
SCustomData* GetSynced(CStringName name);
49-
void Set(CStringName name, const CLuaArgument& Variable, ESyncType syncType = ESyncType::BROADCAST);
47+
SCustomData* Get(const CStringName& name) const;
48+
SCustomData* GetSynced(const CStringName& name);
49+
void Set(const CStringName& name, const CLuaArgument& Variable, ESyncType syncType = ESyncType::BROADCAST);
5050

51-
bool Delete(CStringName name);
51+
bool Delete(const CStringName& name);
5252

53-
void SetClientChangesMode(CStringName name, eCustomDataClientTrust mode);
53+
void SetClientChangesMode(const CStringName& name, eCustomDataClientTrust mode);
5454

5555
unsigned short CountOnlySynchronized();
5656

@@ -63,8 +63,8 @@ class CCustomData
6363
std::unordered_map<CStringName, SCustomData>::const_iterator SyncedIterEnd() { return m_SyncedData.end(); }
6464

6565
private:
66-
bool DeleteSynced(CStringName name);
67-
void UpdateSynced(CStringName name, const CLuaArgument& Variable, ESyncType syncType);
66+
bool DeleteSynced(const CStringName& name);
67+
void UpdateSynced(const CStringName& name, const CLuaArgument& Variable, ESyncType syncType);
6868

6969
std::unordered_map<CStringName, SCustomData> m_Data;
7070
std::unordered_map<CStringName, SCustomData> m_SyncedData;

0 commit comments

Comments
 (0)