Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

GameMgr.c File Reference

#include <Windows.h>
#include <Assert.h>
#include <stdio.h>
#include <direct.h>
#include "Ram.h"
#include "Errorlog.h"
#include "GameMgr.h"
#include "Procedurals\gebmutil.h"
#include "procedurals/ProcEng.h"

Go to the source code of this file.

Compounds

struct  GameMgr
struct  GameMgr_WorldInfo

Defines

#define PATH_SEPERATOR   '/'

Typedefs

typedef GameMgr GameMgr

Functions

void GenVS_Error (const char *Msg,...)
HWND CreateMainWindow (HANDLE hInstance, const char *AppName, int32 Width, int32 Height)
void GameMgr_FreeAllObjects (GameMgr *GMgr)
GameMgrGameMgr_Create (HINSTANCE hInstance, int32 Width, int32 Height, const char *AppName)
void GameMgr_Destroy (GameMgr *GMgr)
geBoolean GameMgr_Frame (GameMgr *GMgr, float Time)
geBoolean GameMgr_IsValid (GameMgr *GMgr)
void GameMgr_PrepareToChangeMode (GameMgr *GMgr)
geBoolean GameMgr_SetDriverAndMode (GameMgr *GMgr, geDriver *Driver, geDriver_Mode *DriverMode, int Width, int Height)
geBoolean GameMgr_BeginFrame (GameMgr *GMgr, geWorld *World, geBoolean ClearScreen)
geBoolean GameMgr_EndFrame (GameMgr *GMgr)
void GameMgr_ConsolePrintf (GameMgr *GMgr, geBoolean DrawNow, const char *Str,...)
geBoolean GameMgr_ClearBackground (GameMgr *GMgr, int32 x, int32 y, const char *Str)
geBoolean GameMgr_FreeWorld (GameMgr *GMgr)
void DefaultExtension (char *Path, const char *Ext)
geBoolean GameMgr_SetWorld (GameMgr *GMgr, const char *WorldName)
geBoolean GameMgr_SetActorIndex (GameMgr *GMgr, int32 Index, const char *FileName)
GameMgr_ActorIndexGameMgr_GetActorIndex (GameMgr *GMgr, int32 Index)
geBoolean GameMgr_MotionIndexIsValid (GameMgr *GMgr, GameMgr_MotionIndex Index)
geBoolean GameMgr_SetMotionIndexDef (GameMgr *GMgr, GameMgr_MotionIndex Index, const char *MotionName)
GameMgr_MotionIndexDefGameMgr_GetMotionIndexDef (GameMgr *GMgr, GameMgr_MotionIndex Index)
geBoolean GameMgr_SetBoneIndex (GameMgr *GMgr, int32 BoneIndex, const char *BoneName)
GameMgr_BoneIndexGameMgr_GetBoneIndex (GameMgr *GMgr, int32 Index)
geBoolean GameMgr_SetTextureIndex (GameMgr *GMgr, int32 Index, const char *FileName, const char *AFileName)
GameMgr_TextureIndexGameMgr_GetTextureIndex (GameMgr *GMgr, int32 Index)
geBoolean GameMgr_SetSoundIndex (GameMgr *GMgr, int32 SoundIndex, const char *FileName)
GameMgr_SoundIndexGameMgr_GetSoundIndex (GameMgr *GMgr, int32 Index)
geEngineGameMgr_GetEngine (GameMgr *GMgr)
geSound_SystemGameMgr_GetSoundSystem (GameMgr *GMgr)
Console_ConsoleGameMgr_GetConsole (GameMgr *GMgr)
geWorldGameMgr_GetWorld (GameMgr *GMgr)
geCameraGameMgr_GetCamera (GameMgr *GMgr)
GameMgr_FrameState GameMgr_GetFrameState (GameMgr *GMgr)
int32 GameMgr_GetNumModels (GameMgr *GMgr)
geWorld_ModelGameMgr_GetModel (GameMgr *GMgr, int32 Index)
Fx_SystemGameMgr_GetFxSystem (GameMgr *GMgr)
geBitmapGameMgr_GetShadowMap (GameMgr *GMgr)
float GameMgr_GetTime (GameMgr *GMgr)
HWND GameMgr_GethWnd (GameMgr *GMgr)
VidMode GameMgr_GetVidMode (GameMgr *GMgr)
LRESULT CALLBACK WndProc (HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
void GameMgr_ResetMainWindow (HWND hWnd, int32 Width, int32 Height)

Variables

geVFileMainFS


Define Documentation

#define PATH_SEPERATOR   '/'
 

Definition at line 697 of file GameMgr.c.

Referenced by DefaultExtension().


Typedef Documentation

typedef struct GameMgr GameMgr
 


Function Documentation

HWND CreateMainWindow HANDLE  hInstance,
const char *  AppName,
int32  Width,
int32  Height
[static]
 

Definition at line 1343 of file GameMgr.c.

References AppName, tagRECT::bottom, GameMgr_ResetMainWindow(), HWND, tagRECT::left, NULL, tagRECT::right, tagRECT::top, and WndProc().

Referenced by GameMgr_Create().

01344 {
01345         WNDCLASS                wc;
01346         HWND                    hWnd;
01347         RECT                ScreenRect;
01348         
01349         //
01350         // Set up and register application window class
01351         //
01352         wc.style         = CS_HREDRAW | CS_VREDRAW;
01353         wc.lpfnWndProc   = WndProc;
01354         wc.cbClsExtra    = 0;
01355         wc.cbWndExtra    = 0;
01356         wc.hInstance     = hInstance;
01357         // change this if we ever make an icon.
01358         wc.hIcon         = NULL; //LoadIcon(hInstance, IDI_APPLICATION);
01359         wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
01360         wc.hbrBackground = GetStockObject(BLACK_BRUSH);
01361         wc.lpszMenuName  = (const char*)NULL;
01362         wc.lpszClassName = AppName;
01363 
01364         RegisterClass(&wc);
01365 
01366         //
01367         // Create application's main window
01368         //
01369         GetWindowRect(GetDesktopWindow(),&ScreenRect);
01370         hWnd = CreateWindowEx(
01371                 0,
01372                 AppName,
01373                 AppName,
01374                 0,
01375                 (ScreenRect.right+ScreenRect.left)/2 - Width/2,
01376                 (ScreenRect.bottom+ScreenRect.top)/2 - Height/2, 
01377                 Width,
01378                 Height,
01379                 NULL,
01380                 NULL,
01381                 hInstance,
01382                 NULL);
01383 
01384         if (!hWnd)
01385         {
01386                 MessageBox(0, "Could not create window.", "** ERROR **", MB_OK);
01387                 _exit(1);
01388         }       
01389 
01390         
01391         GameMgr_ResetMainWindow(hWnd, Width, Height);
01392         SetFocus(hWnd);
01393 
01394         return hWnd;
01395 
01396 }

void DefaultExtension char *  Path,
const char *  Ext
 

Definition at line 702 of file GameMgr.c.

References PATH_SEPERATOR.

Referenced by GameMgr_SetWorld().

00703 {
00704         char    *Src;
00705         
00706         Src = Path + strlen(Path) - 1;
00707 
00708         while (*Src != PATH_SEPERATOR && Src != Path)
00709         {
00710                 if (*Src == '.')
00711                         return;                 // it has an extension
00712                 Src--;
00713         }
00714 
00715         strcat (Path, Ext);
00716 }

geBoolean GameMgr_BeginFrame GameMgr GMgr,
geWorld World,
geBoolean  ClearScreen
 

Definition at line 416 of file GameMgr.c.

References Engine, GameMgr::FrameState, FrameState_Begin, FrameState_None, GameMgr_GetCamera(), GameMgr_GetEngine(), GameMgr_IsValid(), GE_TRUE, geBoolean, geEngine_BeginFrame(), and GenVS_Error().

Referenced by GameMgr_ClearBackground(), GameMgr_ConsolePrintf(), and WinMain().

00417 {
00418         geEngine        *Engine;
00419         geCamera        *Camera;
00420 
00421         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00422 
00423         if (GMgr->FrameState != FrameState_None)
00424                 GenVS_Error("GameMgr_BeginFrame:  GMgr->FrameState != FrameState_None.\n");
00425 
00426         Engine = GameMgr_GetEngine(GMgr);
00427         assert(Engine);
00428 
00429         Camera = GameMgr_GetCamera(GMgr);
00430         assert(Camera);
00431 
00432         if (!geEngine_BeginFrame(Engine, Camera, ClearScreen))
00433         {
00434                 GMgr->FrameState = FrameState_None;
00435                 GenVS_Error("GameMgr_BeginFrame:  geEngine_BeginFrame failed.\n");
00436         }
00437 
00438         GMgr->FrameState = FrameState_Begin;
00439 
00440         return GE_TRUE;
00441 }

geBoolean GameMgr_ClearBackground GameMgr GMgr,
int32  x,
int32  y,
const char *  Str
 

Definition at line 516 of file GameMgr.c.

References Engine, GameMgr::FrameState, FrameState_None, GameMgr_BeginFrame(), GameMgr_EndFrame(), GameMgr_FrameState, GameMgr_GetCamera(), GameMgr_GetEngine(), GE_TRUE, geBoolean, geEngine_Printf(), GenVS_Error(), GameMgr_WorldInfo::World, GameMgr::WorldInfo, and y.

Referenced by GameMgr_SetWorld(), Host_Create(), and WinMain().

00517 {
00518         geCamera                        *Camera;
00519         geEngine                        *Engine;
00520         GameMgr_FrameState      OldFrameState;
00521         geWorld                         *World;
00522 
00523         Engine = GameMgr_GetEngine(GMgr);
00524         assert(Engine);
00525 
00526         Camera = GameMgr_GetCamera(GMgr);
00527         assert(Camera);
00528 
00529         World = GMgr->WorldInfo[0].World;
00530 
00531         OldFrameState = GMgr->FrameState;
00532 
00533         if (GMgr->FrameState != FrameState_None)                // Make sure we are not in a nested begin/frame loop
00534         {
00535                 if (!GameMgr_EndFrame(GMgr))
00536                         GenVS_Error("GameMgr_ClearBackground:  GameMgr_EndFrame 1 failed.\n");
00537         }
00538         
00539         if (!GameMgr_BeginFrame(GMgr, World, GE_TRUE))
00540                 GenVS_Error("GameMgr_ClearBackground:  GameMgr_BeginFrame 1 failed.\n");
00541 
00542         if (!GameMgr_EndFrame(GMgr))
00543                 GenVS_Error("GameMgr_ClearBackground:  GameMgr_EndFrame failed.\n");
00544 
00545         if (!GameMgr_BeginFrame(GMgr, World, GE_TRUE))
00546                 GenVS_Error("GameMgr_ClearBackground:  GameMgr_BeginFrame 2 failed.\n");
00547 
00548         if (Str)
00549                 geEngine_Printf(Engine, x, y, (char*)Str);
00550 
00551         if (!GameMgr_EndFrame(GMgr))
00552                 GenVS_Error("GameMgr_ClearBackground:  GameMgr_EndFrame 2 failed.\n");
00553 
00554         if (OldFrameState != FrameState_None)           // Restore old state...
00555         {
00556                 if (!GameMgr_BeginFrame(GMgr, World, GE_TRUE))
00557                         GenVS_Error("GameMgr_ClearBackground:  GameMgr_BeginFrame 3 failed.\n");
00558         }
00559 
00560         return GE_TRUE;
00561 }

void GameMgr_ConsolePrintf GameMgr GMgr,
geBoolean  DrawNow,
const char *  Str,
... 
 

Definition at line 472 of file GameMgr.c.

References GameMgr::Console, Console_Frame(), Console_Printf(), Engine, GameMgr::FrameState, FrameState_Begin, FrameState_None, GameMgr_BeginFrame(), GameMgr_EndFrame(), GameMgr_FrameState, GameMgr_GetCamera(), GameMgr_GetEngine(), GE_TRUE, GenVS_Error(), GameMgr_WorldInfo::World, and GameMgr::WorldInfo.

00473 {
00474         geCamera                        *Camera;
00475         geEngine                        *Engine;
00476         GameMgr_FrameState      OldFrameState;
00477         geWorld                         *World;
00478 
00479         Engine = GameMgr_GetEngine(GMgr);
00480         assert(Engine);
00481 
00482         Camera = GameMgr_GetCamera(GMgr);
00483         assert(Camera);
00484 
00485         World = GMgr->WorldInfo[0].World;
00486         
00487         OldFrameState = GMgr->FrameState;
00488 
00489         if (DrawNow && GMgr->FrameState != FrameState_Begin)
00490         {
00491                 if (!GameMgr_BeginFrame(GMgr, World, GE_TRUE))
00492                         GenVS_Error("GameMgr_ConsolePrintf:  GameMgr_BeginFrame 1 failed.\n");
00493         }
00494 
00495         if (!Console_Printf(GMgr->Console, Str))
00496                 GenVS_Error("GameMgr_ConsolePrintf:  Console_Printf failed.\n");
00497 
00498         if (DrawNow && GMgr->FrameState != FrameState_None)
00499         {
00500                 Console_Frame(GMgr->Console, 0.0f);
00501 
00502                 if (!GameMgr_EndFrame(GMgr))
00503                         GenVS_Error("GameMgr_ConsolePrintf:  GameMgr_EndFrame failed.\n");
00504                 
00505                 if (OldFrameState != GMgr->FrameState)          // Restore old state...
00506                 {
00507                         if (!GameMgr_BeginFrame(GMgr, World, GE_TRUE))
00508                                 GenVS_Error("GameMgr_ConsolePrintf:  GameMgr_BeginFrame 3 failed.\n");
00509                 }
00510         }
00511 }

GameMgr* GameMgr_Create HINSTANCE  hInstance,
int32  Width,
int32  Height,
const char *  AppName
 

Definition at line 124 of file GameMgr.c.

References AppName, CreateMainWindow(), GameMgr::Engine, GameMgr_FreeAllObjects(), GE_FALSE, GE_RAM_ALLOCATE_STRUCT, geErrorLog_AddString, geSound_CreateSoundSystem(), geXForm3d_SetMaximalAssertionMode(), GameMgr::hWnd, NULL, GameMgr::ProcEng, GameMgr::SelfCheck1, GameMgr::SelfCheck2, and GameMgr::SoundSys.

Referenced by WinMain().

00125 {
00126         GameMgr *GMgr;
00127         char    PathBuf[_MAX_PATH];
00128 
00129         assert(AppName);
00130 
00131         // Allocate the GameMgr structure
00132         GMgr = GE_RAM_ALLOCATE_STRUCT(GameMgr);
00133 
00134         if (!GMgr)
00135         {
00136                 geErrorLog_AddString(-1, "GameMgr_Create:  Out of memory for GameMgr.", NULL);
00137                 return NULL;
00138         }
00139 
00140         // Zero out memory
00141         memset(GMgr, 0, sizeof(GameMgr));
00142 
00143         // Save self check flags
00144         GMgr->SelfCheck1 = GMgr;
00145         GMgr->SelfCheck2 = GMgr;
00146 
00147         // Create the window
00148         GMgr->hWnd = CreateMainWindow(hInstance, AppName, Width, Height);
00149         
00150         // Create an engine object
00151         if (_getcwd(PathBuf,_MAX_PATH)==NULL)
00152                 {
00153                         geErrorLog_AddString(-1, "GameMgr_Create:  Could not get current working directory.", NULL);
00154                         goto ExitWithError;
00155                 }
00156         GMgr->Engine = geEngine_Create(GMgr->hWnd, AppName, PathBuf);
00157         
00158         if (!GMgr->Engine)
00159         {
00160                 geErrorLog_AddString(-1, "GameMgr_Create:  Could not create the geEngine object.", NULL);
00161                 goto ExitWithError;
00162         }
00163 
00164         #ifdef _DEBUG
00165         geXForm3d_SetMaximalAssertionMode(GE_FALSE);
00166         #endif
00167         
00168         //
00169         // Create the sound system
00170         //
00171         GMgr->SoundSys = geSound_CreateSoundSystem(GMgr->hWnd);
00172 
00173         if (!GMgr->SoundSys)
00174         {
00175                 geErrorLog_AddString(-1, "GameMgr_Create:  Could not create the geSound_System object. (continuing)", NULL);
00176                 //goto ExitWithError;
00177         }
00178 
00179         GMgr->ProcEng = NULL;
00180 
00181         return GMgr;
00182 
00183         ExitWithError:
00184         {
00185                 if (GMgr)
00186                         GameMgr_FreeAllObjects(GMgr);
00187 
00188                 return NULL;
00189         }
00190 }

void GameMgr_Destroy GameMgr GMgr  ) 
 

