OpenMortal Apocalypse mirror
Sourceforge mirror
SourceForge.net Logo
      News | Info | Characters | Arenas | Screenshots | Forums | Download  
Developer: Making of | Character-HOWTO | AI Design | Submit a Character
Documentation: Main Page | Modules | Class Hierarchy | Class List | File List

CMortalNetworkImpl Class Reference
[Networking layer]

Implementation of the CMortalNetwork interface. More...

#include <MortalNetworkImpl.h>

Inheritance diagram for CMortalNetworkImpl:

CMortalNetwork List of all members.

Public Member Functions

 CMortalNetworkImpl ()
virtual ~CMortalNetworkImpl ()
bool Start (const char *a_pcServerName)
void Stop ()
bool IsConnectionAlive ()
void Update ()
const char * GetLastError ()
bool IsMaster ()
const char * GetRemoteUsername ()
void SendMsg (const char *a_pcMsg)
bool IsMsgAvailable ()
const char * GetMsg ()
bool IsRemoteFighterAvailable (FighterEnum a_enFighter)
FighterEnum GetRemoteFighter ()
bool IsRemoteSideReady ()
void SendFighter (FighterEnum a_enFighter)
void SendReady ()
void SendGameParams (int a_iGameSpeed, int a_iGameTime, int a_iHitPoints, int a_iBackgroundNumber)
SGameParams GetGameParams ()
bool SynchStartRound ()
void SendGameData (const char *a_pcGameData)
const char * GetLatestGameData ()
void SendKeystroke (int a_iTime, int a_iKey, bool a_bPressed)
bool GetKeystroke (int &a_riOutTime, int &a_riOutKey, bool &a_rbPressed)
void SendGameTick (int a_iGameTick)
int GetGameTick ()
void SendHurryup (int a_iHurryUpCode)
int GetHurryup ()
void SendRoundOver (int a_iWhoWon, bool a_bGameOver)
int GetWhoWon ()
bool IsRoundOver ()
bool IsGameOver ()

Protected Types

enum  TNetworkState { NS_DISCONNECTED, NS_CHARACTER_SELECTION, NS_IN_GAME }

Protected Member Functions

void SendRawData (char a_cID, const void *a_pData, int a_iLength)
 All sent data must go through this method.
void ReceiveMsg (void *a_pData, int a_iLength)
void ReceiveRemoteUserName (void *a_pData, int a_iLength)
void ReceiveGameData (void *a_pData, int a_iLength)
void ReceiveKeystroke (void *a_pData, int a_iLength)
void ReceiveFighter (void *a_pData, int a_iLength)
void ReceiveReady (void *a_pData, int a_iLength)
void ReceiveRoundOver (void *a_pData, int a_iLength)
void ReceiveGameTick (void *a_pData, int a_iLength)
void ReceiveHurryup (void *a_pData, int a_iLength)
void ReceiveRemoteFighterAvailable (void *a_pData, int a_iLength)
void ReceiveRemoteFighterQuery (void *a_pData, int a_iLength)
void ReceiveGameParams (void *a_pData, int a_iLength)

Protected Attributes

bool m_bNetworkAvailable
 Is the networking API initialized correctly?
TNetworkState m_enState
 The current state.
bool m_bServer
 We are the server side.
bool m_bMaster
 We are the master side. (Initially the server side).
TCPsocket m_poSocket
 The TCP/IP network socket.
SDLNet_SocketSet m_poSocketSet
 SDLNet construct for watching the socket.
char m_acIncomingBuffer [2048]
 Received data goes here.
int m_iIncomingBufferSize
 How much of the buffer is filled?
std::string m_sLastError
 The last error message from SDLNet.
TStringList m_asMsgs
 Incoming chatlines.
std::string m_sRemoteUserName
TIntList m_aiAvailableRemoteFighters
FighterEnum m_enRemoteFighter
bool m_bRemoteReady
SGameParams m_oGameParams
std::string m_sLatestGameData
TIntList m_aiKeyTimes
TIntList m_aiKeystrokes
TIntList m_abKeystrokes
bool m_bRoundOver
int m_iWhoWon
bool m_bGameOver
int m_iGameTick
int m_iHurryupCode
bool m_bSynchQueryResponse

Detailed Description

Implementation of the CMortalNetwork interface.

SUMMARY OF MESSAGES:

I <version> <username> - Introduction sent both ways on connection. U <text> - Remote user's name M <text> - Incoming Msg text.

