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

#include <ConnectionManager.h>

Public Member Functions

 ConnectionManager ()
 
 ~ConnectionManager ()
 
virtual void init ()
 Initialize this instance.
 
virtual void reset ()
 Take this instance back to the initial state.
 
virtual void update (Bool isInGame)
 Service the Connections being managed by this instance.
 
void updateRunAhead (Int oldRunAhead, Int frameRate, Bool didSelfSlug, Int nextExecutionFrame)
 Update the run ahead value. If we are the current packet router, issue the command.
 
void attachTransport (Transport *transport)
 
void parseUserList (const GameInfo *game)
 
void sendChat (UnicodeString text, Int playerMask, UnsignedInt executionFrame)
 
void sendDisconnectChat (UnicodeString text)
 
void sendLocalCommand (NetCommandMsg *msg, UnsignedByte relay=0xff)
 Send command to the players specified in the relay, goes through packet router.
 
void sendLocalCommandDirect (NetCommandMsg *msg, UnsignedByte relay)
 Send command directly to the players specified, doesn't go through packet router.
 
void sendLocalGameMessage (GameMessage *msg, UnsignedInt frame)
 
void sendCommand (NetCommandMsg *msg)
 
Bool allCommandsReady (UnsignedInt frame, Bool justTesting=FALSE)
 
void handleAllCommandsReady (void)
 
NetCommandListgetFrameCommandList (UnsignedInt frame)
 
void determineRouterFallbackPlan ()
 
void zeroFrames (UnsignedInt startingFrame, UnsignedInt numFrames)
 
void destroyGameMessages ()
 
void setLocalAddress (UnsignedInt ip, UnsignedInt port)
 
void initTransport ()
 
void processFrameTick (UnsignedInt frame)
 
void handleLocalPlayerLeaving (UnsignedInt frame)
 
void sendFile (AsciiString path, UnsignedByte playerMask, UnsignedShort commandID)
 
UnsignedShort sendFileAnnounce (AsciiString path, UnsignedByte playerMask)
 
Int getFileTransferProgress (Int playerID, AsciiString path)
 
Bool areAllQueuesEmpty (void)
 
UnsignedInt getLocalPlayerID ()
 
UnicodeString getPlayerName (Int playerNum)
 
Int getNumPlayers ()
 
UnsignedInt getPacketRouterFallbackSlot (Int packetRouterNumber)
 Returns the slot of the given packet router number in the fallback plan.
 
UnsignedInt getPacketRouterSlot ()
 Returns the current packet router's slot.
 
PlayerLeaveCode disconnectPlayer (Int slot)
 Disconnect this player immediately. This should only be called by the disconnect manager.
 
void disconnectLocalPlayer ()
 Does whatever is necessary to get TheNetwork to realize that it should be leaving the game now.
 
void quitGame ()
 Disconnect from the game RIGHT NOW!! Tell everyone else we are disconnecting.
 
void voteForPlayerDisconnect (Int slot)
 Register a vote for a player to be disconnected.
 
void resendPendingCommands ()
 Resend the pending commands to the packet router.
 
void setFrameGrouping (time_t frameGrouping)
 Set the number of frames that are grouped together into packets.
 
PlayerLeaveCode processPlayerLeave (NetPlayerLeaveCommandMsg *msg)
 
Bool canILeave ()
 Returns true if the local player is allowed to leave.
 
Real getIncomingBytesPerSecond (void)
 
Real getIncomingPacketsPerSecond (void)
 
Real getOutgoingBytesPerSecond (void)
 
Real getOutgoingPacketsPerSecond (void)
 
Real getUnknownBytesPerSecond (void)
 
Real getUnknownPacketsPerSecond (void)
 
UnsignedInt getPacketArrivalCushion (void)
 
UnsignedInt getMinimumCushion ()
 
void flushConnections ()
 
void processChat (NetChatCommandMsg *msg)
 
void updateLoadProgress (Int progress)
 
void loadProgressComplete (void)
 
void sendTimeOutGameStart (void)
 
Bool isPacketRouter (void)
 
Bool isPlayerConnected (Int playerID)
 
void notifyOthersOfCurrentFrame (Int frame)
 
void sendFrameDataToPlayer (UnsignedInt playerID, UnsignedInt startingFrame)
 
void sendSingleFrameToPlayer (UnsignedInt playerID, UnsignedInt frame)
 
void notifyOthersOfNewFrame (UnsignedInt frame)
 
UnsignedInt getNextPacketRouterSlot (UnsignedInt playerID)
 returns the packet router player that comes after the given player.
 
Int getAverageFPS (void)
 
Int getSlotAverageFPS (Int slot)
 
UnsignedInt getPingFrame ()
 
Int getPingsSent ()
 
