1
0
forked from 0ad/0ad

# move ps/Network into top level project (and static lib).

This was SVN commit r4249.
This commit is contained in:
janwas 2006-08-26 20:25:37 +00:00
parent 855e9bce02
commit 7d3d8fdbf3
45 changed files with 46 additions and 55 deletions

View File

@ -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];

View File

@ -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;

View File

@ -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"

View File

@ -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"

View File

@ -0,0 +1 @@
#include "precompiled.h"

View File

@ -0,0 +1,7 @@
#include "lib/precompiled.h" // common precompiled header
// network-specific PCH:
#if HAVE_PCH
#endif // HAVE_PCH

View File

@ -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"

View File

@ -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 <cassert>
#include <sstream>

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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 )
{

View File

@ -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()
{

View File

@ -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"

View File

@ -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"