Definition at line 195 of file GameMgr.c.

References GameMgr_FreeAllObjects(), GameMgr_IsValid(), and GE_TRUE.

Referenced by ShutdownAll().

00196 {
00197         assert(GMgr);
00198         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00199 
00200         GameMgr_FreeAllObjects(GMgr);
00201 }

geBoolean GameMgr_EndFrame GameMgr GMgr  ) 
 

Definition at line 446 of file GameMgr.c.

References Engine, GameMgr::FrameState, FrameState_Begin, FrameState_None, GameMgr_GetEngine(), GameMgr_IsValid(), GE_TRUE, geBoolean, geEngine_EndFrame(), and GenVS_Error().

Referenced by GameMgr_ClearBackground(), GameMgr_ConsolePrintf(), and WinMain().

00447 {
00448         geEngine        *Engine;
00449 
00450         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00451 
00452         if (GMgr->FrameState != FrameState_Begin)
00453                 GenVS_Error("GameMgr_EndFrame:  GMgr->FrameState != FrameState_Begin.\n");
00454 
00455         Engine = GameMgr_GetEngine(GMgr);
00456         assert(Engine);
00457 
00458         if (!geEngine_EndFrame(Engine))
00459         {
00460                 GMgr->FrameState = FrameState_None;
00461                 GenVS_Error("GameMgr_EndFrame:  geEngine_EndFrame failed.\n");
00462         }
00463         
00464         GMgr->FrameState = FrameState_None;
00465 
00466         return GE_TRUE;
00467 }

geBoolean GameMgr_Frame GameMgr GMgr,
float  Time
 

Definition at line 292 of file GameMgr.c.

References Fx_SystemFrame(), GameMgr::FxSystem, GameMgr_IsValid(), GE_TRUE, geBoolean, GenVS_Error(), GameMgr::ProcEng, ProcEng_Animate(), and GameMgr::Time.

Referenced by WinMain().

00293 {
00294         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00295 
00296         if (Time < 0.001f)
00297                 Time = 0.001f;
00298         
00299         if (Time > 0.1f)
00300                 Time = 0.1f;
00301         
00302         GMgr->Time += Time;
00303 
00304         //
00305         //      Do an fx system frame
00306         //
00307         if (GMgr->FxSystem)
00308         {
00309                 if (!Fx_SystemFrame(GMgr->FxSystem, Time))
00310                         GenVS_Error("GameMgr_Frame:  Fx_SystemFrame failed.\n");
00311         }
00312 
00313         if (GMgr->ProcEng)
00314         {
00315                 if (!ProcEng_Animate(GMgr->ProcEng, Time))
00316                         GenVS_Error("GameMgr_Frame:  ProcEng_Animate failed.\n");
00317         }
00318 
00319         return GE_TRUE;
00320 }

void GameMgr_FreeAllObjects GameMgr GMgr  ) 
 

Definition at line 91 of file GameMgr.c.

References GameMgr::Camera, GameMgr::Console, Console_Destroy(), GameMgr::Engine, Fx_SystemDestroy(), GameMgr::FxSystem, GameMgr_FreeWorld(), geCamera_Destroy(), geEngine_Free(), geRam_Free, geSound_DestroySoundSystem(), NULL, and GameMgr::SoundSys.

Referenced by GameMgr_Create(), and GameMgr_Destroy().