Int getPingsRecieved ()
 

Detailed Description

Definition at line 50 of file ConnectionManager.h.

Constructor & Destructor Documentation

◆ ConnectionManager()

ConnectionManager::ConnectionManager ( void )

Le constructor

Definition at line 128 of file ConnectionManager.cpp.

◆ ~ConnectionManager()

ConnectionManager::~ConnectionManager ( void )

Le destructor.

Definition at line 65 of file ConnectionManager.cpp.

Member Function Documentation

◆ allCommandsReady()

Bool ConnectionManager::allCommandsReady ( UnsignedInt frame,
Bool justTesting = FALSE )

Returns true if all the commands for the given frame are ready to be executed.

Definition at line 1552 of file ConnectionManager.cpp.

◆ areAllQueuesEmpty()

Bool ConnectionManager::areAllQueuesEmpty ( void )

Definition at line 976 of file ConnectionManager.cpp.

◆ attachTransport()

void ConnectionManager::attachTransport ( Transport * transport)

Definition at line 305 of file ConnectionManager.cpp.

◆ canILeave()

Bool ConnectionManager::canILeave ( )

Returns true if the local player is allowed to leave.

Definition at line 991 of file ConnectionManager.cpp.

◆ destroyGameMessages()

void ConnectionManager::destroyGameMessages ( )

Destroy any game messages that are left over due to the run ahead.

Definition at line 329 of file ConnectionManager.cpp.

◆ determineRouterFallbackPlan()

void ConnectionManager::determineRouterFallbackPlan ( )

◆ disconnectLocalPlayer()

void ConnectionManager::disconnectLocalPlayer ( )

Does whatever is necessary to get TheNetwork to realize that it should be leaving the game now.

Definition at line 1792 of file ConnectionManager.cpp.

◆ disconnectPlayer()

PlayerLeaveCode ConnectionManager::disconnectPlayer ( Int slot)

Disconnect this player immediately. This should only be called by the disconnect manager.

Definition at line 1697 of file ConnectionManager.cpp.

◆ flushConnections()

void ConnectionManager::flushConnections ( )

Takes all the commands that are ready to send and sends them right now.

Definition at line 1805 of file ConnectionManager.cpp.

◆ getAverageFPS()

Int ConnectionManager::getAverageFPS ( void )

Definition at line 2297 of file ConnectionManager.cpp.

◆ getFileTransferProgress()

Int ConnectionManager::getFileTransferProgress ( Int playerID,
AsciiString path )

Definition at line 2212 of file ConnectionManager.cpp.

◆ getFrameCommandList()

NetCommandList * ConnectionManager::getFrameCommandList ( UnsignedInt frame)

Only call this after making sure that all the commands are there for this frame. After calling this the commands for this frame will be removed from the connection.

BGC - To account for the case where the host disconnects without sending the same commands to all players, we now have to keep around the last 'run ahead' frames so we can potentially send those commands to the other players in the game so they can catch up.

Definition at line 1613 of file ConnectionManager.cpp.

◆ getIncomingBytesPerSecond()

Real ConnectionManager::getIncomingBytesPerSecond ( void )

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

Definition at line 2000 of file ConnectionManager.cpp.

◆ getIncomingPacketsPerSecond()

Real ConnectionManager::getIncomingPacketsPerSecond ( void )

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

Definition at line 2011 of file ConnectionManager.cpp.

◆ getLocalPlayerID()

UnsignedInt ConnectionManager::getLocalPlayerID ( )

Definition at line 1837 of file ConnectionManager.cpp.

◆ getMinimumCushion()

UnsignedInt ConnectionManager::getMinimumCushion ( )

Definition at line 1395 of file ConnectionManager.cpp.

◆ getNextPacketRouterSlot()

UnsignedInt ConnectionManager::getNextPacketRouterSlot ( UnsignedInt playerID)

returns the packet router player that comes after the given player.

Definition at line 2412 of file ConnectionManager.cpp.

◆ getNumPlayers()

Int ConnectionManager::getNumPlayers ( )

Definition at line 2237 of file ConnectionManager.cpp.

◆ getOutgoingBytesPerSecond()

Real ConnectionManager::getOutgoingBytesPerSecond ( void )

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

Definition at line 2022 of file ConnectionManager.cpp.

◆ getOutgoingPacketsPerSecond()

Real ConnectionManager::getOutgoingPacketsPerSecond ( void )

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

Definition at line 2033 of file ConnectionManager.cpp.

◆ getPacketArrivalCushion()

UnsignedInt ConnectionManager::getPacketArrivalCushion ( void )

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

Definition at line 2067 of file ConnectionManager.cpp.

◆ getPacketRouterFallbackSlot()

UnsignedInt ConnectionManager::getPacketRouterFallbackSlot ( Int packetRouterNumber)

