$treeview $search $mathjax
Stratagus
2.2.6
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
00001 // _________ __ __ 00002 // / _____// |_____________ _/ |______ ____ __ __ ______ 00003 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ 00004 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | 00005 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > 00006 // \/ \/ \//_____/ \/ 00007 // ______________________ ______________________ 00008 // T H E W A R B E G I N S 00009 // Stratagus - A free fantasy real time strategy game engine 00010 // 00012 // 00013 // (c) Copyright 1998-2008 by Lutz Sammer, Andreas Arens, and Jimmy Salmon 00014 // 00015 // This program is free software; you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation; only version 2 of the License. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 00029 #ifndef __NETCONNECT_H__ 00030 #define __NETCONNECT_H__ 00031 00033 00034 #include <string> 00035 #include "SDL.h" 00036 00037 /*---------------------------------------------------------------------------- 00038 -- Defines 00039 ----------------------------------------------------------------------------*/ 00040 00042 #define NetworkProtocolMajorVersion StratagusMajorVersion 00044 #define NetworkProtocolMinorVersion StratagusMinorVersion 00046 #define NetworkProtocolPatchLevel StratagusPatchLevel 00048 #define NetworkProtocolVersion \ 00049 (NetworkProtocolMajorVersion * 10000 + NetworkProtocolMinorVersion * 100 + \ 00050 NetworkProtocolPatchLevel) 00051 00053 #define NetworkProtocolFormatString "%d.%d.%d" 00055 #define NetworkProtocolFormatArgs(v) (v) / 10000, ((v) / 100) % 100, (v) % 100 00056 00057 #define NetworkDefaultPort 6660 00058 00059 /*---------------------------------------------------------------------------- 00060 -- Declarations 00061 ----------------------------------------------------------------------------*/ 00062 00066 class CNetworkHost { 00067 public: 00068 unsigned char *Serialize() const; 00069 void Deserialize(const unsigned char *p); 00070 static size_t Size() { return 4+2+2+16; } 00071 00072 Uint32 Host; 00073 Uint16 Port; 00074 Uint16 PlyNr; 00075 char PlyName[16]; 00076 }; 00077 00081 typedef struct _network_state_ { 00082 unsigned char State; 00083 unsigned short MsgCnt; 00084 // Fill in here... 00085 } NetworkState; 00086 00090 class CServerSetup { 00091 public: 00092 unsigned char *Serialize() const; 00093 void Deserialize(const unsigned char *p); 00094 static size_t Size() { return 4+4+4+4+4+4+4+4+ 4*PlayerMax + 4*PlayerMax + 4*PlayerMax + 4*PlayerMax; } 00095 void Clear() { 00096 ResourcesOption = UnitsOption = FogOfWar = RevealMap = TilesetSelection = 00097 GameTypeOption = Difficulty = MapRichness = 0; 00098 memset(CompOpt, 0, sizeof(CompOpt)); 00099 memset(Ready, 0, sizeof(Ready)); 00100 memset(LastFrame, 0, sizeof(LastFrame)); 00101 } 00102 00103 Uint32 ResourcesOption; 00104 Uint32 UnitsOption; 00105 Uint32 FogOfWar; 00106 Uint32 RevealMap; 00107 Uint32 TilesetSelection; 00108 Uint32 GameTypeOption; 00109 Uint32 Difficulty; 00110 Uint32 MapRichness; 00111 Uint32 CompOpt[PlayerMax]; 00112 Uint32 Ready[PlayerMax]; 00113 Uint32 Race[PlayerMax]; 00114 Uint32 LastFrame[PlayerMax]; 00115 // Fill in here... 00116 }; 00117 00124 class CInitMessage { 00125 public: 00126 unsigned char *Serialize() const; 00127 void Deserialize(const unsigned char *p); 00128 static size_t Size() { return 1+1+4+4+4+4+4+4+1+256 + CNetworkHost::Size()*PlayerMax + CServerSetup::Size(); } 00129 00130 Uint8 Type; 00131 Uint8 SubType; 00132 Sint32 Stratagus; 00133 Sint32 Version; 00134 Uint32 ConfUID; 00135 Uint32 MapUID; 00136 Sint32 Lag; 00137 Sint32 Updates; 00138 Uint8 HostsCount; 00139 00140 union { 00141 CNetworkHost Hosts[PlayerMax]; 00142 char MapPath[256]; 00143 CServerSetup State; 00144 } u; 00145 }; 00146 00150 enum _ic_message_subtype_ { 00151 ICMHello, 00152 ICMConfig, 00153 00154 ICMEngineMismatch, 00155 ICMProtocolMismatch, 00156 ICMEngineConfMismatch, 00157 ICMMapUidMismatch, 00158 00159 ICMGameFull, 00160 ICMWelcome, 00161 00162 ICMWaiting, 00163 ICMMap, 00164 ICMState, 00165 ICMResync, 00166 00167 ICMServerQuit, 00168 ICMGoodBye, 00169 ICMSeeYou, 00170 00171 ICMGo, 00172 00173 ICMAYT, 00174 ICMIAH 00175 }; 00176 00180 enum _net_client_con_state_ { 00181 ccs_unused = 0, 00182 ccs_connecting, 00183 ccs_connected, 00184 ccs_mapinfo, 00185 ccs_badmap, 00186 ccs_synced, 00187 ccs_async, 00188 ccs_changed, 00189 ccs_detaching, 00190 ccs_disconnected, 00191 ccs_unreachable, 00192 ccs_usercanceled, 00193 ccs_nofreeslots, 00194 ccs_serverquits, 00195 ccs_goahead, 00196 ccs_started, 00197 ccs_incompatibleengine, 00198 ccs_incompatiblenetwork 00199 }; 00200 00201 /*---------------------------------------------------------------------------- 00202 -- Variables 00203 ----------------------------------------------------------------------------*/ 00204 00205 extern std::string NetworkArg; 00206 extern int NetPlayers; 00207 extern char* NetworkAddr; 00208 extern int NetworkPort; 00209 00210 extern int HostsCount; 00211 extern CNetworkHost Hosts[PlayerMax]; 00212 00213 extern int NetConnectRunning; 00214 extern NetworkState NetStates[PlayerMax]; 00215 extern unsigned char NetLocalState; 00216 extern int NetLocalHostsSlot; 00217 extern int NetLocalPlayerNumber; 00218 00219 extern CServerSetup ServerSetupState; 00220 extern CServerSetup LocalSetupState; 00221 00222 /*---------------------------------------------------------------------------- 00223 -- Functions 00224 ----------------------------------------------------------------------------*/ 00225 00226 extern void NetworkServerStartGame(); 00227 extern void NetworkGamePrepareGameSettings(); 00228 extern void NetworkConnectSetupGame(); 00229 00230 extern void NetworkInitClientConnect(); 00231 extern void NetworkExitClientConnect(); 00232 extern void NetworkInitServerConnect(int openslots); 00233 extern void NetworkExitServerConnect(); 00234 extern int NetworkParseSetupEvent(const unsigned char *buf, int size); 00235 extern int NetworkSetupServerAddress(const std::string &serveraddr); 00236 extern void NetworkProcessClientRequest(); 00237 extern void NetworkProcessServerRequest(); 00238 extern void NetworkServerResyncClients(); 00239 extern void NetworkDetachFromServer(); 00240 00242 00243 #endif // !__NETCONNECT_H__