00092 {
00093         assert(GMgr);
00094 
00095         if (GMgr->Camera)
00096                 geCamera_Destroy(&GMgr->Camera);
00097 
00098         GameMgr_FreeWorld(GMgr);                // Make sure no old world is laying around
00099         
00100         if (GMgr->FxSystem)
00101                 Fx_SystemDestroy(GMgr->FxSystem);
00102 
00103         if (GMgr->Console)
00104                 Console_Destroy(GMgr->Console);
00105 
00106         if (GMgr->SoundSys)
00107                 geSound_DestroySoundSystem(GMgr->SoundSys);
00108 
00109         if (GMgr->Engine)
00110                 geEngine_Free(GMgr->Engine);
00111 
00112         GMgr->FxSystem  = NULL;
00113         GMgr->Engine    = NULL;
00114         GMgr->Console   = NULL;
00115         GMgr->SoundSys  = NULL;
00116         GMgr->Camera    = NULL;
00117 
00118         geRam_Free(GMgr);                               // Free the manager itself...
00119 }

geBoolean GameMgr_FreeWorld GameMgr GMgr  ) 
 

Definition at line 567 of file GameMgr.c.

References GameMgr_ActorIndex::Active, GameMgr_TextureIndex::Active, GameMgr_SoundIndex::Active, GameMgr_ActorIndex::ActorDef, GameMgr_ActorIndex::ActorHack, GameMgr::ActorIndex, GameMgr::BoneIndex, Corona_Shutdown(), Electric_Shutdown(), GameMgr::Engine, Fx_SystemDestroy(), GameMgr::FxSystem, GameMgr_IsValid(), GAMEMGR_MAX_ACTOR_INDEX, GAMEMGR_MAX_SOUND_INDEX, GAMEMGR_MAX_TEXTURE_INDEX, GE_FALSE, GE_TRUE, geActor_DefDestroy(), geActor_Destroy(), geBitmap_Destroy(), geBoolean, geEngine_RemoveWorld(), geErrorLog_AddString, geSound_FreeSoundDef(), geWorld_Free(), geWorld_RemoveActor(), geWorld_RemoveBitmap(), int32, GameMgr::MotionIndexDefs, NULL, GameMgr::ProcEng, ProcEng_Destroy(), GameMgr::ShadowMap, GameMgr_SoundIndex::SoundDef, GameMgr::SoundIndex, GameMgr::SoundSys, GameMgr_TextureIndex::TextureDef, GameMgr::TextureIndex, GameMgr::Time, GameMgr_WorldInfo::World, and GameMgr::WorldInfo.

Referenced by GameMgr_FreeAllObjects(), GameMgr_SetWorld(), and Host_DestroyAllObjects().

00568 {
00569         GameMgr_WorldInfo       *WInfo;
00570         int32                           i;
00571         geBoolean                       Ret;
00572 
00573         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00574 
00575         Ret = GE_TRUE;
00576         
00577         WInfo = &GMgr->WorldInfo[0];
00578 
00579         // There is nothing to fre in these arrays, so just zap them
00580         memset(GMgr->MotionIndexDefs, 0, sizeof(GMgr->MotionIndexDefs));
00581         memset(GMgr->BoneIndex, 0, sizeof(GMgr->BoneIndex));
00582 
00583         // Free all the actors
00584         for (i=0; i<GAMEMGR_MAX_ACTOR_INDEX; i++)
00585         {
00586                 GameMgr_ActorIndex              *AIndex;
00587 
00588                 AIndex = &GMgr->ActorIndex[i];
00589                 
00590                 if (AIndex->ActorDef)
00591                 {
00592                         assert(WInfo->World);
00593                         assert(AIndex->Active == GE_TRUE);
00594                         assert(AIndex->ActorHack);
00595                         
00596                         if (!geWorld_RemoveActor(WInfo->World, AIndex->ActorHack))
00597                         {
00598                                 geErrorLog_AddString(-1, "GameMgr_FreeWorld:  geWorld_RemoveActor failed.", NULL);
00599                                 Ret = GE_FALSE;
00600                         }
00601                         
00602                         geActor_Destroy(&AIndex->ActorHack);
00603 
00604                         geActor_DefDestroy(&AIndex->ActorDef);
00605                 }
00606                 
00607                 memset(AIndex, 0, sizeof(*AIndex));
00608         }
00609 
00610         // Free all the textures
00611         for (i=0; i<GAMEMGR_MAX_TEXTURE_INDEX; i++)
00612         {
00613                 GameMgr_TextureIndex *TIndex;
00614 
00615                 TIndex = &GMgr->TextureIndex[i];
00616 
00617                 if (TIndex->TextureDef)
00618                 {
00619                         assert(WInfo->World);                           // If there are bitmaps, there better be a world!!!
00620                         assert(TIndex->Active == GE_TRUE);
00621 
00622                         if (!geWorld_RemoveBitmap(WInfo->World, TIndex->TextureDef))
00623                                 Ret = GE_FALSE;
00624 
00625                         geBitmap_Destroy(&TIndex->TextureDef);
00626                 }
00627 
00628                 memset(TIndex, 0, sizeof(*TIndex));
00629         }
00630 
00631         for (i=0; i<GAMEMGR_MAX_SOUND_INDEX; i++)
00632         {
00633                 GameMgr_SoundIndex *SIndex;
00634 
00635                 SIndex = &GMgr->SoundIndex[i];
00636 
00637                 if (SIndex->SoundDef)
00638                 {
00639                         assert(GMgr->SoundSys);                         // If there are sounds, there better be a sound system!!!
00640                         assert(SIndex->Active == GE_TRUE);
00641                         geSound_FreeSoundDef(GMgr->SoundSys, SIndex->SoundDef);
00642                 }
00643                 memset(SIndex, 0, sizeof(*SIndex));
00644         }
00645 
00646         if (GMgr->FxSystem)             // YES, Fx_System depends on a world, so it must be freed now, until a new world is loaded...
00647         {
00648                 Fx_SystemDestroy(GMgr->FxSystem);
00649                 GMgr->FxSystem = NULL;
00650         }
00651 
00652         if (GMgr->ShadowMap)
00653         {
00654                 assert(WInfo->World);
00655 
00656                 geWorld_RemoveBitmap(WInfo->World, GMgr->ShadowMap);
00657                 geBitmap_Destroy( &(GMgr->ShadowMap) );
00658                 GMgr->ShadowMap = NULL;
00659         }
00660 
00661         // Free the world last, so that all data contained in the world would have been freed above...
00662         // Free any previously existing world
00663         if (WInfo->World)
00664         {
00665                 if (!Electric_Shutdown())
00666                 {
00667                         geErrorLog_AddString(-1, "GameMgr_FreeWorld:  Electric_Shutdown failed...", NULL);
00668                         Ret = GE_FALSE;
00669                 }
00670 
00671                 if (!Corona_Shutdown())
00672                 {
00673                         geErrorLog_AddString(-1, "GameMgr_FreeWorld:  Corona_Shutdown failed...", NULL);
00674                         Ret = GE_FALSE;
00675                 }
00676 
00677                 if (!geEngine_RemoveWorld(GMgr->Engine, WInfo->World))
00678                 {
00679                         geErrorLog_AddString(-1, "GameMgr_FreeWorld:  geEngine_RemoveWorld failed...", NULL);
00680                         Ret = GE_FALSE;
00681                 }
00682 
00683                 geWorld_Free(WInfo->World);
00684                 
00685                 if ( GMgr->ProcEng )
00686                         ProcEng_Destroy(&(GMgr->ProcEng));
00687                 GMgr->ProcEng = NULL;
00688         }
00689 
00690         WInfo->World = NULL;
00691 
00692         GMgr->Time = 0.0f;              // FIXME:  Take out?  Put in GameMgr_SetWorld?
00693 
00694         return Ret;
00695 }

GameMgr_ActorIndex* GameMgr_GetActorIndex GameMgr GMgr,
int32  Index
 

Definition at line 908 of file GameMgr.c.

References GameMgr::ActorIndex, GameMgr_IsValid(), GAMEMGR_MAX_ACTOR_INDEX, and GE_TRUE.

Referenced by CheckClientPlayerChanges(), and Server_SendClientCurrentWorldData().

00909 {
00910         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00911         assert(Index >= 0 && Index < GAMEMGR_MAX_ACTOR_INDEX);
00912 
00913         return &GMgr->ActorIndex[Index];
00914 }

GameMgr_BoneIndex* GameMgr_GetBoneIndex GameMgr GMgr,
int32  Index
 

Definition at line 978 of file GameMgr.c.

References GameMgr::BoneIndex, GameMgr_IsValid(), GAMEMGR_MAX_BONE_INDEX, and GE_TRUE.

Referenced by Client_UpdateSinglePlayer(), and Server_SendClientCurrentWorldData().

00979 {
00980         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00981         assert(Index >= 0 && Index < GAMEMGR_MAX_BONE_INDEX);
00982 
00983         return &GMgr->BoneIndex[Index];
00984 }

geCamera* GameMgr_GetCamera GameMgr GMgr  ) 
 

Definition at line 1193 of file GameMgr.c.

References GameMgr::Camera, GameMgr_IsValid(), and GE_TRUE.

Referenced by GameMgr_BeginFrame(), GameMgr_ClearBackground(), GameMgr_ConsolePrintf(), RenderWorld(), and WinMain().

01194 {
01195         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01196 
01197         return GMgr->Camera;
01198 }

Console_Console* GameMgr_GetConsole GameMgr GMgr  ) 
 

Definition at line 1173 of file GameMgr.c.

References GameMgr::Console, GameMgr_IsValid(), and GE_TRUE.

Referenced by Client_Create(), Client_MovePlayerModel(), DrawStatusBar(), Host_Create(), ParseClientMessage(), PrintClientScores(), PrintCrossHair(), ReadServerMessages(), Server_BotConnect(), Server_ClientConnect(), Server_ClientDisconnect(), Server_ConsolePrintf(), Server_Create(), Server_CreatePlayer(), Server_GetNextPlayer(), Server_MovePlayerModel(), Server_SetClientHealth(), Server_SetClientScore(), Server_SetViewPlayer(), and WinMain().

01174 {
01175         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01176 
01177         return GMgr->Console;
01178 }

geEngine* GameMgr_GetEngine GameMgr GMgr  ) 
 

Definition at line 1153 of file GameMgr.c.

References GameMgr::Engine, GameMgr_IsValid(), and GE_TRUE.

