torque Torque Game Engine Documentation
CVS Revision Label 1.3.x

GameConnection Class Reference

#include <gameConnection.h>

Inheritance diagram for GameConnection:

NetConnection ConnectionProtocol SimGroup SimSet SimObject ConsoleObject AIConnection AIClient

Client side first/third person

bool mUpdateCameraFov
 Set to notify server of camera FOV change.
F32 mCameraFov
 Current camera fov (in degrees).
F32 mCameraPos
 Current camera pos (0-1).
F32 mCameraSpeed
 Camera in/out speed.
static bool mFirstPerson
 Are we currently first person or not.

Public Types

enum  Constants {
  BlockTypeMove = NetConnectionBlockTypeCount,
  GameConnectionBlockTypeCount,
  MaxConnectArgs = 16,
  DataBlocksDone = NumConnectionMessages,
  DataBlocksDownloadDone
}
 Configuration. More...

Public Member Functions

void setConnectArgs (U32 argc, const char **argv)
 Set connection arguments; these are passed to the server when we connect.
void setJoinPassword (const char *password)
 Set the server password to use when we join.
bool canRemoteCreate ()
 DECLARE_CONOBJECT (GameConnection)
void handleConnectionMessage (U32 message, U32 sequence, U32 ghostCount)
 Handle message from sendConnectionMessage().
void preloadDataBlock (SimDataBlock *block)
void fileDownloadSegmentComplete ()
 Called when we finish downloading file data.
void preloadNextDataBlock (bool hadNew)
void setDisconnectReason (const char *reason)
 GameConnection ()
 ~GameConnection ()
U32 getDataBlockSequence ()
void setDataBlockSequence (U32 seq)
bool onAdd ()
 Called when the object is added to the sim.
void onRemove ()
 Called when the object is removed from the sim.
void detectLag ()
Event Handling
void onTimedOut ()
void onConnectTimedOut ()
void onDisconnect (const char *reason)
void onConnectionRejected (const char *reason)
void onConnectionEstablished (bool isInitiator)
void handleStartupError (const char *errorString)
Packet I/O
void writeConnectRequest (BitStream *stream)
bool readConnectRequest (BitStream *stream, const char **errorString)
void writeConnectAccept (BitStream *stream)
bool readConnectAccept (BitStream *stream, const char **errorString)
Control object
void setControlObject (ShapeBase *co)
ShapeBasegetControlObject ()
void setCameraObject (ShapeBase *co)
ShapeBasegetCameraObject ()
bool getControlCameraTransform (F32 dt, MatrixF *mat)
bool getControlCameraVelocity (Point3F *vel)
bool getControlCameraFov (F32 *fov)
bool setControlCameraFov (F32 fov)
bool isValidControlCameraFov (F32 fov)
Datablock management
S32 getDataBlockModifiedKey ()
void setDataBlockModifiedKey (S32 key)
S32 getMaxDataBlockModifiedKey ()
void setMaxDataBlockModifiedKey (S32 key)
Fade control
F32 getDamageFlash ()
F32 getWhiteOut ()
void setBlackOut (bool fadeToBlack, S32 timeMS)
F32 getBlackOut ()
Move Management
void pushMove (const Move &mv)
bool getNextMove (Move &curMove)
bool isBacklogged ()
virtual void getMoveList (Move **, U32 *numMoves)
virtual void clearMoves (U32 count)
void collectMove (U32 simTime)
virtual bool areMovesPending ()
void incMoveCredit (U32 count)
Authentication
This is remnant code from Tribes 2.

void setAuthInfo (const AuthInfo *info)
const AuthInfogetAuthInfo ()
Sound
void play2D (const AudioProfile *profile)
void play3D (const AudioProfile *profile, const MatrixF *transform)
Misc.
bool isFirstPerson ()
bool isAIControlled ()
void doneScopingScene ()
 Called when we're done with normal scoping.
void demoPlaybackComplete ()
void setMissionCRC (U32 crc)
U32 getMissionCRC ()

Static Public Member Functions

static void consoleInit ()
 Register global constant variables and do other one-time initialization tasks in a subclass of ConsoleObject.
static GameConnectiongetServerConnection ()
static GameConnectiongetLocalClientConnection ()

