Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Main.cpp File Reference


Detailed Description

The Main of the entire game ModernWarfare. This is the application entry point.

Definition in file Main.cpp.

#include "WinMainSelector.h"
#include "Network.h"
#include "GameConfig.h"
#include "EconData.h"
#include "BattleUnitData.h"
#include "Sound.h"
#include "Typer.h"
#include "..\AEngine\AEngine.h"
#include "Overhead.h"
#include "MainFuncs.h"
#include <time.h>

Include dependency graph for Main.cpp:

Include dependency graph

Go to the source code of this file.

Defines

#define _FULLSCREEN

Functions

void main_init ()
void main_shutdown ()
void main_update ()
void main_render ()
INT WINAPI WinMain (HINSTANCE hInst, HINSTANCE, LPSTR, INT)
 The main function that Windows calls to get it all going.


Variables

int mode


Define Documentation

#define _FULLSCREEN
 

Definition at line 40 of file Main.cpp.


Function Documentation

void main_init  
 

Definition at line 51 of file Main.cpp.

References Singleton< Sound >::getObj(), Sound::init(), NetworkSubsystem::loadNetworkData(), stripComments(), switchToSponsor(), sys_enableConsoleLog(), sys_setSkipRate(), sys_showConsole(), time, and UINT.

00052 {
00053         //Turn on memory leak detection when in a debug build
00054         int tmp = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
00055         _CrtSetDbgFlag ( tmp | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);   
00056         switchToSponsor();
00057         Globals::artWork = new Globals::ArtWork();
00058         sys_setSkipRate(0);
00059 
00060         // unique name console log file
00061         time_t t;
00062         tm     *pTime;
00063         time(&t);
00064         pTime = localtime(&t);
00065         string filename = string(asctime(pTime));       
00066         for( UINT i=0; i<filename.length(); i++ )
00067                 if( filename[i]==':' ) filename[i] = '-';
00068                 else if( filename[i]==' ' ) filename[i] = '_';
00069         filename = "console_" + filename.substr(0,filename.length()-1) + ".log";
00070         char s[1024];
00071         strcpy(s,filename.c_str());     
00072         sys_enableConsoleLog( filename );
00073 
00074         sys_showConsole(false);
00075         ifstream in("sounds.txt");                                                                                              // sound system
00076         if(!in) Error("sounds.txt not found");
00077         ostringstream fileDump;
00078         fileDump << in.rdbuf();
00079         Sound::getObj().init(istringstream(stripComments(fileDump.str())));
00080 #if 0 /*If you want to load a log file to replay a game do it here*/
00081         ifstream loadGame("test.log");
00082         if(!loadGame) Error("test.log not found");
00083         NetworkSubsystem::loadNetworkData(loadGame);
00084 #endif
00085 }

void main_render  
 

Definition at line 167 of file Main.cpp.

References Overhead::overhead_render(), renderCredit(), renderMainMenu(), renderMultiplayMenu(), and renderSponsor().

00168 {
00169         switch(mode)
00170         {
00171         case MainModes::mainMenu :
00172                 renderMainMenu();
00173                 break;
00174 
00175         case MainModes::multiplayMenu :
00176                 renderMultiplayMenu();
00177                 break;
00178 
00179         case MainModes::overhead :
00180                 overhead_render();
00181                 break;
00182 
00183         case MainModes::credit :
00184                 renderCredit();
00185                 break;
00186 
00187         case MainModes::sponsor :
00188                 renderSponsor();
00189                 break;
00190         }       
00191 }

void main_shutdown  
 

Definition at line 87 of file Main.cpp.

References Overhead::overhead_shutdown().

00088 {
00089         overhead_shutdown();
00090 }

void main_update  
 

Definition at line 92 of file Main.cpp.

References Overhead::overhead_update(), updateCredit(), updateMainMenu(), updateMultiplayMenu(), and updateSponsor().

