diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2010-07-05 20:46:32 +0200 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2010-07-05 20:46:32 +0200 |
| commit | d302ba921e61177da9af1f85df58fe6f47ca5e95 (patch) | |
| tree | 4ac19b9caab0a7142b6dfbc05d234af152bd5407 /src/engine | |
| parent | 143af11a25bc4a944c3605b9a165ffd2f1970641 (diff) | |
| parent | bd02c2043e9f76ec47ee9ac35caf23ae294b1dfa (diff) | |
| download | zcatch-d302ba921e61177da9af1f85df58fe6f47ca5e95.tar.gz zcatch-d302ba921e61177da9af1f85df58fe6f47ca5e95.zip | |
Merge branch 'master' of github.com:matricks/teeworlds
Diffstat (limited to 'src/engine')
| -rw-r--r-- | src/engine/client/client.cpp | 13 | ||||
| -rw-r--r-- | src/engine/client/graphics.cpp | 4 | ||||
| -rw-r--r-- | src/engine/client/text.cpp | 2 | ||||
| -rw-r--r-- | src/engine/console.h | 4 | ||||
| -rw-r--r-- | src/engine/server/register.cpp | 17 | ||||
| -rw-r--r-- | src/engine/server/server.cpp | 17 | ||||
| -rw-r--r-- | src/engine/shared/console.cpp | 25 | ||||
| -rw-r--r-- | src/engine/shared/console.h | 7 | ||||
| -rw-r--r-- | src/engine/shared/demorec.cpp | 2 | ||||
| -rw-r--r-- | src/engine/shared/ringbuffer.cpp | 2 | ||||
| -rw-r--r-- | src/engine/shared/storage.cpp | 3 |
11 files changed, 63 insertions, 33 deletions
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 613a8137..eae5ef3a 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1123,6 +1123,7 @@ void CClient::ProcessPacket(CNetChunk *pPacket) int DeltaSize; unsigned char aTmpBuffer2[CSnapshot::MAX_SIZE]; unsigned char aTmpBuffer3[CSnapshot::MAX_SIZE]; + CSnapshot *pTmpBuffer3 = (CSnapshot*)aTmpBuffer3; // Fix compiler warning for strict-aliasing int SnapSize; CompleteSize = (NumParts-1) * MAX_SNAPSHOT_PACKSIZE + PartSize; @@ -1169,19 +1170,19 @@ void CClient::ProcessPacket(CNetChunk *pPacket) // unpack delta PurgeTick = DeltaTick; - SnapSize = m_SnapshotDelta.UnpackDelta(pDeltaShot, (CSnapshot*)aTmpBuffer3, pDeltaData, DeltaSize); + SnapSize = m_SnapshotDelta.UnpackDelta(pDeltaShot, pTmpBuffer3, pDeltaData, DeltaSize); if(SnapSize < 0) { dbg_msg("client", "delta unpack failed!"); return; } - if(Msg != NETMSG_SNAPEMPTY && ((CSnapshot*)aTmpBuffer3)->Crc() != Crc) + if(Msg != NETMSG_SNAPEMPTY && pTmpBuffer3->Crc() != Crc) { if(g_Config.m_Debug) { dbg_msg("client", "snapshot crc error #%d - tick=%d wantedcrc=%d gotcrc=%d compressed_size=%d delta_tick=%d", - m_SnapCrcErrors, GameTick, Crc, ((CSnapshot*)aTmpBuffer3)->Crc(), CompleteSize, DeltaTick); + m_SnapCrcErrors, GameTick, Crc, pTmpBuffer3->Crc(), CompleteSize, DeltaTick); } m_SnapCrcErrors++; @@ -1209,13 +1210,13 @@ void CClient::ProcessPacket(CNetChunk *pPacket) m_SnapshotStorage.PurgeUntil(PurgeTick); // add new - m_SnapshotStorage.Add(GameTick, time_get(), SnapSize, (CSnapshot*)aTmpBuffer3, 1); + m_SnapshotStorage.Add(GameTick, time_get(), SnapSize, pTmpBuffer3, 1); // add snapshot to demo if(m_DemoRecorder.IsRecording()) { // write snapshot - m_DemoRecorder.RecordSnapshot(GameTick, aTmpBuffer3, SnapSize); + m_DemoRecorder.RecordSnapshot(GameTick, pTmpBuffer3, SnapSize); } // apply snapshot, cycle pointers @@ -1963,7 +1964,7 @@ int main(int argc, const char **argv) // ignore_convention m_Client.RegisterInterfaces(); // create the components - IConsole *pConsole = CreateConsole(); + IConsole *pConsole = CreateConsole(CFGFLAG_CLIENT); IStorage *pStorage = CreateStorage("Teeworlds", argv[0]); // ignore_convention IConfig *pConfig = CreateConfig(); IEngineGraphics *pEngineGraphics = CreateEngineGraphics(); diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index e2f4ae4c..bf3f42ea 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -422,7 +422,11 @@ void CGraphics_OpenGL::ScreenshotDirect(const char *pFilename) int h = m_ScreenHeight; unsigned char *pPixelData = (unsigned char *)mem_alloc(w*(h+1)*3, 1); unsigned char *pTempRow = pPixelData+w*h*3; + GLint Alignment; + glGetIntegerv(GL_PACK_ALIGNMENT, &Alignment); + glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0,0, w, h, GL_RGB, GL_UNSIGNED_BYTE, pPixelData); + glPixelStorei(GL_PACK_ALIGNMENT, Alignment); // flip the pixel because opengl works from bottom left corner for(y = 0; y < h/2; y++) diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp index 57e1b43b..8fa8efee 100644 --- a/src/engine/client/text.cpp +++ b/src/engine/client/text.cpp @@ -681,7 +681,7 @@ public: Advance = pChr->m_AdvanceX + Kerning(pFont, Character, Nextcharacter)/Size; } - if(pCursor->m_Flags&TEXTFLAG_STOP_AT_END && DrawX+Advance*Size-pCursor->m_StartX > pCursor->m_LineWidth) + if(pCursor->m_Flags&TEXTFLAG_STOP_AT_END && DrawX+(Advance+pChr->m_Width)*Size-pCursor->m_StartX > pCursor->m_LineWidth) { // we hit the end of the line, no more to render or count pCurrent = pEnd; diff --git a/src/engine/console.h b/src/engine/console.h index 74d789e9..34fa4272 100644 --- a/src/engine/console.h +++ b/src/engine/console.h @@ -37,7 +37,7 @@ public: typedef void (*FCommandCallback)(IResult *pResult, void *pUserData); typedef void (*FChainCommandCallback)(IResult *pResult, void *pUserData, FCommandCallback pfnCallback, void *pCallbackUserData); - virtual CCommandInfo *GetCommandInfo(const char *pName) = 0; + virtual CCommandInfo *GetCommandInfo(const char *pName, int FlagMask) = 0; virtual void PossibleCommands(const char *pStr, int FlagMask, FPossibleCallback pfnCallback, void *pUser) = 0; virtual void ParseArguments(int NumArgs, const char **ppArguments) = 0; @@ -53,6 +53,6 @@ public: virtual void Print(const char *pStr) = 0; }; -extern IConsole *CreateConsole(); +extern IConsole *CreateConsole(int FlagMask); #endif // FILE_ENGINE_CONSOLE_H diff --git a/src/engine/server/register.cpp b/src/engine/server/register.cpp index 959b9288..5e49f499 100644 --- a/src/engine/server/register.cpp +++ b/src/engine/server/register.cpp @@ -231,6 +231,23 @@ void CRegister::RegisterUpdate() int CRegister::RegisterProcessPacket(CNetChunk *pPacket) { + // check for masterserver address + bool Valid = false; + NETADDR Addr1 = pPacket->m_Address; + Addr1.port = 0; + for(int i = 0; i < IMasterServer::MAX_MASTERSERVERS; i++) + { + NETADDR Addr2 = m_aMasterserverInfo[i].m_Addr; + Addr2.port = 0; + if(net_addr_comp(&Addr1, &Addr2) == 0) + { + Valid = true; + break; + } + } + if(!Valid) + return 0; + if(pPacket->m_DataSize == sizeof(SERVERBROWSE_FWCHECK) && mem_comp(pPacket->m_pData, SERVERBROWSE_FWCHECK, sizeof(SERVERBROWSE_FWCHECK)) == 0) { diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 620599c8..c45b2dd4 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -427,6 +427,7 @@ void CServer::DoSnapshot() { char aData[CSnapshot::MAX_SIZE]; + CSnapshot *pData = (CSnapshot*)aData; // Fix compiler warning for strict-aliasing char aDeltaData[CSnapshot::MAX_SIZE]; char aCompData[CSnapshot::MAX_SIZE]; int SnapshotSize; @@ -442,15 +443,15 @@ void CServer::DoSnapshot() GameServer()->OnSnap(i); // finish snapshot - SnapshotSize = m_SnapshotBuilder.Finish(aData); - Crc = ((CSnapshot*)aData)->Crc(); + SnapshotSize = m_SnapshotBuilder.Finish(pData); + Crc = pData->Crc(); // remove old snapshos // keep 3 seconds worth of snapshots m_aClients[i].m_Snapshots.PurgeUntil(m_CurrentGameTick-SERVER_TICK_SPEED*3); // save it the snapshot - m_aClients[i].m_Snapshots.Add(m_CurrentGameTick, time_get(), SnapshotSize, aData, 0); + m_aClients[i].m_Snapshots.Add(m_CurrentGameTick, time_get(), SnapshotSize, pData, 0); // find snapshot that we can preform delta against EmptySnap.Clear(); @@ -468,7 +469,7 @@ void CServer::DoSnapshot() } // create delta - DeltaSize = m_SnapshotDelta.CreateDelta(pDeltashot, (CSnapshot*)aData, aDeltaData); + DeltaSize = m_SnapshotDelta.CreateDelta(pDeltashot, pData, aDeltaData); if(DeltaSize) { @@ -554,9 +555,9 @@ void CServer::SendMap(int ClientId) { //get the name of the map without his path char * pMapShortName = &g_Config.m_SvMap[0]; - for(int i = 0; i < 128; i++) + for(int i = 0; i < str_length(g_Config.m_SvMap)-1; i++) { - if(g_Config.m_SvMap[i] == '/' || g_Config.m_SvMap[i] == '\\' && i+1 < 128) + if(g_Config.m_SvMap[i] == '/' || g_Config.m_SvMap[i] == '\\') pMapShortName = &g_Config.m_SvMap[i+1]; } @@ -1066,7 +1067,7 @@ int CServer::Run() for(int c = 0; c < MAX_CLIENTS; c++) { - if(m_aClients[c].m_State == CClient::STATE_EMPTY) + if(m_aClients[c].m_State <= CClient::STATE_AUTH) continue; SendMap(c); @@ -1390,7 +1391,7 @@ int main(int argc, const char **argv) // ignore_convention // create the components IEngineMap *pEngineMap = CreateEngineMap(); IGameServer *pGameServer = CreateGameServer(); - IConsole *pConsole = CreateConsole(); + IConsole *pConsole = CreateConsole(CFGFLAG_SERVER); IEngineMasterServer *pEngineMasterServer = CreateEngineMasterServer(); IStorage *pStorage = CreateStorage("Teeworlds", argv[0]); // ignore_convention IConfig *pConfig = CreateConfig(); diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp index eacf9b78..b7850bea 100644 --- a/src/engine/shared/console.cpp +++ b/src/engine/shared/console.cpp @@ -210,7 +210,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr) if(ParseStart(&Result, pStr, (pEnd-pStr) + 1) != 0) return; - CCommand *pCommand = FindCommand(Result.m_pCommand); + CCommand *pCommand = FindCommand(Result.m_pCommand, m_FlagMask); if(pCommand) { @@ -234,7 +234,7 @@ void CConsole::ExecuteLineStroked(int Stroke, const char *pStr) pCommand->m_pfnCallback(&Result, pCommand->m_pUserData); } } - else + else if(Stroke) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "No such command: %s.", Result.m_pCommand); @@ -258,14 +258,16 @@ void CConsole::PossibleCommands(const char *pStr, int FlagMask, FPossibleCallbac } } -// TODO: this should regard the commands flag -CConsole::CCommand *CConsole::FindCommand(const char *pName) +CConsole::CCommand *CConsole::FindCommand(const char *pName, int FlagMask) { CCommand *pCommand; for (pCommand = m_pFirstCommand; pCommand; pCommand = pCommand->m_pNext) { - if(str_comp_nocase(pCommand->m_pName, pName) == 0) - return pCommand; + if(pCommand->m_Flags&FlagMask) + { + if(str_comp_nocase(pCommand->m_pName, pName) == 0) + return pCommand; + } } return 0x0; @@ -385,8 +387,9 @@ static void StrVariableCommand(IConsole::IResult *pResult, void *pUserData) } } -CConsole::CConsole() +CConsole::CConsole(int FlagMask) { + m_FlagMask = FlagMask; m_pFirstCommand = 0; m_pFirstExec = 0; m_pPrintCallbackUserdata = 0; @@ -459,7 +462,7 @@ void CConsole::Con_Chain(IResult *pResult, void *pUserData) void CConsole::Chain(const char *pName, FChainCommandCallback pfnChainFunc, void *pUser) { - CCommand *pCommand = FindCommand(pName); + CCommand *pCommand = FindCommand(pName, m_FlagMask); if(!pCommand) { @@ -481,10 +484,10 @@ void CConsole::Chain(const char *pName, FChainCommandCallback pfnChainFunc, void } -IConsole::CCommandInfo *CConsole::GetCommandInfo(const char *pName) +IConsole::CCommandInfo *CConsole::GetCommandInfo(const char *pName, int FlagMask) { - return FindCommand(pName); + return FindCommand(pName, FlagMask); } -extern IConsole *CreateConsole() { return new CConsole(); } +extern IConsole *CreateConsole(int FlagMask) { return new CConsole(FlagMask); } diff --git a/src/engine/shared/console.h b/src/engine/shared/console.h index 93d23547..9064fa86 100644 --- a/src/engine/shared/console.h +++ b/src/engine/shared/console.h @@ -24,6 +24,7 @@ class CConsole : public IConsole void *m_pUserData; }; + int m_FlagMask; CCommand *m_pFirstCommand; class CExecFile @@ -74,12 +75,12 @@ class CConsole : public IConsole int ParseStart(CResult *pResult, const char *pString, int Length); int ParseArgs(CResult *pResult, const char *pFormat); - CCommand *FindCommand(const char *pName); + CCommand *FindCommand(const char *pName, int FlagMask); public: - CConsole(); + CConsole(int FlagMask); - virtual CCommandInfo *GetCommandInfo(const char *pName); + virtual CCommandInfo *GetCommandInfo(const char *pName, int FlagMask); virtual void PossibleCommands(const char *pStr, int FlagMask, FPossibleCallback pfnCallback, void *pUser) ; virtual void ParseArguments(int NumArgs, const char **ppArguments); diff --git a/src/engine/shared/demorec.cpp b/src/engine/shared/demorec.cpp index 48b06e9a..6c2ba07d 100644 --- a/src/engine/shared/demorec.cpp +++ b/src/engine/shared/demorec.cpp @@ -335,7 +335,7 @@ void CDemoPlayer::DoTick() static char aDecompressed[CSnapshot::MAX_SIZE]; static char aData[CSnapshot::MAX_SIZE]; int ChunkType, ChunkTick, ChunkSize; - int DataSize; + int DataSize = 0; int GotSnapshot = 0; // update ticks diff --git a/src/engine/shared/ringbuffer.cpp b/src/engine/shared/ringbuffer.cpp index 45a845ee..b84db5a3 100644 --- a/src/engine/shared/ringbuffer.cpp +++ b/src/engine/shared/ringbuffer.cpp @@ -98,7 +98,7 @@ void *CRingBufferBase::Allocate(int Size) // okey, we have our block // split the block if needed - if(pBlock->m_Size > WantedSize+sizeof(CItem)) + if(pBlock->m_Size > WantedSize+(int)sizeof(CItem)) { CItem *pNewItem = (CItem *)((char *)pBlock + WantedSize); pNewItem->m_pPrev = pBlock; diff --git a/src/engine/shared/storage.cpp b/src/engine/shared/storage.cpp index 491795ad..1d0e2f78 100644 --- a/src/engine/shared/storage.cpp +++ b/src/engine/shared/storage.cpp @@ -30,6 +30,9 @@ public: str_format(aPath, sizeof(aPath), "%s/maps", m_aApplicationSavePath); fs_makedir(aPath); + str_format(aPath, sizeof(aPath), "%s/dumps", m_aApplicationSavePath); + fs_makedir(aPath); + str_format(aPath, sizeof(aPath), "%s/downloadedmaps", m_aApplicationSavePath); fs_makedir(aPath); |