From be5e19d2bd3011128b12e8dfd4897b3514760941 Mon Sep 17 00:00:00 2001 From: xalduin Date: Mon, 7 Jun 2010 09:38:38 +0800 Subject: Fixed some compiler warnings --- src/engine/server/server.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/engine') diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 620599c8..bd5bebe1 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -554,9 +554,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 < 127; 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]; } -- cgit 1.4.1 From dc3feaf42cd8bcb22b04fdba17dc10caacc94fef Mon Sep 17 00:00:00 2001 From: xalduin Date: Thu, 10 Jun 2010 00:24:38 +0800 Subject: Fixed remaining compiler warnings for gcc on Linux --- src/engine/client/client.cpp | 11 ++++++----- src/engine/server/server.cpp | 11 ++++++----- src/engine/shared/demorec.cpp | 2 +- src/engine/shared/ringbuffer.cpp | 2 +- src/game/client/components/maplayers.cpp | 2 +- src/game/client/components/menus_demo.cpp | 2 +- src/game/server/entities/character.cpp | 16 ++++++++++++++-- 7 files changed, 30 insertions(+), 16 deletions(-) (limited to 'src/engine') diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 613a8137..881f06d8 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 diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index bd5bebe1..7a26704c 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,7 +555,7 @@ 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 < 127; 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] == '\\') pMapShortName = &g_Config.m_SvMap[i+1]; 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/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index 202ea2da..62b32a1f 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -42,7 +42,7 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void pChannels[2] = 0; pChannels[3] = 0; - CEnvPoint *pPoints; + CEnvPoint *pPoints = 0; { int Start, Num; diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index fd0caf62..784212ca 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -475,7 +475,7 @@ void CMenus::RenderDemoList(CUIRect MainView) str_copy(aTitleButton, "Open", sizeof(aTitleButton)); else str_copy(aTitleButton, "Play", sizeof(aTitleButton)); - // /!\ TODO: Add "Open" in Localization /!\ + //TODO: Add "Open" in Localization if(DoButton_Menu(&s_PlayButton, Localize(aTitleButton), 0, &PlayRect) || Activated) { if(s_SelectedItem >= 0 && s_SelectedItem < m_lDemos.size()) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 77d8f462..81d1f85b 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -585,14 +585,26 @@ void CCharacter::TickDefered() if(!StuckBefore && (StuckAfterMove || StuckAfterQuant)) { + // Hackish solution to get rid of strict-aliasing warning + union + { + float f; + unsigned u; + }StartPosX, StartPosY, StartVelX, StartVelY; + + StartPosX.f = StartPos.x; + StartPosY.f = StartPos.y; + StartVelX.f = StartVel.x; + StartVelY.f = StartVel.y; + dbg_msg("char_core", "STUCK!!! %d %d %d %f %f %f %f %x %x %x %x", StuckBefore, StuckAfterMove, StuckAfterQuant, StartPos.x, StartPos.y, StartVel.x, StartVel.y, - *((unsigned *)&StartPos.x), *((unsigned *)&StartPos.y), - *((unsigned *)&StartVel.x), *((unsigned *)&StartVel.y)); + StartPosX.u, StartPosY.u, + StartVelX.u, StartVelY.u); } int Events = m_Core.m_TriggeredEvents; -- cgit 1.4.1 From 6e1eaa96ec4d7e443a6967c80bda8acaf8002c7f Mon Sep 17 00:00:00 2001 From: xalduin Date: Thu, 10 Jun 2010 06:40:22 +0800 Subject: Fixed issue #115, text now fits into columns in server browser --- src/engine/client/text.cpp | 2 +- src/game/client/components/menus_browser.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/engine') 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/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 9b816f15..32243a2a 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -309,7 +309,12 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) TextRender()->TextEx(&Cursor, pItem->m_aName, -1); } else if(Id == COL_MAP) - UI()->DoLabel(&Button, pItem->m_aMap, 12.0f, -1); + { + CTextCursor Cursor; + TextRender()->SetCursor(&Cursor, Button.x, Button.y, 12.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + Cursor.m_LineWidth = Button.w; + TextRender()->TextEx(&Cursor, pItem->m_aMap, -1); + } else if(Id == COL_PLAYERS) { str_format(aTemp, sizeof(aTemp), "%i/%i", pItem->m_NumPlayers, pItem->m_MaxPlayers); @@ -332,7 +337,10 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) } else if(Id == COL_GAMETYPE) { - UI()->DoLabel(&Button, pItem->m_aGameType, 12.0f, 0); + CTextCursor Cursor; + TextRender()->SetCursor(&Cursor, Button.x, Button.y, 12.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + Cursor.m_LineWidth = Button.w; + TextRender()->TextEx(&Cursor, pItem->m_aGameType, -1); } } -- cgit 1.4.1 From a5bc567e84902d55fe1f2eec9df621d984a0d808 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 13 Jun 2010 19:34:14 +0200 Subject: fixed a server register issue --- src/engine/server/register.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/engine') 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) { -- cgit 1.4.1 From ea64b0d7b361308d3b3737ecbac724856bfddda4 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 18 Jun 2010 20:32:52 +0200 Subject: made the console use the flagmask when looking for command (FindCommand) and removed double "No such command" console message --- src/engine/client/client.cpp | 2 +- src/engine/console.h | 4 ++-- src/engine/server/server.cpp | 2 +- src/engine/shared/console.cpp | 25 ++++++++++++++----------- src/engine/shared/console.h | 7 ++++--- src/game/client/components/console.cpp | 2 +- 6 files changed, 23 insertions(+), 19 deletions(-) (limited to 'src/engine') diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 881f06d8..eae5ef3a 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1964,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/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/server.cpp b/src/engine/server/server.cpp index 7a26704c..ea2815e7 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -1391,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/game/client/components/console.cpp b/src/game/client/components/console.cpp index b323ab48..9e09e6a2 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -184,7 +184,7 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event) aBuf[i] = *pSrc; aBuf[i] = 0; - m_pCommand = m_pGameConsole->m_pConsole->GetCommandInfo(aBuf); + m_pCommand = m_pGameConsole->m_pConsole->GetCommandInfo(aBuf, m_CompletionFlagmask); } } } -- cgit 1.4.1 From a5113c6740e22e633a7fd7d853b81518762e4e21 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 20 Jun 2010 14:12:59 +0200 Subject: added commands to dump the output of the consoles into a file --- src/engine/shared/storage.cpp | 3 +++ src/game/client/components/console.cpp | 49 ++++++++++++++++++++++++++++++++++ src/game/client/components/console.h | 3 +++ 3 files changed, 55 insertions(+) (limited to 'src/engine') 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); diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 5ffe1efd..433ff409 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -1,5 +1,6 @@ //#include "gc_console.h" #include +#include #include @@ -9,6 +10,7 @@ #include #include #include +#include #include #include @@ -570,6 +572,41 @@ void CGameConsole::Toggle(int Type) m_ConsoleType = Type; } +void CGameConsole::Dump(int Type) +{ + CInstance *pConsole = Type == 1 ? &m_RemoteConsole : &m_LocalConsole; + char aFilename[128]; + time_t Time; + char aDate[20]; + + time(&Time); + tm* TimeInfo = localtime(&Time); + strftime(aDate, sizeof(aDate), "%Y-%m-%d_%I-%M", TimeInfo); + + for(int i = 0; i < 10; i++) + { + IOHANDLE io; + str_format(aFilename, sizeof(aFilename), "dumps/%s_dump%s-%05d.txt", Type==1?"remote_console":"local_console", aDate, i); + io = Storage()->OpenFile(aFilename, IOFLAG_WRITE); + if(io) + { + #if defined(CONF_FAMILY_WINDOWS) + static const char Newline[] = "\r\n"; + #else + static const char Newline[] = "\n"; + #endif + + for(char *pEntry = pConsole->m_Backlog.First(); pEntry; pEntry = pConsole->m_Backlog.Next(pEntry)) + { + io_write(io, pEntry, str_length(pEntry)); + io_write(io, Newline, sizeof(Newline)-1); + } + io_close(io); + break; + } + } +} + void CGameConsole::ConToggleLocalConsole(IConsole::IResult *pResult, void *pUserData) { ((CGameConsole *)pUserData)->Toggle(0); @@ -590,6 +627,16 @@ void CGameConsole::ConClearRemoteConsole(IConsole::IResult *pResult, void *pUser ((CGameConsole *)pUserData)->m_RemoteConsole.ClearBacklog(); } +void CGameConsole::ConDumpLocalConsole(IConsole::IResult *pResult, void *pUserData) +{ + ((CGameConsole *)pUserData)->Dump(0); +} + +void CGameConsole::ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserData) +{ + ((CGameConsole *)pUserData)->Dump(1); +} + void CGameConsole::ClientConsolePrintCallback(const char *pStr, void *pUserData) { ((CGameConsole *)pUserData)->m_LocalConsole.PrintLine(pStr); @@ -618,6 +665,8 @@ void CGameConsole::OnConsoleInit() Console()->Register("toggle_remote_console", "", CFGFLAG_CLIENT, ConToggleRemoteConsole, this, "Toggle remote console"); Console()->Register("clear_local_console", "", CFGFLAG_CLIENT, ConClearLocalConsole, this, "Clear local console"); Console()->Register("clear_remote_console", "", CFGFLAG_CLIENT, ConClearRemoteConsole, this, "Clear remote console"); + Console()->Register("dump_local_console", "", CFGFLAG_CLIENT, ConDumpLocalConsole, this, "Dump local console"); + Console()->Register("dump_remote_console", "", CFGFLAG_CLIENT, ConDumpRemoteConsole, this, "Dump remote console"); } /* diff --git a/src/game/client/components/console.h b/src/game/client/components/console.h index 68f3965d..a4d22790 100644 --- a/src/game/client/components/console.h +++ b/src/game/client/components/console.h @@ -56,6 +56,7 @@ class CGameConsole : public CComponent float m_StateChangeDuration; void Toggle(int Type); + void Dump(int Type); static void PossibleCommandsRenderCallback(const char *pStr, void *pUser); static void ClientConsolePrintCallback(const char *pStr, void *pUserData); @@ -63,6 +64,8 @@ class CGameConsole : public CComponent static void ConToggleRemoteConsole(IConsole::IResult *pResult, void *pUserData); static void ConClearLocalConsole(IConsole::IResult *pResult, void *pUserData); static void ConClearRemoteConsole(IConsole::IResult *pResult, void *pUserData); + static void ConDumpLocalConsole(IConsole::IResult *pResult, void *pUserData); + static void ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserData); public: CGameConsole(); -- cgit 1.4.1 From 9130c918419fdc1e29d66e53cd21b34ed05eabc7 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 26 Jun 2010 17:59:59 +0200 Subject: fixed entering a private server on a map change without password. Closes #142 --- src/engine/server/server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/engine') diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index ea2815e7..c45b2dd4 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -1067,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); -- cgit 1.4.1 From 29d29df4f043aecf7711e956da5076456241d68f Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 27 Jun 2010 13:12:00 +0200 Subject: fixed screenshot bug. Closes #144 --- src/engine/client/graphics.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/engine') 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++) -- cgit 1.4.1