123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688 |
- //--------------------------------------------------------------------------
- //
- // And away we go. MechCommander 2 -- Electric Boogaloo
- //
- //---------------------------------------------------------------------------//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- //-----------------------------------
- // Include Files
- #ifndef MCLIB_H
- #include "mclib.h"
- #endif
- #ifndef MISSION_H
- #include "mission.h"
- #endif
- #ifndef UNITDESG_H
- #include "unitdesg.h"
- #endif
- #ifndef LOGISTICS_H
- #include "logistics.h"
- #endif
- #ifndef GAMESOUND_H
- #include "gamesound.h"
- #endif
- #ifndef SOUNDS_H
- #include "sounds.h"
- #endif
- #ifndef MULTPLYR_H
- #include "multplyr.h"
- #endif
- #ifndef TEAM_H
- #include "team.h"
- #endif
- #ifndef VERSION_H
- #include "version.h"
- #endif
- #ifndef TURRET_H
- #include "turret.h"
- #endif
- #ifndef OPTIONSSCREENWRAPPER_H
- #include "OptionsScreenWrapper.h"
- #endif
- #ifndef GAMELOG_H
- #include "gamelog.h"
- #endif
- #ifndef LOGISTICSDIALOG_H
- #include "LogisticsDialog.h"
- #endif'
- #ifndef PREFS_H
- #include "prefs.h"
- #endif
- extern CPrefs prefs;
- #include "..\resource.h"
- #include <GameOS.hpp>
- #include <ToolOS.hpp>
- #include <Stuff\stuff.hpp>
- #include <MLR\MLR.hpp>
- #include <GosFX\gosfxheaders.hpp>
- //------------------------------------------------------------------------------------------------------------
- // MechCmdr2 Global Instances of Things
- UserHeapPtr systemHeap = NULL;
- UserHeapPtr guiHeap = NULL;
- FastFile **fastFiles = NULL;
- long numFastFiles = 0;
- long maxFastFiles = 0;
- long GameDifficulty = 0;
- long gammaLevel = 0;
- extern long DigitalMasterVolume;
- extern long MusicVolume;
- extern long sfxVolume;
- extern long RadioVolume;
- extern long BettyVolume;
- long resolution = 0;
- long renderer = 0;
- long FilterState = gos_FilterNone;
- bool quitGame = FALSE;
- bool justStartMission = FALSE;
- bool gamePaused = FALSE;
- bool hasGuardBand = false;
- bool canMultiTextureDetail = false;
- bool useUnlimitedAmmo = true;
- bool useLeftRightMouseProfile = true; // if false, use old style commands
- bool justResaveAllMaps = false;
- extern bool useWaterInterestTexture;
- extern bool useShadows;
- extern bool aborted;
- bool gotBombData = false;
- TimerManagerPtr timerManager = NULL;
- bool initGameLogs = false;
- bool initNetLog = false;
- GameLog* NetLog = NULL;
- bool initCombatLog = false;
- GameLog* CombatLog = NULL;
- bool initBugLog = false;
- GameLog* BugLog = NULL;
- bool initLRMoveLog = false;
- bool KillAmbientLight = false;
- void InitDW (void);
- extern DWORD NumDevices;
- unsigned long elementHeapSize = 1024000;
- unsigned long maxElements = 2048;
- unsigned long maxGroups = 1024;
- unsigned long systemHeapSize = 8192000;
- unsigned long guiHeapSize = 1023999;
- unsigned long logisticsHeapSize = 4095999;
- unsigned long missionHeapSize = 3072000;
- unsigned long spriteDataHeapSize = 2048000;
- unsigned long spriteHeapSize = 8192000;
- unsigned long polyHeapSize = 1024000;
- extern float ProcessorSpeed;
- void __stdcall ExitGameOS();
- DWORD gosResourceHandle = 0;
- HGOSFONT3D gosFontHandle = 0;
- float gosFontScale = 1.0;
- extern HGOSFONT3D FontHandle;
- FloatHelpPtr globalFloatHelp = NULL;
- unsigned long currentFloatHelp = 0;
- float MaxMinUV = 8.0f;
- DWORD BaseVertexColor = 0x00000000; //This color is applied to all vertices in game as Brightness correction.
- enum { CPU_UNKNOWN, CPU_PENTIUM, CPU_MMX, CPU_KATMAI } Processor = CPU_PENTIUM; //Needs to be set when GameOS supports ProcessorID -- MECHCMDR2
- extern float frameRate;
- void EnterWindowMode();
- extern long MaxMoveGoalChecks;
- extern bool useSound;
- extern bool useMusic;
- long MaxResourcePoints = -1;
- bool ShowMovers = false;
- bool EnemiesGoalPlan = false;
- bool inViewMode = false;
- extern bool CullPathAreas;
- unsigned long viewObject = 0x0;
- char missionName[1024];
- extern char FileMissingString[];
- extern char CDMissingString[];
- extern char MissingTitleString[];
- char* ExceptionGameMsg = NULL;
- char buildNumber[80];
- extern long TERRAIN_TXM_SIZE;
- long ObjectTextureSize = 128;
- extern unsigned long MultiPlayCommanderId;
- extern bool useRealLOS;
- bool reloadBounds = false;
- extern long DrawDebugCells;
- extern long GameVisibleVertices;
- bool EULAShown = false;
- SoundSystem* sndSystem;
- extern bool gNoDialogs;
- //DEBUG
- #define MAX_SHAPES 0
- TG_MultiShape testShape[36];
- TG_AnimateShape testAnim[36];
- Stuff::Vector3D pos[36] =
- {
- Stuff::Vector3D(-3400.0f,3000.0f,-1.0f),
- Stuff::Vector3D(-3300.0f,2700.0f,-1.0f),
- Stuff::Vector3D(-3300.0f,2800.0f,-1.0f),
- Stuff::Vector3D(-3300.0f,2900.0f,-1.0f),
- Stuff::Vector3D(-3300.0f,3000.0f,-1.0f),
- Stuff::Vector3D(-3200.0f,2700.0f,-1.0f),
- Stuff::Vector3D(-3200.0f,2800.0f,-1.0f),
- Stuff::Vector3D(-3200.0f,2900.0f,-1.0f),
- Stuff::Vector3D(-3200.0f,3000.0f,-1.0f),
- Stuff::Vector3D(-3100.0f,2700.0f,-1.0f),
- Stuff::Vector3D(-3100.0f,2800.0f,-1.0f),
- Stuff::Vector3D(-3100.0f,2900.0f,-1.0f),
- Stuff::Vector3D(-3100.0f,3000.0f,-1.0f),
- Stuff::Vector3D(-3000.0f,2700.0f,-1.0f),
- Stuff::Vector3D(-3000.0f,2800.0f,-1.0f),
- Stuff::Vector3D(-3000.0f,2900.0f,-1.0f),
- Stuff::Vector3D(-3000.0f,3000.0f,-1.0f),
- Stuff::Vector3D(-2900.0f,2700.0f,-1.0f),
- Stuff::Vector3D(-2900.0f,2800.0f,-1.0f),
- Stuff::Vector3D(-2900.0f,2900.0f,-1.0f),
- Stuff::Vector3D(-2900.0f,3000.0f,-1.0f),
- Stuff::Vector3D(-2800.0f,2700.0f,-1.0f),
- Stuff::Vector3D(-2800.0f,2800.0f,-1.0f),
- Stuff::Vector3D(-2800.0f,2900.0f,-1.0f),
- Stuff::Vector3D(-2800.0f,3000.0f,-1.0f),
- Stuff::Vector3D(-2700.0f,2700.0f,-1.0f),
- Stuff::Vector3D(-2700.0f,2800.0f,-1.0f),
- Stuff::Vector3D(-2700.0f,2900.0f,-1.0f),
- Stuff::Vector3D(-2700.0f,3000.0f,-1.0f),
- Stuff::Vector3D(-2600.0f,2700.0f,-1.0f),
- Stuff::Vector3D(-2600.0f,2800.0f,-1.0f),
- Stuff::Vector3D(-2600.0f,2900.0f,-1.0f),
- Stuff::Vector3D(-2600.0f,3000.0f,-1.0f),
- Stuff::Vector3D(-2500.0f,2700.0f,-1.0f),
- Stuff::Vector3D(-2500.0f,2800.0f,-1.0f),
- Stuff::Vector3D(-2500.0f,2900.0f,-1.0f)
- };
- #ifdef LAB_ONLY
- long currentLineElement = 0;
- LineElement *debugLines[10000];
- #define ProfileTime(x,y) x=GetCycles();y;x=GetCycles()-x;
- extern __int64 MCTimeMultiplayerUpdate;
- #else
- #define ProfileTime(x,y) y;
- #endif
- #define MAX_KILL_AT_START 100
- long NumDisableAtStart = 0;
- long DisableAtStart[MAX_KILL_AT_START];
- OptionsScreenWrapper *optionsScreenWrapper = NULL;
- bool bInvokeOptionsScreenFlag = false;
- bool SnifferMode = false;
- gos_VERTEX *testVertex = NULL;
- WORD *indexArray = NULL;
- DWORD testTextureHandle = 0xffffffff;
- float totalTime = 0;
- DWORD numIterations = 4;
- DWORD curIteration = 0;
- DWORD curDevice = 0;
- bool isUsingSoftware = false;
- #define MAX_HARDWARE_CARDS 5
- float trisPerSecond[MAX_HARDWARE_CARDS] =
- {
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
- };
- extern bool loadInMissionSave;
- extern char CDInstallPath[];
- extern float averageFrameRate;
- extern long currentFrameNum;
- extern float last30Frames[];
- extern bool WindowsNT;
- extern EString *g_textureCache_FilenameOfLastLoadedTexture;
- bool checkedBomb = false;
- //***************************************************************************
- // DEBUGGING WINDOWS
- //***************************************************************************
- #define NUM_DEBUG_WINDOWS 4
- char DebugStatusBarString[256];
- GameDebugWindow* DebugWindow[NUM_DEBUG_WINDOWS] = {NULL, NULL, NULL, NULL};
- GameObjectPtr DebugGameObject[3] = {NULL, NULL, NULL};
- long GameObjectWindowList[3] = {0, 0, 0};
- long NumGameObjectsToDisplay = 0;
- bool DebugWindowOpen[NUM_DEBUG_WINDOWS] = {false, false, false, false};
- bool DebugStatusBarOpen = false;
- bool DebugScoreBoardOpen = false;
- bool DebugHelpOpen = false;
- void DEBUGWINS_print (char* s, long window = 0);
- //---------------------------------------------------------------------------
- void DEBUGWINS_init (void) {
- sprintf(DebugStatusBarString, "DEBUG Status Bar: GLENNBA");
- DebugWindow[0] = new GameDebugWindow;
- DebugWindow[0]->init();
- DebugWindow[0]->setPos(10, 200);
- if (DebugWindowOpen[0])
- DebugWindow[0]->open();
- else
- DebugWindow[0]->close();
- DebugWindow[1] = new GameDebugWindow;
- DebugWindow[1]->init();
- DebugWindow[1]->setPos(10, 20);
- if (DebugWindowOpen[1])
- DebugWindow[1]->open();
- else
- DebugWindow[1]->close();
- DebugWindow[2] = new GameDebugWindow;
- DebugWindow[2]->init();
- DebugWindow[2]->setPos(220, 20);
- if (DebugWindowOpen[2])
- DebugWindow[2]->open();
- else
- DebugWindow[2]->close();
- DebugWindow[3] = new GameDebugWindow;
- DebugWindow[3]->init();
- DebugWindow[3]->setPos(430, 20);
- if (DebugWindowOpen[3])
- DebugWindow[3]->open();
- else
- DebugWindow[3]->close();
- }
- //---------------------------------------------------------------------------
- void DEBUGWINS_destroy (void) {
- for (long i = 0; i < NUM_DEBUG_WINDOWS; i++)
- if (DebugWindow[i]) {
- DebugWindow[i]->destroy();
- delete DebugWindow[i];
- DebugWindow[i] = NULL;
- }
- }
- void initDialogs()
- {
- FullPathFileName path;
- path.init( artPath, "mcl_dialog", ".fit" );
- FitIniFile file;
- if ( NO_ERR != file.open( path ) )
- {
- char error[256];
- sprintf( error, "couldn't open file %s", (char*)path );
- Assert( 0, 0, error );
- return;
- }
- LogisticsOKDialog::init( file );
- file.close();
- path.init( artPath, "mcl_sm", ".fit" );
- if ( NO_ERR != file.open( path ) )
- {
- char error[256];
- sprintf( error, "couldn't open file %s", (char*)path );
- Assert( 0, 0, error );
- return;
- }
- LogisticsSaveDialog::init( file );
- file.close();
- path.init( artPath, "mcl_dialog_onebutton", ".fit" );
- if ( NO_ERR != file.open( path ) )
- {
- char error[256];
- sprintf( error, "couldn't open file %s", (char*)path );
- Assert( 0, 0, error );
- return;
- }
- LogisticsOneButtonDialog::init( file );
- }
- void endDialogs()
- {
- if (LogisticsOKDialog::s_instance)
- {
- delete LogisticsOKDialog::s_instance;
- LogisticsOKDialog::s_instance = NULL;
- }
- if (LogisticsSaveDialog::s_instance)
- {
- delete LogisticsSaveDialog::s_instance;
- LogisticsSaveDialog::s_instance = NULL;
- }
- if (LogisticsOneButtonDialog::s_instance)
- {
- delete LogisticsOneButtonDialog::s_instance;
- LogisticsOneButtonDialog::s_instance = NULL;
- }
- if (LogisticsLegalDialog::s_instance)
- {
- delete LogisticsLegalDialog::s_instance;
- LogisticsLegalDialog::s_instance = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void DEBUGWINS_toggle (bool* windowsOpen) {
- for (long i = 0; i < NUM_DEBUG_WINDOWS; i++)
- if (windowsOpen[i])
- DebugWindow[i]->toggle();
- DebugHelpOpen = windowsOpen[NUM_DEBUG_WINDOWS];
- DebugStatusBarOpen = windowsOpen[NUM_DEBUG_WINDOWS + 1];
- DebugScoreBoardOpen = windowsOpen[NUM_DEBUG_WINDOWS + 2];
- }
- //---------------------------------------------------------------------------
- void DEBUGWINS_display (bool* windowsOpen) {
- for (long i = 0; i < NUM_DEBUG_WINDOWS; i++) {
- if (windowsOpen[i]) {
- DebugWindowOpen[i] = true;
- DebugWindow[i]->open();
- }
- else {
- DebugWindowOpen[i] = false;
- DebugWindow[i]->close();
- }
- }
- DebugHelpOpen = windowsOpen[NUM_DEBUG_WINDOWS];
- DebugStatusBarOpen = windowsOpen[NUM_DEBUG_WINDOWS + 1];
- DebugScoreBoardOpen = windowsOpen[NUM_DEBUG_WINDOWS + 2];
- }
- //---------------------------------------------------------------------------
- void DEBUGWINS_print (char* s, long window) {
- DebugWindow[window]->print(s);
- }
- //---------------------------------------------------------------------------
- void DEBUGWINS_setGameObject (long debugObj, GameObjectPtr obj) {
- if (debugObj == -1) {
- DebugGameObject[2] = DebugGameObject[1];
- DebugGameObject[1] = DebugGameObject[0];
- debugObj = 0;
- }
- DebugGameObject[debugObj] = obj;
- }
- //---------------------------------------------------------------------------
- void DEBUGWINS_viewGameObject (long debugObj) {
- if (DebugGameObject[debugObj]) {
- Stuff::Vector3D newPos = DebugGameObject[debugObj]->getPosition();
- eye->setPosition(newPos,false);
- }
- }
- //---------------------------------------------------------------------------
- void DEBUGWINS_removeGameObject (GameObjectPtr obj) {
- for (long i = 0; i < 3; i++)
- if (DebugGameObject[i] == obj) {
- DebugGameObject[i] = NULL;
- DebugWindow[1 + i]->clear();
- }
- }
- //---------------------------------------------------------------------------
- void DEBUGWINS_update (void) {
- for (long i = 0; i < 3; i++)
- if (DebugGameObject[i])
- DebugGameObject[i]->updateDebugWindow(DebugWindow[1 + i]);
- }
- //---------------------------------------------------------------------------
- void DEBUGWINS_renderSpecialWindows (void) {
- gos_TextSetAttributes(DebugWindow[0]->font, 0xffffffff, 1.0, true, true, false, false);
- gos_TextSetRegion(0, 0, Environment.screenWidth, Environment.screenHeight );
- gos_TextSetPosition(15, 10);
- if (DebugStatusBarOpen && DebugStatusBarString[0])
- gos_TextDraw(DebugStatusBarString);
- if (DebugScoreBoardOpen) {
- if (MPlayer) {
- long curY = Environment.screenHeight - 390;
- for (long i = 0; i < MPlayer->numTeams; i++) {
- char s[256];
- sprintf(s, "Team %d score = %d", i, MPlayer->teamScore[i]);
- gos_TextSetPosition(Environment.screenWidth - 380, curY);
- gos_TextDraw(s);
- curY += 10;
- }
- curY += 10;
- for (i = 0; i < MAX_MC_PLAYERS; i++)
- if (MPlayer->playerInfo[i].commanderID > -1) {
- char s[256];
- sprintf(s, "Player %d (%s) score = %d, %d kills, %d losses",
- i,
- MPlayer->playerInfo[i].name,
- MPlayer->playerInfo[i].score,
- MPlayer->playerInfo[i].kills,
- MPlayer->playerInfo[i].losses);
- gos_TextSetPosition(Environment.screenWidth - 380, curY);
- gos_TextDraw(s);
- curY += 10;
- }
- }
- else {
- gos_TextSetPosition(Environment.screenWidth - 275, Environment.screenHeight - 120);
- gos_TextDraw("Single-player Mission");
- }
- }
- if (DebugHelpOpen) {
- gos_TextSetPosition(15, 10);
- gos_TextDraw("DEBUGGING COMMANDS");
- gos_TextSetPosition(15, 20);
- gos_TextDraw("----------------------------------------------------------------------------");
- gos_TextSetPosition(15, 30);
- gos_TextDraw("ALT-W");
- gos_TextSetPosition(140, 30);
- gos_TextDraw("Toggle Debug Windows");
- gos_TextSetPosition(15, 40);
- gos_TextDraw("ALT-T");
- gos_TextSetPosition(140, 40);
- gos_TextDraw("Teleport to mouse");
- gos_TextSetPosition(15, 50);
- gos_TextDraw("ALT-/");
- gos_TextSetPosition(140, 50);
- gos_TextDraw("Quick Info");
- gos_TextSetPosition(15, 60);
- gos_TextDraw("ALT-SHFT-/");
- gos_TextSetPosition(140, 60);
- gos_TextDraw("Select Debug Object");
- gos_TextSetPosition(15, 70);
- gos_TextDraw("ALT-#");
- gos_TextSetPosition(140, 70);
- gos_TextDraw("Center on Debug Object # (1 thru 3)");
- gos_TextSetPosition(15, 80);
- gos_TextDraw("ALT-CTRL-#");
- gos_TextSetPosition(140, 80);
- gos_TextDraw("Toggle Info for Debug Object (1 thru 3)");
- gos_TextSetPosition(15, 90);
- gos_TextDraw("ALT-M");
- gos_TextSetPosition(140, 90);
- gos_TextDraw("Show All Movers (toggle)");
- gos_TextSetPosition(15, 100);
- gos_TextDraw("ALT-G");
- gos_TextSetPosition(140, 100);
- gos_TextDraw("GlobalMap Move Log (toggle)");
- gos_TextSetPosition(15, 110);
- gos_TextDraw("ALT-B");
- gos_TextSetPosition(140, 110);
- gos_TextDraw("Enemies Brain Dead (toggle)");
- gos_TextSetPosition(15, 120);
- gos_TextDraw("ALT-P");
- gos_TextSetPosition(140, 120);
- gos_TextDraw("Use Goal Planning (toggle on selected movers)");
- gos_TextSetPosition(15, 130);
- gos_TextDraw("ALT-CTRL-P");
- gos_TextSetPosition(140, 130);
- gos_TextDraw("Computer AI Use Goal Planning (toggle)");
- gos_TextSetPosition(15, 140);
- gos_TextDraw("ALT-4");
- gos_TextSetPosition(140, 140);
- gos_TextDraw("Damage Object for 1 point");
- gos_TextSetPosition(15, 150);
- gos_TextDraw("ALT-5");
- gos_TextSetPosition(140, 150);
- gos_TextDraw("Damage Object for 4 points");
- gos_TextSetPosition(15, 160);
- gos_TextDraw("ALT-6");
- gos_TextSetPosition(140, 160);
- gos_TextDraw("Damage Object for 9 points");
- gos_TextSetPosition(15, 170);
- gos_TextDraw("ALT-7");
- gos_TextSetPosition(140, 170);
- gos_TextDraw("Damage Object for 16 points");
- gos_TextSetPosition(15, 180);
- gos_TextDraw("ALT-8");
- gos_TextSetPosition(140, 180);
- gos_TextDraw("Damage Object for 25 points");
- gos_TextSetPosition(15, 190);
- gos_TextDraw("ALT-9");
- gos_TextSetPosition(140, 190);
- gos_TextDraw("Damage Object for 36 points");
- gos_TextSetPosition(15, 200);
- gos_TextDraw("ALT-0");
- gos_TextSetPosition(140, 200);
- gos_TextDraw("Disable Object");
- gos_TextSetPosition(15, 210);
- gos_TextDraw("ALT-V");
- gos_TextSetPosition(140, 210);
- gos_TextDraw("Display TacOrder Target in Debug Window");
- }
- }
- //---------------------------------------------------------------------------
- void DEBUGWINS_render (void) {
- for (long i = 0; i < NUM_DEBUG_WINDOWS; i++)
- DebugWindow[i]->render();
- DEBUGWINS_renderSpecialWindows();
- }
- //***************************************************************************
- char* GetGameInformation()
- {
- return(ExceptionGameMsg);
- }
- //long cLoadString (HINSTANCE hInstance, UINT uID, LPTSTR lpBuffer, int nBufferMax );
- #define SnifferTime(x,y)
- DWORD startTime;
- DWORD endTime;
- //---------------------------------------------------------------------------
- void UpdateRenderers()
- {
- if (!SnifferMode)
- {
- hasGuardBand = true;
- //hasGuardBand = gos_GetMachineInformation(gos_Info_HasGuardBandClipping) != 0;
- canMultiTextureDetail = (gos_GetMachineInformation(gos_Info_CanMultitextureDetail) != 0);
- //---------------------------------------------------------------------------------
- //Doesn't work. Always returns 0 for TNT in Win2K build 2183 with 3.55 detonator
- //Assume worst case is +/- 8.0 for now.
- //MaxMinUV = gos_GetMachineInformation(gos_Info_GetMaximumUVSize);
- DWORD bColor = 0x0;
- if (eye && mission->isActive())
- bColor = eye->fogColor;
- gos_SetupViewport(1,1.0,1,bColor, 0.0, 0.0, 1.0, 1.0 ); //ALWAYS FULL SCREEN for now
- gos_SetRenderState( gos_State_Filter, gos_FilterBiLinear );
- gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha );
- gos_SetRenderState( gos_State_AlphaTest, TRUE );
- gos_SetRenderState( gos_State_Clipping, TRUE);
- gos_SetRenderState( gos_State_TextureAddress, gos_TextureClamp );
- gos_SetRenderState( gos_State_Dither, 1);
- //---------------------------------------------------------------------------------------
- // Tell the mission to render, the operation to render and the logistics to render here.
- if (mission && (!optionsScreenWrapper || optionsScreenWrapper->isDone() ) )
- mission->render();
- if (logistics)
- {
- float viewMulX, viewMulY, viewAddX, viewAddY;
- gos_GetViewport(&viewMulX, &viewMulY, &viewAddX, &viewAddY);
- userInput->setViewport(viewMulX,viewMulY,viewAddX,viewAddY);
- logistics->render();
- }
- if (optionsScreenWrapper && !optionsScreenWrapper->isDone() )
- {
- float viewMulX, viewMulY, viewAddX, viewAddY;
- gos_GetViewport(&viewMulX, &viewMulY, &viewAddX, &viewAddY);
- userInput->setViewport(viewMulX,viewMulY,viewAddX,viewAddY);
- optionsScreenWrapper->render();
- }
- //------------------------------------------------------------
- gos_SetRenderState( gos_State_Filter, gos_FilterNone );
- userInput->render();
- DEBUGWINS_render();
- #ifdef LAB_ONLY
- if (currentLineElement)
- {
- for (long i=0;i<currentLineElement;i++)
- {
- debugLines[i]->draw();
- }
- }
- #endif
- }
- else
- {
- if (gos_GetMachineInformation(gos_Info_GetDeviceLocalMemory, curDevice) >= 6291456)
- {
- startTime=timeGetTime();
- gos_SetupViewport(1,1.0,1,0, 0.0, 0.0, 1.0, 1.0 ); //ALWAYS FULL SCREEN for now
- if (Environment.Renderer == 3)
- {
- gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_OneZero);
- gos_SetRenderState( gos_State_ShadeMode, gos_ShadeGouraud);
- gos_SetRenderState( gos_State_MonoEnable, 1);
- gos_SetRenderState( gos_State_Perspective, 0);
- gos_SetRenderState( gos_State_Clipping, 2);
- gos_SetRenderState( gos_State_AlphaTest, 0);
- gos_SetRenderState( gos_State_Specular, 0);
- gos_SetRenderState( gos_State_Dither, 0);
- gos_SetRenderState( gos_State_TextureMapBlend, gos_BlendModulate);
- gos_SetRenderState( gos_State_Filter, gos_FilterBiLinear);
- gos_SetRenderState( gos_State_TextureAddress, gos_TextureWrap);
- gos_SetRenderState( gos_State_ZCompare, 1);
- gos_SetRenderState( gos_State_ZWrite, 1);
- //DWORD fogColor = 0x009f9f9f;
- //gos_SetRenderState( gos_State_Fog, (int)&fogColor);
- }
- else
- {
- gos_SetRenderState( gos_State_AlphaMode, gos_Alpha_AlphaInvAlpha);
- gos_SetRenderState( gos_State_ShadeMode, gos_ShadeGouraud);
- gos_SetRenderState( gos_State_MonoEnable, 1);
- gos_SetRenderState( gos_State_Perspective, 1);
- gos_SetRenderState( gos_State_Clipping, 2);
- gos_SetRenderState( gos_State_AlphaTest, 1);
- gos_SetRenderState( gos_State_Specular, 1);
- gos_SetRenderState( gos_State_Dither, 1);
- gos_SetRenderState( gos_State_TextureMapBlend, gos_BlendModulateAlpha);
- gos_SetRenderState( gos_State_Filter, gos_FilterBiLinear);
- gos_SetRenderState( gos_State_TextureAddress, gos_TextureWrap);
- gos_SetRenderState( gos_State_ZCompare, 1);
- gos_SetRenderState( gos_State_ZWrite, 1);
- DWORD fogColor = 0x009f9f9f;
- gos_SetRenderState( gos_State_Fog, (int)&fogColor);
- }
- //Send down 5000 triangles
- long nIterations = 5;
- for (long i=0;i<nIterations;i++)
- {
- DWORD totalVertices = 3000;
- gos_SetRenderState( gos_State_Texture, testTextureHandle);
- gos_RenderIndexedArray( testVertex, totalVertices, indexArray, totalVertices );
- }
- endTime=timeGetTime()-startTime;
- totalTime += endTime;
- }
- }
- }
- //---------------------------------------------------------------------------
- #define GAME_REG_KEY "Software\\Microsoft\\Microsoft Games\\MechCommander2\\1.0"
- typedef DWORD (*EBUPROC) (LPCTSTR lpRegKeyLocation, LPCTSTR lpEULAFileName, LPCSTR lpWarrantyFileName, BOOL fCheckForFirstRun);
- bool FirstRunEula(void)
- {
- return (true);
- }
- Stuff::MemoryStream *effectStream = NULL;
- extern MidLevelRenderer::MLRClipper * theClipper;
- bool gameStarted = false;
- void InitializeGameEngine()
- {
- __asm push esi;
- // gotta have this no matter what
- gosResourceHandle = gos_OpenResourceDLL("mc2res.dll");
- //Check for enough SwapFile Space FIRST!!!
- // In order to do that, we must force Win2K/XP to enlarge
- // its swapfile at the get go to insure goodness and that
- // the message does not come up during game run.
- void *testMem = VirtualAlloc(NULL,123000000,MEM_COMMIT,PAGE_READWRITE);
- MEMORYSTATUS ms;
- GlobalMemoryStatus( &ms );
-
- if (ms.dwTotalPageFile < 250000000)
- {
- char txt[4096];
- char msg[4096];
- cLoadString(IDS_SWAPFILE_TOO_SMALL,txt,4095);
- sprintf(msg,txt,(ms.dwAvailPageFile / (1024 * 1024)));
- char caption[1024];
- cLoadString(IDS_SWAPFILE_CAPTION,caption,1023);
- MessageBox(NULL,msg,caption,MB_OK | MB_ICONWARNING);
- gos_TerminateApplication();
- return;
- }
- if (testMem)
- VirtualFree(testMem,0,MEM_RELEASE);
- cLoadString(IDS_MC2_FILEMISSING,FileMissingString,511);
- cLoadString(IDS_MC2_CDMISSING,CDMissingString,1023);
- cLoadString(IDS_MC2_MISSING_TITLE,MissingTitleString,255);
- if ( !EULAShown )
- {
- if ( !FirstRunEula() )
- {
- gos_TerminateApplication();
- return;
- }
- }
- //Check for sufficient hard Drive space on drive game is running from
- char currentPath[1024];
- gos_GetCurrentPath( currentPath, 1023 );
- __int64 driveSpace = gos_GetDriveFreeSpace(currentPath);
- if (driveSpace < (20 * 1024 * 1024))
- {
- char title[256];
- char msg[2048];
- cLoadString(IDS_GAME_HDSPACE_ERROR,title,255);
- cLoadString(IDS_GAME_HDSPACE_MSG,msg,2047);
- DWORD result = MessageBox(NULL,msg,title,MB_OKCANCEL | MB_ICONWARNING);
- if (result == IDCANCEL)
- ExitGameOS();
- }
- //Check if we are a Voodoo 3. If so, ONLY allow editor to run IF
- // Starting resolution is 1024x768x16 or LOWER. NO 32-BIT ALLOWED!
- if ((gos_GetMachineInformation(gos_Info_GetDeviceVendorID,0) == 0x121a) &&
- (gos_GetMachineInformation(gos_Info_GetDeviceDeviceID,0) == 0x0005))
- {
- DEVMODE dev;
- memset( &dev, 0, sizeof ( DEVMODE ) );
- dev.dmSize = sizeof( DEVMODE );
- dev.dmSpecVersion = DM_SPECVERSION;
- EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &dev );
- if ((dev.dmPelsWidth > 1024) || (dev.dmPelsHeight > 768) || (dev.dmBitsPerPel > 16))
- {
- char title[256];
- char msg[2048];
- cLoadString(IDS_GAME_ERROR,title,255);
- cLoadString(IDS_GAME_VOODOO3,msg,2047);
- MessageBox(NULL,msg,title,MB_OK | MB_ICONWARNING);
- ExitGameOS();
- }
- }
- //Then, we should check to see if the options.cfg exists. if NOT,
- // Bring up a sniffer warning dialog, sniff, bring up sniffer end dialog and end.
- if (!fileExists("options.cfg"))
- {
- //Must also check for a RIVA TNT card with driver 4.10.1.0131
- // If this card is in the machine with this driver, do NOT allow sniffer to run.
- // Just copy minprefs.cfg to options.cfg and move on.
- if ((gos_GetMachineInformation(gos_Info_GetDeviceVendorID,0) == 0x10de) &&
- (gos_GetMachineInformation(gos_Info_GetDeviceDeviceID,0) == 0x0020) &&
- (gos_GetMachineInformation(gos_Info_GetDeviceDriverVersionHi,0) == 0x0004000a) &&
- (gos_GetMachineInformation(gos_Info_GetDeviceDriverVersionLo,0) == 0x00010083))
- {
- CopyFile("minprefs.cfg","orgprefs.cfg",true);
- CopyFile("minprefs.cfg","options.cfg",true);
- }
- else
- {
- //NEW Plan. Regardless, copy the minprefs to options. That way, sniffer can only screw up once!!
- // After the first run, it will no longer run and the game will continue with minprefs.
- SnifferMode = true;
- CopyFile("minprefs.cfg","orgprefs.cfg",true);
- CopyFile("minprefs.cfg","options.cfg",true);
- }
- }
- //Seed the random Number generator.
- gos_srand(timeGetTime());
- if (!SnifferMode)
- {
- //---------------------------------------------------------------------
- float doubleClickThreshold = 0.2f;
- long dragThreshold = .016667;
-
- Environment.Key_Exit=-1; // so escape doesn't kill your app
-
- //-------------------------------------------------------------
- // Find the CDPath in the registry and save it off so I can
- // look in CD Install Path for files.
-
- //Changed for the shared source release, just set to current directory
- //DWORD maxPathLength = 1023;
- //gos_LoadDataFromRegistry("CDPath", CDInstallPath, &maxPathLength);
- //if (!maxPathLength)
- // strcpy(CDInstallPath,"..\\");
- strcpy(CDInstallPath,".\\");
- //--------------------------------------------------------------
- // Start the SystemHeap and globalHeapList
- globalHeapList = new HeapList;
- gosASSERT(globalHeapList != NULL);
-
- globalHeapList->init();
- globalHeapList->update(); //Run Instrumentation into GOS Debugger Screen
-
- systemHeap = new UserHeap;
- gosASSERT(systemHeap != NULL);
-
- systemHeap->init(systemHeapSize,"SYSTEM");
-
- //Start finding the Leaks
- // systemHeap->startHeapMallocLog();
- //Check for OrgPrefs.cfg. If this file is not present,
- // We need to create it because sniffer didn't run.
- // Create a new prefs.cfg, too. This way, we can easily restore
- // them to a running state if they screw up their prefs.
- // All they have to do is delete the orgprefs.cfg file.
- // OR re-install!!
- //
- // ALWAYS use minPrefs.cfg here!
- if (!fileExists("orgprefs.cfg"))
- {
- CopyFile("minprefs.cfg","orgprefs.cfg",true);
- CopyFile("minprefs.cfg","options.cfg",true);
- }
- //--------------------------------------------------------------
- // Read in System.CFG
- FitIniFilePtr systemFile = new FitIniFile;
-
- #ifdef _DEBUG
- long systemOpenResult =
- #endif
- systemFile->open("system.cfg");
-
- #ifdef _DEBUG
- if( systemOpenResult != NO_ERR)
- {
- char Buffer[256];
- gos_GetCurrentPath( Buffer, 256 );
- STOP(( "Cannot find \"system.cfg\" file in %s",Buffer ));
- }
- #endif
-
- {
- #ifdef _DEBUG
- long systemBlockResult =
- #endif
- systemFile->seekBlock("systemHeap");
- gosASSERT(systemBlockResult == NO_ERR);
- {
- long result = systemFile->readIdULong("systemHeapSize",systemHeapSize);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdULong("guiHeapSize",guiHeapSize);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdULong("logisticsHeapSize",logisticsHeapSize);
- gosASSERT(result == NO_ERR);
- }
-
- #ifdef _DEBUG
- long systemPathResult =
- #endif
- systemFile->seekBlock("systemPaths");
- gosASSERT(systemPathResult == NO_ERR);
- {
- long result = systemFile->readIdString("terrainPath",terrainPath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("artPath",artPath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("fontPath",fontPath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("savePath",savePath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("spritePath",spritePath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("shapesPath",shapesPath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("soundPath",soundPath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("objectPath",objectPath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("cameraPath",cameraPath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("tilePath",tilePath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("missionPath",missionPath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("warriorPath",warriorPath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("profilePath",profilePath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("interfacepath",interfacePath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("moviepath",moviePath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("CDsoundPath",CDsoundPath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("CDmoviepath",CDmoviePath,79);
- gosASSERT(result == NO_ERR);
-
- result = systemFile->readIdString("CDspritePath",CDspritePath,79);
- gosASSERT(result == NO_ERR);
- }
-
- #ifdef _DEBUG
- long fastFileResult =
- #endif
- systemFile->seekBlock("FastFiles");
- gosASSERT(fastFileResult == NO_ERR);
- {
- long result = systemFile->readIdLong("NumFastFiles",maxFastFiles);
- if (result != NO_ERR)
- maxFastFiles = 0;
-
- if (maxFastFiles)
- {
- fastFiles = (FastFile **)malloc(maxFastFiles*sizeof(FastFile *));
- memset(fastFiles,0,maxFastFiles*sizeof(FastFile *));
-
- long fileNum = 0;
- char fastFileId[10];
- char fileName[100];
- sprintf(fastFileId,"File%d",fileNum);
-
- while (systemFile->readIdString(fastFileId,fileName,99) == NO_ERR)
- {
- bool result = FastFileInit(fileName);
- if (!result)
- STOP(("Unable to startup fastfiles. Probably an old one in the directory!!"));
-
- fileNum++;
- sprintf(fastFileId,"File%d",fileNum);
- }
- }
- }
-
- long result = systemFile->seekBlock("UseMusic");
- if (result == NO_ERR)
- useMusic = TRUE;
- else
- useMusic = FALSE;
-
- result = systemFile->seekBlock("UseSound");
- if (result == NO_ERR)
- {
- useSound = TRUE;
- }
- else
- {
- useSound = FALSE;
- useMusic = FALSE;
- }
- result = systemFile->seekBlock("CameraSettings");
- if (result == NO_ERR)
- {
- result = systemFile->readIdFloat("MaxPerspective",Camera::MAX_PERSPECTIVE);
- if (result != NO_ERR)
- Camera::MAX_PERSPECTIVE = 88.0f;
- if (Camera::MAX_PERSPECTIVE > 90.0f)
- Camera::MAX_PERSPECTIVE = 90.0f;
- result = systemFile->readIdFloat("MinPerspective",Camera::MIN_PERSPECTIVE);
- if (result != NO_ERR)
- Camera::MIN_PERSPECTIVE = 18.0f;
- if (Camera::MIN_PERSPECTIVE < 0.0f)
- Camera::MIN_PERSPECTIVE = 0.0f;
- result = systemFile->readIdFloat("MaxOrtho",Camera::MAX_ORTHO);
- if (result != NO_ERR)
- Camera::MAX_ORTHO = 88.0f;
- if (Camera::MAX_ORTHO > 90.0f)
- Camera::MAX_ORTHO = 90.0f;
- result = systemFile->readIdFloat("MinOrtho",Camera::MIN_ORTHO);
- if (result != NO_ERR)
- Camera::MIN_ORTHO = 18.0f;
- if (Camera::MIN_ORTHO < 0.0f)
- Camera::MIN_ORTHO = 0.0f;
- result = systemFile->readIdFloat("AltitudeMinimum",Camera::AltitudeMinimum);
- if (result != NO_ERR)
- Camera::AltitudeMinimum = 560.0f;
- if (Camera::AltitudeMinimum < 110.0f)
- Camera::AltitudeMinimum = 110.0f;
- result = systemFile->readIdFloat("AltitudeMaximumHi",Camera::AltitudeMaximumHi);
- if (result != NO_ERR)
- Camera::AltitudeMaximumHi = 1600.0f;
- result = systemFile->readIdFloat("AltitudeMaximumLo",Camera::AltitudeMaximumLo);
- if (result != NO_ERR)
- Camera::AltitudeMaximumHi = 1500.0f;
- }
- }
-
- systemFile->close();
- delete systemFile;
- systemFile = NULL;
-
- if (initGameLogs) {
- GameLog::setup();
- if (initNetLog && !NetLog) {
- NetLog = GameLog::getNewFile();
- if (!NetLog)
- Fatal(0, " Couldn't create Net Log ");
- long err = NetLog->open("net.log");
- if (err)
- Fatal(0, " Couldn't open Net Log ");
- }
- if (initCombatLog && !CombatLog) {
- CombatLog = GameLog::getNewFile();
- if (!CombatLog)
- Fatal(0, " Couldn't create Combat Log ");
- long err = CombatLog->open("combat.log");
- if (err)
- Fatal(0, " Couldn't open Combat Log ");
- }
- if (initBugLog && !BugLog) {
- BugLog = GameLog::getNewFile();
- if (!BugLog)
- Fatal(0, " Couldn't create Bug Log ");
- long err = BugLog->open("bug.log");
- if (err)
- Fatal(0, " Couldn't open Bug Log ");
- }
- if (initLRMoveLog && !GlobalMap::logEnabled) {
- GlobalMap::toggleLog();
- }
- }
-
- //--------------------------------------------------------------
- // Read in Prefs.cfg
- bool fullScreen = false;
- FitIniFilePtr prefsFile = new FitIniFile;
- FitIniFilePtr optsFile = new FitIniFile;
-
- long prefsOpenResult = prefsFile->open("prefs.cfg");
-
- gosASSERT (prefsOpenResult == NO_ERR);
-
- prefsOpenResult = optsFile->open("options.cfg");
-
- gosASSERT (prefsOpenResult == NO_ERR);
-
- {
- #ifdef _DEBUG
- long prefsBlockResult =
- #endif
- prefsFile->seekBlock("MechCommander2");
- optsFile->seekBlock("MechCommander2");
- gosASSERT(prefsBlockResult == NO_ERR);
- {
- /*The following commented out options have been moved to "options.cfg" and are
- handled by the CPrefs class (in "prefs.h"). They have been moved to CPrefs
- because these options are potentially affected by the options screen and may
- need to support "apply, cancel and save" functionality.
-
- Understood. Game must also know about them know or it cannot start up correctly!!
- -fs
- */
-
- // store volume settings in global variable since soundsystem
- // does not exist yet. These will be set in SoundSystem::init()
- long result = optsFile->readIdLong("DigitalMasterVolume",DigitalMasterVolume);
- if (result != NO_ERR)
- DigitalMasterVolume = 255;
-
- result = optsFile->readIdLong("MusicVolume",MusicVolume);
- if (result != NO_ERR)
- MusicVolume = 64;
-
- result = optsFile->readIdLong("RadioVolume",RadioVolume);
- if (result != NO_ERR)
- RadioVolume = 64;
-
- result = optsFile->readIdLong("SFXVolume",sfxVolume);
- if (result != NO_ERR)
- sfxVolume = 64;
-
- result = optsFile->readIdLong("BettyVolume",BettyVolume);
- if (result != NO_ERR)
- BettyVolume = 64;
-
- result = optsFile->readIdBoolean( "Shadows", useShadows);
- if (result != NO_ERR)
- useShadows = true;
-
- result = optsFile->readIdBoolean( "DetailTexture", useWaterInterestTexture);
- if (result != NO_ERR)
- useWaterInterestTexture = true;
-
- result = optsFile->readIdLong("Difficulty",GameDifficulty);
- if (result != NO_ERR)
- GameDifficulty = 1;
-
- result = optsFile->readIdBoolean("UnlimitedAmmo",useUnlimitedAmmo);
- if (result != NO_ERR)
- useUnlimitedAmmo = true;
-
- result = optsFile->readIdLong("Rasterizer",renderer);
- if (result != NO_ERR)
- renderer = 0;
-
- if ((renderer < 0) || (renderer > 3))
- renderer = 0;
-
- result = optsFile->readIdLong("Resolution",resolution);
- if (result != NO_ERR)
- resolution = 0;
-
- result = optsFile->readIdBoolean("FullScreen",fullScreen);
- if (result != NO_ERR)
- fullScreen = true;
-
- result = optsFile->readIdLong("Brightness",gammaLevel);
- if (result != NO_ERR)
- gammaLevel = 0;
-
- result = optsFile->readIdBoolean( "useLeftRightMouseProfile", useLeftRightMouseProfile );
- if ( result != NO_ERR )
- useLeftRightMouseProfile = true;
-
- bool asyncMouse = false;
- result = optsFile->readIdBoolean( "useAsyncMouse", asyncMouse );
- if ( result != NO_ERR )
- asyncMouse = false;
-
- mc2UseAsyncMouse = asyncMouse;
-
- long filterSetting;
- result = prefsFile->readIdLong("FilterState",filterSetting);
- if (result == NO_ERR)
- {
- switch (filterSetting)
- {
- default:
- case 0:
- FilterState = gos_FilterNone;
- break;
-
- case 1:
- FilterState = gos_FilterBiLinear;
- break;
-
- case 2:
- FilterState = gos_FilterTriLinear;
- break;
- }
- }
-
- result = prefsFile->readIdLong("TerrainTextureRes",TERRAIN_TXM_SIZE);
- if (result != NO_ERR)
- TERRAIN_TXM_SIZE = 64;
-
- result = prefsFile->readIdLong("ObjectTextureRes",ObjectTextureSize);
- if (result != NO_ERR)
- ObjectTextureSize = 128;
-
- result = prefsFile->readIdFloat("DoubleClickThreshold",doubleClickThreshold);
- if (result != NO_ERR)
- doubleClickThreshold = 0.2f;
-
- result = prefsFile->readIdLong("DragThreshold",dragThreshold);
- if (result != NO_ERR)
- dragThreshold = .01667f;
-
- result = prefsFile->readIdULong("BaseVertexColor",BaseVertexColor);
- if (result != NO_ERR)
- BaseVertexColor = 0x00000000;
-
- result = prefsFile->readIdBoolean("RealLOS",useRealLOS);
- if (result != NO_ERR)
- useRealLOS = true;
-
- result = prefsFile->readIdLong("GameVisibleVertices",GameVisibleVertices);
- if (result != NO_ERR)
- GameVisibleVertices = 30;
-
- result = prefsFile->readIdFloat("MaxClipDistance",Camera::MaxClipDistance);
- if (result != NO_ERR)
- Camera::MaxClipDistance = 3000.0f;
-
- result = prefsFile->readIdFloat("MinHazeDistance",Camera::MinHazeDistance);
- if (result != NO_ERR)
- Camera::MinHazeDistance = 2000.0f;
-
- result = prefsFile->readIdFloat("View0Zoom",Camera::cameraZoom[0]);
- if (result != NO_ERR)
- Camera::cameraZoom[0] = 1200.0f;
-
- result = prefsFile->readIdFloat("View0Tilt",Camera::cameraTilt[0]);
- if (result != NO_ERR)
- Camera::cameraTilt[0] = 35.0f;
-
- result = prefsFile->readIdFloat("View1Zoom",Camera::cameraZoom[1]);
- if (result != NO_ERR)
- Camera::cameraZoom[1] = 1200.0f;
-
- result = prefsFile->readIdFloat("View1Tilt",Camera::cameraTilt[1]);
- if (result != NO_ERR)
- Camera::cameraTilt[1] = 35.0f;
-
- result = prefsFile->readIdFloat("View2Zoom",Camera::cameraZoom[2]);
- if (result != NO_ERR)
- Camera::cameraZoom[2] = 1200.0f;
-
- result = prefsFile->readIdFloat("View2Tilt",Camera::cameraTilt[2]);
- if (result != NO_ERR)
- Camera::cameraTilt[2] = 35.0f;
-
- result = prefsFile->readIdFloat("View3Zoom",Camera::cameraZoom[3]);
- if (result != NO_ERR)
- Camera::cameraZoom[3] = 1200.0f;
-
- result = prefsFile->readIdFloat("View3Tilt",Camera::cameraTilt[3]);
- if (result != NO_ERR)
- Camera::cameraTilt[3] = 35.0f;
- }
- }
-
- prefsFile->close();
- optsFile->close();
-
- delete prefsFile;
- prefsFile = NULL;
-
- delete optsFile;
- optsFile = NULL;
-
- //---------------------------------------------------------------------
- //void __stdcall gos_SetScreenMode( DWORD Width, DWORD Height, DWORD bitDepth=16, DWORD Device=0, bool disableZBuffer=0, bool AntiAlias=0, bool RenderToVram=0, bool GotoFullScreen=0, int DirtyRectangle=0, bool GotoWindowMode=0, bool EnableStencil=0, DWORD Renderer=0 );
-
- /*The following commented out code is now handled by CPrefs::applyPrefs()
- (in "prefs.cpp").*/
- /*
- switch (resolution)
- {
- case 0: //640by480
- if (renderer == 3)
- gos_SetScreenMode(640,480,16,0,0,0,true,fullScreen,0,!fullScreen,0,renderer);
- else
- gos_SetScreenMode(640,480,16,0,0,0,0,fullScreen,0,!fullScreen,0,renderer);
- break;
-
- case 1: //800by600
- if (renderer == 3)
- gos_SetScreenMode(800,600,16,0,0,0,true,fullScreen,0,!fullScreen,0,renderer);
- else
- gos_SetScreenMode(800,600,16,0,0,0,0,fullScreen,0,!fullScreen,0,renderer);
- break;
-
- case 2: //1024by768
- if (renderer == 3)
- gos_SetScreenMode(1024,768,16,0,0,0,true,fullScreen,0,!fullScreen,0,renderer);
- else
- gos_SetScreenMode(1024,768,16,0,0,0,0,fullScreen,0,!fullScreen,0,renderer);
- break;
-
- case 3: //1280by1024
- if (renderer == 3)
- gos_SetScreenMode(1280,1024,16,0,0,0,true,fullScreen,0,!fullScreen,0,renderer);
- else
- gos_SetScreenMode(1280,1024,16,0,0,0,0,fullScreen,0,!fullScreen,0,renderer);
- break;
-
- case 4: //1600by1200
- if (renderer == 3)
- gos_SetScreenMode(1600,1200,16,0,0,0,true,fullScreen,0,!fullScreen,0,renderer);
- else
- gos_SetScreenMode(1600,1200,16,0,0,0,0,fullScreen,0,!fullScreen,0,renderer);
- break;
- }
- */
-
- /* load and apply options from "options.cfg" */
- prefs.load();
- prefs.applyPrefs();
-
-
- //--------------------------------------------------
- // Setup Mouse Parameters from Prefs.CFG
- userInput = new UserInput;
- userInput->init();
- userInput->setMouseDoubleClickThreshold(doubleClickThreshold);
- userInput->setMouseDragThreshold(dragThreshold);
- //--------------------------------------------------
-
-
- char temp[256];
- cLoadString( IDS_FLOAT_HELP_FONT, temp, 255 );
- char* pStr = strstr( temp, "," );
- if ( pStr )
- {
- gosFontScale = -atoi( pStr + 1 );
- *pStr = 0;
- }
- char path [256];
- strcpy( path, "assets\\graphics\\" );
- strcat( path, temp );
-
- gosFontHandle = gos_LoadFont(path);
- FontHandle = gosFontHandle;
-
- globalFloatHelp = new FloatHelp(MAX_FLOAT_HELPS);
-
- //
- //----------------------------------
- // Start associated stuff.
- //----------------------------------
-
- //-------------------------------
- // Used to output debug stuff!
- // Mondo COOL!
- // simply do this in the code and stuff goes to the file called mc2.output
- // DEBUG_STREAM << thing_you_want_to_output
- //
- // IMPORTANT NOTE:
- Stuff::InitializeClasses();
- MidLevelRenderer::InitializeClasses(8192*4,8192,0,0,true);
- gosFX::InitializeClasses();
-
- gos_PushCurrentHeap(MidLevelRenderer::Heap);
-
- MidLevelRenderer::TGAFilePool *pool = new MidLevelRenderer::TGAFilePool("data\\tgl\\128\\");
- MidLevelRenderer::MLRTexturePool::Instance = new MidLevelRenderer::MLRTexturePool(pool);
-
- MidLevelRenderer::MLRSortByOrder *cameraSorter = new MidLevelRenderer::MLRSortByOrder(MidLevelRenderer::MLRTexturePool::Instance);
- theClipper = new MidLevelRenderer::MLRClipper(0, cameraSorter);
-
- gos_PopCurrentHeap();
-
- //------------------------------------------------------
- // Start the GOS FX.
- gos_PushCurrentHeap(gosFX::Heap);
-
- gosFX::EffectLibrary::Instance = new gosFX::EffectLibrary();
- Check_Object(gosFX::EffectLibrary::Instance);
-
- FullPathFileName effectsName;
- effectsName.init(effectsPath,"mc2.fx","");
-
- File effectFile;
- long result = effectFile.open(effectsName);
- if (result != NO_ERR)
- STOP(("Could not find MC2.fx"));
-
- long effectsSize = effectFile.fileSize();
- MemoryPtr effectsData = (MemoryPtr)systemHeap->Malloc(effectsSize);
- effectFile.read(effectsData,effectsSize);
- effectFile.close();
-
- effectStream = new Stuff::MemoryStream(effectsData,effectsSize);
- gosFX::EffectLibrary::Instance->Load(effectStream);
-
- gosFX::LightManager::Instance = new gosFX::LightManager();
-
- gos_PopCurrentHeap();
-
- systemHeap->Free(effectsData);
-
-
- //--------------------------------------------------------------
- // Start the GUI Heap.
- guiHeap = new UserHeap;
- gosASSERT(guiHeap != NULL);
-
- guiHeap->init(guiHeapSize,"GUI");
-
- //------------------------------------------------
- // Fire up the MC Texture Manager.
- mcTextureManager = new MC_TextureManager;
- mcTextureManager->start();
-
- //--------------------------------------------------------------
- // Load up the mouse cursors
- userInput->initMouseCursors("cursors");
- userInput->mouseOff();
- userInput->setMouseCursor(mState_NORMAL);
-
- //------------------------------------------------
- // Give the Sound System a Whirl!
- soundSystem = new GameSoundSystem;
- soundSystem->init();
- ((SoundSystem *)soundSystem)->init("sound");
- sndSystem = soundSystem; // for things in the lib that use sound
-
- //-----------------------------------------------
- // Only used by camera to retrieve screen coords.
- globalPane = new PANE;
- globalWindow = new WINDOW;
-
- globalPane->window = globalWindow;
- globalPane->x0 = 0;
- globalPane->y0 = 0;
- globalPane->x1 = Environment.screenWidth;
- globalPane->y1 = Environment.screenHeight;
-
- globalWindow->buffer = NULL; //This is set at the start of Renders. For now we HOLD LOCK during entire old 2D render test. This will go away once we hit 3D
- globalWindow->shadow = NULL;
- globalWindow->stencil = NULL;
- globalWindow->x_max = globalPane->x1 - globalPane->x0 - 1;
- globalWindow->y_max = globalPane->y1 - globalPane->y0 - 1;
-
- //---------------------------------------------------------
- // Start the Timers
- timerManager = new TimerManager;
- timerManager->init();
-
- //---------------------------------------------------------
- // Start the Color table code
- initColorTables();
-
- //---------------------------------------------------------
- // Start the Mission, Scenario and Logistics classes here
- mission = new Mission;
-
- logistics = new Logistics;
-
- GameDebugWindow::setFont("assets\\graphics\\arial8.tga");
- DEBUGWINS_init();
-
- StartupNetworking();
- #ifdef USE_movie
- movieSoundUseDirectSound(0);
- #endif
- if (justStartMission)
- {
- logistics->setLogisticsState(log_STARTMISSIONFROMCMDLINE);
- char commandersToLoad[MAX_MC_PLAYERS][3] = {{0, 0, 0}, {1, 1, 1}, {2, 0, 2}, {3, 3, 3}, {4, 4, 4}, {5, 5, 5}, {6, 6, 6}, {7, 7, 7}};
- mission->init(missionName, MISSION_LOAD_SP_QUICKSTART, 0, NULL, commandersToLoad, 2);
- eye->activate();
- eye->update();
- mission->start();
- }
- else
- {
- int param = log_SPLASH;
- if ( MPlayer && MPlayer->launchedFromLobby )
- param = log_ZONE;
- logistics->start( param); //Always start with logistics in Splash Screen Mode
- Mission::initBareMinimum();
- }
-
- initDialogs();
-
- gos_EnableSetting(gos_Set_LoseFocusBehavior, 2 );
-
- DWORD numJoysticks = gosJoystick_CountJoysticks();
-
- for (long i=0;i<numJoysticks;i++)
- {
- gosJoystick_Info joyInfo;
- gosJoystick_GetInfo(i, &joyInfo);
-
- //Search for the Attila Strategic Commander here.
- // Look for the Attila VidPid 0x045e0033 (Unique!)
- // Andy G did not do what I asked for here. Will do in our version when we branch.
- // For NOW, ANY 3 Axis joystick with 15 buttons is a Strategic Commander.
- if ((joyInfo.nAxes == 3) && (joyInfo.nButtons == 15))
- {
- userInput->addAttila(i);
- gosJoystick_SetPolling(i, true, 0.1f);
- }
- }
-
- //Time BOMB goes here.
- // Set Date and write Binary data to registry under key
- // GraphicsData!!
- SYSTEMTIME bombDate;
- DWORD dataSize = sizeof(SYSTEMTIME);
- gos_LoadDataFromRegistry("GraphicsDataInit2", &bombDate, &dataSize);
- if (dataSize == 0)
- {
- bombDate.wYear = 2001;
- bombDate.wMonth = 6;
- bombDate.wDayOfWeek = 5;
- bombDate.wDay = 15;
- bombDate.wHour = 0;
- bombDate.wMinute = 0;
- bombDate.wSecond = 0;
- bombDate.wMilliseconds = 0;
-
- dataSize = sizeof(SYSTEMTIME);
- gos_SaveDataToRegistry("GraphicsDataInit2", &bombDate, dataSize);
- }
- gameStarted = true;
- }
- else
- {
- char msgBuffer[4096];
- char msgTitle[1024];
- cLoadString(IDS_SNIFFER_INIT_MSG,msgBuffer,4095);
- cLoadString(IDS_SNIFFER_INIT_TITLE,msgTitle,1023);
- MessageBox(NULL,msgBuffer,msgTitle,MB_OK);
- //-------------------------------------------------------------
- // Find the CDPath in the registry and save it off so I can
- // look in CD Install Path for files.
-
- //Changed for the shared source release, just set to current directory
- //DWORD maxPathLength = 1023;
- //gos_LoadDataFromRegistry("CDPath", CDInstallPath, &maxPathLength);
- //if (!maxPathLength)
- // memset(CDInstallPath,0,1024);
- memset(CDInstallPath,0,1024);
- //Set ScreenMode to 800x600x16 FULLSCREEN!!!!
- // A window will return BAD DATA!!
- //
- // If this fails, GAME CANNOT RUN on their machine!!!!!
- //
- // Check which rasterizer comes up. If software, tell prefs we cannot run in hardware!!
- //
- while (((gos_GetMachineInformation(gos_Info_GetDeviceLocalMemory, curDevice) +
- gos_GetMachineInformation(gos_Info_GetDeviceAGPMemory, curDevice)) < 6291456) &&
- (curDevice < gos_GetMachineInformation( gos_Info_NumberDevices )))
- curDevice++;
- if (curDevice < gos_GetMachineInformation( gos_Info_NumberDevices ))
- gos_SetScreenMode(800,600,16,curDevice,0,0,0,true,0,0,0,0);
- //Create about a thousand textured random triangles.
- testVertex = (gos_VERTEX *)malloc(sizeof(gos_VERTEX) * 3000);
- indexArray = (WORD *)malloc(sizeof(WORD) * 3000);
- for (long i=0;i<3000;i++)
- {
- testVertex[i].x = RandomNumber(1000) - 100;
- testVertex[i].y = RandomNumber(800) - 100;
- testVertex[i].z = ((float)RandomNumber(150) / 100.0f) - 0.25f;
- testVertex[i].rhw = 0.5f;
- testVertex[i].u = (float)RandomNumber(100) / 100.0f;
- testVertex[i].v = (float)RandomNumber(100) / 100.0f;
- testVertex[i].argb = 0x3fffffff;
- testVertex[i].frgb = 0x3f1f2f3f;
- indexArray[i] = i;
- }
- testTextureHandle = gos_NewTextureFromFile(gos_Texture_Solid,"testTxm.tga");
- }
- //Make any directories we need which should be empty.
- CreateDirectory(savePath,NULL);
- CreateDirectory(transcriptsPath,NULL);
- //Startup the Office Watson Handler.
- InitDW();
- __asm pop esi;
- }
- //---------------------------------------------------------------------------
- void TerminateGameEngine()
- {
- if (!gameStarted)
- return;
- if (!SnifferMode)
- {
- //--------------------------------------------------
- // Setup Mouse Parameters from Prefs.CFG
- if (userInput)
- {
- //Must call this to shut off the mouse async draw thread.
- //DO NOT DELETE Yet!! Too many things assume this is around.
- userInput->destroy();
- }
- //--------------------------------------------------
- DEBUGWINS_destroy();
- ShutdownNetworking();
- delete theClipper;
- theClipper = NULL;
- //---------------------------------------------------------
- // End the Mission, Operation and Logistics classes here
- if (mission)
- {
- mission->destroy(false);
- delete mission;
- mission = NULL;
- }
- if (logistics)
- {
- logistics->destroy();
- delete logistics;
- logistics = NULL;
- }
- endDialogs();
- if (optionsScreenWrapper)
- {
- optionsScreenWrapper->destroy();
- delete optionsScreenWrapper;
- optionsScreenWrapper = NULL;
- }
- //---------------------------------------------------------
- // Start the Color table code
- destroyColorTables();
- GameLog::cleanup();
- //---------------------------------------------------------
- // End the Timers
- delete timerManager;
- timerManager = NULL;
- //---------------------------------------------------------
- // TEST of PORT
- // Create VFX PANE and WINDOW to test draw of old terrain!
- if (globalPane)
- {
- delete globalPane;
- globalPane = NULL;
- }
- if (globalWindow)
- {
- delete globalWindow;
- globalWindow = NULL;
- }
- //-------------------------------------------------------------
- // Shut down the soundSytem for a change!
- if (soundSystem)
- {
- soundSystem->destroy();
- delete soundSystem;
- soundSystem = NULL;
- }
- //------------------------------------------------
- // shutdown the MC Texture Manager.
- if (mcTextureManager)
- {
- mcTextureManager->destroy();
- delete mcTextureManager;
- mcTextureManager = NULL;
- }
- delete globalFloatHelp;
- globalFloatHelp = NULL;
- //--------------------------------------------------------------
- // End the SystemHeap and globalHeapList
- if (systemHeap)
- {
- systemHeap->destroy();
- delete systemHeap;
- systemHeap = NULL;
- }
- if (guiHeap)
- {
- guiHeap->destroy();
- delete guiHeap;
- guiHeap = NULL;
- }
- if (globalHeapList)
- {
- globalHeapList->destroy();
- delete globalHeapList;
- globalHeapList = NULL;
- }
- //----------------------------------------------------
- // Shutdown the MLR and associated stuff libraries
- //----------------------------------------------------
- gos_PushCurrentHeap(gosFX::Heap);
- delete effectStream;
- delete gosFX::LightManager::Instance;
- gos_PopCurrentHeap();
- //
- //-------------------
- // Turn off libraries
- //-------------------
- //
- gosFX::TerminateClasses();
- MidLevelRenderer::TerminateClasses();
- Stuff::TerminateClasses();
- delete userInput;
- userInput = NULL;
- //Redundant. Something else is shutting this down.
- //GOS sure does think its bad to delete something multiple times though.
- //Even though it simply never is!
- //gos_DeleteFont(gosFontHandle);
- gos_CloseResourceDLL(gosResourceHandle);
- //
- //--------------------------
- // Turn off the fast Files
- //--------------------------
- //
- FastFileFini();
- //
- //Just down any global allocations
- //
- if (g_textureCache_FilenameOfLastLoadedTexture)
- {
- delete g_textureCache_FilenameOfLastLoadedTexture;
- g_textureCache_FilenameOfLastLoadedTexture = NULL;
- }
- if (ForceGroupIcon::jumpJetIcon)
- {
- delete ForceGroupIcon::jumpJetIcon;
- ForceGroupIcon::jumpJetIcon = NULL;
- }
- if (MechIcon::s_MechTextures)
- {
- delete [] MechIcon::s_MechTextures;
- MechIcon::s_MechTextures = NULL;
- }
- if (ForceGroupIcon::s_textureMemory)
- {
- delete [] ForceGroupIcon::s_textureMemory;
- ForceGroupIcon::s_textureMemory = NULL;
- }
- }
- else
- {
- free(testVertex);
- testVertex = NULL;
- free(indexArray);
- indexArray = NULL;
- }
- }
- //-------------------------------
- // Test TGL Parser.
- bool extracted = false;
- bool doTransformMath = true;
- extern bool useFog;
- extern long terrainLineChanged;
- float frameNum = 0.0f;
- bool enoughTime = true;
- long enoughCount = 0;
- //---------------------------------------------------------------------------
- //
- // No multi-thread now!
- //
- bool DoneSniffing = false;
- void DoGameLogic()
- {
- if (!SnifferMode)
- {
- #ifdef LAB_ONLY //Used for debugging LOS
- currentLineElement = 0;
- #endif
-
- if (MPlayer) {
- ProfileTime(MCTimeMultiplayerUpdate,MPlayer->update());
- if (MPlayer->waitingToStartMission)
- {
- if (MPlayer->startMission)
- {
- // logistics->setLogisticsState(log_DONE); // can't do this until screen animates out
- soundSystem->playBettySample(BETTY_NEW_CAMPAIGN);
- MPlayer->waitingToStartMission = false;
- }
- }
- }
-
- FloatHelp::resetAll();
-
- //-------------------------------------
- // Get me the current frameRate.
- // Convert to frameLength and any other timing stuff.
- //if (frameRate < 15.0)
- // frameRate = 15.0;
-
- //FrameRate can be zero in GameOS for some unknown fu-cocked reason.
- if (frameRate < Stuff::SMALL)
- frameRate = 4.0f;
-
- frameLength = 1.0 / frameRate;
- if (frameLength > 0.25f)
- frameLength = 0.25f;
- //Calc out the average frame rate so we can decide if we should use the
- // movie Video or Just the Audio Track!
- currentFrameNum++;
- if (currentFrameNum == 30)
- currentFrameNum = 0;
- last30Frames[currentFrameNum] = frameRate;
- averageFrameRate = 0.0f;
- for (long fc=0;fc<30;fc++)
- averageFrameRate += last30Frames[fc];
- averageFrameRate /= 30.0f;
- if (userInput->getKeyDown(KEY_R) && userInput->ctrl() && !userInput->alt() && !userInput->shift())
- {
- doTransformMath ^= true;
- terrainLineChanged = turn;
- }
-
- if (doTransformMath)
- {
- //-------------------------------------
- // Poll devices for this frame.
- userInput->update();
-
- //----------------------------------------
- // Update the Sound System for this frame
- soundSystem->update();
-
- //----------------------------------------
- // Update all of the timers
- timerManager->update();
-
- //-----------------------------------------------------
- // Update Mission and Logistics here.
- if (logistics)
- {
- long result = logistics->update();
- if (result == log_DONE)
- {
- logistics->stop();
- }
- }
-
- if ((true == bInvokeOptionsScreenFlag)
- || (userInput->getKeyDown(KEY_O) && userInput->ctrl() && !userInput->alt() && !userInput->shift()))
- {
- bInvokeOptionsScreenFlag = false;
- if ((!optionsScreenWrapper) || (optionsScreenWrapper->isDone()))
- {
- if (!optionsScreenWrapper)
- {
- optionsScreenWrapper = new OptionsScreenWrapper;
- optionsScreenWrapper->init();
- }
- if (mission && mission->missionInterface && !mission->missionInterface->isPaused())
- mission->missionInterface->togglePauseWithoutMenu();
- optionsScreenWrapper->begin();
- }
- }
- else
- if (mission && (!optionsScreenWrapper || optionsScreenWrapper->isDone() ) )
- {
- long result = mission->update();
- if (result == 9999) {
- mission->destroy();
- //delete mission;
- //mission = NULL;
- for (long i = 0; i < 3; i++) {
- DebugGameObject[i] = NULL;
- DebugWindow[i + 1]->clear();
- }
- if (MPlayer && MPlayer->isServer())
- MPlayer->sendEndMission(1);
- quitGame = true;
- }
- else if (result != mis_PLAYING)
- {
- //if (MPlayer && MPlayer->isServer())
- // MPlayer->sendEndMission(1);
- if (result < mis_PLAYER_DRAW)
- soundSystem->playBettySample(BETTY_MISSION_LOST);
- else if (result > mis_PLAYER_DRAW)
- soundSystem->playBettySample(BETTY_MISSION_WON);
-
- //Gotta get rid of the mission textures before Heidi starts her stuff!
- // No RAM otherwise in mc2_18.
- mcTextureManager->flush(true);
- if (MPlayer && aborted) {
- MPlayer->closeSession();
- MPlayer->setMode(MULTIPLAYER_MODE_NONE);
- logistics->start(log_SPLASH);
- }
- else
- logistics->start(log_RESULTS); //Should be log_RESULTS!!!!!!
- aborted = false;
- if ( !LogisticsData::instance->campaignOver() || MPlayer || LogisticsData::instance->isSingleMission() ) {
- mission->destroy();
- //delete mission;
- //mission = NULL;
- }
-
- for (long i = 0; i < 3; i++) {
- DebugGameObject[i] = NULL;
- DebugWindow[i + 1]->clear();
- }
-
- }
- }
- if (optionsScreenWrapper && !optionsScreenWrapper->isDone())
- {
- OptionsScreenWrapper::status_type result = optionsScreenWrapper->update();
- if (result == OptionsScreenWrapper::opt_DONE)
- {
- optionsScreenWrapper->end();
- if (mission && mission->missionInterface && mission->missionInterface->isPaused())
- mission->missionInterface->togglePauseWithoutMenu();
- }
- }
-
- }
-
- DEBUGWINS_update();
-
- //---------------------------------------------------
- // Update heap instrumentation.
- #ifdef LAB_ONLY
- if (turn > 3)
- globalHeapList->update();
- #endif
-
- //-----------------------------------------------------
- // Check the TimeBomb to see if we should go away
- /*
- if (!checkedBomb)
- {
- SYSTEMTIME checkTime;
- SYSTEMTIME bombTime;
- DWORD dataSize = sizeof(SYSTEMTIME);
- GetSystemTime(&checkTime);
-
- if (!gotBombData)
- {
- gos_LoadDataFromRegistry("GraphicsDataInit2", &bombTime, &dataSize);
- gotBombData = true;
- }
-
- if (dataSize == 0)
- {
- STOP(("NO Graphics Data Initializer - Please Login with administrator privileges")); //In Case they try to whack the registry entry while running!
- }
-
- if ((checkTime.wYear >= bombTime.wYear) &&
- (checkTime.wMonth >= bombTime.wMonth) &&
- (checkTime.wDay >= bombTime.wDay))
- {
- //If bomb goes off, set date to IMPOSSIBLE to achieve time!!
- // If they whack the entry after this, it doesn't matter! The normal bomb will go off and then set this anyway.
- // If they whack the entry, then reset their system clock, then run the game, it will work. Not much more I can do!
- // I could delete files but it won't matter, they have the CD!
- //
- // MUST change version numbers on fastfiles after Code Complete and after EACH Beta we release!!
- bombTime.wYear = 1950;
- bombTime.wMonth = 0;
- bombTime.wDay = 0;
-
- gos_SaveDataToRegistry("GraphicsDataInit2", &bombTime, sizeof(SYSTEMTIME));
-
- STOP(("Time Bomb has exploded!"));
-
- quitGame = true;
- }
- checkedBomb = true;
- }
- */
-
- //---------------------------------------------------------------
- // Somewhere in all of the updates, we have asked to be excused!
- if (quitGame)
- {
- //EnterWindowMode(); //Game crashes if _TerminateApp called from fullScreen
- gos_TerminateApplication();
- }
- if (loadInMissionSave)
- {
- mission->load("data\\savegame\\testgame.ims");
- loadInMissionSave = false;
- }
- }
- else
- {
- if (!DoneSniffing)
- {
- for (long i=0;i<3000;i++)
- {
- testVertex[i].x = RandomNumber(1000) - 100;
- testVertex[i].y = RandomNumber(800) - 100;
- testVertex[i].z = ((float)RandomNumber(150) / 100.0f) - 0.25f;
- testVertex[i].rhw = 0.5f;
- testVertex[i].u = (float)RandomNumber(100) / 100.0f;
- testVertex[i].v = (float)RandomNumber(100) / 100.0f;
- testVertex[i].argb = 0x3fffffff;
- testVertex[i].frgb = 0x3f1f2f3f;
- indexArray[i] = i;
- }
- curIteration++;
- if (curIteration > numIterations)
- {
- if (gos_GetMachineInformation(gos_Info_GetDeviceLocalMemory, curDevice) >= 6291456)
- trisPerSecond[curDevice] = 5000.0f * numIterations / (totalTime / 1000);
- else
- trisPerSecond[curDevice] = 0.0f;
- curDevice++;
- if ((curDevice >= NumDevices) || (curDevice > MAX_HARDWARE_CARDS))
- {
- FILE *sniffData = fopen("sniff.dat","wt");
- if (sniffData)
- {
- char sniff[2048];
- sprintf(sniff,"%f,%f,%f,%f,%f,%f\n",trisPerSecond[0],ProcessorSpeed,trisPerSecond[1],trisPerSecond[2],trisPerSecond[3],trisPerSecond[4]);
- fputs(sniff,sniffData);
- fclose(sniffData);
- }
- if ((trisPerSecond[0] > 1000000.0f) && (ProcessorSpeed > 595.0f))
- {
- CopyFile("hiPrefs.cfg","orgprefs.cfg",false);
- CopyFile("hiPrefs.cfg","options.cfg",false);
- }
- else if ((trisPerSecond[0] > 1000000.0f) && (ProcessorSpeed <= 595.0f))
- {
- CopyFile("h2Prefs.cfg","orgprefs.cfg",false);
- CopyFile("h2Prefs.cfg","options.cfg",false);
- }
- else if ((trisPerSecond[0] > 10000.0f) && (ProcessorSpeed > 595.0f))
- {
- CopyFile("midPrefs.cfg","orgprefs.cfg",false);
- CopyFile("midPrefs.cfg","options.cfg",false);
- }
- else if ((trisPerSecond[1] > 1000000.0f) && (ProcessorSpeed > 595.0f))
- {
- CopyFile("hiPrefs1.cfg","orgprefs.cfg",false);
- CopyFile("hiPrefs1.cfg","options.cfg",false);
- }
- else if ((trisPerSecond[1] > 1000000.0f) && (ProcessorSpeed <= 595.0f))
- {
- CopyFile("h2Prefs1.cfg","orgprefs.cfg",false);
- CopyFile("h2Prefs1.cfg","options.cfg",false);
- }
- else if ((trisPerSecond[1] > 10000.0f) && (ProcessorSpeed > 595.0f))
- {
- CopyFile("midPrefs1.cfg","orgprefs.cfg",false);
- CopyFile("midPrefs1.cfg","options.cfg",false);
- }
- else if (trisPerSecond[1] > 0.0f)
- {
- CopyFile("minPrefs1.cfg","orgprefs.cfg",false);
- CopyFile("minPrefs1.cfg","options.cfg",false);
- }
- else
- {
- CopyFile("minPrefs.cfg","orgprefs.cfg",false);
- CopyFile("minPrefs.cfg","options.cfg",false);
- }
- DoneSniffing = true;
- }
- else
- {
- //Don't sniff a below minspec card. Crash O Roni!
- if (gos_GetMachineInformation(gos_Info_GetDeviceLocalMemory, curDevice) >= 6291456)
- gos_SetScreenMode(800,600,16,curDevice,0,0,0,true,0,0,0,0);
- else
- curDevice++;
- curIteration = 0;
- }
- }
- }
- else
- {
- gos_SetScreenMode(800,600,16,0,0,0,0,false,0,true,0,0);
- DoneSniffing = true;
- if (Environment.fullScreen == 0)
- {
- char msgBuffer[4096];
- char msgTitle[1024];
- cLoadString(IDS_SNIFFER_DONE_MSG,msgBuffer,4095);
- cLoadString(IDS_SNIFFER_INIT_TITLE,msgTitle,1023);
- MessageBox(NULL,msgBuffer,msgTitle,MB_OK);
- gos_TerminateApplication();
- }
- }
- }
- }
- //---------------------------------------------------------------------------
- long textToLong (char *num)
- {
- long result = 0;
-
- //------------------------------------
- // Check if Hex Number
- char *hexOffset = strstr(num,"0x");
- if (hexOffset == NULL)
- {
- result = atol(num);
- }
- else
- {
- hexOffset += 2;
- long numDigits = strlen(hexOffset)-1;
- for (int i=0; i<=numDigits; i++)
- {
- if (!isalnum(hexOffset[i]) || (isalpha(hexOffset[i]) && toupper(hexOffset[i]) > 'F'))
- {
- hexOffset[i] = 0; // we've reach a "wrong" character. Either start of a comment or something illegal. Either way, stop evaluation here.
- break;
- }
- }
- numDigits = strlen(hexOffset)-1;
- long power = 0;
- for (long count = numDigits;count >= 0;count--,power++)
- {
- unsigned char currentDigit = toupper(hexOffset[count]);
-
- if (currentDigit >= 'A' && currentDigit <= 'F')
- {
- result += (currentDigit - 'A' + 10)<<(4*power);
- }
- else if (currentDigit >= '0' && currentDigit <= '9')
- {
- result += (currentDigit - '0')<<(4*power);
- }
- else
- {
- //---------------------------------------------------------
- // There is a digit in here I don't understand. Return 0.
- result = 0;
- break;
- }
- }
- }
-
- return(result);
- }
- //----------------------------------------------------------------------------
- // Same command line Parser as MechCommander
- void ParseCommandLine(char *command_line)
- {
- int i;
- int n_args = 0;
- int index = 0;
- char *argv[30];
-
- char tempCommandLine[4096];
- memset(tempCommandLine,0,4096);
- strncpy(tempCommandLine,command_line,4095);
- while (tempCommandLine[index] != '\0') // until we null out
- {
- argv[n_args] = tempCommandLine + index;
- n_args++;
- while (tempCommandLine[index] != ' ' && tempCommandLine[index] != '\0')
- {
- index++;
- }
- while (tempCommandLine[index] == ' ')
- {
- tempCommandLine[index] = '\0';
- index++;
- }
- }
- i=0;
- while (i<n_args)
- {
- if (strcmpi(argv[i],"-mission") == 0)
- {
- i++;
- if (i < n_args)
- {
- justStartMission = true;
- inViewMode = false;
- if (argv[i][0] == '"')
- {
- // They typed in a quote, keep reading argvs
- // until you find the close quote
- strcpy(missionName,&(argv[i][1]));
- bool scanName = true;
- while (scanName && (i < n_args))
- {
- i++;
- if (i < n_args)
- {
- strcat(missionName," ");
- strcat(missionName,argv[i]);
- if (strstr(argv[i],"\"") != NULL)
- {
- scanName = false;
- missionName[strlen(missionName)-1] = 0;
- }
- }
- else
- {
- //They put a quote on the line with no space.
- //
- scanName = false;
- missionName[strlen(missionName)-1] = 0;
- }
- }
- }
- else
- strcpy(missionName,argv[i]);
- }
- }
- else if (strcmpi(argv[i],"-viewer") == 0)
- {
- i++;
- if (i < n_args)
- {
- inViewMode = true;
- justStartMission = true;
- viewObject = textToLong(argv[i]);
- strcpy(missionName,"mis0101");
- }
- }
- else if (strcmpi(argv[i],"-nodialog") == 0)
- {
- gNoDialogs = true;
- }
- else if (strcmpi(argv[i],"-sniffer") == 0)
- {
- SnifferMode = true;
- }
- else if (strcmpi(argv[i], "-braindead") == 0) {
- i++;
- if (i < n_args) {
- long teamID = textToLong(argv[i]);
- MechWarrior::brainsEnabled[teamID] = false;
- }
- }
- else if (strcmpi(argv[i], "-turrets_off") == 0) {
- i++;
- if (i < n_args) {
- long teamID = textToLong(argv[i]);
- Turret::turretsEnabled[teamID] = false;
- }
- }
- else if (strcmpi(argv[i], "-debugwins") == 0) {
- i++;
- if (i < n_args) {
- long winState = textToLong(argv[i]);
- if (winState == 1)
- DebugWindowOpen[0] = true;
- else if (winState == 2) {
- DebugWindowOpen[1] = true;
- DebugWindowOpen[2] = true;
- DebugWindowOpen[3] = true;
- }
- else if (winState == 3) {
- DebugWindowOpen[0] = true;
- DebugWindowOpen[1] = true;
- DebugWindowOpen[2] = true;
- DebugWindowOpen[3] = true;
- }
- }
- }
- else if (strcmpi(argv[i], "-objectwins") == 0) {
- i++;
- if (i < n_args) {
- long partNumber = textToLong(argv[i]);
- if (NumGameObjectsToDisplay < 3)
- GameObjectWindowList[NumGameObjectsToDisplay++] = partNumber;
- }
- }
- else if (strcmpi(argv[i], "-debugcells") == 0) {
- i++;
- if (i < n_args) {
- long setting = textToLong(argv[i]);
- if ((setting > 0) && (setting < 5))
- DrawDebugCells = setting;
- }
- }
- else if (strcmpi(argv[i], "-nopain") == 0) {
- i++;
- if (i < n_args) {
- long teamID = textToLong(argv[i]);
- Team::noPain[teamID] = true;
- }
- }
- else if (strcmpi(argv[i], "-disable") == 0) {
- i++;
- if (i < n_args) {
- long partID = textToLong(argv[i]);
- DisableAtStart[NumDisableAtStart++] = partID;
- }
- }
- else if (strcmpi(argv[i], "-log") == 0) {
- i++;
- initGameLogs = true;
- if (i < n_args) {
- if (strcmpi(argv[i], "net") == 0)
- initNetLog = true;
- if (strcmpi(argv[i], "weaponfire") == 0)
- initCombatLog = true;
- if (strcmpi(argv[i], "bugs") == 0)
- initBugLog = true;
- if (strcmpi(argv[i], "lrmove") == 0)
- initLRMoveLog = true;
- }
- }
- else if (strcmpi(argv[i], "-show") == 0) {
- i++;
- if (i < n_args) {
- if (strcmpi(argv[i], "movers") == 0)
- ShowMovers = true;
- }
- }
- else if (strcmpi(argv[i], "-goalplan") == 0) {
- i++;
- if (i < n_args) {
- if (strcmpi(argv[i], "enemies") == 0)
- EnemiesGoalPlan = true;
- }
- }
- else if (strcmpi(argv[i], "-killambient") == 0) {
- KillAmbientLight = true;
- }
- else if (strcmpi(argv[i], "-movegoals") == 0) {
- i++;
- if (i < n_args)
- MaxMoveGoalChecks = textToLong(argv[i]);
- }
- else if (strcmpi(argv[i], "-rps") == 0) {
- i++;
- if (i < n_args)
- MaxResourcePoints = textToLong(argv[i]);
- }
- else if (strcmpi(argv[i], "-registerzone") == 0) {
- MultiPlayer::registerZone = true;
- }
- else if (strcmpi(argv[i], "-dropzones") == 0) {
- i++;
- if (i < n_args) {
- long numPlayers = strlen(argv[i]);
- for (long j = 0; j < numPlayers; j++)
- MultiPlayer::presetDropZones[j] = (argv[i][j] - '0');
- }
- }
- i++;
- }
- }
- bool notFirstTime = false;
- //---------------------------------------------------------------------------
- //
- // Setup the GameOS structure -- This tells GameOS what I am using
- //
- void GetGameOSEnvironment( char* CommandLine )
- {
- ParseCommandLine(CommandLine);
- Environment.applicationName = "MechCommander2\\1.0"; // MP012001";
- Environment.debugLog = "";
- Environment.spew = "";
- Environment.TimeStampSpew = 0;
- Environment.GetGameInformation = GetGameInformation;
- Environment.UpdateRenderers = UpdateRenderers;
- Environment.InitializeGameEngine = InitializeGameEngine;
- Environment.DoGameLogic = DoGameLogic;
- Environment.TerminateGameEngine = TerminateGameEngine;
- Environment.Renderer = 0;
- Environment.allowMultipleApps = false;
- Environment.dontClearRegistry = true;
-
- if (useSound)
- {
- Environment.soundDisable = FALSE;
- Environment.soundHiFi = TRUE;
- Environment.soundChannels = 20;
- }
- else
- {
- Environment.soundDisable = TRUE;
- Environment.soundHiFi = FALSE;
- Environment.soundChannels = 0;
- }
- //--------------------------
- // Networking information...
- // MechCommander GUID = {09608800-4815-11d2-92D2-0060973CFB2C}
- // or {0x9608800, 0x4815, 0x11d2, {0x92, 0xd2, 0x0, 0x60, 0x97, 0x3c, 0xfb, 0x2c}}
- Environment.NetworkGame = FALSE;
- Environment.NetworkMaxPlayers = MAX_COMMANDERS;
- Environment.NetworkGUID[0] = 0x09;
- Environment.NetworkGUID[1] = 0x60;
- Environment.NetworkGUID[2] = 0x88;
- Environment.NetworkGUID[3] = 0x00;
- Environment.NetworkGUID[4] = 0x48;
- Environment.NetworkGUID[5] = 0x15;
- Environment.NetworkGUID[6] = 0x11;
- Environment.NetworkGUID[7] = 0xd2;
- Environment.NetworkGUID[8] = 0x92;
- Environment.NetworkGUID[9] = 0xd2;
- Environment.NetworkGUID[10] = 0x00;
- Environment.NetworkGUID[11] = 0x60;
- Environment.NetworkGUID[12] = 0x97;
- Environment.NetworkGUID[13] = 0x3c;
- Environment.NetworkGUID[14] = 0xfb;
- Environment.NetworkGUID[15] = 0x2c;
-
- Environment.Key_FullScreen = 0;
- Environment.Key_SwitchMonitors = 0;
- Environment.Key_Exit = 0;
- Environment.screenWidth = 800;
- Environment.screenHeight = 600;
- Environment.bitDepth = 16;
- Environment.fullScreen = 0;
- HKEY hKey;
- LONG result;
- char pData[1024];
- DWORD szData = 1023;
- result=RegOpenKey(HKEY_CURRENT_USER,GAME_REG_KEY,&hKey);
- if( ERROR_SUCCESS==result )
- {
- result=RegQueryValueEx(hKey,"FIRSTRUN",NULL,NULL,(PBYTE)pData,&szData);
- if ((result == ERROR_SUCCESS) && pData[0])
- {
- if (fileExists("options.cfg") && !SnifferMode)
- #ifndef LAB_ONLY
- Environment.fullScreen = 1;
- #endif
- EULAShown = true;
- }
- RegCloseKey(hKey);
- }
- Environment.version = versionStamp;
- Environment.FullScreenDevice = 0;
- Environment.AntiAlias = 0;
- Environment.disableZBuffer = 0;
- //
- // Texture infomation
- //
- Environment.Texture_S_256 = 6;
- Environment.Texture_S_128 = 1;
- Environment.Texture_S_64 = 0;
- Environment.Texture_S_32 = 1;
- Environment.Texture_S_16 = 5;
- Environment.Texture_K_256 = 2;
- Environment.Texture_K_128 = 5;
- Environment.Texture_K_64 = 5;
- Environment.Texture_K_32 = 5;
- Environment.Texture_K_16 = 5;
- Environment.Texture_A_256 = 0;
- Environment.Texture_A_128 = 1;
- Environment.Texture_A_64 = 5;
- Environment.Texture_A_32 = 1;
- Environment.Texture_A_16 = 0;
- Environment.RaidDataSource = "MechCommander 2:Raid4";
- Environment.RaidFilePath = "\\\\aas1\\MC2\\Test\\GOSRaid";
- Environment.RaidCustomFields = "Area=GOSRaid";
- Environment.DisableLowEndCard = 1;
- Environment.Suppress3DFullScreenWarning = 1;
- Environment.RenderToVram = 1;
- notFirstTime = true;
- }
- //***************************************************************************
|