S - Ready for the next round (synch). G <text> - Update on the game backend data. T <number> <number> - Update the game time and game phase. K <number> <bool> - Key # up/down H <number> - Hurryup and other special messages O <number> <bool> - The round is over (who won, are there more rounds).

F <number> - I have switched to fighter X. R - I have chosen a fighter. Q <number> - Is fighter X available? A <number> - Fighter A is available. P <number> x3 - Game parameters


Member Enumeration Documentation

enum CMortalNetworkImpl::TNetworkState [protected]
 

Enumeration values:
NS_DISCONNECTED 
NS_CHARACTER_SELECTION 
NS_IN_GAME 


Constructor & Destructor Documentation

CMortalNetworkImpl::CMortalNetworkImpl  ) 
 

CMortalNetworkImpl::~CMortalNetworkImpl  )  [virtual]
 


Member Function Documentation

CMortalNetworkImpl::SGameParams CMortalNetworkImpl::GetGameParams  )  [virtual]
 

Implements CMortalNetwork.

int CMortalNetworkImpl::GetGameTick  )  [virtual]
 

Implements CMortalNetwork.

int CMortalNetworkImpl::GetHurryup  )  [virtual]
 

Implements CMortalNetwork.

bool CMortalNetworkImpl::GetKeystroke int &  a_riOutTime,
int &  a_riOutKey,
bool &  a_rbPressed
[virtual]
 

Implements CMortalNetwork.

const char * CMortalNetworkImpl::GetLastError  )  [virtual]
 

Implements CMortalNetwork.

const char * CMortalNetworkImpl::GetLatestGameData  )  [virtual]
 

Implements CMortalNetwork.

const char * CMortalNetworkImpl::GetMsg  )  [virtual]
 

Implements CMortalNetwork.

FighterEnum CMortalNetworkImpl::GetRemoteFighter  )  [virtual]
 

Implements CMortalNetwork.

const char * CMortalNetworkImpl::GetRemoteUsername  )  [virtual]
 

Implements CMortalNetwork.

int CMortalNetworkImpl::GetWhoWon  )  [virtual]
 

Implements CMortalNetwork.

bool CMortalNetworkImpl::IsConnectionAlive  )  [virtual]
 

Implements CMortalNetwork.

bool CMortalNetworkImpl::IsGameOver  )  [virtual]
 

Implements CMortalNetwork.

bool CMortalNetworkImpl::IsMaster  )  [virtual]
 

Implements CMortalNetwork.

bool CMortalNetworkImpl::IsMsgAvailable  )  [virtual]
 

Implements CMortalNetwork.

bool CMortalNetworkImpl::IsRemoteFighterAvailable FighterEnum  a_enFighter  )  [virtual]
 

Implements CMortalNetwork.

bool CMortalNetworkImpl::IsRemoteSideReady  )  [virtual]
 

Implements CMortalNetwork.

bool CMortalNetworkImpl::IsRoundOver  )  [virtual]
 

Implements CMortalNetwork.

void CMortalNetworkImpl::ReceiveFighter void *  a_pData,
int  a_iLength
[protected]
 

void CMortalNetworkImpl::ReceiveGameData void *  a_pData,
int  a_iLength
[protected]
 

void CMortalNetworkImpl::ReceiveGameParams void *  a_pData,
int  a_iLength
[protected]
 

void CMortalNetworkImpl::ReceiveGameTick void *  a_pData,
int  a_iLength
[protected]
 

void CMortalNetworkImpl::ReceiveHurryup void *  a_pData,
int  a_iLength
[protected]
 

void CMortalNetworkImpl::ReceiveKeystroke void *  a_pData,
int  a_iLength
[protected]
 

void CMortalNetworkImpl::ReceiveMsg void *  a_pData,
int  a_iLength
[protected]
 

void CMortalNetworkImpl::ReceiveReady void *  a_pData,
int  a_iLength
[protected]
 

void CMortalNetworkImpl::ReceiveRemoteFighterAvailable void *  a_pData,
int  a_iLength
[protected]
 

void CMortalNetworkImpl::ReceiveRemoteFighterQuery void *  a_pData,
int  a_iLength
[protected]
 

void CMortalNetworkImpl::ReceiveRemoteUserName void *  a_pData,
int  a_iLength
[protected]
 

void CMortalNetworkImpl::ReceiveRoundOver void *  a_pData,
int  a_iLength
[protected]
 

