mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Mark some return values as const
This commit is contained in:
parent
a929a99fd9
commit
a2cb7d339a
|
@ -140,7 +140,7 @@ class CNetObjHandler
|
|||
public:
|
||||
CNetObjHandler();
|
||||
|
||||
int ValidateObj(int Type, void *pData, int Size);
|
||||
int ValidateObj(int Type, const void *pData, int Size);
|
||||
const char *GetObjName(int Type) const;
|
||||
int GetObjSize(int Type) const;
|
||||
int NumObjCorrections() const;
|
||||
|
@ -265,7 +265,7 @@ if gen_network_source:
|
|||
lines += ["};", ""]
|
||||
|
||||
lines = []
|
||||
lines += ['int CNetObjHandler::ValidateObj(int Type, void *pData, int Size)']
|
||||
lines += ['int CNetObjHandler::ValidateObj(int Type, const void *pData, int Size)']
|
||||
lines += ['{']
|
||||
lines += ['\tswitch(Type)']
|
||||
lines += ['\t{']
|
||||
|
|
|
@ -96,7 +96,7 @@ public:
|
|||
virtual int MapDownloadTotalsize() const = 0;
|
||||
|
||||
// input
|
||||
virtual int *GetInput(int Tick) const = 0;
|
||||
virtual const int *GetInput(int Tick) const = 0;
|
||||
|
||||
// remote console
|
||||
virtual void RconAuth(const char *pUsername, const char *pPassword) = 0;
|
||||
|
@ -117,8 +117,8 @@ public:
|
|||
|
||||
// TODO: Refactor: should redo this a bit i think, too many virtual calls
|
||||
virtual int SnapNumItems(int SnapID) const = 0;
|
||||
virtual void *SnapFindItem(int SnapID, int Type, int ID) const = 0;
|
||||
virtual void *SnapGetItem(int SnapID, int Index, CSnapItem *pItem) const = 0;
|
||||
virtual const void *SnapFindItem(int SnapID, int Type, int ID) const = 0;
|
||||
virtual const void *SnapGetItem(int SnapID, int Index, CSnapItem *pItem) const = 0;
|
||||
virtual void SnapInvalidateItem(int SnapID, int Index) = 0;
|
||||
|
||||
virtual void *SnapNewItem(int Type, int ID, int Size) = 0;
|
||||
|
|
|
@ -429,7 +429,7 @@ const char *CClient::LatestVersion() const
|
|||
}
|
||||
|
||||
// TODO: OPT: do this alot smarter!
|
||||
int *CClient::GetInput(int Tick) const
|
||||
const int *CClient::GetInput(int Tick) const
|
||||
{
|
||||
int Best = -1;
|
||||
for(int i = 0; i < 200; i++)
|
||||
|
@ -439,7 +439,7 @@ int *CClient::GetInput(int Tick) const
|
|||
}
|
||||
|
||||
if(Best != -1)
|
||||
return (int *)m_aInputs[Best].m_aData;
|
||||
return (const int *)m_aInputs[Best].m_aData;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -591,7 +591,7 @@ int CClient::LoadData()
|
|||
|
||||
// ---
|
||||
|
||||
void *CClient::SnapGetItem(int SnapID, int Index, CSnapItem *pItem) const
|
||||
const void *CClient::SnapGetItem(int SnapID, int Index, CSnapItem *pItem) const
|
||||
{
|
||||
CSnapshotItem *i;
|
||||
dbg_assert(SnapID >= 0 && SnapID < NUM_SNAPSHOT_TYPES, "invalid SnapID");
|
||||
|
@ -617,7 +617,7 @@ void CClient::SnapInvalidateItem(int SnapID, int Index)
|
|||
}
|
||||
}
|
||||
|
||||
void *CClient::SnapFindItem(int SnapID, int Type, int ID) const
|
||||
const void *CClient::SnapFindItem(int SnapID, int Type, int ID) const
|
||||
{
|
||||
// TODO: linear search. should be fixed.
|
||||
int i;
|
||||
|
|
|
@ -212,7 +212,7 @@ public:
|
|||
void SendInput();
|
||||
|
||||
// TODO: OPT: do this alot smarter!
|
||||
virtual int *GetInput(int Tick) const;
|
||||
virtual const int *GetInput(int Tick) const;
|
||||
|
||||
const char *LatestVersion() const;
|
||||
void VersionUpdate();
|
||||
|
@ -236,9 +236,9 @@ public:
|
|||
|
||||
// ---
|
||||
|
||||
void *SnapGetItem(int SnapID, int Index, CSnapItem *pItem) const;
|
||||
const void *SnapGetItem(int SnapID, int Index, CSnapItem *pItem) const;
|
||||
void SnapInvalidateItem(int SnapID, int Index);
|
||||
void *SnapFindItem(int SnapID, int Type, int ID) const;
|
||||
const void *SnapFindItem(int SnapID, int Type, int ID) const;
|
||||
int SnapNumItems(int SnapID) const;
|
||||
void *SnapNewItem(int Type, int ID, int Size);
|
||||
void SnapSetStaticsize(int ItemType, int Size);
|
||||
|
|
|
@ -900,7 +900,7 @@ void CGameClient::OnNewSnapshot()
|
|||
for(int Index = 0; Index < Num; Index++)
|
||||
{
|
||||
IClient::CSnapItem Item;
|
||||
void *pData = Client()->SnapGetItem(IClient::SNAP_CURRENT, Index, &Item);
|
||||
const void *pData = Client()->SnapGetItem(IClient::SNAP_CURRENT, Index, &Item);
|
||||
if(m_NetObjHandler.ValidateObj(Item.m_Type, pData, Item.m_DataSize) != 0)
|
||||
{
|
||||
if(g_Config.m_Debug)
|
||||
|
@ -1252,9 +1252,9 @@ void CGameClient::OnPredict()
|
|||
if(m_LocalClientID == c)
|
||||
{
|
||||
// apply player input
|
||||
int *pInput = Client()->GetInput(Tick);
|
||||
const int *pInput = Client()->GetInput(Tick);
|
||||
if(pInput)
|
||||
World.m_apCharacters[c]->m_Input = *((CNetObj_PlayerInput*)pInput);
|
||||
World.m_apCharacters[c]->m_Input = *((const CNetObj_PlayerInput*)pInput);
|
||||
World.m_apCharacters[c]->Tick(true);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue