From 7d3d8fdbf36f367c2d7e560fd87f2712e3a07cf1 Mon Sep 17 00:00:00 2001 From: janwas Date: Sat, 26 Aug 2006 20:25:37 +0000 Subject: [PATCH] # move ps/Network into top level project (and static lib). This was SVN commit r4249. --- source/graphics/Terrain.cpp | 47 +++++-------------- source/graphics/Terrain.h | 8 ++++ source/gui/MiniMap.cpp | 2 +- source/main.cpp | 2 +- .../{ps/Network => network}/AllNetMessages.h | 0 source/{ps/Network => network}/Client.cpp | 0 source/{ps/Network => network}/Client.h | 0 source/{ps/Network => network}/JSEvents.h | 0 source/{ps/Network => network}/NMTCreator.h | 0 source/{ps/Network => network}/NetLog.cpp | 0 source/{ps/Network => network}/NetLog.h | 0 source/{ps/Network => network}/NetMessage.cpp | 0 source/{ps/Network => network}/NetMessage.h | 0 source/{ps/Network => network}/Network.cpp | 0 source/{ps/Network => network}/Network.h | 0 .../{ps/Network => network}/NetworkInternal.h | 0 .../{ps/Network => network}/Serialization.h | 0 source/{ps/Network => network}/Server.cpp | 0 source/{ps/Network => network}/Server.h | 0 .../{ps/Network => network}/ServerSession.cpp | 0 .../{ps/Network => network}/ServerSession.h | 0 .../{ps/Network => network}/ServerSocket.cpp | 0 source/{ps/Network => network}/Session.cpp | 0 source/{ps/Network => network}/Session.h | 0 .../Network => network}/SessionManager.cpp | 0 .../{ps/Network => network}/SessionManager.h | 0 source/{ps/Network => network}/SocketBase.cpp | 0 source/{ps/Network => network}/SocketBase.h | 0 .../{ps/Network => network}/StreamSocket.cpp | 0 source/{ps/Network => network}/StreamSocket.h | 0 .../Network => network}/StringConverters.h | 0 source/pch/network/precompiled.cpp | 1 + source/pch/network/precompiled.h | 7 +++ source/ps/CConsole.cpp | 4 +- source/ps/CStr.cpp | 2 +- source/ps/GameAttributes.cpp | 2 +- source/ps/GameSetup/GameSetup.cpp | 6 +-- source/ps/Interact.cpp | 2 +- source/ps/Player.cpp | 2 +- source/scripting/JSSerialization.h | 2 +- source/scripting/ScriptGlue.cpp | 4 +- source/simulation/EntityFormation.cpp | 2 +- source/simulation/EntityHandles.cpp | 2 +- source/simulation/Simulation.cpp | 2 +- source/simulation/TurnManager.cpp | 4 +- 45 files changed, 46 insertions(+), 55 deletions(-) rename source/{ps/Network => network}/AllNetMessages.h (100%) rename source/{ps/Network => network}/Client.cpp (100%) rename source/{ps/Network => network}/Client.h (100%) rename source/{ps/Network => network}/JSEvents.h (100%) rename source/{ps/Network => network}/NMTCreator.h (100%) rename source/{ps/Network => network}/NetLog.cpp (100%) rename source/{ps/Network => network}/NetLog.h (100%) rename source/{ps/Network => network}/NetMessage.cpp (100%) rename source/{ps/Network => network}/NetMessage.h (100%) rename source/{ps/Network => network}/Network.cpp (100%) rename source/{ps/Network => network}/Network.h (100%) rename source/{ps/Network => network}/NetworkInternal.h (100%) rename source/{ps/Network => network}/Serialization.h (100%) rename source/{ps/Network => network}/Server.cpp (100%) rename source/{ps/Network => network}/Server.h (100%) rename source/{ps/Network => network}/ServerSession.cpp (100%) rename source/{ps/Network => network}/ServerSession.h (100%) rename source/{ps/Network => network}/ServerSocket.cpp (100%) rename source/{ps/Network => network}/Session.cpp (100%) rename source/{ps/Network => network}/Session.h (100%) rename source/{ps/Network => network}/SessionManager.cpp (100%) rename source/{ps/Network => network}/SessionManager.h (100%) rename source/{ps/Network => network}/SocketBase.cpp (100%) rename source/{ps/Network => network}/SocketBase.h (100%) rename source/{ps/Network => network}/StreamSocket.cpp (100%) rename source/{ps/Network => network}/StreamSocket.h (100%) rename source/{ps/Network => network}/StringConverters.h (100%) create mode 100644 source/pch/network/precompiled.cpp create mode 100644 source/pch/network/precompiled.h diff --git a/source/graphics/Terrain.cpp b/source/graphics/Terrain.cpp index e24747b782..09166bb8bb 100644 --- a/source/graphics/Terrain.cpp +++ b/source/graphics/Terrain.cpp @@ -154,8 +154,10 @@ void CTerrain::CalcNormal(u32 i, u32 j, CVector3D& normal) const // out of bounds CPatch* CTerrain::GetPatch(i32 i, i32 j) const { - if (i<0 || i>=i32(m_MapSizePatches)) return 0; - if (j<0 || j>=i32(m_MapSizePatches)) return 0; + // range check: >= 0 and < m_MapSizePatches + if( (unsigned)i >= m_MapSizePatches || (unsigned)j >= m_MapSizePatches ) + return 0; + return &m_Patches[(j*m_MapSizePatches)+i]; } @@ -165,8 +167,9 @@ CPatch* CTerrain::GetPatch(i32 i, i32 j) const // of bounds CMiniPatch* CTerrain::GetTile(i32 i, i32 j) const { - if (i<0 || i>=i32(m_MapSize)-1) return 0; - if (j<0 || j>=i32(m_MapSize)-1) return 0; + // see above + if( (unsigned)i >= m_MapSize-1 || (unsigned)j >= m_MapSize-1 ) + return 0; CPatch* patch=GetPatch(i/PATCH_SIZE, j/PATCH_SIZE); return &patch->m_MiniPatches[j%PATCH_SIZE][i%PATCH_SIZE]; @@ -195,23 +198,8 @@ float CTerrain::getSlope(float x, float z) const int xi = (int)floor(x); int zi = (int)floor(z); - if (xi < 0) - { - xi = 0; - } - else if (xi >= (int)m_MapSize-1) - { - xi = m_MapSize - 2; - } - - if (zi < 0) - { - zi = 0; - } - else if (zi >= (int)m_MapSize-1) - { - zi = m_MapSize - 2; - } + clampCoordToMap(xi); + clampCoordToMap(zi); float h00 = m_Heightmap[zi*m_MapSize + xi]; float h01 = m_Heightmap[zi*m_MapSize + xi + m_MapSize]; @@ -244,14 +232,8 @@ CVector2D CTerrain::getSlopeAngleFace(float x, float y, CEntity*& entity ) const side += 8; //Keep it in bounds - if (xi < 0) - xi = 0; - else if (xi >= (int)m_MapSize-1) - xi = m_MapSize - 2; - if (yi < 0) - yi = 0; - else if (yi >= (int)m_MapSize-1) - yi = m_MapSize - 2; + clampCoordToMap(xi); + clampCoordToMap(yi); float h00 = m_Heightmap[yi*m_MapSize + xi] * HEIGHT_SCALE; float h01 = m_Heightmap[yi*m_MapSize + xi + m_MapSize] * HEIGHT_SCALE; @@ -355,13 +337,6 @@ float CTerrain::getExactGroundLevel(float x, float z) const zi = m_MapSize - 2; zf = 1.0f; } - /* - debug_assert( isOnMap( x, y ) ); - - if( !isOnMap( x, y ) ) - return 0.0f; - */ - float h00 = m_Heightmap[zi*m_MapSize + xi]; float h01 = m_Heightmap[zi*m_MapSize + xi + m_MapSize]; float h10 = m_Heightmap[zi*m_MapSize + xi + 1]; diff --git a/source/graphics/Terrain.h b/source/graphics/Terrain.h index 40575d5663..6bc12bd2a2 100644 --- a/source/graphics/Terrain.h +++ b/source/graphics/Terrain.h @@ -55,6 +55,14 @@ public: } bool isOnMap(const CVector2D& v) const; + void clampCoordToMap(int& index) const + { + if(index < 0) + index = 0; + else if(index >= (int)m_MapSize-1) + index = m_MapSize - 2; + } + float getVertexGroundLevel(int i, int j) const; float getExactGroundLevel(float x, float z) const; float getExactGroundLevel(const CVector2D& v) const; diff --git a/source/gui/MiniMap.cpp b/source/gui/MiniMap.cpp index 463edb33e5..724cb76605 100644 --- a/source/gui/MiniMap.cpp +++ b/source/gui/MiniMap.cpp @@ -15,7 +15,7 @@ #include "maths/Bound.h" #include "ps/Game.h" #include "ps/Interact.h" -#include "ps/Network/NetMessage.h" +#include "network/NetMessage.h" #include "ps/Profile.h" #include "renderer/Renderer.h" #include "renderer/WaterManager.h" diff --git a/source/main.cpp b/source/main.cpp index ea5d5197c2..25dac44211 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -31,7 +31,7 @@ that of Atlas depending on commandline parameters. #include "ps/Hotkey.h" #include "ps/Globals.h" #include "ps/Interact.h" -#include "ps/Network/SessionManager.h" +#include "network/SessionManager.h" #include "graphics/GameView.h" #include "simulation/Scheduler.h" #include "sound/CMusicPlayer.h" diff --git a/source/ps/Network/AllNetMessages.h b/source/network/AllNetMessages.h similarity index 100% rename from source/ps/Network/AllNetMessages.h rename to source/network/AllNetMessages.h diff --git a/source/ps/Network/Client.cpp b/source/network/Client.cpp similarity index 100% rename from source/ps/Network/Client.cpp rename to source/network/Client.cpp diff --git a/source/ps/Network/Client.h b/source/network/Client.h similarity index 100% rename from source/ps/Network/Client.h rename to source/network/Client.h diff --git a/source/ps/Network/JSEvents.h b/source/network/JSEvents.h similarity index 100% rename from source/ps/Network/JSEvents.h rename to source/network/JSEvents.h diff --git a/source/ps/Network/NMTCreator.h b/source/network/NMTCreator.h similarity index 100% rename from source/ps/Network/NMTCreator.h rename to source/network/NMTCreator.h diff --git a/source/ps/Network/NetLog.cpp b/source/network/NetLog.cpp similarity index 100% rename from source/ps/Network/NetLog.cpp rename to source/network/NetLog.cpp diff --git a/source/ps/Network/NetLog.h b/source/network/NetLog.h similarity index 100% rename from source/ps/Network/NetLog.h rename to source/network/NetLog.h diff --git a/source/ps/Network/NetMessage.cpp b/source/network/NetMessage.cpp similarity index 100% rename from source/ps/Network/NetMessage.cpp rename to source/network/NetMessage.cpp diff --git a/source/ps/Network/NetMessage.h b/source/network/NetMessage.h similarity index 100% rename from source/ps/Network/NetMessage.h rename to source/network/NetMessage.h diff --git a/source/ps/Network/Network.cpp b/source/network/Network.cpp similarity index 100% rename from source/ps/Network/Network.cpp rename to source/network/Network.cpp diff --git a/source/ps/Network/Network.h b/source/network/Network.h similarity index 100% rename from source/ps/Network/Network.h rename to source/network/Network.h diff --git a/source/ps/Network/NetworkInternal.h b/source/network/NetworkInternal.h similarity index 100% rename from source/ps/Network/NetworkInternal.h rename to source/network/NetworkInternal.h diff --git a/source/ps/Network/Serialization.h b/source/network/Serialization.h similarity index 100% rename from source/ps/Network/Serialization.h rename to source/network/Serialization.h diff --git a/source/ps/Network/Server.cpp b/source/network/Server.cpp similarity index 100% rename from source/ps/Network/Server.cpp rename to source/network/Server.cpp diff --git a/source/ps/Network/Server.h b/source/network/Server.h similarity index 100% rename from source/ps/Network/Server.h rename to source/network/Server.h diff --git a/source/ps/Network/ServerSession.cpp b/source/network/ServerSession.cpp similarity index 100% rename from source/ps/Network/ServerSession.cpp rename to source/network/ServerSession.cpp diff --git a/source/ps/Network/ServerSession.h b/source/network/ServerSession.h similarity index 100% rename from source/ps/Network/ServerSession.h rename to source/network/ServerSession.h diff --git a/source/ps/Network/ServerSocket.cpp b/source/network/ServerSocket.cpp similarity index 100% rename from source/ps/Network/ServerSocket.cpp rename to source/network/ServerSocket.cpp diff --git a/source/ps/Network/Session.cpp b/source/network/Session.cpp similarity index 100% rename from source/ps/Network/Session.cpp rename to source/network/Session.cpp diff --git a/source/ps/Network/Session.h b/source/network/Session.h similarity index 100% rename from source/ps/Network/Session.h rename to source/network/Session.h diff --git a/source/ps/Network/SessionManager.cpp b/source/network/SessionManager.cpp similarity index 100% rename from source/ps/Network/SessionManager.cpp rename to source/network/SessionManager.cpp diff --git a/source/ps/Network/SessionManager.h b/source/network/SessionManager.h similarity index 100% rename from source/ps/Network/SessionManager.h rename to source/network/SessionManager.h diff --git a/source/ps/Network/SocketBase.cpp b/source/network/SocketBase.cpp similarity index 100% rename from source/ps/Network/SocketBase.cpp rename to source/network/SocketBase.cpp diff --git a/source/ps/Network/SocketBase.h b/source/network/SocketBase.h similarity index 100% rename from source/ps/Network/SocketBase.h rename to source/network/SocketBase.h diff --git a/source/ps/Network/StreamSocket.cpp b/source/network/StreamSocket.cpp similarity index 100% rename from source/ps/Network/StreamSocket.cpp rename to source/network/StreamSocket.cpp diff --git a/source/ps/Network/StreamSocket.h b/source/network/StreamSocket.h similarity index 100% rename from source/ps/Network/StreamSocket.h rename to source/network/StreamSocket.h diff --git a/source/ps/Network/StringConverters.h b/source/network/StringConverters.h similarity index 100% rename from source/ps/Network/StringConverters.h rename to source/network/StringConverters.h diff --git a/source/pch/network/precompiled.cpp b/source/pch/network/precompiled.cpp new file mode 100644 index 0000000000..7ff8df544a --- /dev/null +++ b/source/pch/network/precompiled.cpp @@ -0,0 +1 @@ +#include "precompiled.h" diff --git a/source/pch/network/precompiled.h b/source/pch/network/precompiled.h new file mode 100644 index 0000000000..560701eab4 --- /dev/null +++ b/source/pch/network/precompiled.h @@ -0,0 +1,7 @@ +#include "lib/precompiled.h" // common precompiled header + +// network-specific PCH: + +#if HAVE_PCH + +#endif // HAVE_PCH diff --git a/source/ps/CConsole.cpp b/source/ps/CConsole.cpp index 0c46c1abcb..abf445c123 100644 --- a/source/ps/CConsole.cpp +++ b/source/ps/CConsole.cpp @@ -13,8 +13,8 @@ #include "ps/Globals.h" #include "ps/Hotkey.h" #include "ps/Interact.h" -#include "ps/Network/Client.h" -#include "ps/Network/Server.h" +#include "network/Client.h" +#include "network/Server.h" #include "ps/Pyrogenesis.h" #include "scripting/ScriptingHost.h" #include "simulation/Entity.h" diff --git a/source/ps/CStr.cpp b/source/ps/CStr.cpp index 2e21a6e391..355270c9df 100644 --- a/source/ps/CStr.cpp +++ b/source/ps/CStr.cpp @@ -4,7 +4,7 @@ #define CStr_CPP_FIRST #include "lib/posix.h" // for htons, ntohs -#include "ps/Network/Serialization.h" +#include "network/Serialization.h" #include #include diff --git a/source/ps/GameAttributes.cpp b/source/ps/GameAttributes.cpp index 78d2b43068..b5d08d93b6 100644 --- a/source/ps/GameAttributes.cpp +++ b/source/ps/GameAttributes.cpp @@ -5,7 +5,7 @@ #include "GameAttributes.h" #include "Game.h" #include "ConfigDB.h" -#include "ps/Network/ServerSession.h" +#include "network/ServerSession.h" #include "CLogger.h" #include "ps/XML/Xeromyces.h" diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index 405c7215a3..76250486d9 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -78,9 +78,9 @@ #include "sound/CMusicPlayer.h" #include "sound/JSI_Sound.h" -#include "ps/Network/SessionManager.h" -#include "ps/Network/Server.h" -#include "ps/Network/Client.h" +#include "network/SessionManager.h" +#include "network/Server.h" +#include "network/Client.h" #include "Atlas.h" #include "GameSetup.h" diff --git a/source/ps/Interact.cpp b/source/ps/Interact.cpp index 22e1869dce..ce2fefe39b 100644 --- a/source/ps/Interact.cpp +++ b/source/ps/Interact.cpp @@ -19,7 +19,7 @@ #include "lib/timer.h" #include "maths/MathUtil.h" #include "ps/Globals.h" -#include "ps/Network/NetMessage.h" +#include "network/NetMessage.h" #include "ps/Player.h" #include "ps/VFSUtil.h" #include "ps/World.h" diff --git a/source/ps/Player.cpp b/source/ps/Player.cpp index cc4e2ccd37..e9dc231e16 100644 --- a/source/ps/Player.cpp +++ b/source/ps/Player.cpp @@ -1,7 +1,7 @@ #include "precompiled.h" #include "Player.h" -#include "ps/Network/NetMessage.h" +#include "network/NetMessage.h" #include "simulation/Entity.h" #include "simulation/EntityManager.h" #include "ps/scripting/JSCollection.h" diff --git a/source/scripting/JSSerialization.h b/source/scripting/JSSerialization.h index a6d7ae4276..00ef766f87 100644 --- a/source/scripting/JSSerialization.h +++ b/source/scripting/JSSerialization.h @@ -3,7 +3,7 @@ // Mark Thompson (mark@wildfiregames.com / mot20@cam.ac.uk) // WIP, not yet functional -#include "ps/Network/Serialization.h" +#include "network/Serialization.h" #include "JSConversions.h" #include "ps/CStr.h" diff --git a/source/scripting/ScriptGlue.cpp b/source/scripting/ScriptGlue.cpp index 24e5d5d15d..a6d5d36e45 100644 --- a/source/scripting/ScriptGlue.cpp +++ b/source/scripting/ScriptGlue.cpp @@ -23,8 +23,8 @@ #include "ps/Game.h" #include "ps/GameSetup/GameSetup.h" #include "ps/Interact.h" -#include "ps/Network/Client.h" -#include "ps/Network/Server.h" +#include "network/Client.h" +#include "network/Server.h" #include "ps/i18n.h" #include "ps/Hotkey.h" #include "ps/scripting/JSCollection.h" diff --git a/source/simulation/EntityFormation.cpp b/source/simulation/EntityFormation.cpp index 9ef393b926..e5764e4da2 100644 --- a/source/simulation/EntityFormation.cpp +++ b/source/simulation/EntityFormation.cpp @@ -8,7 +8,7 @@ #include "Simulation.h" #include "ps/Game.h" #include "ps/Interact.h" -#include "ps/Network/NetMessage.h" +#include "network/NetMessage.h" CEntityFormation::CEntityFormation( CFormation*& base, size_t index ) { diff --git a/source/simulation/EntityHandles.cpp b/source/simulation/EntityHandles.cpp index d37ea6de6e..f017405230 100644 --- a/source/simulation/EntityHandles.cpp +++ b/source/simulation/EntityHandles.cpp @@ -4,7 +4,7 @@ #include "EntityManager.h" #include "Entity.h" #include "ps/CStr.h" -#include "ps/Network/Serialization.h" +#include "network/Serialization.h" CHandle::CHandle() { diff --git a/source/simulation/Simulation.cpp b/source/simulation/Simulation.cpp index 14ae1ae82e..4e0e0c0664 100644 --- a/source/simulation/Simulation.cpp +++ b/source/simulation/Simulation.cpp @@ -20,7 +20,7 @@ #include "ps/GameAttributes.h" #include "ps/Loader.h" #include "ps/LoaderThunks.h" -#include "ps/Network/NetMessage.h" +#include "network/NetMessage.h" #include "ps/Profile.h" #include "renderer/Renderer.h" #include "renderer/WaterManager.h" diff --git a/source/simulation/TurnManager.cpp b/source/simulation/TurnManager.cpp index 585f2a860f..945c65b466 100644 --- a/source/simulation/TurnManager.cpp +++ b/source/simulation/TurnManager.cpp @@ -1,8 +1,8 @@ #include "precompiled.h" #include "TurnManager.h" -#include "ps/Network/NetMessage.h" -#include "ps/Network/Network.h" +#include "network/NetMessage.h" +#include "network/Network.h" #include "ps/GameRecord.h" #include "ps/CLogger.h"