Returns the slot of the given packet router number in the fallback plan.

Definition at line 965 of file ConnectionManager.cpp.

◆ getPacketRouterSlot()

UnsignedInt ConnectionManager::getPacketRouterSlot ( )

Returns the current packet router's slot.

Definition at line 972 of file ConnectionManager.cpp.

◆ getPingFrame()

UnsignedInt ConnectionManager::getPingFrame ( )

Definition at line 285 of file ConnectionManager.cpp.

◆ getPingsRecieved()

Int ConnectionManager::getPingsRecieved ( )

Definition at line 295 of file ConnectionManager.cpp.

◆ getPingsSent()

Int ConnectionManager::getPingsSent ( )

Definition at line 290 of file ConnectionManager.cpp.

◆ getPlayerName()

UnicodeString ConnectionManager::getPlayerName ( Int playerNum)

Definition at line 1841 of file ConnectionManager.cpp.

◆ getSlotAverageFPS()

Int ConnectionManager::getSlotAverageFPS ( Int slot)

Definition at line 2302 of file ConnectionManager.cpp.

◆ getUnknownBytesPerSecond()

Real ConnectionManager::getUnknownBytesPerSecond ( void )

Return the number of bytes not from generals clients received per second averaged over the last 30 sec.

Definition at line 2045 of file ConnectionManager.cpp.

◆ getUnknownPacketsPerSecond()

Real ConnectionManager::getUnknownPacketsPerSecond ( void )

Return the number ov packets not from generals clients received per second averaged over the last 30 sec.

Definition at line 2056 of file ConnectionManager.cpp.

◆ handleAllCommandsReady()

void ConnectionManager::handleAllCommandsReady ( void )

Definition at line 1598 of file ConnectionManager.cpp.

◆ handleLocalPlayerLeaving()

void ConnectionManager::handleLocalPlayerLeaving ( UnsignedInt frame)

The local player is leaving. Tell the local player as well as the other players to remove this player at the specified frame.

Definition at line 999 of file ConnectionManager.cpp.

◆ init()

void ConnectionManager::init ( )
virtual

Initialize this instance.

Initialize the connection manager and any subsystems.

Todo
The LAN/WOL interface should be telling us who the packet router is based on machine specs passed around through game options.

Definition at line 147 of file ConnectionManager.cpp.

◆ initTransport()

void ConnectionManager::initTransport ( )

Initialize the transport object

Definition at line 1437 of file ConnectionManager.cpp.

◆ isPacketRouter()

Bool ConnectionManager::isPacketRouter ( void )

Definition at line 2292 of file ConnectionManager.cpp.

◆ isPlayerConnected()

Bool ConnectionManager::isPlayerConnected ( Int playerID)

Definition at line 300 of file ConnectionManager.cpp.

◆ loadProgressComplete()

void ConnectionManager::loadProgressComplete ( void )

Definition at line 2264 of file ConnectionManager.cpp.

◆ notifyOthersOfCurrentFrame()

void ConnectionManager::notifyOthersOfCurrentFrame ( Int frame)

Definition at line 2327 of file ConnectionManager.cpp.

◆ notifyOthersOfNewFrame()

void ConnectionManager::notifyOthersOfNewFrame ( UnsignedInt frame)

Definition at line 2351 of file ConnectionManager.cpp.

◆ parseUserList()

void ConnectionManager::parseUserList ( const GameInfo * game)

Take a user list and make connections and frame data manager objects for each of the players. For now, this is also how we'll determine the packet router fallback plan.

Definition at line 1855 of file ConnectionManager.cpp.

◆ processChat()

void ConnectionManager::processChat ( NetChatCommandMsg * msg)

Definition at line 639 of file ConnectionManager.cpp.

◆ processFrameTick()

void ConnectionManager::processFrameTick ( UnsignedInt frame)

The commands for the given frame are all ready, time to send out our command count for that frame.

Definition at line 1402 of file ConnectionManager.cpp.

◆ processPlayerLeave()

PlayerLeaveCode ConnectionManager::processPlayerLeave ( NetPlayerLeaveCommandMsg * msg)

A player has just left our game. Delete their connection and frame data manager. return codes are: PLAYERLEAVECODE_UNKNOWN - player didn't have a valid slot number. PLAYERLEAVECODE_CLIENT - someone in the game that wasn't us or the packet router. PLAYERLEAVECODE_LOCAL - We are leaving the game, we could also be the packet router. PLAYERLEAVECODE_PACKETROUTER - The packet router left the game.

If we are leaving and are also the packet router, it will return the PLAYERLEAVECODE_LOCAL return code.

Definition at line 931 of file ConnectionManager.cpp.

◆ quitGame()

void ConnectionManager::quitGame ( )

