My Project
Public Member Functions | Static Public Member Functions | List of all members
ParaEngine::CEnvSimServer Class Reference

this is the environment simulator of a standard game world server. More...

#include <EnvSimServer.h>

Inheritance diagram for ParaEngine::CEnvSimServer:
ParaEngine::IEnvironmentSim

Public Member Functions

virtual SIMULATOR_TYPE GetSimulatorType ()
 return the current type of simulator. More...
 
virtual void Animate (double dTimeDelta)
 called each frame to simulate the game world. More...
 
virtual void CheckLoadPhysics (const D3DXVECTOR3 &vCenter, float fRadius)
 when this function is called, it ensures that the physics object around an object is properly loaded. More...
 
virtual void Release ()
 delete this object. More...
 
virtual CNetTimeGetNetTime ()
 get the net time object More...
 
bool SendNormalUpdate (const string &id, NPL::CBitStream *s)
 send normal update information of an Other Player Character (OPC) to a given client. More...
 
bool SendNormalUpdate (COPCBiped *pOPC, NPL::CBitStream *s)
 
bool OnReceiveNormalUpdate (const string &id, NPL::CBitStream *s)
 called when received normal update messages from a given client. More...
 
bool SendCharacterUpdate (CBipedObject *pChar, CCharacterTracker *pCharTracker, NPL::CBitStream *s, const char *sIdentifier=NULL)
 send a block for just a single character. More...
 
IGameObjectReceiveCharacterUpdate (NPL::CBitStream *s, bool &bIsDifferentUpdate, const char *sIdentifier=NULL)
 receive a block of a single character. More...
 
- Public Member Functions inherited from ParaEngine::IEnvironmentSim
virtual void CheckLoadPhysics (CShapeSphere *points, int nPointCount=1)=0
 when this function is called, it ensures that the physics object around one or more points are properly loaded. More...
 
void CheckLoadPhysics (const Vector3 &vCenter, float fRadius)
 

Static Public Member Functions

static bool NetworkMoveCharacter (CBipedObject *pBiped, const D3DXVECTOR3 &vDest, float fFacing, float fSpeed, float fVerticalSpeed, bool bForceRun, bool bForceWalk)
 move a character. More...
 
- Static Public Member Functions inherited from ParaEngine::IEnvironmentSim
static void EnableLog (bool bWriteLog)
 
static bool IsLogEnabled ()
 

Additional Inherited Members

- Public Types inherited from ParaEngine::IEnvironmentSim
enum  SIMULATOR_TYPE { SIM_TYPE_STANDALONE = 0, SIM_TYPE_SERVER = 1, SIM_TYPE_CLIENT = 2 }
 

Detailed Description

this is the environment simulator of a standard game world server.

Member Function Documentation

§ Animate()

void CEnvSimServer::Animate ( double  dTimeDelta)
virtual

called each frame to simulate the game world.

Parameters
dTimeDeltain seconds.

time lag more than MAX_SIM_LAG(1) second will be detected by the environment simulator

advance the game time

Check load physics around the current player and the camera position this is very game specific. It only ensures that physics object around the current player and camera is loaded.

frame move each unexploded missile objects.

Implements ParaEngine::IEnvironmentSim.

§ CheckLoadPhysics()

void CEnvSimServer::CheckLoadPhysics ( const D3DXVECTOR3 &  vCenter,
float  fRadius 
)
virtual

when this function is called, it ensures that the physics object around an object is properly loaded.

It increases the hit count of these physics objects by 1. The garbage collector in the physics world may use the hit count to move out unused static physics object from the physics scene. This function might be called for the current player, each active mobile object in the scene and the camera eye position.

Parameters
vCenterthe center of the object in world coordinates
fRadiusthe radius of the object within which all physics object must be active.

breadth first transversing the scene(the root tile is ignored) pTile is now the root tile. object attached to it are never rendered directly

add other tiles

rough culling algorithm using the quad tree terrain tiles test against a sphere round the eye

go down the quad tree terrain tile to render objects

even we know that the tile is empty, we still need to see if there is anything in the queueNode for rendering so when both queue are empty, we can exit the main rendering transversing loop