void CMortalNetworkImpl::SendFighter FighterEnum  a_enFighter  )  [virtual]
 

Implements CMortalNetwork.

void CMortalNetworkImpl::SendGameData const char *  a_pcGameData  )  [virtual]
 

Implements CMortalNetwork.

void CMortalNetworkImpl::SendGameParams int  a_iGameSpeed,
int  a_iGameTime,
int  a_iHitPoints,
int  a_iBackgroundNumber
[virtual]
 

Implements CMortalNetwork.

void CMortalNetworkImpl::SendGameTick int  a_iGameTick  )  [virtual]
 

Implements CMortalNetwork.

void CMortalNetworkImpl::SendHurryup int  a_iHurryUpCode  )  [virtual]
 

Implements CMortalNetwork.

void CMortalNetworkImpl::SendKeystroke int  a_iTime,
int  a_iKey,
bool  a_bPressed
[virtual]
 

Implements CMortalNetwork.

void CMortalNetworkImpl::SendMsg const char *  a_pcMsg  )  [virtual]
 

Implements CMortalNetwork.

void CMortalNetworkImpl::SendRawData char  a_cID,
const void *  a_pData,
int  a_iLength
[protected]
 

All sent data must go through this method.

It ensures the well-formed header for the data. The header itself looks like this: ID char Length Uint16 Reserved char This is followed by as many bytes as the Length is.

void CMortalNetworkImpl::SendReady  )  [virtual]
 

Implements CMortalNetwork.

void CMortalNetworkImpl::SendRoundOver int  a_iWhoWon,
bool  a_bGameOver
[virtual]
 

Implements CMortalNetwork.

bool CMortalNetworkImpl::Start const char *  a_pcServerName  )  [virtual]
 

Implements CMortalNetwork.

void CMortalNetworkImpl::Stop  )  [virtual]
 

Implements CMortalNetwork.

bool CMortalNetworkImpl::SynchStartRound  )  [virtual]
 

Implements CMortalNetwork.

void CMortalNetworkImpl::Update  )  [virtual]
 

Implements CMortalNetwork.


Member Data Documentation

TIntList CMortalNetworkImpl::m_abKeystrokes [protected]
 

char CMortalNetworkImpl::m_acIncomingBuffer[2048] [protected]
 

Received data goes here.

TIntList CMortalNetworkImpl::m_aiAvailableRemoteFighters [protected]
 

TIntList CMortalNetworkImpl::m_aiKeystrokes [protected]
 

TIntList CMortalNetworkImpl::m_aiKeyTimes [protected]
 

TStringList CMortalNetworkImpl::m_asMsgs [protected]
 

Incoming chatlines.

bool CMortalNetworkImpl::m_bGameOver [protected]
 

bool CMortalNetworkImpl::m_bMaster [protected]
 

We are the master side. (Initially the server side).

bool CMortalNetworkImpl::m_bNetworkAvailable [protected]
 

Is the networking API initialized correctly?

bool CMortalNetworkImpl::m_bRemoteReady [protected]
 

bool CMortalNetworkImpl::m_bRoundOver [protected]
 

bool CMortalNetworkImpl::m_bServer [protected]
 

We are the server side.

bool CMortalNetworkImpl::m_bSynchQueryResponse [protected]
 

FighterEnum CMortalNetworkImpl::m_enRemoteFighter [protected]
 

TNetworkState CMortalNetworkImpl::m_enState [protected]
 

The current state.

int CMortalNetworkImpl::m_iGameTick [protected]
 

int CMortalNetworkImpl::m_iHurryupCode [protected]
 

int CMortalNetworkImpl::m_iIncomingBufferSize [protected]
 

How much of the buffer is filled?

int CMortalNetworkImpl::m_iWhoWon [protected]
 

SGameParams CMortalNetworkImpl::m_oGameParams [protected]
 

TCPsocket CMortalNetworkImpl::m_poSocket [protected]
 

The TCP/IP network socket.

SDLNet_SocketSet CMortalNetworkImpl::m_poSocketSet [protected]
 

SDLNet construct for watching the socket.

std::string CMortalNetworkImpl::m_sLastError [protected]
 

The last error message from SDLNet.

std::string CMortalNetworkImpl::m_sLatestGameData [protected]
 

std::string CMortalNetworkImpl::m_sRemoteUserName [protected]
 


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