Disconnect from the game RIGHT NOW!! Tell everyone else we are disconnecting.

Definition at line 1772 of file ConnectionManager.cpp.

◆ resendPendingCommands()

void ConnectionManager::resendPendingCommands ( )

Resend the pending commands to the packet router.

Definition at line 1823 of file ConnectionManager.cpp.

◆ reset()

void ConnectionManager::reset ( )
virtual

Take this instance back to the initial state.

Reset the connection manager and any subsystems.

Definition at line 221 of file ConnectionManager.cpp.

◆ sendChat()

void ConnectionManager::sendChat ( UnicodeString text,
Int playerMask,
UnsignedInt executionFrame )

Definition at line 2073 of file ConnectionManager.cpp.

◆ sendCommand()

void ConnectionManager::sendCommand ( NetCommandMsg * msg)

◆ sendDisconnectChat()

void ConnectionManager::sendDisconnectChat ( UnicodeString text)

Definition at line 2093 of file ConnectionManager.cpp.

◆ sendFile()

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

Definition at line 2143 of file ConnectionManager.cpp.

◆ sendFileAnnounce()

UnsignedShort ConnectionManager::sendFileAnnounce ( AsciiString path,
UnsignedByte playerMask )

Definition at line 2105 of file ConnectionManager.cpp.

◆ sendFrameDataToPlayer()

void ConnectionManager::sendFrameDataToPlayer ( UnsignedInt playerID,
UnsignedInt startingFrame )

Definition at line 2369 of file ConnectionManager.cpp.

◆ sendLocalCommand()

void ConnectionManager::sendLocalCommand ( NetCommandMsg * msg,
UnsignedByte relay = 0xff )

Send command to the players specified in the relay, goes through packet router.

This is a NetCommandMsg that originated on the local computer. Send this to everyone specified in the relay field. Commands sent in this way go through the packet router.

Definition at line 1474 of file ConnectionManager.cpp.

◆ sendLocalCommandDirect()

void ConnectionManager::sendLocalCommandDirect ( NetCommandMsg * msg,
UnsignedByte relay )

Send command directly to the players specified, doesn't go through packet router.

This is a NetCommandMsg that originated on the local computer. Send this to everyone specified in the relay field. Commands sent in this way do not go through the packet router.

Definition at line 1524 of file ConnectionManager.cpp.

◆ sendLocalGameMessage()

void ConnectionManager::sendLocalGameMessage ( GameMessage * msg,
UnsignedInt frame )

This is where the commands from the local client are sent to the other clients in the game. This is also where the local commands are put into the frame data for future execution.

Definition at line 1454 of file ConnectionManager.cpp.

◆ sendSingleFrameToPlayer()

void ConnectionManager::sendSingleFrameToPlayer ( UnsignedInt playerID,
UnsignedInt frame )

Definition at line 2377 of file ConnectionManager.cpp.

◆ sendTimeOutGameStart()

void ConnectionManager::sendTimeOutGameStart ( void )

Definition at line 2278 of file ConnectionManager.cpp.

◆ setFrameGrouping()

void ConnectionManager::setFrameGrouping ( time_t frameGrouping)

Set the number of frames that are grouped together into packets.

Definition at line 1633 of file ConnectionManager.cpp.

◆ setLocalAddress()

void ConnectionManager::setLocalAddress ( UnsignedInt ip,
UnsignedInt port )

Set the local address.

Definition at line 1428 of file ConnectionManager.cpp.

◆ update()

void ConnectionManager::update ( Bool isInGame)
virtual

Service the Connections being managed by this instance.

ConnectionManager::update Update the connections. Tell them to do the receive and send. Also relay commands to their final destinations as necessary.

Definition at line 1156 of file ConnectionManager.cpp.

◆ updateLoadProgress()

void ConnectionManager::updateLoadProgress ( Int progress)

Definition at line 2250 of file ConnectionManager.cpp.

◆ updateRunAhead()

void ConnectionManager::updateRunAhead ( Int oldRunAhead,
Int frameRate,
Bool didSelfSlug,
Int nextExecutionFrame )

Update the run ahead value. If we are the current packet router, issue the command.

Definition at line 1213 of file ConnectionManager.cpp.

◆ voteForPlayerDisconnect()

void ConnectionManager::voteForPlayerDisconnect ( Int slot)

Register a vote for a player to be disconnected.

Definition at line 2231 of file ConnectionManager.cpp.

◆ zeroFrames()

void ConnectionManager::zeroFrames ( UnsignedInt startingFrame,
UnsignedInt numFrames )

zero out the command counts for the given frames. Presently this is used for the start of a game since there won't be any commands for the first few frames due to runahead.

Definition at line 317 of file ConnectionManager.cpp.


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