Static Public Attributes

Protocol Versions
Protocol versions are used to indicated changes in network traffic. These could be changes in how any object transmits or processes network information. You can specify backwards compatability by specifying a MinRequireProtocolVersion. If the client protocol is >= this min value, the connection is accepted.

Torque (V12) SDK 1.0 uses protocol = 1

Torque SDK 1.1 uses protocol = 2

static const U32 CurrentProtocolVersion
static const U32 MinRequiredProtocolVersion

Protected Member Functions

PacketNotify * allocNotify ()
 Get a free Notify structure.
Packet I/O
void readPacket (BitStream *bstream)
void writePacket (BitStream *bstream, PacketNotify *note)
void packetReceived (PacketNotify *note)
void packetDropped (PacketNotify *note)
void connectionError (const char *errorString)
void writeDemoStartBlock (ResizeBitStream *stream)
bool readDemoStartBlock (BitStream *stream)
void handleRecordedBlock (U32 type, U32 size, void *data)

Protected Attributes

U32 mLastMoveAck
U32 mLastClientMove
U32 mFirstMoveIndex
U32 mMoveCredit
U32 mLastControlObjectChecksum
Vector< SimDataBlock * > mDataBlockLoadList
MoveList mMoveList
bool mAIControlled
AuthInfomAuthInfo
S32 mLastPacketTime
bool mLagging
F32 mDamageFlash
 Note, these variables are not networked, they are for the local connection only.
F32 mWhiteOut
F32 mBlackOut
S32 mBlackOutTimeMS
S32 mBlackOutStartTimeMS
bool mFadeToBlack

Static Protected Attributes

static S32 mLagThresholdMS

Private Types

typedef NetConnection Parent
typedef Vector< MoveMoveList
enum  PrivateConstants {
  MoveCountBits = 5,
  MaxMoveCount = 30
}

Private Member Functions

Move Packets
Write/read move data to the packet.

void moveWritePacket (BitStream *bstream)
void moveReadPacket (BitStream *bstream)

Private Attributes

SimObjectPtr< ShapeBasemControlObject
SimObjectPtr< ShapeBasemCameraObject
U32 mDataBlockSequence
char mDisconnectReason [256]
U32 mMissionCRC
U32 mLastControlRequestTime
S32 mDataBlockModifiedKey
S32 mMaxDataBlockModifiedKey
Connection State
This data is set with setConnectArgs() and setJoinPassword(), and sent across the wire when we connect.

U32 mConnectArgc
char * mConnectArgv [MaxConnectArgs]
char * mJoinPassword

Data Structures

struct  GamePacketNotify

Member Typedef Documentation

typedef NetConnection GameConnection::Parent [private]
 

Reimplemented from NetConnection.

Reimplemented in AIClient, and AIConnection.

typedef Vector<Move> GameConnection::MoveList [private]
 


Member Enumeration Documentation

enum GameConnection::PrivateConstants [private]
 

Enumeration values:
MoveCountBits 
MaxMoveCount  MaxMoveCount should not exceed the MoveManager's own maximum (MaxMoveQueueSize).

enum GameConnection::Constants
 

Configuration.

Enumeration values:
BlockTypeMove 
GameConnectionBlockTypeCount 
MaxConnectArgs 
DataBlocksDone 
DataBlocksDownloadDone 

Reimplemented from NetConnection.


Constructor & Destructor Documentation

GameConnection::GameConnection  ) 
 

GameConnection::~GameConnection  ) 
 


Member Function Documentation

void GameConnection::moveWritePacket BitStream bstream  )  [private]
 

void GameConnection::moveReadPacket BitStream bstream  )  [private]
 

void GameConnection::setConnectArgs U32  argc,
const char **  argv
 

Set connection arguments; these are passed to the server when we connect.

void GameConnection::setJoinPassword const char *  password  ) 
 

Set the server password to use when we join.

void GameConnection::onTimedOut  )  [virtual]
 

Reimplemented from NetConnection.

void GameConnection::onConnectTimedOut  )  [virtual]
 

Reimplemented from NetConnection.

void GameConnection::onDisconnect const char *  reason  )  [virtual]
 

Reimplemented from NetConnection.

void GameConnection::onConnectionRejected const char *  reason  )  [virtual]
 

