_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

network.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 1998-2007 by Lutz Sammer, Russell Smith, and Jimmy Salmon
14 //
15 // This program is free software; you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation; only version 2 of the License.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 // 02111-1307, USA.
28 
29 #ifndef __NETWORK_H__
30 #define __NETWORK_H__
31 
33 
34 /*----------------------------------------------------------------------------
35 -- Includes
36 ----------------------------------------------------------------------------*/
37 
38 #include "network/netsockets.h"
39 
40 /*----------------------------------------------------------------------------
41 -- Declarations
42 ----------------------------------------------------------------------------*/
43 
44 class CUnit;
45 class CUnitType;
46 
48 {
49 public:
51  void FixValues();
52 public:
53  std::string localHost;
54  unsigned int localPort;
55  unsigned int gameCyclesPerUpdate;
56  unsigned int NetworkLag;
57  unsigned int timeoutInS;
58 
59 public:
60  static const int defaultPort = 6660;
61 public:
63 };
64 
65 /*----------------------------------------------------------------------------
66 -- Variables
67 ----------------------------------------------------------------------------*/
68 
70 extern bool NetworkInSync;
71 
72 /*----------------------------------------------------------------------------
73 -- Functions
74 ----------------------------------------------------------------------------*/
75 
76 extern inline bool IsNetworkGame() { return NetworkFildes.IsValid(); }
77 extern void InitNetwork1();
78 extern void ExitNetwork1();
79 extern void NetworkOnStartGame();
80 extern void NetworkEvent();
81 extern void NetworkSync();
82 extern void NetworkQuitGame();
83 extern void NetworkRecover();
84 extern void NetworkCommands();
85 extern void NetworkSendChatMessage(const std::string &msg);
86 extern void NetworkSendCommand(int command, const CUnit &unit, int x,
88  int y, const CUnit *dest, const CUnitType *type, int status);
90 extern void NetworkSendExtendedCommand(int command, int arg1, int arg2,
91  int arg3, int arg4, int status);
93 extern void NetworkSendSelection(CUnit **units, int count);
94 
95 extern void NetworkCclRegister();
96 
98 
99 #endif // !__NETWORK_H__
NetworkCommands
void NetworkCommands()
Recover network.
Definition: network.cpp:1129
NetworkRecover
void NetworkRecover()
Quit game: warn other users.
Definition: network.cpp:1207
InitNetwork1
void InitNetwork1()
Definition: network.cpp:409
NetworkSendChatMessage
void NetworkSendChatMessage(const std::string &msg)
Get all network commands.
Definition: network.cpp:648
NetworkFildes
CUDPSocket NetworkFildes
Network is in sync.
Definition: network.cpp:298
CNetworkParameter::NetworkLag
unsigned int NetworkLag
Network update each # game cycles.
Definition: network.h:56
CUDPSocket
Definition: netsockets.h:57
CNetworkParameter::Instance
static CNetworkParameter Instance
Default communication port.
Definition: network.h:62
NetworkSendExtendedCommand
void NetworkSendExtendedCommand(int command, int arg1, int arg2, int arg3, int arg4, int status)
Send extended network command.
Definition: network.cpp:585
CNetworkParameter::CNetworkParameter
CNetworkParameter()
Definition: network.cpp:281
CUDPSocket::IsValid
bool IsValid() const
Definition: netsockets.cpp:174
NetworkSendCommand
void NetworkSendCommand(int command, const CUnit &unit, int x, int y, const CUnit *dest, const CUnitType *type, int status)
Send network command.
Definition: network.cpp:542
CNetworkParameter::timeoutInS
unsigned int timeoutInS
Network lag (# update cycles)
Definition: network.h:57
CUnitType
Definition: unittype.h:508
CNetworkParameter::FixValues
void FixValues()
Definition: network.cpp:290
ExitNetwork1
void ExitNetwork1()
Initialise network.
Definition: network.cpp:449
NetworkCclRegister
void NetworkCclRegister()
Definition: netconnect.cpp:2096
CNetworkParameter::defaultPort
static const int defaultPort
Number of seconds until player times out.
Definition: network.h:60
IsNetworkGame
bool IsNetworkGame()
Network is in sync.
Definition: network.h:76
CNetworkParameter::localPort
unsigned int localPort
Local network address to use.
Definition: network.h:54
CNetworkParameter::localHost
std::string localHost
Definition: network.h:53
NetworkEvent
void NetworkEvent()
Initialise network data for ingame communication.
Definition: network.cpp:872
NetworkQuitGame
void NetworkQuitGame()
Hold in sync.
Definition: network.cpp:909
NetworkSendSelection
void NetworkSendSelection(CUnit **units, int count)
Send Selections to Team.
Definition: network.cpp:612
netsockets.h
NetworkSync
void NetworkSync()
Handle network events.
NetworkInSync
bool NetworkInSync
Network file descriptor.
Definition: network.cpp:296
CUnit
The big unit structure.
Definition: unit.h:135
CNetworkParameter::gameCyclesPerUpdate
unsigned int gameCyclesPerUpdate
Local network port to use.
Definition: network.h:55
NetworkOnStartGame
void NetworkOnStartGame()
Cleanup network (port)
Definition: network.cpp:471
CNetworkParameter
Definition: network.h:47
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.