#include <Windows.h>#include <Assert.h>#include "Host.h"#include "Server.h"#include "Client.h"#include "GMenu.h"#include "Game\Game.h"#include "cd.h"Go to the source code of this file.
Functions | |
| void | GenVS_Error (const char *Msg,...) |
| Host_Host * | Host_Create (geEngine *Engine, Host_Init *InitData, GameMgr *GMgr, VidMode VidMode) |
| void | Host_Destroy (Host_Host *Host) |
| void | Host_ClientRefreshStatusBar (int32 NumPages) |
| void | Host_DestroyAllObjects (Host_Host *Host) |
| geBoolean | Host_Frame (Host_Host *Host, float Time) |
| geBoolean | Host_RenderFrame (Host_Host *Host, float Time) |
Variables | |
| int32 | CWidth |
| int32 | CHeight |
| Server_Server * | GServer |
| int32 | GMode |
|
||||||||||||
|
|
|
|
Definition at line 209 of file Host.c. References Client_RefreshStatusBar(). Referenced by GMenu_Key().
00210 {
00211 Client_RefreshStatusBar(NumPages);
00212 }
|
|
||||||||||||||||||||
|
Definition at line 41 of file Host.c. References Host_Host::Client, Client_Create(), Client_Mode, ClientMode_Dumb, ClientMode_Proxy, Host_Init::ClientName, Console_Printf(), Host_Init::DemoFile, Host_Init::DemoMode, Engine, Host_Host::Engine, GameMgr_ClearBackground(), GameMgr_GetConsole(), GameMgr_GetVidMode(), GE_FALSE, GE_RAM_ALLOCATE_STRUCT, GE_TRUE, GenVS_Error(), geRam_Free, Host_Host::GMgr, GMode, GServer, HOST_DEMO_PLAY, Host_DestroyAllObjects(), HOST_MODE_CLIENT, HOST_MODE_SERVER_CLIENT, HOST_MODE_SERVER_DEDICATED, HOST_MODE_SINGLE_PLAYER, Host_Host::hWnd, geCSNetMgr_NetClient::Id, int32, Host_Init::IPAddress, Host_Init::LevelHack, Host_Host::Mode, Host_Init::Mode, geCSNetMgr_NetClient::Name, NetMgr_Create(), NetMgr_GetOurID(), NetMgr_JoinSession(), NETMGR_SINGLE_PLAYER_NETID, NetMgr_StartSession(), NETMGR_VERSION_MAJOR, NETMGR_VERSION_MINOR, Host_Host::NMgr, NULL, Host_Host::Server, Server_ClientConnect(), Server_Create(), Host_Host::VidMode, VidMode, and VidMode_GetResolution(). Referenced by WinMain(), and WndProc().
00042 {
00043 Host_Host *NewHost;
00044 geCSNetMgr_NetClient GEClient;
00045 Console_Console *Console;
00046 int32 Width, Height;
00047
00048 assert(Engine != NULL);
00049
00050 // Create the host object
00051 NewHost = GE_RAM_ALLOCATE_STRUCT(Host_Host);
00052
00053 assert(NewHost != NULL);
00054
00055 if (!NewHost)
00056 return NULL;
00057
00058 // Clear it
00059 memset(NewHost, 0, sizeof(Host_Host));
00060
00061 // Grab the console
00062 Console = GameMgr_GetConsole(GMgr);
00063 assert(Console);
00064
00065 //Console_SetActive(Console, GE_TRUE, GE_TRUE);
00066 VidMode_GetResolution(GameMgr_GetVidMode(GMgr), &Width, &Height);
00067
00068 // Save the mode we are in...
00069 NewHost->VidMode = VidMode;
00070 NewHost->Mode = InitData->Mode;
00071 NewHost->GMgr = GMgr;
00072
00073 // The host will need a copy of the VALID engine object
00074 NewHost->Engine = Engine;
00075
00076 //
00077 // Create a net mgr... (if needed)
00078 //
00079 if (InitData->Mode == HOST_MODE_SINGLE_PLAYER)
00080 NewHost->NMgr = NetMgr_Create(GE_TRUE);
00081 else
00082 NewHost->NMgr = NetMgr_Create(GE_FALSE);
00083
00084 // Create a client if NOT running dedicated...
00085 if (InitData->Mode != HOST_MODE_SERVER_DEDICATED)
00086 {
00087 Client_Mode ClientMode;
00088
00089 if (InitData->Mode == HOST_MODE_CLIENT || InitData->DemoMode == HOST_DEMO_PLAY)
00090 ClientMode = ClientMode_Proxy;
00091 else
00092 ClientMode = ClientMode_Dumb;
00093
00094 // Create the client for server/client mode
00095 // NOTE - DemoMode assumes that demomodes in host.h map directly to demo modes in client.h!!!
00096 NewHost->Client = Client_Create(Engine, ClientMode, GMgr, NewHost->NMgr, VidMode, InitData->DemoMode, InitData->DemoFile, InitData->Mode != HOST_MODE_SINGLE_PLAYER);
00097
00098 if (!NewHost->Client)
00099 goto ExitWithError;
00100
00101 }
00102
00103 // Copy name over
00104 strcpy(GEClient.Name, InitData->ClientName);
00105
00106 if (InitData->Mode == HOST_MODE_SERVER_CLIENT) // Create a game as server with local client
00107 {
00108 GMode = 1;
00109
00110 // Start up session
00111 if (!NetMgr_StartSession(NewHost->NMgr, "Genesis Virtual Studio", InitData->ClientName))
00112 goto ExitWithError;
00113
00114 // Create the server
00115 NewHost->Server = Server_Create(GMgr, NewHost->NMgr, NewHost->Client, InitData->LevelHack);
00116 assert(NewHost->Server != NULL);
00117
00118 if (!NewHost->Server)
00119 goto ExitWithError;
00120
00121 // Steal the ID we were assigned by netplay
00122 GEClient.Id = NetMgr_GetOurID(NewHost->NMgr);
00123 }
00124 else if (InitData->Mode == HOST_MODE_CLIENT) // Join as client
00125 {
00126 GMode = 2;
00127
00128 //GameMgr_ConsolePrintf(GMgr, GE_TRUE,"Connecting to server...\n");
00129 if (!GameMgr_ClearBackground(GMgr, (Width/2)-(24*8/2), Height/2-10, "Connecting to server..."))
00130 GenVS_Error("GameMgr_SetWorld: GameMgr_ClearBackground failed.\n");
00131
00132 if (!NetMgr_JoinSession(NewHost->NMgr, InitData->IPAddress, InitData->ClientName))
00133 GenVS_Error("Host_Create: NetMgr_JoinSession failed...");
00134
00135 NewHost->Server = NULL;
00136
00137 // Steal the Id we were assigned by netplay
00138 GEClient.Id = NetMgr_GetOurID(NewHost->NMgr);
00139
00140 if (!GameMgr_ClearBackground(GMgr, (Width/2)-(13*8/2), Height/2-10, "Connected..."))
00141 GenVS_Error("GameMgr_SetWorld: GameMgr_ClearBackground failed.\n");
00142 }
00143 else if (InitData->Mode == HOST_MODE_SINGLE_PLAYER)
00144 {
00145 GMode = 0;
00146
00147 NewHost->Mode = HOST_MODE_SINGLE_PLAYER;
00148 // Record the single player ID
00149 GEClient.Id = NETMGR_SINGLE_PLAYER_NETID;
00150
00151 // If we are going to play a demo, then we do not need a server...
00152 if (InitData->DemoMode != HOST_DEMO_PLAY)
00153 {
00154 // Create the server
00155 NewHost->Server = Server_Create(GMgr, NewHost->NMgr, NewHost->Client, InitData->LevelHack);
00156
00157 assert(NewHost->Server != NULL);
00158
00159 if (!NewHost->Server)
00160 goto ExitWithError;
00161
00162 // Manually add client...
00163 // FIXME: Make this a message!!!
00164 if (!Server_ClientConnect(NewHost->Server, &GEClient))
00165 GenVS_Error("Host_Create: Could not add client in single player mode...\n");
00166 }
00167 }
00168
00169 //GameMgr_ConsolePrintf(GMgr, GE_TRUE,"Connected...\n");
00170 //Console_SetActive(Console, GE_TRUE, GE_FALSE);
00171
00172 // HACK!!! Hack for global console test
00173 GServer = NewHost->Server;
00174
00175 NewHost->hWnd = 0;
00176
00177 //NewHost->Time = 0.0f;
00178
00179 Console_Printf(GameMgr_GetConsole(NewHost->GMgr), "--- Genesis Host initialized v%i.%i ---\n", NETMGR_VERSION_MAJOR, NETMGR_VERSION_MINOR);
00180
00181 return NewHost;
00182
00183 ExitWithError:
00184 {
00185 if (NewHost)
00186 {
00187 Host_DestroyAllObjects(NewHost);
00188 geRam_Free(NewHost);
00189 }
00190 }
00191 return NULL;
00192 }
|
|
|
Definition at line 197 of file Host.c. References geRam_Free, Host, Host_DestroyAllObjects(), and NULL. Referenced by ShutdownAll(), WinMain(), and WndProc().
00198 {
00199 assert(Host != NULL);
00200
00201 Host_DestroyAllObjects(Host);
00202
00203 geRam_Free(Host);
00204 }
|
|
|
Definition at line 217 of file Host.c. References Host_Host::Client, Client_Destroy(), GameMgr_FreeWorld(), Host_Host::GMgr, Host, NetMgr_Destroy(), Host_Host::NMgr, NULL, Host_Host::Server, and Server_Destroy(). Referenced by Host_Create(), and Host_Destroy().
00218 {
00219 if (Host->Server)
00220 {
00221 Server_Destroy(Host->Server);
00222 Host->Server = NULL;
00223 }
00224
00225 if (Host->Client)
00226 {
00227 Client_Destroy(Host->Client);
00228 Host->Client = NULL;
00229 }
00230
00231 if (Host->NMgr)
00232 {
00233 NetMgr_Destroy(Host->NMgr);
00234 Host->NMgr = NULL;
00235 }
00236
00237 if (Host->GMgr)
00238 {
00239 // Make we clean up any old world that might by laying around
00240 GameMgr_FreeWorld(Host->GMgr);
00241 }
00242 }
|
|
||||||||||||
|
Definition at line 247 of file Host.c. References Host_Host::Client, Client_Frame(), Host_Host::Engine, GameMgr_GetEngine(), GE_FALSE, GE_TRUE, geBoolean, Host_Host::GMgr, Host, NetMgr_ResetClientBuffer(), NetMgr_ResetServerBuffer(), Host_Host::NMgr, Host_Host::Server, and Server_Frame(). Referenced by WinMain().
00248 {
00249
00250 if (Time < 0.001f)
00251 Time = 0.001f;
00252
00253 if (Time > 0.1f)
00254 Time = 0.1f;
00255
00256 //Host->Time += Time;
00257
00258 Host->Engine = GameMgr_GetEngine(Host->GMgr);
00259
00260 //
00261 // Do a server frame (if not in demo play mode)
00262 //
00263 if (Host->Server)
00264 {
00265 if (!Server_Frame(Host->Server, Host->GMgr, Time))
00266 return GE_FALSE;
00267 }
00268
00269 //
00270 // Do a client frame
00271 //
00272 NetMgr_ResetClientBuffer(Host->NMgr);
00273
00274 if (Host->Client) // Client will be NULL for dedicated servers
00275 {
00276 if (!Client_Frame(Host->Client, Time))
00277 return GE_FALSE;
00278 }
00279
00280 NetMgr_ResetServerBuffer(Host->NMgr);
00281
00282 return GE_TRUE;
00283 }
|
|
||||||||||||
|
Definition at line 288 of file Host.c. References Host_Host::Client, Client_RenderFrame(), GE_FALSE, GE_TRUE, geBoolean, geErrorLog_AddString, Host, and NULL. Referenced by WinMain().
00289 {
00290 if (Host->Client)
00291 {
00292 if (!Client_RenderFrame(Host->Client, Time))
00293 {
00294 geErrorLog_AddString(-1, "Host_RenderFrame: Client_RenderFrame failed...", NULL);
00295 return GE_FALSE;
00296 }
00297 }
00298
00299 return GE_TRUE;
00300 }
|
|
|
Definition at line 30 of file Host.c. Referenced by geEngine_DrawAlphaBitmap(). |
|
|
Definition at line 29 of file Host.c. Referenced by geEngine_DrawAlphaBitmap(). |
|
|
Definition at line 36 of file Host.c. Referenced by GetBotMatchSpawn(), GetDMSpawn(), and Host_Create(). |
|
|
Definition at line 34 of file Host.c. Referenced by Host_Create(). |
1.3.2