Referenced by GameMgr_BeginFrame(), GameMgr_ClearBackground(), GameMgr_ConsolePrintf(), GameMgr_EndFrame(), GameMgr_SetWorld(), Host_Frame(), ReadServerMessages(), RenderWorld(), SendPlayersToClients(), Server_Frame(), and WinMain().

01154 {
01155         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01156 
01157         return GMgr->Engine;
01158 }

GameMgr_FrameState GameMgr_GetFrameState GameMgr GMgr  ) 
 

Definition at line 1203 of file GameMgr.c.

References GameMgr::FrameState, GameMgr_FrameState, GameMgr_IsValid(), and GE_TRUE.

Referenced by GameMgr_SetActorIndex(), GameMgr_SetTextureIndex(), and GameMgr_SetWorld().

01204 {
01205         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01206 
01207         return GMgr->FrameState;
01208 }

Fx_System* GameMgr_GetFxSystem GameMgr GMgr  ) 
 

Definition at line 1235 of file GameMgr.c.

References GameMgr::FxSystem, GameMgr_IsValid(), and GE_TRUE.

Referenced by Client_DestroyPlayer(), Client_ParsePlayerData(), Client_UpdateSinglePlayer(), ControlTempPlayers(), ReadServerMessages(), and UpdatePlayers().

01236 {
01237         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01238 
01239         return GMgr->FxSystem;
01240 }

HWND GameMgr_GethWnd GameMgr GMgr  ) 
 

Definition at line 1265 of file GameMgr.c.

References GameMgr_IsValid(), GE_TRUE, HWND, and GameMgr::hWnd.

Referenced by Client_SendMove(), PickMode(), ShutdownAll(), WinMain(), and WndProc().

01266 {
01267         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01268 
01269         return GMgr->hWnd;
01270 }

geWorld_Model* GameMgr_GetModel GameMgr GMgr,
int32  Index
 

Definition at line 1223 of file GameMgr.c.

References GameMgr_GetNumModels(), GameMgr_IsValid(), GE_TRUE, GameMgr_WorldInfo::Models, and GameMgr::WorldInfo.

Referenced by CheckClientPlayerChanges(), and Server_ModelToViewIndex().

01224 {
01225         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01226 
01227         assert(Index >= 0 && Index < GameMgr_GetNumModels(GMgr));
01228 
01229         return GMgr->WorldInfo[0].Models[Index];
01230 }

GameMgr_MotionIndexDef* GameMgr_GetMotionIndexDef GameMgr GMgr,
GameMgr_MotionIndex  Index
 

Definition at line 950 of file GameMgr.c.

References GameMgr_IsValid(), GameMgr_MotionIndexIsValid(), GE_TRUE, and GameMgr::MotionIndexDefs.

Referenced by Client_UpdateSinglePlayer(), Server_GetPlayerTimeExtents(), and Server_SendClientCurrentWorldData().

00951 {
00952         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00953         assert(GameMgr_MotionIndexIsValid(GMgr, Index));
00954 
00955         return &GMgr->MotionIndexDefs[Index];
00956 }

int32 GameMgr_GetNumModels GameMgr GMgr  ) 
 

Definition at line 1213 of file GameMgr.c.

References GameMgr_IsValid(), GE_TRUE, int32, GameMgr_WorldInfo::NumModels, and GameMgr::WorldInfo.

Referenced by GameMgr_GetModel(), and Server_ModelToViewIndex().

01214 {
01215         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01216 
01217         return GMgr->WorldInfo[0].NumModels;
01218 }

geBitmap* GameMgr_GetShadowMap GameMgr GMgr  ) 
 

Definition at line 1245 of file GameMgr.c.

References GameMgr_IsValid(), GE_TRUE, and GameMgr::ShadowMap.

Referenced by CheckClientPlayerChanges().

01246 {
01247         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01248 
01249         return GMgr->ShadowMap;
01250 }

GameMgr_SoundIndex* GameMgr_GetSoundIndex GameMgr GMgr,
int32  Index
 

Definition at line 1142 of file GameMgr.c.

References GameMgr_IsValid(), GAMEMGR_MAX_SOUND_INDEX, GE_TRUE, and GameMgr::SoundIndex.

Referenced by ReadServerMessages(), and Server_SendClientCurrentWorldData().

01143 {
01144         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01145         assert(Index >= 0 && Index < GAMEMGR_MAX_SOUND_INDEX);
01146 
01147         return &GMgr->SoundIndex[Index];
01148 }

geSound_System* GameMgr_GetSoundSystem GameMgr GMgr  ) 
 

Definition at line 1163 of file GameMgr.c.

References GameMgr_IsValid(), GE_TRUE, and GameMgr::SoundSys.

Referenced by GameMgr_SetWorld(), ReadServerMessages(), and WinMain().

01164 {
01165         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01166 
01167         return GMgr->SoundSys;
01168 }

GameMgr_TextureIndex* GameMgr_GetTextureIndex GameMgr GMgr,
int32  Index
 

Definition at line 1090 of file GameMgr.c.

References GameMgr_IsValid(), GAMEMGR_MAX_TEXTURE_INDEX, GE_TRUE, and GameMgr::TextureIndex.

Referenced by CheckClientPlayerChanges(), and Server_SendClientCurrentWorldData().

01091 {
01092         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01093         assert(Index >= 0 && Index < GAMEMGR_MAX_TEXTURE_INDEX);
01094 
01095         return &GMgr->TextureIndex[Index];
01096 }

float GameMgr_GetTime GameMgr GMgr  ) 
 

Definition at line 1255 of file GameMgr.c.

References GameMgr_IsValid(), GE_TRUE, and GameMgr::Time.

Referenced by Client_GetTime(), ForceServerPlayerOnLocalClient(), ParseClientMove(), SendClientPlayerData(), SendPlayersToClients(), Server_Frame(), and Server_GetTime().

01256 {
01257         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01258 
01259         return GMgr->Time;
01260 }

VidMode GameMgr_GetVidMode GameMgr GMgr  ) 
 

Definition at line 1275 of file GameMgr.c.

References GameMgr_IsValid(), GE_TRUE, VidMode, and GameMgr::VidMode.

Referenced by Host_Create(), WinMain(), and WndProc().

01276 {
01277         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01278 
01279         return GMgr->VidMode;
01280 }

geWorld* GameMgr_GetWorld GameMgr GMgr  ) 
 

Definition at line 1183 of file GameMgr.c.

References GameMgr_IsValid(), GE_TRUE, GameMgr_WorldInfo::World, and GameMgr::WorldInfo.

Referenced by CheckClientPlayerChanges(), Client_DestroyPlayerWorldObjects(), Client_GetWorld(), Client_MoveClientLocally(), Client_MovePlayerModel(), Client_UpdateSinglePlayer(), ForceServerPlayerOnLocalClient(), GameMgr_SetWorld(), ParseClientMove(), ReadServerMessages(), RenderWorld(), SendPlayersToClients(), Server_Frame(), Server_GetPlayerTimeExtents(), Server_GetWorld(), Server_ModelToViewIndex(), Server_MovePlayerModel(), Server_SendClientCurrentWorldData(), Server_SendClientStartupData(), Server_SetupClientWithCurrentWorld(), Server_SetupWorld(), Server_SpawnWorld(), Server_ValidateClient(), SetClientProxyPlayer(), UpdatePlayers(), and WinMain().

01184 {
01185         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01186 
01187         return GMgr->WorldInfo[0].World;
01188 }

geBoolean GameMgr_IsValid GameMgr GMgr  ) 
 

Definition at line 325 of file GameMgr.c.

References GameMgr::Engine, GE_FALSE, GE_TRUE, geBoolean, geErrorLog_AddString, NULL, GameMgr::SelfCheck1, and GameMgr::SelfCheck2.

Referenced by GameMgr_BeginFrame(), GameMgr_Destroy(), GameMgr_EndFrame(), GameMgr_Frame(), GameMgr_FreeWorld(), GameMgr_GetActorIndex(), GameMgr_GetBoneIndex(), GameMgr_GetCamera(), GameMgr_GetConsole(), GameMgr_GetEngine(), GameMgr_GetFrameState(), GameMgr_GetFxSystem(), GameMgr_GethWnd(), GameMgr_GetModel(), GameMgr_GetMotionIndexDef(), GameMgr_GetNumModels(), GameMgr_GetShadowMap(), GameMgr_GetSoundIndex(), GameMgr_GetSoundSystem(), GameMgr_GetTextureIndex(), GameMgr_GetTime(), GameMgr_GetVidMode(), GameMgr_GetWorld(), GameMgr_PrepareToChangeMode(), GameMgr_SetActorIndex(), GameMgr_SetBoneIndex(), GameMgr_SetDriverAndMode(), GameMgr_SetMotionIndexDef(), GameMgr_SetSoundIndex(), GameMgr_SetTextureIndex(), and GameMgr_SetWorld().

00326 {
00327         if (!GMgr)
00328         {
00329                 geErrorLog_AddString(-1, "GameMgr_IsValid:  The GameMgr object passed was NULL.", NULL);
00330                 return GE_FALSE;
00331         }
00332 
00333         if (GMgr->SelfCheck1 != GMgr)                   // Check head of struct
00334         {
00335                 geErrorLog_AddString(-1, "GameMgr_IsValid:  SelfCheck1 is invalid.", NULL);
00336                 return GE_FALSE;
00337         }
00338 
00339         if (GMgr->SelfCheck2 != GMgr)                   // Check tail of struct
00340         {
00341                 geErrorLog_AddString(-1, "GameMgr_IsValid:  SelfCheck2 is invalid.", NULL);
00342                 return GE_FALSE;
00343         }
00344 
00345         if (!GMgr->Engine)
00346         {
00347                 geErrorLog_AddString(-1, "GameMgr_IsValid:  Engine is NULL.", NULL);
00348                 return GE_FALSE;
00349         }
00350 
00351         return GE_TRUE;
00352 }

geBoolean GameMgr_MotionIndexIsValid GameMgr GMgr,
GameMgr_MotionIndex  Index
 

Definition at line 919 of file GameMgr.c.

References GAMEMGR_MAX_MOTION_INDEX, GAMEMGR_MOTION_INDEX_NONE, GE_FALSE, GE_TRUE, and geBoolean.

