From 1b2703aaba9ef21b8fca7c12b299fcd0fd4b9251 Mon Sep 17 00:00:00 2001 From: GreYFoXGTi Date: Sat, 12 Feb 2011 12:40:36 +0200 Subject: Refactoring & fixed WEAPONSPEC_GUN in content.py --- src/engine/client.h | 12 +-- src/engine/client/client.cpp | 38 +++---- src/engine/client/client.h | 8 +- src/engine/client/graphics.cpp | 6 +- src/engine/client/sound.cpp | 66 ++++++------ src/engine/client/sound.h | 14 +-- src/engine/client/text.cpp | 32 +++--- src/engine/map.h | 4 +- src/engine/server.h | 4 +- src/engine/server/server.cpp | 226 ++++++++++++++++++++--------------------- src/engine/server/server.h | 20 ++-- src/engine/shared/datafile.cpp | 44 ++++---- src/engine/shared/datafile.h | 8 +- src/engine/shared/map.cpp | 4 +- src/engine/shared/snapshot.cpp | 6 +- src/engine/sound.h | 8 +- 16 files changed, 250 insertions(+), 250 deletions(-) (limited to 'src/engine') diff --git a/src/engine/client.h b/src/engine/client.h index 2da2bd8b..e6bc0f2e 100644 --- a/src/engine/client.h +++ b/src/engine/client.h @@ -32,7 +32,7 @@ public: { public: int m_Type; - int m_Id; + int m_ID; int m_DataSize; }; @@ -108,10 +108,10 @@ public: }; // TODO: Refactor: should redo this a bit i think, too many virtual calls - virtual int SnapNumItems(int SnapId) = 0; - virtual void *SnapFindItem(int SnapId, int Type, int Id) = 0; - virtual void *SnapGetItem(int SnapId, int Index, CSnapItem *pItem) = 0; - virtual void SnapInvalidateItem(int SnapId, int Index) = 0; + virtual int SnapNumItems(int SnapID) = 0; + virtual void *SnapFindItem(int SnapID, int Type, int ID) = 0; + virtual void *SnapGetItem(int SnapID, int Index, CSnapItem *pItem) = 0; + virtual void SnapInvalidateItem(int SnapID, int Index) = 0; virtual void SnapSetStaticsize(int ItemType, int Size) = 0; @@ -149,7 +149,7 @@ public: virtual void OnRender() = 0; virtual void OnStateChange(int NewState, int OldState) = 0; virtual void OnConnected() = 0; - virtual void OnMessage(int MsgId, CUnpacker *pUnpacker) = 0; + virtual void OnMessage(int MsgID, CUnpacker *pUnpacker) = 0; virtual void OnPredict() = 0; virtual void OnActivateEditor() = 0; diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 6b52615e..c0be7bc0 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -771,55 +771,55 @@ int CClient::LoadData() // --- -void *CClient::SnapGetItem(int SnapId, int Index, CSnapItem *pItem) +void *CClient::SnapGetItem(int SnapID, int Index, CSnapItem *pItem) { CSnapshotItem *i; - dbg_assert(SnapId >= 0 && SnapId < NUM_SNAPSHOT_TYPES, "invalid SnapId"); - i = m_aSnapshots[SnapId]->m_pAltSnap->GetItem(Index); - pItem->m_DataSize = m_aSnapshots[SnapId]->m_pAltSnap->GetItemSize(Index); + dbg_assert(SnapID >= 0 && SnapID < NUM_SNAPSHOT_TYPES, "invalid SnapID"); + i = m_aSnapshots[SnapID]->m_pAltSnap->GetItem(Index); + pItem->m_DataSize = m_aSnapshots[SnapID]->m_pAltSnap->GetItemSize(Index); pItem->m_Type = i->Type(); - pItem->m_Id = i->ID(); + pItem->m_ID = i->ID(); return (void *)i->Data(); } -void CClient::SnapInvalidateItem(int SnapId, int Index) +void CClient::SnapInvalidateItem(int SnapID, int Index) { CSnapshotItem *i; - dbg_assert(SnapId >= 0 && SnapId < NUM_SNAPSHOT_TYPES, "invalid SnapId"); - i = m_aSnapshots[SnapId]->m_pAltSnap->GetItem(Index); + dbg_assert(SnapID >= 0 && SnapID < NUM_SNAPSHOT_TYPES, "invalid SnapID"); + i = m_aSnapshots[SnapID]->m_pAltSnap->GetItem(Index); if(i) { - if((char *)i < (char *)m_aSnapshots[SnapId]->m_pAltSnap || (char *)i > (char *)m_aSnapshots[SnapId]->m_pAltSnap + m_aSnapshots[SnapId]->m_SnapSize) + if((char *)i < (char *)m_aSnapshots[SnapID]->m_pAltSnap || (char *)i > (char *)m_aSnapshots[SnapID]->m_pAltSnap + m_aSnapshots[SnapID]->m_SnapSize) m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", "snap invalidate problem"); - if((char *)i >= (char *)m_aSnapshots[SnapId]->m_pSnap && (char *)i < (char *)m_aSnapshots[SnapId]->m_pSnap + m_aSnapshots[SnapId]->m_SnapSize) + if((char *)i >= (char *)m_aSnapshots[SnapID]->m_pSnap && (char *)i < (char *)m_aSnapshots[SnapID]->m_pSnap + m_aSnapshots[SnapID]->m_SnapSize) m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client", "snap invalidate problem"); i->m_TypeAndID = -1; } } -void *CClient::SnapFindItem(int SnapId, int Type, int Id) +void *CClient::SnapFindItem(int SnapID, int Type, int ID) { // TODO: linear search. should be fixed. int i; - if(!m_aSnapshots[SnapId]) + if(!m_aSnapshots[SnapID]) return 0x0; - for(i = 0; i < m_aSnapshots[SnapId]->m_pSnap->NumItems(); i++) + for(i = 0; i < m_aSnapshots[SnapID]->m_pSnap->NumItems(); i++) { - CSnapshotItem *pItem = m_aSnapshots[SnapId]->m_pAltSnap->GetItem(i); - if(pItem->Type() == Type && pItem->ID() == Id) + CSnapshotItem *pItem = m_aSnapshots[SnapID]->m_pAltSnap->GetItem(i); + if(pItem->Type() == Type && pItem->ID() == ID) return (void *)pItem->Data(); } return 0x0; } -int CClient::SnapNumItems(int SnapId) +int CClient::SnapNumItems(int SnapID) { - dbg_assert(SnapId >= 0 && SnapId < NUM_SNAPSHOT_TYPES, "invalid SnapId"); - if(!m_aSnapshots[SnapId]) + dbg_assert(SnapID >= 0 && SnapID < NUM_SNAPSHOT_TYPES, "invalid SnapID"); + if(!m_aSnapshots[SnapID]) return 0; - return m_aSnapshots[SnapId]->m_pSnap->NumItems(); + return m_aSnapshots[SnapID]->m_pSnap->NumItems(); } void CClient::SnapSetStaticsize(int ItemType, int Size) diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 8ba70662..35cbad3b 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -266,10 +266,10 @@ public: // --- - void *SnapGetItem(int SnapId, int Index, CSnapItem *pItem); - void SnapInvalidateItem(int SnapId, int Index); - void *SnapFindItem(int SnapId, int Type, int Id); - int SnapNumItems(int SnapId); + void *SnapGetItem(int SnapID, int Index, CSnapItem *pItem); + void SnapInvalidateItem(int SnapID, int Index); + void *SnapFindItem(int SnapID, int Type, int ID); + int SnapNumItems(int SnapID); void SnapSetStaticsize(int ItemType, int Size); void Render(); diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index 045d15d0..f313e6e3 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -357,7 +357,7 @@ int CGraphics_OpenGL::LoadTextureRaw(int Width, int Height, int Format, const vo int CGraphics_OpenGL::LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags) { int l = str_length(pFilename); - int Id; + int ID; CImageInfo Img; if(l < 3) @@ -367,9 +367,9 @@ int CGraphics_OpenGL::LoadTexture(const char *pFilename, int StorageType, int St if (StoreFormat == CImageInfo::FORMAT_AUTO) StoreFormat = Img.m_Format; - Id = LoadTextureRaw(Img.m_Width, Img.m_Height, Img.m_Format, Img.m_pData, StoreFormat, Flags); + ID = LoadTextureRaw(Img.m_Width, Img.m_Height, Img.m_Format, Img.m_pData, StoreFormat, Flags); mem_free(Img.m_pData); - return Id; + return ID; } return m_InvalidTexture; diff --git a/src/engine/client/sound.cpp b/src/engine/client/sound.cpp index 01012a60..fea79285 100644 --- a/src/engine/client/sound.cpp +++ b/src/engine/client/sound.cpp @@ -253,21 +253,21 @@ int CSound::Shutdown() return 0; } -int CSound::AllocId() +int CSound::AllocID() { // TODO: linear search, get rid of it - for(unsigned SampleId = 0; SampleId < NUM_SAMPLES; SampleId++) + for(unsigned SampleID = 0; SampleID < NUM_SAMPLES; SampleID++) { - if(m_aSamples[SampleId].m_pData == 0x0) - return SampleId; + if(m_aSamples[SampleID].m_pData == 0x0) + return SampleID; } return -1; } -void CSound::RateConvert(int SampleId) +void CSound::RateConvert(int SampleID) { - CSample *pSample = &m_aSamples[SampleId]; + CSample *pSample = &m_aSamples[SampleID]; int NumFrames = 0; short *pNewData = 0; @@ -311,7 +311,7 @@ int CSound::ReadData(void *pBuffer, int Size) int CSound::LoadWV(const char *pFilename) { CSample *pSample; - int SampleId = -1; + int SampleID = -1; char aError[100]; WavpackContext *pContext; @@ -333,10 +333,10 @@ int CSound::LoadWV(const char *pFilename) return -1; } - SampleId = AllocId(); - if(SampleId < 0) + SampleID = AllocID(); + if(SampleID < 0) return -1; - pSample = &m_aSamples[SampleId]; + pSample = &m_aSamples[SampleID]; pContext = WavpackOpenFileInput(ReadData, aError); if (pContext) @@ -399,8 +399,8 @@ int CSound::LoadWV(const char *pFilename) if(g_Config.m_Debug) dbg_msg("sound/wv", "loaded %s", pFilename); - RateConvert(SampleId); - return SampleId; + RateConvert(SampleID); + return SampleID; } void CSound::SetListenerPos(float x, float y) @@ -410,15 +410,15 @@ void CSound::SetListenerPos(float x, float y) } -void CSound::SetChannel(int ChannelId, float Vol, float Pan) +void CSound::SetChannel(int ChannelID, float Vol, float Pan) { - m_aChannels[ChannelId].m_Vol = (int)(Vol*255.0f); - m_aChannels[ChannelId].m_Pan = (int)(Pan*255.0f); // TODO: this is only on and off right now + m_aChannels[ChannelID].m_Vol = (int)(Vol*255.0f); + m_aChannels[ChannelID].m_Pan = (int)(Pan*255.0f); // TODO: this is only on and off right now } -int CSound::Play(int ChannelId, int SampleId, int Flags, float x, float y) +int CSound::Play(int ChannelID, int SampleID, int Flags, float x, float y) { - int VoiceId = -1; + int VoiceID = -1; int i; lock_wait(m_SoundLock); @@ -429,43 +429,43 @@ int CSound::Play(int ChannelId, int SampleId, int Flags, float x, float y) int id = (m_NextVoice + i) % NUM_VOICES; if(!m_aVoices[id].m_pSample) { - VoiceId = id; + VoiceID = id; m_NextVoice = id+1; break; } } // voice found, use it - if(VoiceId != -1) + if(VoiceID != -1) { - m_aVoices[VoiceId].m_pSample = &m_aSamples[SampleId]; - m_aVoices[VoiceId].m_pChannel = &m_aChannels[ChannelId]; - m_aVoices[VoiceId].m_Tick = 0; - m_aVoices[VoiceId].m_Vol = 255; - m_aVoices[VoiceId].m_Flags = Flags; - m_aVoices[VoiceId].m_X = (int)x; - m_aVoices[VoiceId].m_Y = (int)y; + m_aVoices[VoiceID].m_pSample = &m_aSamples[SampleID]; + m_aVoices[VoiceID].m_pChannel = &m_aChannels[ChannelID]; + m_aVoices[VoiceID].m_Tick = 0; + m_aVoices[VoiceID].m_Vol = 255; + m_aVoices[VoiceID].m_Flags = Flags; + m_aVoices[VoiceID].m_X = (int)x; + m_aVoices[VoiceID].m_Y = (int)y; } lock_release(m_SoundLock); - return VoiceId; + return VoiceID; } -int CSound::PlayAt(int ChannelId, int SampleId, int Flags, float x, float y) +int CSound::PlayAt(int ChannelID, int SampleID, int Flags, float x, float y) { - return Play(ChannelId, SampleId, Flags|ISound::FLAG_POS, x, y); + return Play(ChannelID, SampleID, Flags|ISound::FLAG_POS, x, y); } -int CSound::Play(int ChannelId, int SampleId, int Flags) +int CSound::Play(int ChannelID, int SampleID, int Flags) { - return Play(ChannelId, SampleId, Flags, 0, 0); + return Play(ChannelID, SampleID, Flags, 0, 0); } -void CSound::Stop(int VoiceId) +void CSound::Stop(int VoiceID) { // TODO: a nice fade out lock_wait(m_SoundLock); - m_aVoices[VoiceId].m_pSample = 0; + m_aVoices[VoiceID].m_pSample = 0; lock_release(m_SoundLock); } diff --git a/src/engine/client/sound.h b/src/engine/client/sound.h index ac34c2ac..1372b9c4 100644 --- a/src/engine/client/sound.h +++ b/src/engine/client/sound.h @@ -18,9 +18,9 @@ public: int Update(); int Shutdown(); - int AllocId(); + int AllocID(); - static void RateConvert(int SampleId); + static void RateConvert(int SampleID); // TODO: Refactor: clean this mess up static IOHANDLE ms_File; @@ -29,12 +29,12 @@ public: virtual int LoadWV(const char *pFilename); virtual void SetListenerPos(float x, float y); - virtual void SetChannel(int ChannelId, float Vol, float Pan); + virtual void SetChannel(int ChannelID, float Vol, float Pan); - int Play(int ChannelId, int SampleId, int Flags, float x, float y); - virtual int PlayAt(int ChannelId, int SampleId, int Flags, float x, float y); - virtual int Play(int ChannelId, int SampleId, int Flags); - virtual void Stop(int VoiceId); + int Play(int ChannelID, int SampleID, int Flags, float x, float y); + virtual int PlayAt(int ChannelID, int SampleID, int Flags, float x, float y); + virtual int Play(int ChannelID, int SampleID, int Flags); + virtual void Stop(int VoiceID); virtual void StopAll(); }; diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp index e3509143..df28283d 100644 --- a/src/engine/client/text.cpp +++ b/src/engine/client/text.cpp @@ -35,7 +35,7 @@ static int aFontSizes[] = {8,9,10,11,12,13,14,15,16,17,18,19,20,36,64}; struct CFontChar { - int m_Id; + int m_ID; // these values are scaled to the pFont size // width * font_size == real_size @@ -244,10 +244,10 @@ class CTextRender : public IEngineTextRender } - void UploadGlyph(CFontSizeData *pSizeData, int Texnum, int SlotId, int Chr, const void *pData) + void UploadGlyph(CFontSizeData *pSizeData, int Texnum, int SlotID, int Chr, const void *pData) { - int x = (SlotId%pSizeData->m_NumXChars) * (pSizeData->m_TextureWidth/pSizeData->m_NumXChars); - int y = (SlotId/pSizeData->m_NumXChars) * (pSizeData->m_TextureHeight/pSizeData->m_NumYChars); + int x = (SlotID%pSizeData->m_NumXChars) * (pSizeData->m_TextureWidth/pSizeData->m_NumXChars); + int y = (SlotID/pSizeData->m_NumXChars) * (pSizeData->m_TextureHeight/pSizeData->m_NumYChars); glBindTexture(GL_TEXTURE_2D, pSizeData->m_aTextures[Texnum]); glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, @@ -293,7 +293,7 @@ class CTextRender : public IEngineTextRender int RenderGlyph(CFont *pFont, CFontSizeData *pSizeData, int Chr) { FT_Bitmap *pBitmap; - int SlotId = 0; + int SlotID = 0; int SlotW = pSizeData->m_TextureWidth / pSizeData->m_NumXChars; int SlotH = pSizeData->m_TextureHeight / pSizeData->m_NumYChars; int SlotSize = SlotW*SlotH; @@ -312,8 +312,8 @@ class CTextRender : public IEngineTextRender pBitmap = &pFont->m_FtFace->glyph->bitmap; // ignore_convention // fetch slot - SlotId = GetSlot(pSizeData); - if(SlotId < 0) + SlotID = GetSlot(pSizeData); + if(SlotID < 0) return -1; // adjust spacing @@ -345,12 +345,12 @@ class CTextRender : public IEngineTextRender ms_aGlyphData[py*SlotW+px] = 255; // upload the glyph - UploadGlyph(pSizeData, 0, SlotId, Chr, ms_aGlyphData); + UploadGlyph(pSizeData, 0, SlotID, Chr, ms_aGlyphData); if(OutlineThickness == 1) { Grow(ms_aGlyphData, ms_aGlyphDataOutlined, SlotW, SlotH); - UploadGlyph(pSizeData, 1, SlotId, Chr, ms_aGlyphDataOutlined); + UploadGlyph(pSizeData, 1, SlotID, Chr, ms_aGlyphDataOutlined); } else { @@ -359,32 +359,32 @@ class CTextRender : public IEngineTextRender Grow(ms_aGlyphData, ms_aGlyphDataOutlined, SlotW, SlotH); Grow(ms_aGlyphDataOutlined, ms_aGlyphData, SlotW, SlotH); } - UploadGlyph(pSizeData, 1, SlotId, Chr, ms_aGlyphData); + UploadGlyph(pSizeData, 1, SlotID, Chr, ms_aGlyphData); } // set char info { - CFontChar *pFontchr = &pSizeData->m_aCharacters[SlotId]; + CFontChar *pFontchr = &pSizeData->m_aCharacters[SlotID]; float Scale = 1.0f/pSizeData->m_FontSize; float Uscale = 1.0f/pSizeData->m_TextureWidth; float Vscale = 1.0f/pSizeData->m_TextureHeight; int Height = pBitmap->rows + OutlineThickness*2 + 2; // ignore_convention int Width = pBitmap->width + OutlineThickness*2 + 2; // ignore_convention - pFontchr->m_Id = Chr; + pFontchr->m_ID = Chr; pFontchr->m_Height = Height * Scale; pFontchr->m_Width = Width * Scale; pFontchr->m_OffsetX = (pFont->m_FtFace->glyph->bitmap_left-1) * Scale; // ignore_convention pFontchr->m_OffsetY = (pSizeData->m_FontSize - pFont->m_FtFace->glyph->bitmap_top) * Scale; // ignore_convention pFontchr->m_AdvanceX = (pFont->m_FtFace->glyph->advance.x>>6) * Scale; // ignore_convention - pFontchr->m_aUvs[0] = (SlotId%pSizeData->m_NumXChars) / (float)(pSizeData->m_NumXChars); - pFontchr->m_aUvs[1] = (SlotId/pSizeData->m_NumXChars) / (float)(pSizeData->m_NumYChars); + pFontchr->m_aUvs[0] = (SlotID%pSizeData->m_NumXChars) / (float)(pSizeData->m_NumXChars); + pFontchr->m_aUvs[1] = (SlotID/pSizeData->m_NumXChars) / (float)(pSizeData->m_NumYChars); pFontchr->m_aUvs[2] = pFontchr->m_aUvs[0] + Width*Uscale; pFontchr->m_aUvs[3] = pFontchr->m_aUvs[1] + Height*Vscale; } - return SlotId; + return SlotID; } CFontChar *GetChar(CFont *pFont, CFontSizeData *pSizeData, int Chr) @@ -396,7 +396,7 @@ class CTextRender : public IEngineTextRender int i; for(i = 0; i < pSizeData->m_CurrentCharacter; i++) { - if(pSizeData->m_aCharacters[i].m_Id == Chr) + if(pSizeData->m_aCharacters[i].m_ID == Chr) { pFontchr = &pSizeData->m_aCharacters[i]; break; diff --git a/src/engine/map.h b/src/engine/map.h index eaa8432b..d55c4912 100644 --- a/src/engine/map.h +++ b/src/engine/map.h @@ -12,9 +12,9 @@ public: virtual void *GetData(int Index) = 0; virtual void *GetDataSwapped(int Index) = 0; virtual void UnloadData(int Index) = 0; - virtual void *GetItem(int Index, int *Type, int *pId) = 0; + virtual void *GetItem(int Index, int *Type, int *pID) = 0; virtual void GetType(int Type, int *pStart, int *pNum) = 0; - virtual void *FindItem(int Type, int Id) = 0; + virtual void *FindItem(int Type, int ID) = 0; virtual int NumItems() = 0; }; diff --git a/src/engine/server.h b/src/engine/server.h index fdfcb7a7..eb980d17 100644 --- a/src/engine/server.h +++ b/src/engine/server.h @@ -48,7 +48,7 @@ public: virtual int SnapNewID() = 0; virtual void SnapFreeID(int ID) = 0; - virtual void *SnapNewItem(int Type, int Id, int Size) = 0; + virtual void *SnapNewItem(int Type, int ID, int Size) = 0; virtual void SnapSetStaticsize(int ItemType, int Size) = 0; @@ -70,7 +70,7 @@ public: virtual void OnSnap(int ClientID) = 0; virtual void OnPostSnap() = 0; - virtual void OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientID) = 0; + virtual void OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) = 0; virtual void OnClientConnected(int ClientID) = 0; virtual void OnClientEnter(int ClientID) = 0; diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 95cb06bd..30cdf259 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -113,15 +113,15 @@ int CSnapIDPool::NewID() while(m_FirstTimed != -1 && m_aIDs[m_FirstTimed].m_Timeout < Now) RemoveFirstTimeout(); - int Id = m_FirstFree; - dbg_assert(Id != -1, "id error"); - if(Id == -1) - return Id; + int ID = m_FirstFree; + dbg_assert(ID != -1, "id error"); + if(ID == -1) + return ID; m_FirstFree = m_aIDs[m_FirstFree].m_Next; - m_aIDs[Id].m_State = 1; + m_aIDs[ID].m_State = 1; m_Usage++; m_InUsage++; - return Id; + return ID; } void CSnapIDPool::TimeoutIDs() @@ -131,26 +131,26 @@ void CSnapIDPool::TimeoutIDs() RemoveFirstTimeout(); } -void CSnapIDPool::FreeID(int Id) +void CSnapIDPool::FreeID(int ID) { - if(Id < 0) + if(ID < 0) return; - dbg_assert(m_aIDs[Id].m_State == 1, "id is not alloced"); + dbg_assert(m_aIDs[ID].m_State == 1, "id is not alloced"); m_InUsage--; - m_aIDs[Id].m_State = 2; - m_aIDs[Id].m_Timeout = time_get()+time_freq()*5; - m_aIDs[Id].m_Next = -1; + m_aIDs[ID].m_State = 2; + m_aIDs[ID].m_Timeout = time_get()+time_freq()*5; + m_aIDs[ID].m_Next = -1; if(m_LastTimed != -1) { - m_aIDs[m_LastTimed].m_Next = Id; - m_LastTimed = Id; + m_aIDs[m_LastTimed].m_Next = ID; + m_LastTimed = ID; } else { - m_FirstTimed = Id; - m_LastTimed = Id; + m_FirstTimed = ID; + m_LastTimed = ID; } } @@ -186,7 +186,7 @@ CServer::CServer() : m_DemoRecorder(&m_SnapshotDelta) m_MapReload = 0; - m_RconClientId = -1; + m_RconClientID = -1; Init(); } @@ -270,7 +270,7 @@ void CServer::Kick(int ClientID, const char *pReason) Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "invalid client id to kick"); return; } - else if(m_RconClientId == ClientID) + else if(m_RconClientID == ClientID) { Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "you can't kick yourself"); return; @@ -338,20 +338,20 @@ void CServer::GetClientIP(int ClientID, char *pIPString, int Size) } -int *CServer::LatestInput(int ClientId, int *size) +int *CServer::LatestInput(int ClientID, int *size) { - if(ClientId < 0 || ClientId >= MAX_CLIENTS || m_aClients[ClientId].m_State < CServer::CClient::STATE_READY) + if(ClientID < 0 || ClientID >= MAX_CLIENTS || m_aClients[ClientID].m_State < CServer::CClient::STATE_READY) return 0; - return m_aClients[ClientId].m_LatestInput.m_aData; + return m_aClients[ClientID].m_LatestInput.m_aData; } -const char *CServer::ClientName(int ClientId) +const char *CServer::ClientName(int ClientID) { - if(ClientId < 0 || ClientId >= MAX_CLIENTS || m_aClients[ClientId].m_State == CServer::CClient::STATE_EMPTY) + if(ClientID < 0 || ClientID >= MAX_CLIENTS || m_aClients[ClientID].m_State == CServer::CClient::STATE_EMPTY) return "(invalid client)"; - else if(m_aClients[ClientId].m_State < CServer::CClient::STATE_READY) + else if(m_aClients[ClientID].m_State < CServer::CClient::STATE_READY) return "(connecting client)"; - return m_aClients[ClientId].m_aName; + return m_aClients[ClientID].m_aName; } bool CServer::ClientIngame(int ClientID) @@ -359,9 +359,9 @@ bool CServer::ClientIngame(int ClientID) return ClientID >= 0 && ClientID < MAX_CLIENTS && m_aClients[ClientID].m_State == CServer::CClient::STATE_INGAME; } -int CServer::SendMsg(CMsgPacker *pMsg, int Flags, int ClientId) +int CServer::SendMsg(CMsgPacker *pMsg, int Flags, int ClientID) { - return SendMsgEx(pMsg, Flags, ClientId, false); + return SendMsgEx(pMsg, Flags, ClientID, false); } int CServer::SendMsgEx(CMsgPacker *pMsg, int Flags, int ClientID, bool System) @@ -542,57 +542,57 @@ void CServer::DoSnapshot() } -int CServer::NewClientCallback(int ClientId, void *pUser) +int CServer::NewClientCallback(int ClientID, void *pUser) { CServer *pThis = (CServer *)pUser; - pThis->m_aClients[ClientId].m_State = CClient::STATE_AUTH; - pThis->m_aClients[ClientId].m_aName[0] = 0; - pThis->m_aClients[ClientId].m_aClan[0] = 0; - pThis->m_aClients[ClientId].m_Authed = 0; - pThis->m_aClients[ClientId].m_AuthTries = 0; - pThis->m_aClients[ClientId].Reset(); + pThis->m_aClients[ClientID].m_State = CClient::STATE_AUTH; + pThis->m_aClients[ClientID].m_aName[0] = 0; + pThis->m_aClients[ClientID].m_aClan[0] = 0; + pThis->m_aClients[ClientID].m_Authed = 0; + pThis->m_aClients[ClientID].m_AuthTries = 0; + pThis->m_aClients[ClientID].Reset(); return 0; } -int CServer::DelClientCallback(int ClientId, const char *pReason, void *pUser) +int CServer::DelClientCallback(int ClientID, const char *pReason, void *pUser) { CServer *pThis = (CServer *)pUser; - NETADDR Addr = pThis->m_NetServer.ClientAddr(ClientId); + NETADDR Addr = pThis->m_NetServer.ClientAddr(ClientID); char aBuf[256]; str_format(aBuf, sizeof(aBuf), "client dropped. cid=%d ip=%d.%d.%d.%d reason=\"%s\"", - ClientId, + ClientID, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], pReason ); pThis->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf); // notify the mod about the drop - if(pThis->m_aClients[ClientId].m_State >= CClient::STATE_READY) - pThis->GameServer()->OnClientDrop(ClientId); + if(pThis->m_aClients[ClientID].m_State >= CClient::STATE_READY) + pThis->GameServer()->OnClientDrop(ClientID); - pThis->m_aClients[ClientId].m_State = CClient::STATE_EMPTY; - pThis->m_aClients[ClientId].m_aName[0] = 0; - pThis->m_aClients[ClientId].m_aClan[0] = 0; - pThis->m_aClients[ClientId].m_Authed = 0; - pThis->m_aClients[ClientId].m_AuthTries = 0; - pThis->m_aClients[ClientId].m_Snapshots.PurgeAll(); + pThis->m_aClients[ClientID].m_State = CClient::STATE_EMPTY; + pThis->m_aClients[ClientID].m_aName[0] = 0; + pThis->m_aClients[ClientID].m_aClan[0] = 0; + pThis->m_aClients[ClientID].m_Authed = 0; + pThis->m_aClients[ClientID].m_AuthTries = 0; + pThis->m_aClients[ClientID].m_Snapshots.PurgeAll(); return 0; } -void CServer::SendMap(int ClientId) +void CServer::SendMap(int ClientID) { CMsgPacker Msg(NETMSG_MAP_CHANGE); Msg.AddString(GetMapName(), 0); Msg.AddInt(m_CurrentMapCrc); - SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientId, true); + SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID, true); } -void CServer::SendRconLine(int ClientId, const char *pLine) +void CServer::SendRconLine(int ClientID, const char *pLine) { CMsgPacker Msg(NETMSG_RCON_LINE); Msg.AddString(pLine, 512); - SendMsgEx(&Msg, MSGFLAG_VITAL, ClientId, true); + SendMsgEx(&Msg, MSGFLAG_VITAL, ClientID, true); } void CServer::SendRconLineAuthed(const char *pLine, void *pUser) @@ -615,7 +615,7 @@ void CServer::SendRconLineAuthed(const char *pLine, void *pUser) void CServer::ProcessClientPacket(CNetChunk *pPacket) { - int ClientId = pPacket->m_ClientID; + int ClientID = pPacket->m_ClientID; NETADDR Addr; CUnpacker Unpacker; Unpacker.Reset(pPacket->m_pData, pPacket->m_DataSize); @@ -628,7 +628,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) if(Unpacker.Error()) return; - if(m_aClients[ClientId].m_State == CClient::STATE_AUTH) + if(m_aClients[ClientID].m_State == CClient::STATE_AUTH) { if(Sys && Msg == NETMSG_INFO) { @@ -640,23 +640,23 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) // OH FUCK! wrong version, drop him char aReason[256]; str_format(aReason, sizeof(aReason), "Wrong version. Server is running '%s' and client '%s'", GameServer()->NetVersion(), aVersion); - m_NetServer.Drop(ClientId, aReason); + m_NetServer.Drop(ClientID, aReason); return; } - str_copy(m_aClients[ClientId].m_aName, Unpacker.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES), MAX_NAME_LENGTH); - str_copy(m_aClients[ClientId].m_aClan, Unpacker.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES), MAX_CLANNAME_LENGTH); + str_copy(m_aClients[ClientID].m_aName, Unpacker.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES), MAX_NAME_LENGTH); + str_copy(m_aClients[ClientID].m_aClan, Unpacker.GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES), MAX_CLANNAME_LENGTH); pPassword = Unpacker.GetString(CUnpacker::SANITIZE_CC); if(g_Config.m_Password[0] != 0 && str_comp(g_Config.m_Password, pPassword) != 0) { // wrong password - m_NetServer.Drop(ClientId, "Wrong password"); + m_NetServer.Drop(ClientID, "Wrong password"); return; } - m_aClients[ClientId].m_State = CClient::STATE_CONNECTING; - SendMap(ClientId); + m_aClients[ClientID].m_State = CClient::STATE_CONNECTING; + SendMap(ClientID); } } else @@ -688,7 +688,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) Msg.AddInt(m_CurrentMapSize); Msg.AddInt(ChunkSize); Msg.AddRaw(&m_pCurrentMapData[Offset], ChunkSize); - SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientId, true); + SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID, true); if(g_Config.m_Debug) { @@ -699,30 +699,30 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) } else if(Msg == NETMSG_READY) { - if(m_aClients[ClientId].m_State == CClient::STATE_CONNECTING) + if(m_aClients[ClientID].m_State == CClient::STATE_CONNECTING) { - Addr = m_NetServer.ClientAddr(ClientId); + Addr = m_NetServer.ClientAddr(ClientID); char aBuf[256]; - str_format(aBuf, sizeof(aBuf), "player is ready. ClientId=%x ip=%d.%d.%d.%d", - ClientId, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3]); + str_format(aBuf, sizeof(aBuf), "player is ready. ClientID=%x ip=%d.%d.%d.%d", + ClientID, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3]); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf); - m_aClients[ClientId].m_State = CClient::STATE_READY; - GameServer()->OnClientConnected(ClientId); + m_aClients[ClientID].m_State = CClient::STATE_READY; + GameServer()->OnClientConnected(ClientID); } } else if(Msg == NETMSG_ENTERGAME) { - if(m_aClients[ClientId].m_State == CClient::STATE_READY) + if(m_aClients[ClientID].m_State == CClient::STATE_READY) { - Addr = m_NetServer.ClientAddr(ClientId); + Addr = m_NetServer.ClientAddr(ClientID); char aBuf[256]; - str_format(aBuf, sizeof(aBuf), "player has entered the game. ClientId=%x ip=%d.%d.%d.%d", - ClientId, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3]); + str_format(aBuf, sizeof(aBuf), "player has entered the game. ClientID=%x ip=%d.%d.%d.%d", + ClientID, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3]); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); - m_aClients[ClientId].m_State = CClient::STATE_INGAME; - GameServer()->OnClientEnter(ClientId); + m_aClients[ClientID].m_State = CClient::STATE_INGAME; + GameServer()->OnClientEnter(ClientID); } } else if(Msg == NETMSG_INPUT) @@ -730,7 +730,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) CClient::CInput *pInput; int64 TagTime; - m_aClients[ClientId].m_LastAckedSnapshot = Unpacker.GetInt(); + m_aClients[ClientID].m_LastAckedSnapshot = Unpacker.GetInt(); int IntendedTick = Unpacker.GetInt(); int Size = Unpacker.GetInt(); @@ -738,27 +738,27 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) if(Unpacker.Error() || Size/4 > MAX_INPUT_SIZE) return; - if(m_aClients[ClientId].m_LastAckedSnapshot > 0) - m_aClients[ClientId].m_SnapRate = CClient::SNAPRATE_FULL; + if(m_aClients[ClientID].m_LastAckedSnapshot > 0) + m_aClients[ClientID].m_SnapRate = CClient::SNAPRATE_FULL; - if(m_aClients[ClientId].m_Snapshots.Get(m_aClients[ClientId].m_LastAckedSnapshot, &TagTime, 0, 0) >= 0) - m_aClients[ClientId].m_Latency = (int)(((time_get()-TagTime)*1000)/time_freq()); + if(m_aClients[ClientID].m_Snapshots.Get(m_aClients[ClientID].m_LastAckedSnapshot, &TagTime, 0, 0) >= 0) + m_aClients[ClientID].m_Latency = (int)(((time_get()-TagTime)*1000)/time_freq()); // add message to report the input timing // skip packets that are old - if(IntendedTick > m_aClients[ClientId].m_LastInputTick) + if(IntendedTick > m_aClients[ClientID].m_LastInputTick) { int TimeLeft = ((TickStartTime(IntendedTick)-time_get())*1000) / time_freq(); CMsgPacker Msg(NETMSG_INPUTTIMING); Msg.AddInt(IntendedTick); Msg.AddInt(TimeLeft); - SendMsgEx(&Msg, 0, ClientId, true); + SendMsgEx(&Msg, 0, ClientID, true); } - m_aClients[ClientId].m_LastInputTick = IntendedTick; + m_aClients[ClientID].m_LastInputTick = IntendedTick; - pInput = &m_aClients[ClientId].m_aInputs[m_aClients[ClientId].m_CurrentInput]; + pInput = &m_aClients[ClientID].m_aInputs[m_aClients[ClientID].m_CurrentInput]; if(IntendedTick <= Tick()) IntendedTick = Tick()+1; @@ -768,27 +768,27 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) for(int i = 0; i < Size/4; i++) pInput->m_aData[i] = Unpacker.GetInt(); - mem_copy(m_aClients[ClientId].m_LatestInput.m_aData, pInput->m_aData, MAX_INPUT_SIZE*sizeof(int)); + mem_copy(m_aClients[ClientID].m_LatestInput.m_aData, pInput->m_aData, MAX_INPUT_SIZE*sizeof(int)); - m_aClients[ClientId].m_CurrentInput++; - m_aClients[ClientId].m_CurrentInput %= 200; + m_aClients[ClientID].m_CurrentInput++; + m_aClients[ClientID].m_CurrentInput %= 200; // call the mod with the fresh input data - if(m_aClients[ClientId].m_State == CClient::STATE_INGAME) - GameServer()->OnClientDirectInput(ClientId, m_aClients[ClientId].m_LatestInput.m_aData); + if(m_aClients[ClientID].m_State == CClient::STATE_INGAME) + GameServer()->OnClientDirectInput(ClientID, m_aClients[ClientID].m_LatestInput.m_aData); } else if(Msg == NETMSG_RCON_CMD) { const char *pCmd = Unpacker.GetString(); - if(Unpacker.Error() == 0 && m_aClients[ClientId].m_Authed) + if(Unpacker.Error() == 0 && m_aClients[ClientID].m_Authed) { char aBuf[256]; - str_format(aBuf, sizeof(aBuf), "ClientId=%d rcon='%s'", ClientId, pCmd); + str_format(aBuf, sizeof(aBuf), "ClientID=%d rcon='%s'", ClientID, pCmd); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf); - m_RconClientId = ClientId; + m_RconClientID = ClientID; Console()->ExecuteLine(pCmd); - m_RconClientId = -1; + m_RconClientID = -1; } } else if(Msg == NETMSG_RCON_AUTH) @@ -801,47 +801,47 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) { if(g_Config.m_SvRconPassword[0] == 0) { - SendRconLine(ClientId, "No rcon password set on server. Set sv_rcon_password to enable the remote console."); + SendRconLine(ClientID, "No rcon password set on server. Set sv_rcon_password to enable the remote console."); } else if(str_comp(pPw, g_Config.m_SvRconPassword) == 0) { CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS); Msg.AddInt(1); - SendMsgEx(&Msg, MSGFLAG_VITAL, ClientId, true); + SendMsgEx(&Msg, MSGFLAG_VITAL, ClientID, true); - m_aClients[ClientId].m_Authed = 1; - SendRconLine(ClientId, "Authentication successful. Remote console access granted."); + m_aClients[ClientID].m_Authed = 1; + SendRconLine(ClientID, "Authentication successful. Remote console access granted."); char aBuf[256]; - str_format(aBuf, sizeof(aBuf), "ClientId=%d authed", ClientId); + str_format(aBuf, sizeof(aBuf), "ClientID=%d authed", ClientID); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); } else if(g_Config.m_SvRconMaxTries) { - m_aClients[ClientId].m_AuthTries++; + m_aClients[ClientID].m_AuthTries++; char aBuf[128]; - str_format(aBuf, sizeof(aBuf), "Wrong password %d/%d.", m_aClients[ClientId].m_AuthTries, g_Config.m_SvRconMaxTries); - SendRconLine(ClientId, aBuf); - if(m_aClients[ClientId].m_AuthTries >= g_Config.m_SvRconMaxTries) + str_format(aBuf, sizeof(aBuf), "Wrong password %d/%d.", m_aClients[ClientID].m_AuthTries, g_Config.m_SvRconMaxTries); + SendRconLine(ClientID, aBuf); + if(m_aClients[ClientID].m_AuthTries >= g_Config.m_SvRconMaxTries) { if(!g_Config.m_SvRconBantime) - m_NetServer.Drop(ClientId, "Too many remote console authentication tries"); + m_NetServer.Drop(ClientID, "Too many remote console authentication tries"); else { - NETADDR Addr = m_NetServer.ClientAddr(ClientId); + NETADDR Addr = m_NetServer.ClientAddr(ClientID); BanAdd(Addr, g_Config.m_SvRconBantime*60, "Too many remote console authentication tries"); } } } else { - SendRconLine(ClientId, "Wrong password."); + SendRconLine(ClientID, "Wrong password."); } } } else if(Msg == NETMSG_PING) { CMsgPacker Msg(NETMSG_PING_REPLY); - SendMsgEx(&Msg, 0, ClientId, true); + SendMsgEx(&Msg, 0, ClientID, true); } else { @@ -859,7 +859,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) } char aBufMsg[256]; - str_format(aBufMsg, sizeof(aBufMsg), "strange message ClientId=%d msg=%d data_size=%d", ClientId, Msg, pPacket->m_DataSize); + str_format(aBufMsg, sizeof(aBufMsg), "strange message ClientID=%d msg=%d data_size=%d", ClientID, Msg, pPacket->m_DataSize); Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBufMsg); Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "server", aBuf); } @@ -868,8 +868,8 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) else { // game message - if(m_aClients[ClientId].m_State >= CClient::STATE_READY) - GameServer()->OnMessage(Msg, &Unpacker, ClientId); + if(m_aClients[ClientID].m_State >= CClient::STATE_READY) + GameServer()->OnMessage(Msg, &Unpacker, ClientID); } } } @@ -1286,9 +1286,9 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser) if(net_addr_from_str(&Addr, pStr) == 0) { - if(pServer->m_RconClientId >= 0 && pServer->m_RconClientId < MAX_CLIENTS && pServer->m_aClients[pServer->m_RconClientId].m_State != CClient::STATE_EMPTY) + if(pServer->m_RconClientID >= 0 && pServer->m_RconClientID < MAX_CLIENTS && pServer->m_aClients[pServer->m_RconClientID].m_State != CClient::STATE_EMPTY) { - NETADDR AddrCheck = pServer->m_NetServer.ClientAddr(pServer->m_RconClientId); + NETADDR AddrCheck = pServer->m_NetServer.ClientAddr(pServer->m_RconClientID); Addr.port = AddrCheck.port = 0; if(net_addr_comp(&Addr, &AddrCheck) == 0) { @@ -1300,20 +1300,20 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser) } else if(StrAllnum(pStr)) { - int ClientId = str_toint(pStr); + int ClientID = str_toint(pStr); - if(ClientId < 0 || ClientId >= MAX_CLIENTS || pServer->m_aClients[ClientId].m_State == CClient::STATE_EMPTY) + if(ClientID < 0 || ClientID >= MAX_CLIENTS || pServer->m_aClients[ClientID].m_State == CClient::STATE_EMPTY) { pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "invalid client id"); return; } - else if(pServer->m_RconClientId == ClientId) + else if(pServer->m_RconClientID == ClientID) { pServer->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "you can't ban yourself"); return; } - Addr = pServer->m_NetServer.ClientAddr(ClientId); + Addr = pServer->m_NetServer.ClientAddr(ClientID); pServer->BanAdd(Addr, Minutes*60, pReason); } else @@ -1483,11 +1483,11 @@ void CServer::SnapFreeID(int ID) } -void *CServer::SnapNewItem(int Type, int Id, int Size) +void *CServer::SnapNewItem(int Type, int ID, int Size) { dbg_assert(Type >= 0 && Type <=0xffff, "incorrect type"); - dbg_assert(Id >= 0 && Id <=0xffff, "incorrect id"); - return Id < 0 ? 0 : m_SnapshotBuilder.NewItem(Type, Id, Size); + dbg_assert(ID >= 0 && ID <=0xffff, "incorrect id"); + return ID < 0 ? 0 : m_SnapshotBuilder.NewItem(Type, ID, Size); } void CServer::SnapSetStaticsize(int ItemType, int Size) diff --git a/src/engine/server/server.h b/src/engine/server/server.h index db12006a..f3726eba 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -36,7 +36,7 @@ public: void RemoveFirstTimeout(); int NewID(); void TimeoutIDs(); - void FreeID(int Id); + void FreeID(int ID); }; class CServer : public IServer @@ -109,7 +109,7 @@ public: //int m_CurrentGameTick; int m_RunServer; int m_MapReload; - int m_RconClientId; + int m_RconClientID; char m_aBrowseinfoGametype[16]; int m_BrowseinfoProgression; @@ -145,21 +145,21 @@ public: bool IsAuthed(int ClientID); int GetClientInfo(int ClientID, CClientInfo *pInfo); void GetClientIP(int ClientID, char *pIPString, int Size); - const char *ClientName(int ClientId); + const char *ClientName(int ClientID); bool ClientIngame(int ClientID); - int *LatestInput(int ClientId, int *size); + int *LatestInput(int ClientID, int *size); - virtual int SendMsg(CMsgPacker *pMsg, int Flags, int ClientId); + virtual int SendMsg(CMsgPacker *pMsg, int Flags, int ClientID); int SendMsgEx(CMsgPacker *pMsg, int Flags, int ClientID, bool System); void DoSnapshot(); - static int NewClientCallback(int ClientId, void *pUser); - static int DelClientCallback(int ClientId, const char *pReason, void *pUser); + static int NewClientCallback(int ClientID, void *pUser); + static int DelClientCallback(int ClientID, const char *pReason, void *pUser); - void SendMap(int ClientId); - void SendRconLine(int ClientId, const char *pLine); + void SendMap(int ClientID); + void SendRconLine(int ClientID, const char *pLine); static void SendRconLineAuthed(const char *pLine, void *pUser); void ProcessClientPacket(CNetChunk *pPacket); @@ -197,7 +197,7 @@ public: virtual int SnapNewID(); virtual void SnapFreeID(int ID); - virtual void *SnapNewItem(int Type, int Id, int Size); + virtual void *SnapNewItem(int Type, int ID, int Size); void SnapSetStaticsize(int ItemType, int Size); }; diff --git a/src/engine/shared/datafile.cpp b/src/engine/shared/datafile.cpp index ea8902a6..a24ea765 100644 --- a/src/engine/shared/datafile.cpp +++ b/src/engine/shared/datafile.cpp @@ -18,13 +18,13 @@ struct CDatafileItemType struct CDatafileItem { - int m_TypeAndId; + int m_TypeAndID; int m_Size; }; struct CDatafileHeader { - char m_aId[4]; + char m_aID[4]; int m_Version; int m_Size; int m_Swaplen; @@ -104,11 +104,11 @@ bool CDataFileReader::Open(class IStorage *pStorage, const char *pFilename, int // TODO: change this header CDatafileHeader Header; io_read(File, &Header, sizeof(Header)); - if(Header.m_aId[0] != 'A' || Header.m_aId[1] != 'T' || Header.m_aId[2] != 'A' || Header.m_aId[3] != 'D') + if(Header.m_aID[0] != 'A' || Header.m_aID[1] != 'T' || Header.m_aID[2] != 'A' || Header.m_aID[3] != 'D') { - if(Header.m_aId[0] != 'D' || Header.m_aId[1] != 'A' || Header.m_aId[2] != 'T' || Header.m_aId[3] != 'A') + if(Header.m_aID[0] != 'D' || Header.m_aID[1] != 'A' || Header.m_aID[2] != 'T' || Header.m_aID[3] != 'A') { - dbg_msg("datafile", "wrong signature. %x %x %x %x", Header.m_aId[0], Header.m_aId[1], Header.m_aId[2], Header.m_aId[3]); + dbg_msg("datafile", "wrong signature. %x %x %x %x", Header.m_aID[0], Header.m_aID[1], Header.m_aID[2], Header.m_aID[3]); return 0; } } @@ -318,15 +318,15 @@ int CDataFileReader::GetItemSize(int Index) return m_pDataFile->m_Info.m_pItemOffsets[Index+1]-m_pDataFile->m_Info.m_pItemOffsets[Index]; } -void *CDataFileReader::GetItem(int Index, int *pType, int *pId) +void *CDataFileReader::GetItem(int Index, int *pType, int *pID) { - if(!m_pDataFile) { if(pType) *pType = 0; if(pId) *pId = 0; return 0; } + if(!m_pDataFile) { if(pType) *pType = 0; if(pID) *pID = 0; return 0; } CDatafileItem *i = (CDatafileItem *)(m_pDataFile->m_Info.m_pItemStart+m_pDataFile->m_Info.m_pItemOffsets[Index]); if(pType) - *pType = (i->m_TypeAndId>>16)&0xffff; // remove sign extention - if(pId) - *pId = i->m_TypeAndId&0xffff; + *pType = (i->m_TypeAndID>>16)&0xffff; // remove sign extention + if(pID) + *pID = i->m_TypeAndID&0xffff; return (void *)(i+1); } @@ -349,7 +349,7 @@ void CDataFileReader::GetType(int Type, int *pStart, int *pNum) } } -void *CDataFileReader::FindItem(int Type, int Id) +void *CDataFileReader::FindItem(int Type, int ID) { if(!m_pDataFile) return 0; @@ -357,9 +357,9 @@ void *CDataFileReader::FindItem(int Type, int Id) GetType(Type, &Start, &Num); for(int i = 0; i < Num; i++) { - int ItemId; - void *pItem = GetItem(Start+i,0, &ItemId); - if(Id == ItemId) + int ItemID; + void *pItem = GetItem(Start+i,0, &ItemID); + if(ID == ItemID) return pItem; } return 0; @@ -414,7 +414,7 @@ bool CDataFileWriter::Open(class IStorage *pStorage, const char *pFilename) return true; } -int CDataFileWriter::AddItem(int Type, int Id, int Size, void *pData) +int CDataFileWriter::AddItem(int Type, int ID, int Size, void *pData) { if(!m_File) return 0; @@ -423,7 +423,7 @@ int CDataFileWriter::AddItem(int Type, int Id, int Size, void *pData) dbg_assert(Size%sizeof(int) == 0, "incorrect boundary"); m_aItems[m_NumItems].m_Type = Type; - m_aItems[m_NumItems].m_Id = Id; + m_aItems[m_NumItems].m_ID = ID; m_aItems[m_NumItems].m_Size = Size; // copy data @@ -533,10 +533,10 @@ int CDataFileWriter::Finish() // construct Header { - Header.m_aId[0] = 'D'; - Header.m_aId[1] = 'A'; - Header.m_aId[2] = 'T'; - Header.m_aId[3] = 'A'; + Header.m_aID[0] = 'D'; + Header.m_aID[1] = 'A'; + Header.m_aID[2] = 'T'; + Header.m_aID[3] = 'A'; Header.m_Version = 4; Header.m_Size = FileSize - 16; Header.m_Swaplen = SwapSize - 16; @@ -634,10 +634,10 @@ int CDataFileWriter::Finish() while(k != -1) { CDatafileItem Item; - Item.m_TypeAndId = (i<<16)|m_aItems[k].m_Id; + Item.m_TypeAndID = (i<<16)|m_aItems[k].m_ID; Item.m_Size = m_aItems[k].m_Size; if(DEBUG) - dbg_msg("datafile", "writing item type=%x idx=%d id=%d size=%d", i, k, m_aItems[k].m_Id, m_aItems[k].m_Size); + dbg_msg("datafile", "writing item type=%x idx=%d id=%d size=%d", i, k, m_aItems[k].m_ID, m_aItems[k].m_Size); #if defined(CONF_ARCH_ENDIAN_BIG) swap_endian(&Item, sizeof(int), sizeof(Item)/sizeof(int)); diff --git a/src/engine/shared/datafile.h b/src/engine/shared/datafile.h index f7ee2847..ce7b11aa 100644 --- a/src/engine/shared/datafile.h +++ b/src/engine/shared/datafile.h @@ -21,10 +21,10 @@ public: void *GetDataSwapped(int Index); // makes sure that the data is 32bit LE ints when saved int GetDataSize(int Index); void UnloadData(int Index); - void *GetItem(int Index, int *pType, int *pId); + void *GetItem(int Index, int *pType, int *pID); int GetItemSize(int Index); void GetType(int Type, int *pStart, int *pNum); - void *FindItem(int Type, int Id); + void *FindItem(int Type, int ID); int NumItems(); int NumData(); void Unload(); @@ -45,7 +45,7 @@ class CDataFileWriter struct CItemInfo { int m_Type; - int m_Id; + int m_ID; int m_Size; int m_Next; int m_Prev; @@ -72,7 +72,7 @@ public: bool Open(class IStorage *pStorage, const char *Filename); int AddData(int Size, void *pData); int AddDataSwapped(int Size, void *pData); - int AddItem(int Type, int Id, int Size, void *pData); + int AddItem(int Type, int ID, int Size, void *pData); int Finish(); }; diff --git a/src/engine/shared/map.cpp b/src/engine/shared/map.cpp index c0931d54..c57dd708 100644 --- a/src/engine/shared/map.cpp +++ b/src/engine/shared/map.cpp @@ -14,9 +14,9 @@ public: virtual void *GetData(int Index) { return m_DataFile.GetData(Index); } virtual void *GetDataSwapped(int Index) { return m_DataFile.GetDataSwapped(Index); } virtual void UnloadData(int Index) { m_DataFile.UnloadData(Index); } - virtual void *GetItem(int Index, int *pType, int *pId) { return m_DataFile.GetItem(Index, pType, pId); } + virtual void *GetItem(int Index, int *pType, int *pID) { return m_DataFile.GetItem(Index, pType, pID); } virtual void GetType(int Type, int *pStart, int *pNum) { m_DataFile.GetType(Type, pStart, pNum); } - virtual void *FindItem(int Type, int Id) { return m_DataFile.FindItem(Type, Id); } + virtual void *FindItem(int Type, int ID) { return m_DataFile.FindItem(Type, ID); } virtual int NumItems() { return m_DataFile.NumItems(); } virtual void Unload() diff --git a/src/engine/shared/snapshot.cpp b/src/engine/shared/snapshot.cpp index 7ead4320..f908d1c2 100644 --- a/src/engine/shared/snapshot.cpp +++ b/src/engine/shared/snapshot.cpp @@ -286,7 +286,7 @@ int CSnapshotDelta::UnpackDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pSrcData CSnapshotItem *pFromItem; int Keep, ItemSize; int *pDeleted; - int Id, Type, Key; + int ID, Type, Key; int FromIndex; int *pNewData; @@ -330,7 +330,7 @@ int CSnapshotDelta::UnpackDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pSrcData return -1; Type = *pData++; - Id = *pData++; + ID = *pData++; if(m_aItemSizes[Type]) ItemSize = m_aItemSizes[Type]; else @@ -343,7 +343,7 @@ int CSnapshotDelta::UnpackDelta(CSnapshot *pFrom, CSnapshot *pTo, void *pSrcData if(RangeCheck(pEnd, pData, ItemSize) || ItemSize < 0) return -3; - Key = (Type<<16)|Id; + Key = (Type<<16)|ID; // create the item if needed pNewData = Builder.GetItemData(Key); diff --git a/src/engine/sound.h b/src/engine/sound.h index d14458e3..8f5dab24 100644 --- a/src/engine/sound.h +++ b/src/engine/sound.h @@ -18,12 +18,12 @@ public: virtual int LoadWV(const char *pFilename) = 0; - virtual void SetChannel(int ChannelId, float Volume, float Panning) = 0; + virtual void SetChannel(int ChannelID, float Volume, float Panning) = 0; virtual void SetListenerPos(float x, float y) = 0; - virtual int PlayAt(int ChannelId, int SoundId, int Flags, float x, float y) = 0; - virtual int Play(int ChannelId, int SoundId, int Flags) = 0; - virtual void Stop(int VoiceId) = 0; + virtual int PlayAt(int ChannelID, int SoundID, int Flags, float x, float y) = 0; + virtual int Play(int ChannelID, int SoundID, int Flags) = 0; + virtual void Stop(int VoiceID) = 0; virtual void StopAll() = 0; }; -- cgit 1.4.1