For each mesh physics object in the tile, load its physics.

§ GetNetTime()

virtual CNetTime* ParaEngine::CEnvSimServer::GetNetTime ( )
inlinevirtual

get the net time object

Returns

Reimplemented from ParaEngine::IEnvironmentSim.

§ GetSimulatorType()

virtual SIMULATOR_TYPE ParaEngine::CEnvSimServer::GetSimulatorType ( )
inlinevirtual

return the current type of simulator.

0 means standalone simulator, 1 means server, 2 means client.

Implements ParaEngine::IEnvironmentSim.

§ NetworkMoveCharacter()

bool CEnvSimServer::NetworkMoveCharacter ( CBipedObject pBiped,
const D3DXVECTOR3 &  vDest,
float  fFacing,
float  fSpeed,
float  fVerticalSpeed,
bool  bForceRun,
bool  bForceWalk 
)
static

move a character.

Parameters
vDestthe absolute solution from the last network.
bForceRunforce using running animation.
bForceWalkforce using walking animation.

§ OnReceiveNormalUpdate()

bool CEnvSimServer::OnReceiveNormalUpdate ( const string &  id,
NPL::CBitStream *  s 
)

called when received normal update messages from a given client.

Parameters
idthe id of the player, from which the package is received.
s[in|out] the bit stream from which the data are read.
Returns
if true, the character is updated over an older time. otherwise, this function might have been called multiple times in the same frame time.

§ ReceiveCharacterUpdate()

IGameObject * CEnvSimServer::ReceiveCharacterUpdate ( NPL::CBitStream *  s,
bool &  bIsDifferentUpdate,
const char *  sIdentifier = NULL 
)

receive a block of a single character.

Parameters
s
IsDifferentUpdate[out], if false, the same character might be updated multiple times in a single frame move.
sIdentifierif this is not NULL, the player ID read from s will be replaced by this one. so it will be this specified character that get updated.
Returns

Group1 if any:

  • Update OPC in the scene (validation may be included)

set perceptive radius for the character

Group2 if any:

  • Update OPC in the scene

in case character model has never been set before

§ Release()

void CEnvSimServer::Release ( )
virtual

delete this object.

Such as Delete this;

Implements ParaEngine::IEnvironmentSim.

§ SendCharacterUpdate()

bool CEnvSimServer::SendCharacterUpdate ( CBipedObject pChar,
CCharacterTracker pCharTracker,
NPL::CBitStream *  s,
const char *  sIdentifier = NULL 
)

send a block for just a single character.

Parameters
pChar
pCharTrackerit contains a history of values sent for the character.
s
sIdentifierif this is not NULL, the player ID of pChar will be replaced by this one.
Returns
true if the character is updated; false if the entire character is escaped(possibly because it has not been changed for long).

Header or group0: send if any of the following is true:

  • either group 1 or group2 is included.
  • The last send time of group0 is older than SERVER_GROUP0_INTERVAL

Group1: send if any of the following is true:

  • The current player has different group 1 info than the one in the tracker.
  • The last send time of group1 is older than SERVER_GROUP1_INTERVAL Update group 1 tracker info of the player, such as group1 send time and all value trackers.

Group2: send if any of the following is true:

  • The current player has different group 2 info than the one in the tracker.
  • The last send time of group2 is older than SERVER_GROUP2_INTERVAL Update group 2 tracker info of the player, such as group 2 send time and all value trackers.

§ SendNormalUpdate()

bool CEnvSimServer::SendNormalUpdate ( const string &  id,
NPL::CBitStream *  s 
)

send normal update information of an Other Player Character (OPC) to a given client.

a normal update usually contains the positions of all characters in the given character's perceptive radius. when a client receives such as package, it will use the information to update its local networked characters, as well as itself.

Parameters
pOPCpointer to an OPC player, to which the package is sent.
s[in|out] the bit stream to which the data are written.
Returns
: if true,entire update for the character is filled in stream. Otherwise, one need to prepare another stream and call this function again with a new stream.

The documentation for this class was generated from the following files: