Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
Network Class Reference

Inherits NetworkInterface.

Public Member Functions

 Network ()
 
 ~Network ()
 
void init (void)
 Initialize or re-initialize the instance.
 
void reset (void)
 Reinitialize the network.
 
void update (void)
 Process command list.
 
void liteupdate (void)
 Do a lightweight update to send packets and pass messages.
 
Bool deinit (void)
 Shutdown connections, release memory.
 
void setLocalAddress (UnsignedInt ip, UnsignedInt port)
 
UnsignedInt getRunAhead (void)
 Get the current RunAhead value.
 
UnsignedInt getFrameRate (void)
 Get the current allowed frame rate.
 
UnsignedInt getPacketArrivalCushion (void)
 Returns the smallest packet arrival cushion since this was last called.
 
Bool isFrameDataReady (void)
 
void parseUserList (const GameInfo *game)
 
void startGame (void)
 Sets the network game frame counter to -1.
 
void sendChat (UnicodeString text, Int playerMask)
 
void sendDisconnectChat (UnicodeString text)
 
void sendFile (AsciiString path, UnsignedByte playerMask, UnsignedShort commandID)
 
UnsignedShort sendFileAnnounce (AsciiString path, UnsignedByte playerMask)
 
Int getFileTransferProgress (Int playerID, AsciiString path)
 
Bool areAllQueuesEmpty (void)
 
void quitGame ()
 
virtual void selfDestructPlayer (Int index)
 
void voteForPlayerDisconnect (Int slot)
 
virtual Bool isPacketRouter (void)
 
Real getIncomingBytesPerSecond (void)
 
Real getIncomingPacketsPerSecond (void)
 
Real getOutgoingBytesPerSecond (void)
 
Real getOutgoingPacketsPerSecond (void)
 
Real getUnknownBytesPerSecond (void)
 
Real getUnknownPacketsPerSecond (void)
 
void updateLoadProgress (Int percent)
 
void loadProgressComplete (void)
 
void sendTimeOutGameStart (void)
 
UnsignedInt getLocalPlayerID (void)
 
UnicodeString getPlayerName (Int playerNum)
 
Int getNumPlayers (void)
 
Int getAverageFPS ()
 
Int getSlotAverageFPS (Int slot)
 
void attachTransport (Transport *transport)
 
void initTransport ()
 
void setSawCRCMismatch (void)
 
Bool sawCRCMismatch (void)
 
Bool isPlayerConnected (Int playerID)
 
void notifyOthersOfCurrentFrame ()
 Tells all the other players what frame we are on.
 
void notifyOthersOfNewFrame (UnsignedInt frame)
 Tells all the other players that we are on a new frame.
 
Int getExecutionFrame ()
 Returns the next valid frame for simultaneous command execution.
 
UnsignedInt getPingFrame ()
 
Int getPingsSent ()
 
Int getPingsRecieved ()
 
- Public Member Functions inherited from NetworkInterface
virtual ~NetworkInterface ()
 
- Public Member Functions inherited from SubsystemInterface
 SubsystemInterface ()
 
virtual ~SubsystemInterface ()
 
virtual void postProcessLoad ()
 
virtual void draw (void)
 
void UPDATE (void)
 
void DRAW (void)
 
AsciiString getName (void)
 
void setName (AsciiString name)
 

Protected Member Functions

void GetCommandsFromCommandList ()
 Remove commands from TheCommandList and put them on the Network command list.
 
void SendCommandsToConnectionManager ()
 Send the new commands to the ConnectionManager.
 
Bool AllCommandsReady (UnsignedInt frame)
 Do we have all the commands for the given frame?
 
void RelayCommandsToCommandList (UnsignedInt frame)
 Put the commands for the given frame onto TheCommandList.
 
Bool isTransferCommand (GameMessage *msg)
 Is this a command that needs to be transfered to the other clients?
 
Bool processCommand (GameMessage *msg)
 Whatever needs to be done as a result of this command, do it now.
 
void processFrameSynchronizedNetCommand (NetCommandRef *msg)
 If there is a network command that needs to be executed at the same frame number on all clients, it happens here.
 
void processRunAheadCommand (NetRunAheadCommandMsg *msg)
 Do what needs to be done when we get a new run ahead command.
 
void processDestroyPlayerCommand (NetDestroyPlayerCommandMsg *msg)
 Do what needs to be done when we need to destroy a player.
 
void endOfGameCheck ()
 Checks to see if its ok to leave this game. If it is, send the apropriate command to the game logic.
 
Bool timeForNewFrame ()
 

Protected Attributes

ConnectionManagerm_conMgr
 The connection manager object.
 
UnsignedInt m_lastFrame
 The last game logic frame that was processed.
 
NetLocalStatus m_localStatus
 My local status as a player in this game.
 
Int m_runAhead
 The current run ahead of the game.
 
Int m_frameRate
 
Int m_lastExecutionFrame
 The highest frame number that a command could have been executed on.
 
Int m_lastFrameCompleted
 
Bool m_didSelfSlug
 
__int64 m_perfCountFreq
 The frequency of the performance counter.
 
__int64 m_nextFrameTime
 When did we execute the last frame? For slugging the GameLogic...
 
Bool m_frameDataReady
 Is the frame data for the next frame ready to be executed by TheGameLogic?
 
Bool m_checkCRCsThisFrame
 
Bool m_sawCRCMismatch
 
std::vector< UnsignedIntm_CRC [MAX_SLOTS]
 
std::list< Intm_playersToDisconnect
 
GameWindowm_messageWindow
 
- Protected Attributes inherited from SubsystemInterface
AsciiString m_name
 

Additional Inherited Members

- Static Public Member Functions inherited from NetworkInterface
static NetworkInterfacecreateNetwork (void)
 

Detailed Description

The Network class is used to instantiate a singleton which implements the interface to all Network operations such as message stream processing and network communications.

Definition at line 106 of file Network.cpp.

Constructor & Destructor Documentation

◆ Network()

Network::Network ( )

The constructor.

Definition at line 269 of file Network.cpp.

◆ ~Network()

Network::~Network ( )

The destructor.

Definition at line 290 of file Network.cpp.

Member Function Documentation

◆ AllCommandsReady()

Bool Network::AllCommandsReady ( UnsignedInt frame)
protected

Do we have all the commands for the given frame?

returns true if all the commands are ready for the given frame.

Definition at line 565 of file Network.cpp.

◆ areAllQueuesEmpty()

Bool Network::areAllQueuesEmpty ( void )
virtual

Implements NetworkInterface.

Definition at line 920 of file Network.cpp.

◆ attachTransport()

void Network::attachTransport ( Transport * transport)
virtual

Implements NetworkInterface.

Definition at line 448 of file Network.cpp.

◆ deinit()

Bool Network::deinit ( void )

Shutdown connections, release memory.

This basically releases all the memory.

Definition at line 298 of file Network.cpp.

◆ endOfGameCheck()

void Network::endOfGameCheck ( )
protected

Checks to see if its ok to leave this game. If it is, send the apropriate command to the game logic.

Definition at line 743 of file Network.cpp.

◆ getAverageFPS()

Int Network::getAverageFPS ( )
inlinevirtual

Implements NetworkInterface.

Definition at line 165 of file Network.cpp.

◆ GetCommandsFromCommandList()

void Network::GetCommandsFromCommandList ( )
protected

Remove commands from TheCommandList and put them on the Network command list.

Take commands from TheCommandList and give them to the connection manager for transport.

Definition at line 468 of file Network.cpp.

◆ getExecutionFrame()

Int Network::getExecutionFrame ( )
virtual

Returns the next valid frame for simultaneous command execution.

Implements NetworkInterface.

Definition at line 489 of file Network.cpp.

◆ getFileTransferProgress()

Int Network::getFileTransferProgress ( Int playerID,
AsciiString path )
virtual

Implements NetworkInterface.

Definition at line 915 of file Network.cpp.

◆ getFrameRate()

UnsignedInt Network::getFrameRate ( void )
inlinevirtual

Get the current allowed frame rate.

Implements NetworkInterface.

Definition at line 121 of file Network.cpp.

◆ getIncomingBytesPerSecond()

Real Network::getIncomingBytesPerSecond ( void )
virtual

returns the number of incoming bytes per second averaged over the last 30 sec.

Implements NetworkInterface.