00093 {
00094         /*
00095         static bool first=true;
00096         if(first)
00097         {
00098                 first = false;
00099                 Vec3D num( 0.3456f, 0.5435f, 324.343f );
00100                 Vec3D num2( 0.3456f, 0.5435f, 324.343f );
00101                 Vec3D adder( 0.043f, 6.72f, 0.03443f );
00102                 Vec3D adder2( 0.128f, 1.32f, 0.89033f );
00103                 FLOAT mult[4] = { 0.534f, 1.134f, 0.859f, 0.345f };
00104                 FLOAT num3 = 0.0f;
00105                 for( int i=0; i<10000; i++ )
00106                 {
00107                         num = num*mult[i%4] + adder + adder2*cosf(mult[i%4]*0.0123809f)*atan2f(mult[(i+1)%4],0.342f);
00108                         num.x += absf(cosf(mult[i%4]*i));
00109                         num2 += math_translateObjectToWorld( Vec3D(0.32432f,1.423f,0.21391f), Vec3D(mult[i%4],0,0), Vec3D(23.4233f,mult[i%4],0.234f) );
00110                         num3 += sqrtf((10001-i)*1.0f/10000.0f);
00111                 }
00112 
00113                 sys_console() << num.x << ' ' << num.y << ' ' << num.z << endl;
00114                 sys_console() << num2.x << ' ' << num2.y << ' ' << num2.z << endl;
00115                 sys_console() << num3 << endl;
00116 
00117                 Vec2D a(4820.858099454f,809.8509438f);
00118                 Vec2D b(8.850394f,1.8403985f);
00119                 sys_console() << D3DXVec2CCW(&a,&b) << endl;
00120 
00121                 for( int i=0; i<100; i++ )
00122                         for( int j=0; j<100; j++ )
00123                         {
00124                                 FLOAT f1 = i * 12.3248324092384f - j * 2.4820938433f;
00125                                 FLOAT f2 = (i+j)*9.72398497f - i*j*3.3428230984f;
00126                                 sys_console() << sinf(f1) << ' ' << cosf(f2) << ' ' << tanf(f1) << ' ' << sqrtf(f2) << ' ' << atan2f(f1,f2) 
00127                                                   << ' ' << atan2f(f2,f1) << ' ' << absf(f1) << ' ' << absf(f2) << endl;
00128                                 Vec2D a(f1,f2);
00129                                 Vec2D b(f1-f2,f2+f1*f1);
00130                                 sys_console() << D3DXVec2CCW(&a,&b) << endl;
00131 
00132                                 Vec3D v(f1,f2,f1*f2);
00133                                 sys_console() << D3DXVec3Length(&v) << ' ';
00134 
00135                                 Vec3D v2(f1*i+f2*j,f2-f1,f1*f1);
00136                                 sys_console() << math_getDir(v,v2) << ' ';
00137                                 sys_console() << math_deltaDir(f2,f1*f1) << ' ';
00138                         }
00139 
00140         }
00141         */
00142 
00143         switch(mode)
00144         {
00145         case MainModes::mainMenu :
00146                 updateMainMenu();
00147                 break;
00148 
00149         case MainModes::multiplayMenu :
00150                 updateMultiplayMenu();
00151                 break;
00152 
00153         case MainModes::overhead :
00154                 overhead_update();
00155                 break;
00156 
00157         case MainModes::credit :
00158                 updateCredit();
00159                 break;
00160 
00161         case MainModes::sponsor :
00162                 updateSponsor();
00163                 break;
00164         }       
00165 }

INT WINAPI WinMain HINSTANCE    hInst,
HINSTANCE   ,
LPSTR   ,
INT   
 

The main function that Windows calls to get it all going.

Definition at line 195 of file Main.cpp.

References sys_go(), sys_init(), sys_setInitFunc(), sys_setRenderFunc(), sys_setShutdownFunc(), and sys_setUpdateFunc().

00196 {
00197 #if defined _FULLSCREEN
00198         sys_init(hInst,1024,768,32,true);
00199 #else
00200         sys_init(hInst,1024,768,32,false);
00201 #endif
00202         sys_setInitFunc(main_init);
00203         sys_setShutdownFunc(main_shutdown);
00204         sys_setUpdateFunc(main_update);
00205         sys_setRenderFunc(main_render);
00206         sys_go();
00207         return 0;
00208 }


Variable Documentation

int mode
 

Definition at line 47 of file Main.cpp.


Generated on Wed Apr 23 05:51:23 2003 for Modern Warfare by doxygen1.3-rc2