Reimplemented from NetConnection.

void GameConnection::onConnectionEstablished bool  isInitiator  )  [virtual]
 

Reimplemented from NetConnection.

void GameConnection::handleStartupError const char *  errorString  )  [virtual]
 

Reimplemented from NetConnection.

void GameConnection::writeConnectRequest BitStream stream  )  [virtual]
 

Reimplemented from NetConnection.

bool GameConnection::readConnectRequest BitStream stream,
const char **  errorString
[virtual]
 

Reimplemented from NetConnection.

void GameConnection::writeConnectAccept BitStream stream  )  [virtual]
 

Reimplemented from NetConnection.

bool GameConnection::readConnectAccept BitStream stream,
const char **  errorString
[virtual]
 

Reimplemented from NetConnection.

bool GameConnection::canRemoteCreate  )  [virtual]
 

Reimplemented from NetConnection.

PacketNotify* GameConnection::allocNotify  )  [protected, virtual]
 

Get a free Notify structure.

Reimplemented from NetConnection.

void GameConnection::readPacket BitStream bstream  )  [protected, virtual]
 

Reimplemented from NetConnection.

void GameConnection::writePacket BitStream bstream,
PacketNotify *  note
[protected, virtual]
 

Reimplemented from NetConnection.

void GameConnection::packetReceived PacketNotify *  note  )  [protected, virtual]
 

Reimplemented from NetConnection.

void GameConnection::packetDropped PacketNotify *  note  )  [protected, virtual]
 

Reimplemented from NetConnection.

void GameConnection::connectionError const char *  errorString  )  [protected, virtual]
 

Reimplemented from NetConnection.

void GameConnection::writeDemoStartBlock ResizeBitStream stream  )  [protected, virtual]
 

Reimplemented from NetConnection.

bool GameConnection::readDemoStartBlock BitStream stream  )  [protected, virtual]
 

Reimplemented from NetConnection.

void GameConnection::handleRecordedBlock U32  type,
U32  size,
void data
[protected, virtual]
 

Reimplemented from NetConnection.

GameConnection::DECLARE_CONOBJECT GameConnection   ) 
 

void GameConnection::handleConnectionMessage U32  message,
U32  sequence,
U32  ghostCount
[virtual]
 

Handle message from sendConnectionMessage().

This is called to handle messages sent via sendConnectionMessage.

Parameters:
message One of GhostStates
sequence A sequence number, if any.
ghostCount A count of ghosts relating to this message.

Reimplemented from NetConnection.

void GameConnection::preloadDataBlock SimDataBlock block  ) 
 

void GameConnection::fileDownloadSegmentComplete  )  [virtual]
 

Called when we finish downloading file data.

Reimplemented from NetConnection.

void GameConnection::preloadNextDataBlock bool  hadNew  ) 
 

static void GameConnection::consoleInit  )  [static]
 

Register global constant variables and do other one-time initialization tasks in a subclass of ConsoleObject.

Deprecated:
You should use ConsoleMethod and ConsoleFunction, not this, to register methods or commands.
See also:
console

Reimplemented from NetConnection.

void GameConnection::setDisconnectReason const char *  reason  ) 
 

U32 GameConnection::getDataBlockSequence  )  [inline]
 

void GameConnection::setDataBlockSequence U32  seq  )  [inline]
 

bool GameConnection::onAdd  )  [virtual]
 

Called when the object is added to the sim.

Reimplemented from SimObject.

void GameConnection::onRemove  )  [virtual]
 

Called when the object is removed from the sim.

Reimplemented from NetConnection.

static GameConnection* GameConnection::getServerConnection  )  [inline, static]
 

Reimplemented from NetConnection.

static GameConnection* GameConnection::getLocalClientConnection  )  [inline, static]
 

Reimplemented from NetConnection.

void GameConnection::setControlObject ShapeBase co  ) 
 

ShapeBase* GameConnection::getControlObject  )  [inline]
 

void GameConnection::setCameraObject ShapeBase co  ) 
 

ShapeBase* GameConnection::getCameraObject  ) 
 

bool GameConnection::getControlCameraTransform F32  dt,
MatrixF mat
 

bool GameConnection::getControlCameraVelocity Point3F vel  ) 
 