Referenced by GameMgr_GetMotionIndexDef(), and GameMgr_SetMotionIndexDef().

00920 {
00921         if (Index == GAMEMGR_MOTION_INDEX_NONE)
00922                 return GE_FALSE;
00923 
00924         if (Index < 0 || Index >= GAMEMGR_MAX_MOTION_INDEX)
00925                 return GE_FALSE;
00926 
00927         return GE_TRUE;
00928 }

void GameMgr_PrepareToChangeMode GameMgr GMgr  ) 
 

Definition at line 357 of file GameMgr.c.

References GameMgr::Camera, GameMgr::Console, Console_Destroy(), GameMgr_IsValid(), GE_TRUE, geCamera_Destroy(), and NULL.

Referenced by PickMode().

00358 {
00359         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00360 
00361         if (GMgr->Camera)
00362                 geCamera_Destroy(&GMgr->Camera);
00363         GMgr->Camera = NULL;
00364 
00365         if (GMgr->Console)
00366                 Console_Destroy(GMgr->Console);
00367         GMgr->Console = NULL;
00368 }

void GameMgr_ResetMainWindow HWND  hWnd,
int32  Width,
int32  Height
 

Definition at line 1285 of file GameMgr.c.

References tagRECT::bottom, FALSE, tagRECT::left, tagRECT::right, and tagRECT::top.

Referenced by AutoSelect_PickDriver(), CreateMainWindow(), and PickMode().

01286 {
01287         RECT ScreenRect;
01288 
01289         GetWindowRect(GetDesktopWindow(),&ScreenRect);
01290 
01291         SetWindowLong(hWnd, 
01292                  GWL_STYLE, 
01293                  GetWindowLong(hWnd, GWL_STYLE) & ~WS_POPUP);
01294 
01295         SetWindowLong(hWnd, 
01296                  GWL_STYLE, 
01297                  GetWindowLong(hWnd, GWL_STYLE) | (WS_OVERLAPPED  | 
01298                                                    WS_CAPTION     | 
01299                                                    WS_SYSMENU     | 
01300                                                    WS_MINIMIZEBOX));
01301 
01302         SetWindowLong(hWnd, 
01303                   GWL_STYLE, 
01304                   GetWindowLong(hWnd, GWL_STYLE) | WS_THICKFRAME |
01305                                                      WS_MAXIMIZEBOX);
01306 
01307         //SetWindowLong(hWnd, 
01308     //              GWL_EXSTYLE, 
01309     //              GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_TOPMOST);
01310 
01311         {
01312                 RECT ClientRect;
01313                 int Style = GetWindowLong (hWnd, GWL_STYLE);
01314                 
01315                 ClientRect.left = 0;
01316                 ClientRect.top = 0;
01317                 ClientRect.right = Width - 1;
01318                 ClientRect.bottom = Height - 1;
01319                 AdjustWindowRect (&ClientRect, Style, FALSE);   // FALSE == No menu     
01320                 
01321                 {
01322                         int WindowWidth = ClientRect.right - ClientRect.left + 1;
01323                         int WindowHeight = ClientRect.bottom - ClientRect.top + 1;
01324                         SetWindowPos 
01325                         (
01326                                 hWnd, HWND_TOP,
01327                                 (ScreenRect.right+ScreenRect.left)/2 - WindowWidth/2,
01328                                 (ScreenRect.bottom+ScreenRect.top)/2 - WindowHeight/2, 
01329                                 WindowWidth, WindowHeight,
01330                                 SWP_NOCOPYBITS | SWP_NOZORDER
01331                         );
01332                 }
01333         }
01334 
01335         ShowWindow(hWnd, SW_SHOWNORMAL);
01336         UpdateWindow(hWnd);
01337         SetFocus(hWnd);
01338 }

geBoolean GameMgr_SetActorIndex GameMgr GMgr,
int32  Index,
const char *  FileName
 

Definition at line 852 of file GameMgr.c.

References GameMgr_ActorIndex::Active, GameMgr_ActorIndex::ActorDef, GameMgr_ActorIndex::ActorHack, GameMgr::ActorIndex, GameMgr_ActorIndex::FileName, FrameState_None, GameMgr_GetFrameState(), GameMgr_IsValid(), GAMEMGR_MAX_ACTOR_INDEX, GAMEMGR_MAX_ACTOR_NAME, GE_FALSE, GE_TRUE, GE_VFILE_OPEN_READONLY, geActor_Create(), geActor_DefCreateFromFile(), geBoolean, GenVS_Error(), geVFile_Close(), geVFile_Open(), geWorld_AddActor(), MainFS, NULL, GameMgr_WorldInfo::World, and GameMgr::WorldInfo.

Referenced by ReadServerMessages(), and Server_ActorIndex().

00853 {
00854         GameMgr_WorldInfo       *WInfo;
00855         GameMgr_ActorIndex      *ActorIndex;
00856         geVFile *                               File;
00857 
00858         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00859         assert(FileName);
00860         assert(strlen(FileName) < GAMEMGR_MAX_ACTOR_NAME);
00861         assert(Index < GAMEMGR_MAX_ACTOR_INDEX);
00862 
00863         ActorIndex = &GMgr->ActorIndex[Index];
00864 
00865         assert(ActorIndex->ActorDef == NULL);
00866         assert(ActorIndex->ActorHack == NULL);
00867         assert(ActorIndex->Active == GE_FALSE);
00868         assert(GameMgr_GetFrameState(GMgr) == FrameState_None);
00869 
00870         if (GameMgr_GetFrameState(GMgr) != FrameState_None)
00871                 GenVS_Error("GameMgr_SetActorIndex:  GameMgr_GetFrameState(GMgr) != FrameState_None.\n");
00872 
00873         WInfo = &GMgr->WorldInfo[0];
00874 
00875         assert(WInfo->World);
00876 
00877         if (!WInfo->World)
00878                 GenVS_Error("GameMgr_SetActorIndex:  NULL World.\n");
00879 
00880         // It is safe to load the mesh index at this point...
00881         File = geVFile_Open(MainFS, FileName, GE_VFILE_OPEN_READONLY);
00882 
00883         if      (!File)
00884                 GenVS_Error("GameMgr_SetActorIndex:  geVFile_Open failed: %s.\n", FileName);
00885 
00886         ActorIndex->ActorDef = geActor_DefCreateFromFile(File);
00887         geVFile_Close(File);
00888 
00889         if (!ActorIndex->ActorDef)
00890                 GenVS_Error("GameMgr_SetActorIndex:  geActor_DefCreateFromFile failed: %s.\n", FileName);
00891 
00892         // Make our "fake" player, do we know for sure that the textures will remain in memory...
00893         ActorIndex->ActorHack = geActor_Create(ActorIndex->ActorDef);
00894         geWorld_AddActor(WInfo->World, ActorIndex->ActorHack, 0, 0);
00895         
00896         if (!ActorIndex->ActorHack)
00897                 GenVS_Error("GameMgr_SetActorIndex:  geWorld_AddActor failed: %s.\n", FileName);
00898 
00899         strcpy(ActorIndex->FileName, FileName);
00900         ActorIndex->Active = GE_TRUE;
00901 
00902         return GE_TRUE;
00903 }

geBoolean GameMgr_SetBoneIndex GameMgr GMgr,
int32  BoneIndex,
const char *  BoneName
 

Definition at line 961 of file GameMgr.c.

References GameMgr_BoneIndex::Active, GameMgr::BoneIndex, GameMgr_BoneIndex::BoneName, GameMgr_IsValid(), GAMEMGR_MAX_BONE_INDEX, GAMEMGR_MAX_BONE_NAME, GE_FALSE, GE_TRUE, and geBoolean.

Referenced by ReadServerMessages(), and Server_BoneIndex().

00962 {
00963         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00964         assert(BoneName);
00965         assert(BoneIndex < GAMEMGR_MAX_BONE_INDEX);
00966         assert(strlen(BoneName) < GAMEMGR_MAX_BONE_NAME);
00967         assert(GMgr->BoneIndex[BoneIndex].Active == GE_FALSE);
00968 
00969         strcpy(GMgr->BoneIndex[BoneIndex].BoneName, BoneName);
00970         GMgr->BoneIndex[BoneIndex].Active = GE_TRUE;
00971 
00972         return GE_TRUE;
00973 }

geBoolean GameMgr_SetDriverAndMode GameMgr GMgr,
geDriver Driver,
geDriver_Mode DriverMode,
int  Width,
int  Height
 

Definition at line 373 of file GameMgr.c.

References GE_Rect::Bottom, GameMgr::Camera, GameMgr::Console, Console_Create(), Console_Printf(), GameMgr::Engine, GameMgr_IsValid(), GE_FALSE, GE_TRUE, geBoolean, geCamera_Create(), geCamera_SetZScale(), GenVS_Error(), GE_Rect::Left, GE_Rect::Right, GE_Rect::Top, GameMgr::VidMode, and VidMode_SetResolution().

Referenced by PickMode().

00374 {
00375         geRect          CameraRect = {0, 0, 0, 0};
00376 
00377         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00378 
00379         if (VidMode_SetResolution(&(GMgr->VidMode),Width,Height)==GE_FALSE)
00380                 GenVS_Error("GameMgr_SetDriverAndMode:  VidMode_SetResolution failed.\n");
00381 
00382         // Make the camera be a good default value...
00383         CameraRect.Left = 0;
00384         CameraRect.Right = Width-1;
00385         CameraRect.Top = 0;
00386         CameraRect.Bottom = Height-1;
00387 
00388         //
00389         // Then create a camera for client, etc to use for rendering, etc...
00390         //
00391         GMgr->Camera = geCamera_Create(2.0f, &CameraRect);
00392 
00393         if (!GMgr->Camera)
00394                 GenVS_Error("GameMgr_SetDriverAndMode:  geCamera_Create failed.\n");
00395 
00396         // Set the camera ZScale
00397 //      geCamera_SetZScale(GMgr->Camera, 0.5f);
00398         geCamera_SetZScale(GMgr->Camera, 1.0f);
00399 
00400         //
00401         // Create the console with the new vid mode...
00402         //
00403         GMgr->Console = Console_Create(GMgr->Engine, GMgr->VidMode);
00404 
00405         if (!GMgr->Console)
00406                 GenVS_Error("GameMgr_SetDriverAndMode:  Console_Create failed.\n");
00407 
00408         Console_Printf(GMgr->Console, "Console Created...\n");
00409 
00410         return GE_TRUE;
00411 }

geBoolean GameMgr_SetMotionIndexDef GameMgr GMgr,
GameMgr_MotionIndex  Index,
const char *  MotionName
 

Definition at line 933 of file GameMgr.c.

References GameMgr_MotionIndexDef::Active, GameMgr_IsValid(), GAMEMGR_MAX_MOTION_NAME, GameMgr_MotionIndexIsValid(), GE_FALSE, GE_TRUE, geBoolean, GameMgr::MotionIndexDefs, and GameMgr_MotionIndexDef::MotionName.

Referenced by ReadServerMessages(), and Server_MotionIndex().

00934 {
00935         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00936         assert(MotionName);
00937         assert(strlen(MotionName) < GAMEMGR_MAX_MOTION_NAME);
00938         assert(GameMgr_MotionIndexIsValid(GMgr, Index));
00939         assert(GMgr->MotionIndexDefs[Index].Active == GE_FALSE);
00940 
00941         strcpy(GMgr->MotionIndexDefs[Index].MotionName, MotionName);
00942         GMgr->MotionIndexDefs[Index].Active = GE_TRUE;
00943 
00944         return GE_TRUE;
00945 }

geBoolean GameMgr_SetSoundIndex GameMgr GMgr,
int32  SoundIndex,
const char *  FileName
 

Definition at line 1101 of file GameMgr.c.

References GameMgr_SoundIndex::Active, GameMgr_SoundIndex::FileName, GameMgr_IsValid(), GAMEMGR_MAX_FILENAME, GAMEMGR_MAX_SOUND_INDEX, GE_FALSE, GE_TRUE, GE_VFILE_OPEN_READONLY, geBoolean, GenVS_Error(), geSound_LoadSoundDef(), geVFile_Close(), geVFile_Open(), MainFS, NULL, GameMgr_SoundIndex::SoundDef, GameMgr::SoundIndex, and GameMgr::SoundSys.

Referenced by ReadServerMessages(), and Server_SoundIndex().

01102 {
01103         GameMgr_SoundIndex      *pSoundIndex;
01104         geVFile *                               File;
01105 
01106         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
01107         
01108         if (!GMgr->SoundSys)
01109                 return GE_TRUE;
01110         
01111         assert(FileName);
01112         assert(SoundIndex < GAMEMGR_MAX_SOUND_INDEX);
01113         assert(strlen(FileName) < GAMEMGR_MAX_FILENAME);
01114         
01115         pSoundIndex = &GMgr->SoundIndex[SoundIndex];
01116 
01117         assert(pSoundIndex->Active == GE_FALSE);
01118         assert(pSoundIndex->SoundDef == NULL);
01119 
01120         File = geVFile_Open(MainFS, FileName, GE_VFILE_OPEN_READONLY);
01121 
01122         if (!File)
01123                 GenVS_Error("GameMgr_SetSoundIndex:  geVFile_Open failed: %s.\n", FileName);
01124 
01125         pSoundIndex->SoundDef = geSound_LoadSoundDef(GMgr->SoundSys, File);
01126         geVFile_Close(File);
01127 
01128         if (!pSoundIndex->SoundDef)
01129                 GenVS_Error("geSound_LoadSoundDef:  geVFile_Open failed: %s.\n", FileName);
01130 
01131         assert(pSoundIndex->SoundDef);
01132 
01133         strcpy(pSoundIndex->FileName, FileName);
01134         pSoundIndex->Active = GE_TRUE;
01135 
01136         return GE_TRUE;
01137 }

geBoolean GameMgr_SetTextureIndex GameMgr GMgr,
int32  Index,
const char *  FileName,
const char *  AFileName
 

Definition at line 989 of file GameMgr.c.

References GameMgr_TextureIndex::Active, GameMgr_TextureIndex::AFileName, GameMgr_TextureIndex::FileName, FrameState_None, GameMgr_GetFrameState(), GameMgr_IsValid(), GAMEMGR_MAX_FILENAME, GAMEMGR_MAX_TEXTURE_INDEX, GE_FALSE, GE_TRUE, geBitmap_CreateFromFileName(), geBitmap_Destroy(), geBitmap_SetAlpha(), geBoolean, geErrorLog_AddString, GenVS_Error(), geWorld_AddBitmap(), MainFS, NULL, GameMgr_TextureIndex::TextureDef, GameMgr::TextureIndex, GameMgr_WorldInfo::World, and GameMgr::WorldInfo.

Referenced by ReadServerMessages(), and Server_TextureIndex().

00990 {
00991         GameMgr_WorldInfo               *WInfo;
00992         const char                              *pFileName, *pAFileName;
00993         GameMgr_TextureIndex    *TextureIndex;
00994         geBitmap                                *ABitmap;
00995 
00996         ABitmap = NULL;
00997 
00998         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00999         assert(Index >= 0 && Index < GAMEMGR_MAX_TEXTURE_INDEX);
01000         assert(FileName);
01001         assert(FileName[0]);
01002         assert(strlen(FileName) < GAMEMGR_MAX_FILENAME);
01003 
01004         TextureIndex = &GMgr->TextureIndex[Index];
01005 
01006         assert(TextureIndex->TextureDef == NULL);
01007         assert(TextureIndex->Active == GE_FALSE);
01008         assert(GameMgr_GetFrameState(GMgr) == FrameState_None);
01009 
01010         if (GameMgr_GetFrameState(GMgr) != FrameState_None)
01011                 GenVS_Error("GameMgr_SetTextureIndex:  GameMgr_GetFrameState(GMgr) != FrameState_None.\n");
01012 
01013         WInfo = &GMgr->WorldInfo[0];
01014 
01015         assert(WInfo->World);
01016 
01017         if (!WInfo->World)
01018                 GenVS_Error("GameMgr_SetTextureIndex:  NULL World.\n");
01019 
01020         // It is now safe to load the texture...
01021         // It better be NULL first!!! ot somthing went wrong...
01022         pFileName = FileName;
01023         
01024         if (AFileName && AFileName[0])
01025         {
01026                 assert(strlen(AFileName) < GAMEMGR_MAX_FILENAME);
01027                 pAFileName = AFileName;
01028         }
01029         else
01030                 pAFileName = NULL;
01031 
01032         // Create the bitmaps
01033         TextureIndex->TextureDef = geBitmap_CreateFromFileName(MainFS, pFileName);
01034 
01035         if (!TextureIndex->TextureDef)
01036         {
01037                 geErrorLog_AddString(-1, "GameMgr_SetTextureIndex:  geBitmap_CreateFromFileName failed:", pFileName);
01038                 goto ExitWithError;
01039         }
01040 
01041         // Load the alpha bitmap
01042         if (pAFileName)
01043         {
01044                 ABitmap = geBitmap_CreateFromFileName(MainFS, pAFileName);
01045 
01046                 if (!geBitmap_SetAlpha(TextureIndex->TextureDef, ABitmap))
01047                 {
01048                         geErrorLog_AddString(-1, "GameMgr_SetTextureIndex:  geBitmap_SetAlpha failed.", NULL);
01049                         goto ExitWithError;
01050                 }
01051                 
01052                 // Don't need this anymore
01053                 geBitmap_Destroy(&ABitmap);
01054         }
01055 
01056         if (!geWorld_AddBitmap(WInfo->World, TextureIndex->TextureDef))
01057         {
01058                 geErrorLog_AddString(-1, "GameMgr_SetTextureIndex:  geWorld_AddBimap failed.", NULL);
01059                 goto ExitWithError;
01060         }
01061 
01062         strcpy(TextureIndex->FileName, FileName);
01063         strcpy(TextureIndex->AFileName, AFileName);
01064         TextureIndex->Active = GE_TRUE;
01065 
01066         return GE_TRUE;
01067 
01068         ExitWithError:
01069         {
01070                 if (TextureIndex->TextureDef)
01071                 {
01072                         geBitmap_Destroy(&TextureIndex->TextureDef);
01073                         TextureIndex->TextureDef = NULL;
01074                 }
01075 
01076                 if (ABitmap)
01077                 {
01078                         geBitmap_Destroy(&ABitmap);
01079                         ABitmap = NULL;
01080                 }
01081 
01082                 GenVS_Error("GameMgr_SetTextureIndex:  Failed.\n");
01083                 return GE_FALSE;                // Shut up compiler
01084         }
01085 }

geBoolean GameMgr_SetWorld GameMgr GMgr,
const char *  WorldName
 

Definition at line 722 of file GameMgr.c.

References Corona_Init(), DefaultExtension(), DynLight_Init(), Electric_Init(), GameMgr::Engine, FrameState_None, Fx_SystemCreate(), GameMgr::FxSystem, GameMgr_ClearBackground(), GameMgr_FreeWorld(), GameMgr_GetEngine(), GameMgr_GetFrameState(), GameMgr_GetSoundSystem(), GameMgr_GetWorld(), GameMgr_IsValid(), GAMEMGR_MAX_MODELS, GAMEMGR_MAX_WORLD_NAME, GE_TRUE, GE_VFILE_OPEN_READONLY, geBitmapUtil_CreateFromFileAndAlphaNames(), geBoolean, geEngine_AddWorld(), GenVS_Error(), geVFile_Close(), geVFile_Open(), geWorld_AddBitmap(), geWorld_Create(), geWorld_GetNextModel(), geWorld_SetLTypeTable(), MainFS, ModelCtl_Init(), GameMgr_WorldInfo::Models, NULL, GameMgr_WorldInfo::NumModels, GameMgr::ProcEng, ProcEng_Create(), GameMgr::ShadowMap, GameMgr::VidMode, VidMode_GetResolution(), GameMgr_WorldInfo::World, and GameMgr::WorldInfo.

Referenced by ReadServerMessages(), and Server_Frame().