Definition at line 814 of file Network.cpp.

◆ getIncomingPacketsPerSecond()

Real Network::getIncomingPacketsPerSecond ( void )
virtual

returns the number of incoming packets per second averaged over the last 30 sec.

Implements NetworkInterface.

Definition at line 825 of file Network.cpp.

◆ getLocalPlayerID()

UnsignedInt Network::getLocalPlayerID ( void )
virtual

Implements NetworkInterface.

Definition at line 984 of file Network.cpp.

◆ getNumPlayers()

Int Network::getNumPlayers ( void )
virtual

Implements NetworkInterface.

Definition at line 1003 of file Network.cpp.

◆ getOutgoingBytesPerSecond()

Real Network::getOutgoingBytesPerSecond ( void )
virtual

returns the number of outgoing bytes per second averaged over the last 30 sec.

Implements NetworkInterface.

Definition at line 836 of file Network.cpp.

◆ getOutgoingPacketsPerSecond()

Real Network::getOutgoingPacketsPerSecond ( void )
virtual

returns the number of outgoing packets per second averaged over the last 30 sec.

Implements NetworkInterface.

Definition at line 847 of file Network.cpp.

◆ getPacketArrivalCushion()

UnsignedInt Network::getPacketArrivalCushion ( void )
virtual

Returns the smallest packet arrival cushion since this was last called.

returns the smallest packet arrival cushion since this was last called.

Implements NetworkInterface.

Definition at line 880 of file Network.cpp.

◆ getPingFrame()

UnsignedInt Network::getPingFrame ( )
virtual

Implements NetworkInterface.

Definition at line 227 of file Network.cpp.

◆ getPingsRecieved()

Int Network::getPingsRecieved ( )
virtual

Implements NetworkInterface.

Definition at line 237 of file Network.cpp.

◆ getPingsSent()

Int Network::getPingsSent ( )
virtual

Implements NetworkInterface.

Definition at line 232 of file Network.cpp.

◆ getPlayerName()

UnicodeString Network::getPlayerName ( Int playerNum)
virtual

Implements NetworkInterface.

Definition at line 991 of file Network.cpp.

◆ getRunAhead()

UnsignedInt Network::getRunAhead ( void )
inlinevirtual

Get the current RunAhead value.

Implements NetworkInterface.

Definition at line 120 of file Network.cpp.

◆ getSlotAverageFPS()

Int Network::getSlotAverageFPS ( Int slot)
virtual

Implements NetworkInterface.

Definition at line 1011 of file Network.cpp.

◆ getUnknownBytesPerSecond()

Real Network::getUnknownBytesPerSecond ( void )
virtual

returns the number of bytes received per second that are not from a generals client averaged over 30 sec.

Implements NetworkInterface.

Definition at line 858 of file Network.cpp.

◆ getUnknownPacketsPerSecond()

Real Network::getUnknownPacketsPerSecond ( void )
virtual

returns the number of packets received per second that are not from a generals client averaged over 30 sec.

Implements NetworkInterface.

Definition at line 869 of file Network.cpp.

◆ init()

void Network::init ( void )
virtual

Initialize or re-initialize the instance.

Initializes all the network subsystems.

<

Todo
: don't hard-code the run-ahead.

Implements NetworkInterface.

Definition at line 324 of file Network.cpp.

◆ initTransport()

void Network::initTransport ( )
virtual

Tell the network to initialize the transport object

Implements NetworkInterface.

Definition at line 441 of file Network.cpp.

◆ isFrameDataReady()

Bool Network::isFrameDataReady ( void )
virtual

Returns true if the game commands for the next frame have been put on the command list.

Implements NetworkInterface.

Definition at line 807 of file Network.cpp.

◆ isPacketRouter()

Bool Network::isPacketRouter ( void )
virtual

Implements NetworkInterface.

Definition at line 948 of file Network.cpp.

◆ isPlayerConnected()

Bool Network::isPlayerConnected ( Int playerID)
virtual

Implements NetworkInterface.

Definition at line 242 of file Network.cpp.

◆ isTransferCommand()

Bool Network::isTransferCommand ( GameMessage * msg)
protected

Is this a command that needs to be transfered to the other clients?

Does this command need to be transfered to the other game clients?

Definition at line 458 of file Network.cpp.

◆ liteupdate()

void Network::liteupdate ( void )
virtual

Do a lightweight update to send packets and pass messages.

Implements NetworkInterface.

Definition at line 726 of file Network.cpp.

◆ loadProgressComplete()

void Network::loadProgressComplete ( void )
virtual

Implements NetworkInterface.

Definition at line 969 of file Network.cpp.

◆ notifyOthersOfCurrentFrame()

void Network::notifyOthersOfCurrentFrame ( )
virtual

Tells all the other players what frame we are on.

Implements NetworkInterface.

Definition at line 1028 of file Network.cpp.

◆ notifyOthersOfNewFrame()

void Network::notifyOthersOfNewFrame ( UnsignedInt frame)
virtual

Tells all the other players that we are on a new frame.

Implements NetworkInterface.

Definition at line 1034 of file Network.cpp.

◆ parseUserList()

void Network::parseUserList ( const GameInfo * game)
virtual

Take a user list and build the connection queues and player lists and stuff like that.

< we zero out m_runAhead frames +1 because the game actually starts at frame 1.

Implements NetworkInterface.

Definition at line 406 of file Network.cpp.

◆ processCommand()

Bool Network::processCommand ( GameMessage * msg)
protected

Whatever needs to be done as a result of this command, do it now.

This is where any processing that needs to be done for specific game messages. Also check here to see if the logic frame number has changed to see if we need to send our info for the last frame to the other players. Return true if the message should be "eaten" by the network.

Definition at line 504 of file Network.cpp.

◆ processDestroyPlayerCommand()

void Network::processDestroyPlayerCommand ( NetDestroyPlayerCommandMsg * msg)
protected

Do what needs to be done when we need to destroy a player.

Definition at line 659 of file Network.cpp.

◆ processFrameSynchronizedNetCommand()

void Network::processFrameSynchronizedNetCommand ( NetCommandRef * msg)
protected

If there is a network command that needs to be executed at the same frame number on all clients, it happens here.

This is where network commands that need to be executed on the same frame should be executed.

Definition at line 619 of file Network.cpp.

◆ processRunAheadCommand()

void Network::processRunAheadCommand ( NetRunAheadCommandMsg * msg)
protected

Do what needs to be done when we get a new run ahead command.

Definition at line 644 of file Network.cpp.

◆ quitGame()

void Network::quitGame ( )
virtual

Quit the game now. This should only be called from the disconnect screen.

Implements NetworkInterface.

Definition at line 928 of file Network.cpp.

◆ RelayCommandsToCommandList()

void Network::RelayCommandsToCommandList ( UnsignedInt frame)
protected

Put the commands for the given frame onto TheCommandList.

Take commands from the connection manager and put them on TheCommandList. The commands need to be put on in the same order across all clients.

Definition at line 585 of file Network.cpp.

◆ reset()

void Network::reset ( void )
virtual

Reinitialize the network.

Takes the network back to the initial state.

Implements NetworkInterface.

Definition at line 317 of file Network.cpp.

◆ sawCRCMismatch()

Bool Network::sawCRCMismatch ( void )
inlinevirtual

Implements NetworkInterface.

Definition at line 172 of file Network.cpp.

◆ selfDestructPlayer()

void Network::selfDestructPlayer ( Int index)
virtual

Implements NetworkInterface.

Definition at line 942 of file Network.cpp.

◆ sendChat()

void Network::sendChat ( UnicodeString text,
Int playerMask )
virtual

Sends a line of chat to the other players

Implements NetworkInterface.

Definition at line 891 of file Network.cpp.

◆ SendCommandsToConnectionManager()

void Network::SendCommandsToConnectionManager ( )
protected

Send the new commands to the ConnectionManager.

◆ sendDisconnectChat()

void Network::sendDisconnectChat ( UnicodeString text)
virtual

Sends a line of chat to the other players using the disconnect manager.

Implements NetworkInterface.

Definition at line 899 of file Network.cpp.

◆ sendFile()

void Network::sendFile ( AsciiString path,
UnsignedByte playerMask,
UnsignedShort commandID )
virtual

Implements NetworkInterface.

Definition at line 904 of file Network.cpp.

