00001 /* 00002 CS Senior Project 2003 00003 Team : Leftfield 00004 Project : ModernWarfare 00005 Members : 00006 - Russ Christensen <rchriste@cs.utah.edu> 00007 - Todd Smith <tcsmith@cs.utah.edu> 00008 - Usit Duongsaa <duongsaa@cs.utah.edu> 00009 Copyright 2003 Russ Christensen, Usit Duongsaa, and Todd Smith. All rights reserved. 00010 00011 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 00012 00013 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 00014 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 00015 THIS SOFTWARE IS PROVIDED BY RUSS CHRISTENSEN, USIT DUONGSAA, AND TODD SMITH ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RUSS, USIT, TODD OR OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00016 */ 00017 00018 00023 #include "WinMainSelector.h" 00024 #if defined COMPILE_MAIN 00025 00026 #include "Network.h" 00027 #include "GameConfig.h" 00028 #include "EconData.h" 00029 #include "BattleUnitData.h" 00030 #include "Sound.h" 00031 #include "Typer.h" 00032 #include "..\AEngine\AEngine.h" 00033 #include "Overhead.h" 00034 #include "MainFuncs.h" 00035 #include <time.h> 00036 00037 using namespace Overhead; 00038 00039 #if 1 /*If you want the game to be full screen, false for windowed*/ 00040 #define _FULLSCREEN 00041 #endif 00042 00043 //------------------------------------------------------------------------------------ 00044 //------------------------------------------------------------------------------------ 00045 // all the buttons, edit box, etc 00046 00047 int mode; // must be one of MainModes:: values 00048 00049 //------------------------------------------------------------------------------------ 00050 //------------------------------------------------------------------------------------ 00051 void main_init() 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 } 00086 //------------------------------------------------------------------------------------ 00087 void main_shutdown() 00088 { 00089 overhead_shutdown(); 00090 } 00091 //------------------------------------------------------------------------------------ 00092 void main_update() 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 } 00166 //------------------------------------------------------------------------------------ 00167 void main_render() 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 } 00192 //------------------------------------------------------------------------------------ 00193 //------------------------------------------------------------------------------------ 00195 INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE /*hPrevInst*/, LPSTR, INT ) 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 } 00209 //------------------------------------------------------------------------------------ 00210 00211 //------------------------------------------------------------------------------------ 00212 00213 #endif
1.3-rc2