bool GameConnection::getControlCameraFov F32 fov  ) 
 

bool GameConnection::setControlCameraFov F32  fov  ) 
 

bool GameConnection::isValidControlCameraFov F32  fov  ) 
 

void GameConnection::detectLag  ) 
 

S32 GameConnection::getDataBlockModifiedKey  )  [inline]
 

void GameConnection::setDataBlockModifiedKey S32  key  )  [inline]
 

S32 GameConnection::getMaxDataBlockModifiedKey  )  [inline]
 

void GameConnection::setMaxDataBlockModifiedKey S32  key  )  [inline]
 

F32 GameConnection::getDamageFlash  )  [inline]
 

F32 GameConnection::getWhiteOut  )  [inline]
 

void GameConnection::setBlackOut bool  fadeToBlack,
S32  timeMS
 

F32 GameConnection::getBlackOut  ) 
 

void GameConnection::pushMove const Move mv  ) 
 

bool GameConnection::getNextMove Move curMove  ) 
 

bool GameConnection::isBacklogged  ) 
 

virtual void GameConnection::getMoveList Move **  ,
U32 numMoves
[virtual]
 

Reimplemented in AIClient, and AIConnection.

virtual void GameConnection::clearMoves U32  count  )  [virtual]
 

Reimplemented in AIConnection.

void GameConnection::collectMove U32  simTime  ) 
 

virtual bool GameConnection::areMovesPending  )  [virtual]
 

void GameConnection::incMoveCredit U32  count  ) 
 

void GameConnection::setAuthInfo const AuthInfo info  ) 
 

const AuthInfo* GameConnection::getAuthInfo  ) 
 

void GameConnection::play2D const AudioProfile profile  ) 
 

void GameConnection::play3D const AudioProfile profile,
const MatrixF transform
 

bool GameConnection::isFirstPerson  )  [inline]
 

bool GameConnection::isAIControlled  )  [inline]
 

void GameConnection::doneScopingScene  )  [virtual]
 

Called when we're done with normal scoping.

This gives subclasses a chance to shove things into scope, such as the results of a sensor network calculation, that would otherwise be awkward to add.

Reimplemented from NetConnection.

void GameConnection::demoPlaybackComplete  )  [virtual]
 

Reimplemented from NetConnection.

void GameConnection::setMissionCRC U32  crc  )  [inline]
 

U32 GameConnection::getMissionCRC  )  [inline]
 


Field Documentation

SimObjectPtr<ShapeBase> GameConnection::mControlObject [private]
 

SimObjectPtr<ShapeBase> GameConnection::mCameraObject [private]
 

U32 GameConnection::mDataBlockSequence [private]
 

char GameConnection::mDisconnectReason[256] [private]
 

U32 GameConnection::mMissionCRC [private]
 

U32 GameConnection::mLastControlRequestTime [private]
 

S32 GameConnection::mDataBlockModifiedKey [private]
 

S32 GameConnection::mMaxDataBlockModifiedKey [private]
 

bool GameConnection::mFirstPerson [static, private]
 

Are we currently first person or not.

bool GameConnection::mUpdateCameraFov [private]
 

Set to notify server of camera FOV change.

F32 GameConnection::mCameraFov [private]
 

Current camera fov (in degrees).

F32 GameConnection::mCameraPos [private]
 

Current camera pos (0-1).

F32 GameConnection::mCameraSpeed [private]
 

Camera in/out speed.

const U32 GameConnection::CurrentProtocolVersion [static]
 

const U32 GameConnection::MinRequiredProtocolVersion [static]
 

U32 GameConnection::mConnectArgc [private]
 

char* GameConnection::mConnectArgv[MaxConnectArgs] [private]
 

char* GameConnection::mJoinPassword [private]
 

U32 GameConnection::mLastMoveAck [protected]
 

U32 GameConnection::mLastClientMove [protected]
 

U32 GameConnection::mFirstMoveIndex [protected]
 

U32 GameConnection::mMoveCredit [protected]
 

U32 GameConnection::mLastControlObjectChecksum [protected]
 

Vector<SimDataBlock *> GameConnection::mDataBlockLoadList [protected]
 

MoveList GameConnection::mMoveList [protected]