$treeview $search $mathjax
Stratagus
2.2.7
$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 <stdint.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 00067 #define NetPlayerNameSize 16 00068 00072 class CNetworkHost 00073 { 00074 public: 00075 unsigned char *Serialize() const; 00076 void Deserialize(const unsigned char *p); 00077 static size_t Size() { return 4 + 2 + 2 + NetPlayerNameSize; } 00078 00079 uint32_t Host; 00080 uint16_t Port; 00081 uint16_t PlyNr; 00082 char PlyName[NetPlayerNameSize]; 00083 }; 00084 00088 typedef struct _network_state_ { 00089 unsigned char State; 00090 unsigned short MsgCnt; 00091 // Fill in here... 00092 } NetworkState; 00093 00097 class CServerSetup 00098 { 00099 public: 00100 unsigned char *Serialize() const; 00101 void Deserialize(const unsigned char *p); 00102 static size_t Size() { return 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 * PlayerMax + 4 * PlayerMax + 4 * PlayerMax + 4 * PlayerMax; } 00103 void Clear() { 00104 ResourcesOption = UnitsOption = FogOfWar = RevealMap = TilesetSelection = 00105 GameTypeOption = Difficulty = MapRichness = 0; 00106 memset(CompOpt, 0, sizeof(CompOpt)); 00107 memset(Ready, 0, sizeof(Ready)); 00108 memset(LastFrame, 0, sizeof(LastFrame)); 00109 } 00110 00111 uint32_t ResourcesOption; 00112 uint32_t UnitsOption; 00113 uint32_t FogOfWar; 00114 uint32_t RevealMap; 00115 uint32_t TilesetSelection; 00116 uint32_t GameTypeOption; 00117 uint32_t Difficulty; 00118 uint32_t MapRichness; 00119 uint32_t CompOpt[PlayerMax]; 00120 uint32_t Ready[PlayerMax]; 00121 uint32_t Race[PlayerMax]; 00122 uint32_t LastFrame[PlayerMax]; 00123 // Fill in here... 00124 }; 00125 00132 class CInitMessage 00133 { 00134 public: 00135 unsigned char *Serialize() const; 00136 void Deserialize(const unsigned char *p); 00137 static size_t Size() { return 1 + 1 + 4 + 4 + 4 + 4 + 4 + 4 + 1 + 256 + CNetworkHost::Size() * PlayerMax + CServerSetup::Size(); } 00138 00139 uint8_t Type; 00140 uint8_t SubType; 00141 int32_t Stratagus; 00142 int32_t Version; 00143 uint32_t ConfUID; 00144 uint32_t MapUID; 00145 int32_t Lag; 00146 int32_t Updates; 00147 uint8_t HostsCount; 00148 00149 union { 00150 CNetworkHost Hosts[PlayerMax]; 00151 char MapPath[256]; 00152 CServerSetup State; 00153 } u; 00154 }; 00155 00159 enum _ic_message_subtype_ { 00160 ICMHello, 00161 ICMConfig, 00162 00163 ICMEngineMismatch, 00164 ICMProtocolMismatch, 00165 ICMEngineConfMismatch, 00166 ICMMapUidMismatch, 00167 00168 ICMGameFull, 00169 ICMWelcome, 00170 00171 ICMWaiting, 00172 ICMMap, 00173 ICMState, 00174 ICMResync, 00175 00176 ICMServerQuit, 00177 ICMGoodBye, 00178 ICMSeeYou, 00179 00180 ICMGo, 00181 00182 ICMAYT, 00183 ICMIAH 00184 }; 00185 00189 enum _net_client_con_state_ { 00190 ccs_unused = 0, 00191 ccs_connecting, 00192 ccs_connected, 00193 ccs_mapinfo, 00194 ccs_badmap, 00195 ccs_synced, 00196 ccs_async, 00197 ccs_changed, 00198 ccs_detaching, 00199 ccs_disconnected, 00200 ccs_unreachable, 00201 ccs_usercanceled, 00202 ccs_nofreeslots, 00203 ccs_serverquits, 00204 ccs_goahead, 00205 ccs_started, 00206 ccs_incompatibleengine, 00207 ccs_incompatiblenetwork 00208 }; 00209 00210 /*---------------------------------------------------------------------------- 00211 -- Variables 00212 ----------------------------------------------------------------------------*/ 00213 00214 extern std::string NetworkArg; 00215 extern int NetPlayers; 00216 extern char *NetworkAddr; 00217 extern int NetworkPort; 00218 00219 extern int HostsCount; 00220 extern CNetworkHost Hosts[PlayerMax]; 00221 00222 extern int NetConnectRunning; 00223 extern NetworkState NetStates[PlayerMax]; 00224 extern unsigned char NetLocalState; 00225 extern int NetLocalHostsSlot; 00226 extern int NetLocalPlayerNumber; 00227 00228 extern CServerSetup ServerSetupState; 00229 extern CServerSetup LocalSetupState; 00230 00231 /*---------------------------------------------------------------------------- 00232 -- Functions 00233 ----------------------------------------------------------------------------*/ 00234 00235 extern void NetworkServerStartGame(); 00236 extern void NetworkGamePrepareGameSettings(); 00237 extern void NetworkConnectSetupGame(); 00238 00239 extern void NetworkInitClientConnect(); 00240 extern void NetworkExitClientConnect(); 00241 extern void NetworkInitServerConnect(int openslots); 00242 extern void NetworkExitServerConnect(); 00243 extern int NetworkParseSetupEvent(const unsigned char *buf, int size); 00244 extern int NetworkSetupServerAddress(const std::string &serveraddr); 00245 extern void NetworkProcessClientRequest(); 00246 extern void NetworkProcessServerRequest(); 00247 extern void NetworkServerResyncClients(); 00248 extern void NetworkDetachFromServer(); 00249 00251 00252 #endif // !__NETCONNECT_H__