00723 {
00724         GameMgr_WorldInfo       *WInfo;
00725         geWorld_Model           *Model;
00726         geVFile *                       WorldFile;
00727         char                            TFile[GAMEMGR_MAX_WORLD_NAME+4];
00728         int                                     Width,Height;
00729         int                                     MessageWidth = 250;
00730 
00731         assert(GameMgr_IsValid(GMgr) == GE_TRUE);
00732         assert(strlen(WorldName) < GAMEMGR_MAX_WORLD_NAME);
00733         
00734         strcpy(TFile, WorldName);
00735 
00736         DefaultExtension(TFile, ".BSP");
00737 
00738         WInfo = &GMgr->WorldInfo[0];
00739 
00740         if (GameMgr_GetFrameState(GMgr) != FrameState_None)
00741                 GenVS_Error("GameMgr_SetWorld:  GameMgr_GetFrameState(GMgr) != FrameState_None.\n");
00742 
00743         VidMode_GetResolution(GMgr->VidMode,&Width,&Height);
00744 
00745         if (!GameMgr_ClearBackground(GMgr, (Width/2)-(MessageWidth/2), Height/2-10, "Loading level, please wait..."))
00746                 GenVS_Error("GameMgr_SetWorld:  GameMgr_ClearBackground failed.\n");
00747         //GameMgr_ConsolePrintf(GMgr, GE_TRUE, "Loading level, please wait...\n");
00748 
00749         // Make sure we free the old world!!!
00750         GameMgr_FreeWorld(GMgr);                // Clear all that belongs to world stuff
00751 
00752         WorldFile = geVFile_Open(MainFS, TFile, GE_VFILE_OPEN_READONLY);
00753 
00754         if      (!WorldFile)
00755                 GenVS_Error("GameMgr_SetWorld:  geVFile_Open failed: %s.\n", TFile);
00756 
00757         WInfo->World = geWorld_Create(WorldFile);
00758         geVFile_Close(WorldFile);
00759 
00760         if (!WInfo->World)
00761                 GenVS_Error("GameMgr_SetWorld:  geWorld_Create failed: %s.\n", TFile);
00762 
00763         if (!geEngine_AddWorld(GMgr->Engine, WInfo->World))
00764                 GenVS_Error("GameMgr_SetWorld:  geEngine_AddWorld failed: %s.\n", TFile);
00765 
00766         {
00767         char ProcCfgName[1024];
00768         geVFile * ProcCfgFile;
00769                 strcpy(ProcCfgName,TFile);
00770                 assert( ProcCfgName[ strlen(TFile) - 4 ] == '.' );
00771                 ProcCfgName[ strlen(TFile) - 4 ] = 0;
00772                 strcat(ProcCfgName,".prc");
00773                 ProcCfgFile = geVFile_Open(MainFS,ProcCfgName, GE_VFILE_OPEN_READONLY);
00774                 
00775                 if      (!ProcCfgFile)
00776                 {
00777                 }
00778                 else
00779                 {
00780                         GMgr->ProcEng = ProcEng_Create(ProcCfgFile, WInfo->World);
00781                         geVFile_Close(ProcCfgFile);
00782                 }
00783         }
00784 
00785         GMgr->FxSystem = Fx_SystemCreate(WInfo->World, NULL);
00786 
00787         if (!GMgr->FxSystem)
00788                 GenVS_Error("GameMgr_SetWorld:  Fx_SystemCreate failed.\n");
00789 
00790         // Create the gamemgr shadow map
00791         if (!(GMgr->ShadowMap = geBitmapUtil_CreateFromFileAndAlphaNames(MainFS, "Bmp\\Fx\\Smoke_05.bmp", "Bmp\\Fx\\A_Smk05.bmp")) )
00792                 GenVS_Error("GameMgr_SetWorld:  geBitmapUtil_CreateFromFileAndAlphaNames failed.\n");
00793 
00794         if (!geWorld_AddBitmap( WInfo->World, GMgr->ShadowMap) )
00795                 GenVS_Error("GameMgr_SetWorld:  geWorld_AddBitmap failed.\n");
00796 
00797         // Setup the models with the world
00798         WInfo->NumModels = 0;
00799         Model = NULL;
00800 
00801         while(1)
00802         {
00803                 assert(WInfo->NumModels <= GAMEMGR_MAX_MODELS);
00804 
00805                 Model = geWorld_GetNextModel(WInfo->World, Model);
00806 
00807                 if (!Model)
00808                         break;
00809 
00810                 WInfo->Models[WInfo->NumModels] = Model;
00811                 WInfo->NumModels++;
00812         }
00813 
00814         // Set some light type defaults
00815         geWorld_SetLTypeTable(WInfo->World, 0, "z");
00816         geWorld_SetLTypeTable(WInfo->World, 1, "mmnmmommommnonmmonqnmmo");
00817         geWorld_SetLTypeTable(WInfo->World, 2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
00818         geWorld_SetLTypeTable(WInfo->World, 3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
00819         geWorld_SetLTypeTable(WInfo->World, 4, "mamamamamama");
00820         geWorld_SetLTypeTable(WInfo->World, 5, "jklmnopqrstuvwxyzyxwvutsrqponmlkj");
00821         geWorld_SetLTypeTable(WInfo->World, 6, "nmonqnmomnmomomno");
00822         geWorld_SetLTypeTable(WInfo->World, 7, "mmmaaaabcdefgmmmmaaaammmaamm");
00823         geWorld_SetLTypeTable(WInfo->World, 8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
00824         geWorld_SetLTypeTable(WInfo->World, 9, "aaaaaaaazzzzzzzz");
00825         geWorld_SetLTypeTable(WInfo->World, 10,"mmamammmmammamamaaamammma");
00826         geWorld_SetLTypeTable(WInfo->World, 11,"abcdefghijklmnopqrrqponmlkjihgfedcba");
00827 
00828         assert(GMgr->Engine);
00829         
00830         // Create the coronas
00831         if (!Corona_Init(GameMgr_GetEngine(GMgr), GameMgr_GetWorld(GMgr), MainFS))
00832                 GenVS_Error("GameMgr_SetWorld:  Corona_Init failed.\n");
00833 
00834         // Create the electric interface
00835         if (!Electric_Init(GameMgr_GetEngine(GMgr), GameMgr_GetWorld(GMgr), MainFS, GameMgr_GetSoundSystem(GMgr)))
00836                 GenVS_Error("GameMgr_SetWorld:  Electric_Init failed.\n");
00837 
00838         // Create the dynlight interface
00839         if (!DynLight_Init(GameMgr_GetEngine(GMgr), GameMgr_GetWorld(GMgr), MainFS))
00840                 GenVS_Error("GameMgr_SetWorld:  DynLight_Init failed.\n");
00841 
00842         // Create the ModelCtl interface
00843         if (!ModelCtl_Init())
00844                 GenVS_Error("GameMgr_SetWorld:  ModelCtl_Init failed.\n");
00845 
00846         return GE_TRUE;
00847 }

void GenVS_Error const char *  Msg,
... 
 

LRESULT CALLBACK WndProc HWND  hWnd,
UINT  iMessage,
WPARAM  wParam,
LPARAM  lParam
 

Definition at line 884 of file Genvs.c.

References AdjustPriority(), GE_Rect::Bottom, tagRECT::bottom, ChangeDisplaySelection, ChangingDisplayMode, Host_Init::ClientName, Console, Console_KeyDown(), Console_Printf(), Console_ToggleActive(), Host_Init::DemoMode, DriverModeList, Engine, FALSE, GameMgr_GethWnd(), GameMgr_GetVidMode(), GameRunning, GE_FALSE, GE_TRUE, geBoolean, geEngine_Activate(), geEngine_ScreenShot(), geEngine_UpdateWindow(), GlobalMouseFlags, GMenu_Connect, GMenu_DoNothing, GMenu_GetMenu(), GMenu_IPEntry, GMenu_IsAMenuActive(), GMenu_Key(), GMenu_NameEntry, GMenu_QuitGame, GMenu_SinglePlayerGame, GMenu_SinglePlayerGame1, GMenu_SinglePlayerGame2, GMenu_SinglePlayerGame3, GMenu_StartGame, GMenu_StartGame1, GMenu_StartGame2, GMenu_UserSinglePlayerGame, GMgr, Host, Host_Create(), HOST_DEMO_NONE, HOST_DEMO_PLAY, Host_Destroy(), HOST_MODE_CLIENT, HOST_MODE_SERVER_CLIENT, HOST_MODE_SINGLE_PLAYER, HostInit, Host_Init::hWnd, int32, Host_Init::IPAddress, GE_Rect::Left, tagRECT::left, Host_Init::LevelHack, Menu_GetStringText(), Host_Init::Mode, NULL, ResetMouse, GE_Rect::Right, tagRECT::right, Running, GE_Rect::Top, tagRECT::top, TRUE, and Host_Init::UserLevel.

Referenced by CreateMainWindow(), and WindowSetup().

00885 {
00886         switch(iMessage)
00887         {
00888                 case WM_SYSCOMMAND:
00889                         if (wParam == SC_SCREENSAVE)
00890                                 return 1;
00891                         break;
00892                 case WM_DISPLAYCHANGE:
00893                         {
00894                                 if (DriverModeList)
00895                                         {
00896                                                 if (DriverModeList[ChangeDisplaySelection].InAWindow)
00897                                                         ChangingDisplayMode=GE_TRUE;
00898                                         }
00899                                 break;
00900                         }
00901                 case WM_ACTIVATEAPP:
00902                 {
00903                         if(Engine)
00904                         {
00905                                 geEngine_Activate(Engine, wParam);
00906                         }
00907 
00908                         if(GameRunning)
00909                         {
00910 
00911                         #ifdef CLIP_CURSOR      
00912                                 if(wParam && GMgr)
00913                                 {
00914                                         RECT    ClipRect;
00915                                         RECT    ClientRect;
00916                                         POINT   RPoint;
00917                                                   
00918                                         GetClientRect(GameMgr_GethWnd(GMgr), &ClientRect);
00919                                         RPoint.x                =ClientRect.left;
00920                                         RPoint.y                =ClientRect.top;
00921                                         ClientToScreen(GameMgr_GethWnd(GMgr), &RPoint);
00922                                         ClipRect.left   =RPoint.x;
00923                                         ClipRect.top    =RPoint.y;
00924 
00925                                         RPoint.x                =ClientRect.right;
00926                                         RPoint.y                =ClientRect.bottom;
00927                                         ClientToScreen(GameMgr_GethWnd(GMgr), &RPoint);
00928                                         ClipRect.right  =RPoint.x;
00929                                         ClipRect.bottom =RPoint.y;
00930                                         ClipCursor(&ClipRect);
00931                                         ResetMouse      =TRUE;
00932                                 }
00933                                 else
00934                                 {
00935                                         ResetMouse      =FALSE;
00936                                         ClipCursor(NULL);
00937                                 }
00938                         #endif
00939                         }
00940                         if ( wParam )
00941                                 {
00942                                         AdjustPriority(THREAD_PRIORITY_HIGHEST);
00943                                 }
00944                         else
00945                                 {
00946                                         AdjustPriority(THREAD_PRIORITY_NORMAL);
00947                                 }
00948                         return  0;
00949                 }
00950                 case WM_MOVE:
00951                 {
00952                         if(GameRunning)
00953                         {
00954                                 geRect          ClipRect;
00955                                 RECT            ClientRect;
00956                                 POINT           RPoint;
00957                                 geBoolean       Ret;
00958 
00959                                 GetClientRect(GameMgr_GethWnd(GMgr), &ClientRect);
00960                                 RPoint.x                =ClientRect.left;
00961                                 RPoint.y                =ClientRect.top;
00962                                 ClientToScreen(GameMgr_GethWnd(GMgr), &RPoint);
00963                                 ClipRect.Left   =RPoint.x;
00964                                 ClipRect.Top    =RPoint.y;
00965 
00966                                 RPoint.x                =ClientRect.right;
00967                                 RPoint.y                =ClientRect.bottom;
00968                                 ClientToScreen(GameMgr_GethWnd(GMgr), &RPoint);
00969                                 ClipRect.Right  =RPoint.x;
00970                                 ClipRect.Bottom =RPoint.y;
00971                                 Ret = geEngine_UpdateWindow(Engine);
00972 
00973                                 assert(Ret == GE_TRUE);
00974                         }
00975                         return  0;
00976                 }
00977                 case WM_MOUSEMOVE:
00978                 {
00979                         return FALSE;
00980                         break;
00981                 }
00982 
00983                 case WM_RBUTTONDOWN:
00984                 case WM_LBUTTONUP:
00985                 case WM_RBUTTONUP:
00986                 case WM_LBUTTONDOWN:
00987                 {
00988                         switch ( iMessage )
00989                         {
00990                                 case WM_LBUTTONDOWN:
00991                                         GlobalMouseFlags |= 1;
00992                                         lParam = VK_LBUTTON;
00993                                         break;
00994                                 case WM_RBUTTONDOWN:
00995                                         GlobalMouseFlags |= 2;
00996                                         lParam = VK_RBUTTON;
00997                                         break;
00998                                 case WM_LBUTTONUP:
00999                                         GlobalMouseFlags &= ~1;
01000                                         lParam = VK_LBUTTON;
01001                                         break;
01002                                 case WM_RBUTTONUP:
01003                                         GlobalMouseFlags &= ~2;
01004                                         lParam = VK_RBUTTON;
01005                                         break;
01006                         }
01007 
01008                         // intentionally falls through if required
01009                         if ( GMenu_IsAMenuActive() == GE_FALSE )
01010                         {
01011                                 break;
01012                         }
01013                 }
01014 
01015                 case (WM_KEYDOWN):
01016                 {
01017                         // locals
01018                         int32                   Result;
01019 
01020                         // process keystroke result //undone
01021                         Result = GMenu_Key( wParam, lParam );
01022 
01023                         switch ( Result )
01024                         {
01025                                 
01026                                 case GMenu_DoNothing:
01027                                 {
01028                                         break;
01029                                 }
01030 
01031                                 case GMenu_UserSinglePlayerGame:
01032                                 case GMenu_SinglePlayerGame:
01033                                 case GMenu_SinglePlayerGame1:
01034                                 case GMenu_SinglePlayerGame2:
01035                                 case GMenu_SinglePlayerGame3:
01036                                 case GMenu_StartGame:
01037                                 case GMenu_StartGame1:
01038                                 case GMenu_StartGame2:
01039                                 case GMenu_Connect:
01040                                 {
01041                                         char    TempString[64];
01042 
01043                                         // Init the host struct
01044                                         if (HostInit.DemoMode == HOST_DEMO_PLAY)        // Make sure we are not in demo play mode...
01045                                                 HostInit.DemoMode = HOST_DEMO_NONE;
01046 
01047                                         HostInit.hWnd = GameMgr_GethWnd(GMgr);
01048                                         
01049                                         // Make sure there is a levelname just in case we are not in demo mode or somthing...
01050                                         strcpy(HostInit.LevelHack, "Levels\\GenVS.BSP");
01051 
01052                                         // zap old host
01053                                         if ( Host != NULL )
01054                                         { 
01055                                                 Host_Destroy( Host );
01056                                                 Host = NULL;
01057                                         }
01058                                 
01059                                         // set host type
01060                                         switch ( Result )
01061                                         {
01062                                                 case GMenu_UserSinglePlayerGame:
01063                                                 {
01064                                                         strcpy(HostInit.LevelHack, HostInit.UserLevel);
01065                                                         HostInit.Mode = HOST_MODE_SINGLE_PLAYER;
01066                                                         break;
01067                                                 }
01068 
01069                                                 case GMenu_SinglePlayerGame:
01070                                                 {
01071                                                         HostInit.Mode = HOST_MODE_SINGLE_PLAYER;
01072                                                         break;
01073                                                 }
01074 
01075                                                 case GMenu_SinglePlayerGame1:
01076                                                 {
01077                                                         strcpy(HostInit.LevelHack, "Levels\\GenVS.BSP");
01078                                                         HostInit.Mode = HOST_MODE_SINGLE_PLAYER;
01079                                                         break;
01080                                                 }
01081 
01082                                                 case GMenu_SinglePlayerGame2:
01083                                                 {
01084                                                         strcpy(HostInit.LevelHack, "Levels\\GenVS2.BSP");
01085                                                         HostInit.Mode = HOST_MODE_SINGLE_PLAYER;
01086                                                         break;
01087                                                 }
01088 
01089                                                 /*case GMenu_SinglePlayerGame3:
01090                                                 {
01091                                                         strcpy(HostInit.LevelHack, "Levels\\Gallery.BSP");
01092                                                         HostInit.Mode = HOST_MODE_SINGLE_PLAYER;
01093                                                         break;
01094                                                 }*/
01095 
01096                                                 case GMenu_StartGame:
01097                                                 {
01098                                                         HostInit.Mode = HOST_MODE_SERVER_CLIENT;
01099                                                         break;
01100                                                 }
01101 
01102                                                 case GMenu_StartGame1:
01103                                                 {
01104                                                         strcpy(HostInit.LevelHack, "Levels\\GenVS.BSP");
01105                                                         HostInit.Mode = HOST_MODE_SERVER_CLIENT;
01106                                                         break;
01107                                                 }
01108 
01109                                                 case GMenu_StartGame2:
01110                                                 {
01111                                                         strcpy(HostInit.LevelHack, "Levels\\GenVS2.BSP");
01112                                                         HostInit.Mode = HOST_MODE_SERVER_CLIENT;
01113                                                         break;
01114                                                 }
01115 
01116                                                 case GMenu_Connect:
01117                                                 {
01118                                                         HostInit.Mode = HOST_MODE_CLIENT;
01119                                                         break;
01120                                                 }
01121                                         }
01122 
01123                                         // Get the client name form the menu
01124                                         Menu_GetStringText( GMenu_GetMenu(GMenu_NameEntry), GMenu_NameEntry, TempString );
01125                                         strcpy(HostInit.ClientName, TempString);
01126 
01127                                         // Get the Ip address from the menu...
01128                                         Menu_GetStringText( GMenu_GetMenu(GMenu_IPEntry), GMenu_IPEntry, TempString );
01129                                         strcpy(HostInit.IPAddress, TempString);
01130 
01131                                         // create new host
01132                                         Host = Host_Create( Engine, &HostInit, GMgr, GameMgr_GetVidMode(GMgr));
01133                                         assert( Host != NULL );
01134                                         break;
01135                                 }
01136 
01137                                 case GMenu_QuitGame:
01138                                 {
01139                                         Running = 0;
01140                                         break;
01141                                 }
01142                         }
01143 
01144                         switch(wParam)
01145                         {
01146 
01147                                 case VK_F12:
01148                                 {
01149                                         int32           i;
01150                                         FILE            *f;
01151                                         char            Name[256];
01152 
01153                                         if (Engine)
01154                                         {
01155                                                 for (i=0 ;i<999; i++)           // Only 999 bmps, oh well...
01156                                                 {
01157                                                         sprintf(Name, "Bmp%i.Bmp", i);
01158 
01159                                                         f = fopen(Name, "rb");
01160 
01161                                                         if (f)
01162                                                         {
01163                                                                 fclose(f);
01164                                                                 continue;
01165                                                         }
01166                                                         
01167                                                         geEngine_ScreenShot(Engine, Name);
01168 
01169                                                         if (Console)
01170                                                                 Console_Printf(Console, "Writing Bmp: %s...\n", Name);
01171 
01172                                                         break;
01173                                                 }
01174                                         }
01175                                         break;
01176                                 }
01177 
01178                                 case 192:               // '~'
01179 
01180                                         if (Console)
01181                                                 Console_ToggleActive(Console);
01182                                         break;
01183 
01184                                 default:
01185                                         if (Console)
01186                                                 Console_KeyDown(Console, (char)wParam, GE_TRUE);
01187                                         break;
01188                         }
01189                         break;
01190                 }
01191                 
01192                 case (WM_KEYUP):
01193                 {
01194                         break;
01195                 }
01196 
01197                 case WM_DESTROY:
01198                         PostQuitMessage(0);
01199                         return  0;
01200 
01201 
01202                 default:
01203                         return DefWindowProc(hWnd, iMessage, wParam, lParam);
01204         }
01205         return 0;
01206 }


Variable Documentation

geVFile* MainFS
 

Definition at line 31 of file GameMgr.c.


Generated on Tue Sep 30 12:37:34 2003 for GTestAndEngine by doxygen 1.3.2