diff --git a/datasrc/compile.py b/datasrc/compile.py index 5516e83d7..c2cd04d92 100644 --- a/datasrc/compile.py +++ b/datasrc/compile.py @@ -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{'] diff --git a/src/engine/client.h b/src/engine/client.h index 24c678e65..e1418f40d 100644 --- a/src/engine/client.h +++ b/src/engine/client.h @@ -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; diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 7efce55cb..393ad9601 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -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; diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 20d8e439c..ef76164e7 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -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); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 3d36e0d1f..73e48f103 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -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