____                _       __
    / __ )____  _____   | |     / /___ ___________
   / __  / __ \/ ___/   | | /| / / __ `/ ___/ ___/
  / /_/ / /_/ (__  )    | |/ |/ / /_/ / /  (__  )
 /_____/\____/____/     |__/|__/\__,_/_/  /____/

       A futuristic real-time strategy game.
          This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project. Distributed under the "GNU General Public License"

network.h File Reference

The network header file. More...

#include "unit.h"
#include "net_lowlevel.h"

Go to the source code of this file.

Classes

class  CNetworkCommand
class  CNetworkExtendedCommand
class  CNetworkChat
struct  _network_selection_header_
class  CNetworkSelection
class  CNetworkPacketHeader
class  CNetworkPacket

Defines

#define MaxNetworkCommands   9
 Max Commands In A Packet.
#define IsNetworkGame()   (NetworkFildes != (Socket)-1)

Typedefs

typedef struct
_network_selection_header_ 
NetworkSelectionHeader

Enumerations

enum  _message_type_ {
  MessageNone, MessageInitHello, MessageInitReply, MessageInitConfig,
  MessageSync, MessageSelection, MessageQuit, MessageQuitAck,
  MessageResend, MessageChat, MessageChatTerm, MessageCommandStop,
  MessageCommandStand, MessageCommandFollow, MessageCommandMove, MessageCommandRepair,
  MessageCommandAutoRepair, MessageCommandAttack, MessageCommandGround, MessageCommandPatrol,
  MessageCommandBoard, MessageCommandUnload, MessageCommandBuild, MessageCommandDismiss,
  MessageCommandResource, MessageCommandReturn, MessageCommandTrain, MessageCommandCancelTrain,
  MessageExtendedCommand, MessageCommandSpellCast
}
enum  _extended_message_type_ { ExtendedMessageDiplomacy, ExtendedMessageSharedVision }

Functions

void InitNetwork1 (void)
 Initialise network part 1 (ports).
void InitNetwork2 (void)
 Initialise network part 2.
void ExitNetwork1 (void)
 Cleanup network part 1 (ports).
void NetworkEvent (void)
 Handle network events.
void NetworkSync (void)
 Hold in sync.
void NetworkQuit (void)
 Quit game.
void NetworkRecover (void)
 Recover network.
void NetworkCommands (void)
 Get all network commands.
void NetworkChatMessage (const std::string &msg)
 Send network command.
void NetworkSendCommand (int command, const CUnit *unit, int x, int y, const CUnit *dest, const CUnitType *type, int status)
 Send extended network command.
void NetworkSendExtendedCommand (int command, int arg1, int arg2, int arg3, int arg4, int status)
 Send Selections to Team.
void NetworkSendSelection (CUnit **units, int count)

Variables

int NetworkNumInterfaces
 Network number of interfaces.
Socket NetworkFildes
 Network file descriptor.
int NetworkInSync
 Network is in sync.
int NetworkUpdates
 Network update each # game cycles.
int NetworkLag
 Network lag (# game cycles).
unsigned long NetworkStatus [PlayerMax]
 Network status.
int NoRandomPlacementMultiplayer
 Removes randomization of player placements.


Detailed Description

The network header file.

Definition in file network.h.


Define Documentation

 
#define IsNetworkGame (  )     (NetworkFildes != (Socket)-1)

#define MaxNetworkCommands   9


Typedef Documentation

Network Selection Info


Enumeration Type Documentation

Network extended message types.

Enumerator:
ExtendedMessageDiplomacy  Change diplomacy.
ExtendedMessageSharedVision  Change shared vision.

Definition at line 102 of file network.h.

Network message types.

Todo:
cleanup the message types.
Enumerator:
MessageNone  When Nothing Is Happening.
MessageInitHello  Start connection.
MessageInitReply  Connection reply.
MessageInitConfig  Setup message configure clients.
MessageSync  Heart beat.
MessageSelection  Update a Selection from Team Player.
MessageQuit  Quit game.
MessageQuitAck  Quit reply - UNUSED YET - Protocol Version 2 - Reserved for menus.
MessageResend  Resend message.
MessageChat  Chat message.
MessageChatTerm  Chat message termination - Protocol Version 2.
MessageCommandStop  Unit command stop.
MessageCommandStand  Unit command stand ground.
MessageCommandFollow  Unit command follow.
MessageCommandMove  Unit command move.
MessageCommandRepair  Unit command repair.
MessageCommandAutoRepair  Unit command autorepair.
MessageCommandAttack  Unit command attack.
MessageCommandGround  Unit command attack ground.
MessageCommandPatrol  Unit command patrol.
MessageCommandBoard  Unit command borad.
MessageCommandUnload  Unit command unload.
MessageCommandBuild  Unit command build building.
MessageCommandDismiss  Unit command dismiss unit.
MessageCommandResource  Unit command resource.
MessageCommandReturn  Unit command return goods.
MessageCommandTrain  Unit command train.
MessageCommandCancelTrain  Unit command cancel training.
MessageExtendedCommand  Command is the next byte.
MessageCommandSpellCast  Unit command spell cast.

Definition at line 60 of file network.h.


Function Documentation

void ExitNetwork1 ( void   ) 

Cleanup network part 1 (ports).

Cleanup network part 1. (to be called _AFTER_ part 2 :)

Definition at line 573 of file network.cpp.

References _C_, DebugPrint, HostsCount, IsNetworkGame, NetCloseUDP(), NetExit(), NetPlayers, NetworkFildes, and NetworkInSync.

Referenced by ApplyReplaySettings(), Exit(), InitNetwork1(), and tolua_stratagus_ExitNetwork100().

void InitNetwork1 ( void   ) 

void InitNetwork2 ( void   ) 

void NetworkChatMessage ( const std::string &  msg  ) 

Send network command.

Send chat message

Send chat message. (Message is sent with low priority)

Parameters:
msg Text message to send.

Definition at line 1121 of file network.cpp.

References AllocNCQ(), CNetworkCommandQueue::Data, CPlayer::Index, IsNetworkGame, MessageChat, MessageChatTerm, MsgCommandsIn, CNetworkChat::Player, CNetworkChat::Text, ThisPlayer, and CNetworkCommandQueue::Type.

Referenced by InputKey().

void NetworkCommands ( void   ) 

Get all network commands.

Handle network commands.

Definition at line 1360 of file network.cpp.

References GameCycle, IsNetworkGame, NetworkExecCommands(), NetworkSendCommands(), NetworkSyncCommands(), and NetworkUpdates.

Referenced by GameMainLoop().

void NetworkEvent ( void   ) 

void NetworkQuit ( void   ) 

void NetworkRecover ( void   ) 

void NetworkSendCommand ( int  command,
const CUnit unit,
int  x,
int  y,
const CUnit dest,
const CUnitType type,
int  status 
)

Send extended network command.

Prepare send of command message.

Convert arguments into network format and place it into output queue.

Parameters:
command Command (Move,Attack,...).
unit Unit that receive the command.
x optional X map position.
y optional y map position.
dest optional destination unit.
type optional unit-type argument.
status Append command or flush old commands.
Warning:
Destination and unit-type shares the same network slot.

Definition at line 672 of file network.cpp.

References AllocNCQ(), Assert, CommandsIn, CNetworkCommandQueue::Data, CNetworkCommand::Dest, GameCycle, CUnitType::Slot, CUnit::Slot, CNetworkCommandQueue::Time, CNetworkCommandQueue::Type, CNetworkCommand::Unit, CNetworkCommand::X, and CNetworkCommand::Y.

Referenced by SendCommandAttack(), SendCommandAttackGround(), SendCommandAutoRepair(), SendCommandAutoSpellCast(), SendCommandBoard(), SendCommandBuildBuilding(), SendCommandCancelTraining(), SendCommandDismiss(), SendCommandFollow(), SendCommandMove(), SendCommandPatrol(), SendCommandRepair(), SendCommandResource(), SendCommandSpellCast(), SendCommandStandGround(), SendCommandStopUnit(), SendCommandTrainUnit(), and SendCommandUnload().

void NetworkSendExtendedCommand ( int  command,
int  arg1,
int  arg2,
int  arg3,
int  arg4,
int  status 
)

Send Selections to Team.

Prepare send of extended command message.

Convert arguments into network format and place it into output queue.

Parameters:
command Command (Move,Attack,...).
arg1 optional argument #1
arg2 optional argument #2
arg3 optional argument #3
arg4 optional argument #4
status Append command or flush old commands.

Definition at line 729 of file network.cpp.

References AllocNCQ(), CNetworkExtendedCommand::Arg1, CNetworkExtendedCommand::Arg2, CNetworkExtendedCommand::Arg3, CNetworkExtendedCommand::Arg4, CommandsIn, CNetworkCommandQueue::Data, CNetworkExtendedCommand::ExtendedType, GameCycle, MessageExtendedCommand, CNetworkCommandQueue::Time, and CNetworkCommandQueue::Type.

Referenced by SendCommandDiplomacy(), and SendCommandSharedVision().

void NetworkSendSelection ( CUnit **  units,
int  count 
)

void NetworkSync ( void   ) 

Hold in sync.


Variable Documentation

Network is in sync.

Definition at line 260 of file network.cpp.

Referenced by ExitNetwork1(), GameMainLoop(), InitNetwork1(), NetworkEvent(), NetworkRecover(), and NetworkSyncCommands().

Network lag (# game cycles).

Definition at line 262 of file network.cpp.

Referenced by ClientParseConnecting(), InitNetwork1(), InitNetwork2(), main(), NetworkQuit(), NetworkSendCommands(), and NetworkSendICMessage().

Network number of interfaces.

Definition at line 258 of file network.cpp.

Referenced by InitNetwork1().

unsigned long NetworkStatus[PlayerMax]

Network status.

Definition at line 263 of file network.cpp.

Referenced by InitNetwork2(), and NetworkEvent().

Removes randomization of player placements.

Definition at line 76 of file script.cpp.

Referenced by CclNoRandomPlacementMultiplayer(), and NetworkServerStartGame().


Generated on Sat Feb 21 00:28:18 2009 for Bos Wars by  doxygen 1.5.6