◆ sendFileAnnounce()

UnsignedShort Network::sendFileAnnounce ( AsciiString path,
UnsignedByte playerMask )
virtual

Implements NetworkInterface.

Definition at line 910 of file Network.cpp.

◆ sendTimeOutGameStart()

void Network::sendTimeOutGameStart ( void )
virtual

Implements NetworkInterface.

Definition at line 976 of file Network.cpp.

◆ setLocalAddress()

void Network::setLocalAddress ( UnsignedInt ip,
UnsignedInt port )
virtual

Tell the network which ip address the user has chosen to use. Well ok, they probably didn't choose it explicitly, but regardless, this is the one we're going to use.

Implements NetworkInterface.

Definition at line 431 of file Network.cpp.

◆ setSawCRCMismatch()

void Network::setSawCRCMismatch ( void )
virtual

Implements NetworkInterface.

Definition at line 372 of file Network.cpp.

◆ startGame()

void Network::startGame ( void )
virtual

Sets the network game frame counter to -1.

Guess what, we're starting a game!

Implements NetworkInterface.

Definition at line 424 of file Network.cpp.

◆ timeForNewFrame()

Bool Network::timeForNewFrame ( )
protected

Definition at line 760 of file Network.cpp.

◆ update()

void Network::update ( void )
virtual

Process command list.

Service queues, process message stream, etc

Implements NetworkInterface.

Definition at line 684 of file Network.cpp.

◆ updateLoadProgress()

void Network::updateLoadProgress ( Int percent)
virtual

Implements NetworkInterface.

Definition at line 962 of file Network.cpp.

◆ voteForPlayerDisconnect()

void Network::voteForPlayerDisconnect ( Int slot)
virtual

Register a vote towards a player being disconnected.

Implements NetworkInterface.

Definition at line 956 of file Network.cpp.

Member Data Documentation

◆ m_checkCRCsThisFrame

Bool Network::m_checkCRCsThisFrame
protected

Definition at line 216 of file Network.cpp.

◆ m_conMgr

ConnectionManager* Network::m_conMgr
protected

The connection manager object.

Definition at line 198 of file Network.cpp.

◆ m_CRC

std::vector<UnsignedInt> Network::m_CRC[MAX_SLOTS]
protected

Definition at line 218 of file Network.cpp.

◆ m_didSelfSlug

Bool Network::m_didSelfSlug
protected

Definition at line 208 of file Network.cpp.

◆ m_frameDataReady

Bool Network::m_frameDataReady
protected

Is the frame data for the next frame ready to be executed by TheGameLogic?

Definition at line 213 of file Network.cpp.

◆ m_frameRate

Int Network::m_frameRate
protected

Definition at line 205 of file Network.cpp.

◆ m_lastExecutionFrame

Int Network::m_lastExecutionFrame
protected

The highest frame number that a command could have been executed on.

Definition at line 206 of file Network.cpp.

◆ m_lastFrame

UnsignedInt Network::m_lastFrame
protected

The last game logic frame that was processed.

Definition at line 200 of file Network.cpp.

◆ m_lastFrameCompleted

Int Network::m_lastFrameCompleted
protected

Definition at line 207 of file Network.cpp.

◆ m_localStatus

NetLocalStatus Network::m_localStatus
protected

My local status as a player in this game.

Definition at line 202 of file Network.cpp.

◆ m_messageWindow

GameWindow* Network::m_messageWindow
protected

Definition at line 220 of file Network.cpp.

◆ m_nextFrameTime

__int64 Network::m_nextFrameTime
protected

When did we execute the last frame? For slugging the GameLogic...

Definition at line 211 of file Network.cpp.

◆ m_perfCountFreq

__int64 Network::m_perfCountFreq
protected

The frequency of the performance counter.

Definition at line 209 of file Network.cpp.

◆ m_playersToDisconnect

std::list<Int> Network::m_playersToDisconnect
protected

Definition at line 219 of file Network.cpp.

◆ m_runAhead

Int Network::m_runAhead
protected

The current run ahead of the game.

Definition at line 204 of file Network.cpp.

◆ m_sawCRCMismatch

Bool Network::m_sawCRCMismatch
protected

Definition at line 217 of file Network.cpp.


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