From: Côme BERNIGAUD Date: Thu, 3 Jun 2010 17:56:13 +0000 (+0200) Subject: merge & removing debug printf. (in Settings.cpp, by myself, useless) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=326621743b8eea53a3a040f657ad77e9f19fc7da;hp=-c;p=lugaru.git merge & removing debug printf. (in Settings.cpp, by myself, useless) --- 326621743b8eea53a3a040f657ad77e9f19fc7da diff --combined Source/GameTick.cpp index e5e619a,8138608..dca83bc --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@@ -31,16 -31,22 +31,23 @@@ Foundation, Inc., 59 Temple Place - Sui #include "Game.h" #include "openal_wrapper.h" #include "Settings.h" +#include "Input.h" using namespace std; + // Added more evilness needed for MSVC + #ifdef _MSC_VER + #define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n) + #define snprintf(buf, size, format, ...) _sprintf_p(buf, size, format) + #endif + + extern float multiplier; extern XYZ viewer; extern int environment; extern float texscale; extern Terrain terrain; -extern OPENAL_SAMPLE *samp[100]; +extern OPENAL_SAMPLE *samp[100]; extern int channels[100]; extern Sprites sprites; extern int kTextureSize; @@@ -83,6 -89,7 +90,6 @@@ extern int netdatanew extern bool loadingstuff; extern char mapname[256]; extern XYZ windvector; -extern bool buttons[3]; extern bool debugmode; static int music1; extern int mainmenu; @@@ -142,6 -149,7 +149,6 @@@ extern float damagetaken extern int maptype; extern int editoractive; extern int editorpathtype; -extern bool oldbuttons[3]; extern float hostiletime; @@@ -160,6 -168,16 +167,6 @@@ extern int currenthotspot extern int kBitsPerPixel; extern int hostile; -extern int numaccounts; -extern int accountactive; -extern int accountdifficulty[10]; -extern int accountprogress[10]; -extern float accountpoints[10]; -extern float accounthighscore[10][50]; -extern float accountfasttime[10][50]; -extern bool accountunlocked[10][60]; -extern char accountname[10][256]; - extern bool stillloading; extern bool winfreeze; @@@ -1177,6 -1195,8 +1184,6 @@@ static void cmd_dispatch(Game *game, co } } - - /********************> Tick() <*****/ extern void ScreenShot(const char * fname); void Screenshot (void) @@@ -1192,7 -1212,192 +1199,7 @@@ mkdir("Screenshots", S_IRWXU); #endif - ScreenShot(temp/*"Screenshots\\Screenshot.png"*/); - - /*FSSpec MAC_file; - GraphicsExportComponent QT_exporter; - OSErr MAC_error_code; - CGrafPtr MAC_currentPort; - GDHandle MAC_currentDevice; - unsigned char* MAC_pixels; - Rect MAC_picture_rectangle; - GWorldPtr MAC_offscreen_graphics_port; - - static int numscreenshots=0; - - // Make an FSSpec - static char buf[256]; - if(numscreenshots==0){ - buf[0]=26; - buf[1]=':'; - buf[2]='S'; - buf[3]='c'; - buf[4]='r'; - buf[5]='e'; - buf[6]='e'; - buf[7]='n'; - buf[8]='s'; - buf[9]='h'; - buf[10]='o'; - buf[11]='t'; - buf[12]='s'; - buf[13]=':'; - buf[14]='S'; - buf[15]='c'; - buf[16]='r'; - buf[17]='e'; - buf[18]='e'; - buf[19]='n'; - buf[20]='s'; - buf[21]='h'; - buf[22]='o'; - buf[23]='t'; - buf[24]='0'; - buf[25]='0'; - buf[26]='0'; - } - - FInfo *fndrInfo; - FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file); - while(!FSpGetFInfo (&MAC_file, fndrInfo)){ - FSMakeFSSpec(0, 0, (unsigned char*)buf, &MAC_file); - if(!FSpGetFInfo (&MAC_file, fndrInfo)){ - numscreenshots++; - buf[26]++; - if(buf[26]==':'){ - buf[26]='0'; - buf[25]++; - if(buf[25]==':'){ - buf[25]='0'; - buf[24]++; - if(buf[24]==':'){ - buf[24]='9'; - buf[25]='9'; - buf[26]='9'; - } - } - } - } - } - - - // Get the GWorld - GWorldPtr MAC_gWorld = (CGrafPtr) FrontWindow(); - //assert(MAC_gWorld != NULL); - - // Allocate memory for loading image - MAC_pixels = new unsigned char[(int)(screenheight * screenwidth * 4)]; - if (MAC_pixels == NULL) { - //UTIL_Error("Could not create Texture data."); - return; - } - - // Get GWorld - ::GetGWorld(&MAC_currentPort, &MAC_currentDevice); - - // Make a picture Rectangle - MAC_picture_rectangle.left = 0; - MAC_picture_rectangle.right = screenwidth; - MAC_picture_rectangle.top = 0; - MAC_picture_rectangle.bottom = screenheight; - - // Create new offscreen GWorld - MAC_error_code = ::QTNewGWorldFromPtr (&MAC_offscreen_graphics_port, k32ARGBPixelFormat, &MAC_picture_rectangle, NULL, NULL, 0, (char *) MAC_pixels, screenwidth * 4); - if (MAC_error_code) { - ::SetGWorld(MAC_currentPort, MAC_currentDevice); - delete MAC_pixels; - //UTIL_Error("Could not create offscreen GWorld. "); - return; - - } - - // Copy OpenGL Context to new GWorld - glReadBuffer(GL_FRONT); - glReadPixels(0,0,screenwidth,screenheight,GL_RGBA,GL_UNSIGNED_BYTE,MAC_pixels); - - // Swizzle texture - for (unsigned long byte = 0; byte < screenheight * screenwidth * 4; byte+=4) { - unsigned char temp = MAC_pixels[byte+0]; - MAC_pixels[byte+0] = MAC_pixels[byte+3]; - MAC_pixels[byte+3] = MAC_pixels[byte+2]; - MAC_pixels[byte+2] = MAC_pixels[byte+1]; - MAC_pixels[byte+1] = temp; - } - - // Flip the image :( This could probably be optimized - int vert; - int src_index; - int dst_index; - unsigned char temp; - for (int horz = 0; horz < screenwidth; ++horz) - for (vert = 0; vert < screenheight / 2; ++vert) { - src_index = (screenwidth * vert + horz) * 4; - dst_index = (screenwidth * (screenheight - vert - 1) + horz) * 4; - - temp=MAC_pixels[src_index+0]; - MAC_pixels[src_index+0]=MAC_pixels[dst_index+0]; - MAC_pixels[dst_index+0]=temp; - - temp=MAC_pixels[src_index+1]; - MAC_pixels[src_index+1]=MAC_pixels[dst_index+1]; - MAC_pixels[dst_index+1]=temp; - - temp=MAC_pixels[src_index+2]; - MAC_pixels[src_index+2]=MAC_pixels[dst_index+2]; - MAC_pixels[dst_index+2]=temp; - - temp=MAC_pixels[src_index+3]; - MAC_pixels[src_index+3]=MAC_pixels[dst_index+3]; - MAC_pixels[dst_index+3]=temp; - } - - - - // Export the Gworld - MAC_error_code = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypeBMP, &QT_exporter); - if (MAC_error_code) { - //UTIL_Warning("Unable to export screenshot."); - ::SetGWorld(MAC_currentPort, MAC_currentDevice); - ::DisposeGWorld(MAC_offscreen_graphics_port); - delete MAC_pixels; - return; - } - - MAC_error_code = GraphicsExportSetInputGWorld(QT_exporter,MAC_offscreen_graphics_port); - if (MAC_error_code) { - ::CloseComponent(QT_exporter); - ::SetGWorld(MAC_currentPort, MAC_currentDevice); - ::DisposeGWorld(MAC_offscreen_graphics_port); - delete MAC_pixels; - //UTIL_Warning("Unable to export screenshot."); - return; - } - - MAC_error_code = GraphicsExportSetOutputFile(QT_exporter,&MAC_file); - if (MAC_error_code) { - ::CloseComponent(QT_exporter); - ::SetGWorld(MAC_currentPort, MAC_currentDevice); - ::DisposeGWorld(MAC_offscreen_graphics_port); - delete MAC_pixels; - //UTIL_Warning("Unable to export screenshot."); - return; - } - - MAC_error_code = GraphicsExportDoExport(QT_exporter,NULL); - if (MAC_error_code) { - ::CloseComponent(QT_exporter); - ::SetGWorld(MAC_currentPort, MAC_currentDevice); - ::DisposeGWorld(MAC_offscreen_graphics_port); - delete MAC_pixels; - //UTIL_Warning("Unable to export screenshot."); - return; - } - - ::CloseComponent(QT_exporter); - ::SetGWorld(MAC_currentPort, MAC_currentDevice); - ::DisposeGWorld(MAC_offscreen_graphics_port); - - delete MAC_pixels;*/ + ScreenShot(temp); } @@@ -1683,7 -1888,7 +1690,7 @@@ void Game::Loadlevel(char *name) damagedealt=0; damagetaken=0; - if(accountactive!=-1)difficulty=accountdifficulty[accountactive]; + if(accountactive)difficulty=accountactive->getDifficulty(); if(difficulty!=2)minimap=1; else minimap=0; @@@ -2327,7 -2532,12 +2334,7 @@@ weapons.position[i]=-1000; weapons.tippoint[i]=-1000; } - -/* for(i=0;i<32;i++){ - //if(i<16||i>20) - OPENAL_StopSound(i); - } -*/ + LOG("Starting background music..."); OPENAL_StopSound(OPENAL_ALL); @@@ -2367,6 -2577,17 +2374,6 @@@ oldmusicvolume[2]=0; oldmusicvolume[3]=0; - - /*LoadTexture(":Data:Textures:cloud.png",&sprites.cloudtexture,1,1); - LoadTexture(":Data:Textures:cloudimpact.png",&sprites.cloudimpacttexture,1,1); - LoadTexture(":Data:Textures:bloodparticle.png",&sprites.bloodtexture,1,1); - LoadTexture(":Data:Textures:snowflake.png",&sprites.snowflaketexture,1,1); - LoadTexture(":Data:Textures:flame.png",&sprites.flametexture,1,1); - LoadTexture(":Data:Textures:bloodflame.png",&sprites.bloodflametexture,1,1); - LoadTexture(":Data:Textures:smoke.png",&sprites.smoketexture,1,1); - LoadTexture(":Data:Textures:shine.png",&sprites.shinetexture,1,0); - */ - if(!firstload) { firstload=1; @@@ -2400,10 -2621,16 +2407,10 @@@ void Game::Tick( displaytime[i]+=multiplier; } - static unsigned char theKeyMap[16]; - GetKeys( theKeyMap ); - keyboardfrozen=0; - - static bool mainmenutogglekeydown; - - if (IsKeyDown(theKeyMap, MAC_F6_KEY) && !freezetogglekeydown) { - if (IsKeyDown(theKeyMap, MAC_SHIFT_KEY)) { + if (Input::isKeyDown(SDLK_F6) && !freezetogglekeydown) { + if (Input::isKeyDown(SDLK_LSHIFT)) { stereoreverse=true; } else { stereoreverse=false; @@@ -2417,8 -2644,8 +2424,8 @@@ freezetogglekeydown=1; } - if (IsKeyDown(theKeyMap, MAC_F7_KEY)) { - if (IsKeyDown(theKeyMap, MAC_SHIFT_KEY)) { + if (Input::isKeyDown(SDLK_F7)) { + if (Input::isKeyDown(SDLK_LSHIFT)) { stereoseparation -= 0.001; } else { stereoseparation -= 0.010; @@@ -2427,8 -2654,8 +2434,8 @@@ printf("Stereo decreased increased to %f\n", stereoseparation); } - if (IsKeyDown(theKeyMap, MAC_F8_KEY)) { - if (IsKeyDown(theKeyMap, MAC_SHIFT_KEY)) { + if (Input::isKeyDown(SDLK_F8)) { + if (Input::isKeyDown(SDLK_LSHIFT)) { stereoseparation += 0.001; } else { stereoseparation += 0.010; @@@ -2440,16 -2667,109 +2447,16 @@@ if(!console){ if(mainmenu&&endgame==1)mainmenu=10; - if(IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)&&!mainmenutogglekeydown&&(mainmenu==7&&entername)){ - for(j=0;j<255;j++){ - displaytext[0][j]=' '; - } - displaychars[0]=0; - displayselected=0; - entername=0; - mainmenutogglekeydown=1; - } - if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)||(mainmenu==0&&((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY)||(campaign)))&&!oldjumpkeydown&&campaign&&winfreeze))&&!mainmenutogglekeydown&&(!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==10)){ + if( (Input::isKeyDown(SDLK_ESCAPE)||(mainmenu==0&&((Input::isKeyDown(jumpkey)||Input::isKeyDown(SDLK_SPACE)||(campaign)))&&!oldjumpkeydown&&campaign&&winfreeze)) + && !mainmenutogglekeydown + && (!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==10) + ) { // go back selected=-1; if(mainmenu==1||mainmenu==2||mainmenu==0){ if(mainmenu==0&&!winfreeze)mainmenu=2; else if(mainmenu==0&&winfreeze&&(campaignchoosenext[campaignchoicewhich[whichchoice]])==1)mainmenu=100; else if(mainmenu==0&&winfreeze){ - /* if(campaignchoosenext[campaignchoicewhich[whichchoice]]==2) - stealthloading=1; - else stealthloading=0; - - if(!stealthloading){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; - } - - startbonustotal=0; - - for(i=0;i2)newdetail=detail; if(newdetail<0)newdetail=detail; @@@ -2479,9 -2810,20 +2486,9 @@@ SaveSettings(*this); } if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==13||mainmenu==10||mainmenu==11||mainmenu==100){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(); + + flash(); } if(mainmenu==3&&gameon)mainmenu=2; if(mainmenu==3&&!gameon)mainmenu=1; @@@ -2501,23 -2843,23 +2508,23 @@@ } mainmenutogglekeydown=1; } - if(!IsKeyDown(theKeyMap, MAC_ESCAPE_KEY)){ + if(!Input::isKeyDown(SDLK_ESCAPE)){ mainmenutogglekeydown=0; } } /*static bool minimaptogglekeydown; - if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown){ + if(Input::isKeyDown(SDLK_TAB)&&!minimaptogglekeydown){ minimap=1-minimap; minimaptogglekeydown=1; } - if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){ + if(!Input::isKeyDown(SDLK_TAB)){ minimaptogglekeydown=0; } */ static bool minimaptogglekeydown; - if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!minimaptogglekeydown&&tutoriallevel){ + if(Input::isKeyDown(SDLK_TAB)&&!minimaptogglekeydown&&tutoriallevel){ if(tutorialstage!=51) tutorialstagetime=tutorialmaxtime; PlaySoundEx( consolefailsound, samp[consolefailsound], NULL, true); @@@ -2525,7 -2867,7 +2532,7 @@@ OPENAL_SetPaused(channels[consolefailsound], false); minimaptogglekeydown=1; } - if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)){ + if(!Input::isKeyDown(SDLK_TAB)){ minimaptogglekeydown=0; } @@@ -2534,17 -2876,37 +2541,17 @@@ if(mainmenu==1||mainmenu==2){ if(Button()&&!oldbutton&&selected==1){ if(!gameon){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(firestartsound); + + flash(); //new game - if(accountactive!=-1)mainmenu=5; - else mainmenu=7; - /* - startbonustotal=0; - - loading=2; - loadtime=0; - if(firstload)TickOnceAfter(); - if(!firstload)LoadStuff(); - else { - Loadlevel(0); + if(accountactive) { + mainmenu=5; + } else { + mainmenu=7; } - mainmenu=0; - gameon=1; - OPENAL_SetPaused(channels[music3], true); */ + selected=-1; } else { @@@ -2556,9 -2918,20 +2563,9 @@@ } if(Button()&&!oldbutton&&selected==2){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(); + + flash(); //options @@@ -2573,9 -2946,20 +2580,9 @@@ } if(Button()&&!oldbutton&&selected==3){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(); + + flash(); if(!gameon){ //quit @@@ -2588,10 -2972,20 +2595,10 @@@ mainmenu=1; } } - if(Button())oldbutton=1; - else oldbutton=0; } - if(mainmenu==3){ if(Button()&&!oldbutton&&selected!=-1){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); + fireSound(); } if(Button()&&!oldbutton&&selected==0){ @@@ -2692,30 -3086,55 +2699,30 @@@ OPENAL_SetSFXMasterVolume((int)(volume*255)); } if(Button()&&!oldbutton&&selected==7){ - /*float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); + /*fireSound(); */ - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + flash(); //options mainmenu=4; + selected=-1; keyselect=-1; } if(Button() && !oldbutton && selected == 12) { - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + flash(); newstereomode = stereomode; mainmenu=18; - keyselect = -1; + keyselect=-1; } if(Button() && !oldbutton && selected == 13) { showdamagebar=!showdamagebar; } if(Button()&&!oldbutton&&selected==8){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(); + + flash(); if(newdetail>2)newdetail=detail; if(newdetail<0)newdetail=detail; @@@ -2727,40 -3146,112 +2734,40 @@@ if(mainmenu==3&&gameon)mainmenu=2; if(mainmenu==3&&!gameon)mainmenu=1; } - if(Button())oldbutton=1; - else oldbutton=0; } if(mainmenu==4){ - if(Button()&&!oldbutton&&selected!=-1&&keyselect==-1){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - } - if(Button()&&!oldbutton&&selected<9&&keyselect==-1){ - keyselect=selected; - oldbuttons[0]=1; - oldbuttons[1]=1; - oldbuttons[2]=1; - } - if(keyselect!=-1){ - for(i=0;i<3;i++) - if(!buttons[i]&&!oldbutton&&!Button())oldbuttons[i]=0; - for(i=0;i<140;i++){ - if((IsKeyDown(theKeyMap, i)||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))&&keyselect!=-1){ - if(i!=MAC_ESCAPE_KEY&&(strcmp(KeyToChar(i),"unknown")||(buttons[0]&&!oldbuttons[0]&&!oldbutton)||(buttons[1]&&!oldbuttons[1]&&!oldbutton))){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - - int keynum; - keynum=i; - if(buttons[0]&&!oldbuttons[0])keynum=MAC_MOUSEBUTTON1; - if(buttons[1]&&!oldbuttons[1])keynum=MAC_MOUSEBUTTON2; - - - - if(keyselect==0)forwardkey=keynum; - if(keyselect==1)backkey=keynum; - if(keyselect==2)leftkey=keynum; - if(keyselect==3)rightkey=keynum; - if(keyselect==4)crouchkey=keynum; - if(keyselect==5)jumpkey=keynum; - if(keyselect==6)drawkey=keynum; - if(keyselect==7)throwkey=keynum; - if(keyselect==8)attackkey=keynum; - keyselect=-1; - } - } - }} - if(Button()&&!oldbutton&&selected==9){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; - - mainmenu=3; - - if(newdetail>2)newdetail=detail; - if(newdetail<0)newdetail=detail; - if(newscreenwidth>3000)newscreenwidth=screenwidth; - if(newscreenwidth<0)newscreenwidth=screenwidth; - if(newscreenheight>3000)newscreenheight=screenheight; - if(newscreenheight<0)newscreenheight=screenheight; + if(Button()&&!oldbutton&&selected!=-1&&!waiting){ + fireSound(); + if(selected<9&&keyselect==-1) + keyselect=selected; + if(keyselect!=-1) + setKeySelected(); + if(selected==9){ + flash(); + + mainmenu=3; + + if(newdetail>2)newdetail=detail; + if(newdetail<0)newdetail=detail; + if(newscreenwidth>3000)newscreenwidth=screenwidth; + if(newscreenwidth<0)newscreenwidth=screenwidth; + if(newscreenheight>3000)newscreenheight=screenheight; + if(newscreenheight<0)newscreenheight=screenheight; + } } } if(mainmenu==5){ if(endgame==2){ - accountcampaignchoicesmade[accountactive]=0; - accountcampaignscore[accountactive]=0; - accountcampaigntime[accountactive]=0; + accountactive->endGame(); endgame=0; } if(Button()&&!oldbutton&&selected==1){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(); + + flash(); startbonustotal=0; @@@ -2777,18 -3268,30 +2784,18 @@@ gameon=1; OPENAL_SetPaused(channels[stream_music3], true); } - if(Button()&&!oldbutton&&selected-7>=accountcampaignchoicesmade[accountactive]){//selected>=7&&(selected-7<=campaignnumchoices)){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + if(Button()&&!oldbutton&&(selected-7>=accountactive->getCampaignChoicesMade())){//selected>=7&&(selected-7<=campaignnumchoices)){ + fireSound(); + + flash(); startbonustotal=0; loading=2; loadtime=0; targetlevel=7; - if(firstload)TickOnceAfter(); - if(!firstload)LoadStuff(); - //else { + if(firstload) TickOnceAfter(); + else LoadStuff(); for(i=0;i<255;i++){ mapname[i]='\0'; } @@@ -2803,52 -3306,110 +2810,52 @@@ mapname[8]='p'; mapname[9]='s'; mapname[10]=':'; - strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountcampaignchoicesmade[accountactive]]]); - whichchoice=selected-7-accountcampaignchoicesmade[accountactive]; + strcat(mapname,campaignmapname[campaignchoicewhich[selected-7-accountactive->getCampaignChoicesMade()]]); + whichchoice=selected-7-accountactive->getCampaignChoicesMade(); visibleloading=1; stillloading=1; Loadlevel(mapname); //Loadlevel(campaignmapname[levelorder[selected-7]]); - //} campaign=1; mainmenu=0; gameon=1; OPENAL_SetPaused(channels[stream_music3], true); } if(Button()&&!oldbutton&&selected==4){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(); + + flash(); if(mainmenu==5&&gameon)mainmenu=2; if(mainmenu==5&&!gameon)mainmenu=1; } if(Button()&&!oldbutton&&selected==5){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(); + + flash(); mainmenu=7; } if(Button()&&!oldbutton&&selected==3){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(); + + flash(); mainmenu=6; } if(Button()&&!oldbutton&&selected==2){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(); + + flash(); mainmenu=9; } - if(Button())oldbutton=1; - else oldbutton=0; } if(mainmenu==9){ - if(Button()&&!oldbutton&&selected=0&&selected<=accountprogress[accountactive]){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + if(Button()&&!oldbutton&&selected=0&&selected<=accountactive->getProgress()){ + fireSound(); + + flash(); startbonustotal=0; @@@ -2867,29 -3428,53 +2874,29 @@@ OPENAL_SetPaused(channels[stream_music3], true); } if(Button()&&!oldbutton&&selected==numchallengelevels){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(); + + flash(); mainmenu=5; } - if(Button())oldbutton=1; - else oldbutton=0; } if(mainmenu==11){ - if(Button()&&!oldbutton&&selected=0&&selected<=accountprogress[accountactive]){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + if(Button()&&!oldbutton&&selected=0&&selected<=accountactive->getProgress()){ + fireSound(); + + flash(); startbonustotal=0; loading=2; loadtime=0; targetlevel=selected; - if(firstload)TickOnceAfter(); - if(!firstload)LoadStuff(); - else { + if(firstload) { + TickOnceAfter(); Loadlevel(selected); - } + } else + LoadStuff(); campaign=0; mainmenu=0; @@@ -2897,78 -3482,211 +2904,78 @@@ OPENAL_SetPaused(channels[stream_music3], true); } if(Button()&&!oldbutton&&selected==numchallengelevels){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(); + + flash(); mainmenu=5; } - if(Button())oldbutton=1; - else oldbutton=0; } if(mainmenu==10){ endgame=2; if(Button()&&!oldbutton&&selected==3){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(); + + flash(); mainmenu=5; } - if(Button())oldbutton=1; - else oldbutton=0; } if(mainmenu==6){ - if(Button()&&!oldbutton&&selected!=-1){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - } - if(Button()&&!oldbutton&&selected==1){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; - - for(i=accountactive;i-1){ + fireSound(); + if(selected==1) { + flash(); + accountactive = Account::destroy(accountactive); + mainmenu=7; + } else if(selected==2) { + flash(); + mainmenu=5; } - accountcampaignhighscore[i]=accountcampaignhighscore[i+1]; - accountprogress[i]=accountprogress[i+1]; - accountcampaignfasttime[i]=accountcampaignfasttime[i+1]; - accountcampaignscore[i]=accountcampaignscore[i+1]; - accountcampaigntime[i]=accountcampaigntime[i+1]; } - - numaccounts--; - accountactive=-1; - - - mainmenu=7; - } - if(Button()&&!oldbutton&&selected==2){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; - - mainmenu=5; } - if(Button())oldbutton=1; - else oldbutton=0; } if(mainmenu==7){ - if(Button()&&!oldbutton&&selected!=-1){ - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - } - if(Button()&&!oldbutton&&selected==0&&numaccounts<8){ - entername=1; - } - if(Button()&&!oldbutton&&selected>0&&selected-1){ + fireSound(); + + if(selected<=2) + accountactive->setDifficulty(selected); mainmenu=5; - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + flash(); } - if(Button())oldbutton=1; - else oldbutton=0; } - if (mainmenu==18) { - if(Button()&&!oldbutton) { - printf("Button %i pressed\n", selected); - } - + if (mainmenu==18) { if(Button()&&!oldbutton&&selected==0) { newstereomode = (StereoMode)(newstereomode + 1); while(!CanInitStereo(newstereomode)) { @@@ -2980,10 -3698,10 +2987,10 @@@ } } - if(buttons[0]&&!oldbutton&&selected==1) { + if(Input::isKeyDown(MOUSEBUTTON1)&&!oldbutton&&selected==1) { stereoseparation+=0.001; } - if(buttons[1]&&!oldbutton&&selected==1) { + if(Input::isKeyDown(MOUSEBUTTON2)&&!oldbutton&&selected==1) { stereoseparation-=0.001; } @@@ -2992,20 -3710,27 +2999,20 @@@ } if(Button()&&!oldbutton&&selected==3) { - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + flash(); stereomode = newstereomode; InitStereo(stereomode); mainmenu=3; } - - if(Button() || buttons[1])oldbutton=1; - else oldbutton=0; } - if(Button()||buttons[1])oldbutton=1; + if(Button()||Input::isKeyDown(MOUSEBUTTON2))oldbutton=1; else oldbutton=0; - if(IsKeyDown(theKeyMap, MAC_Q_KEY)&&IsKeyDown(theKeyMap, MAC_COMMAND_KEY)){ + if(Input::isKeyDown(SDLK_q)&&Input::isKeyDown(SDLK_LMETA)){ tryquit=1; if(mainmenu==3){ if(newdetail>2)newdetail=detail; @@@ -3028,9 -3753,130 +3035,9 @@@ } OPENAL_SetFrequency(channels[stream_music3], 22050); - if(entername){ - for(i=0;i<140;i++){ - if(IsKeyDown(theKeyMap, i)){ - togglekeydelay[i]+=multiplier; - if(togglekeydelay[i]>.4){ - togglekey[i]=0; - togglekeydelay[i]=.36; - } - if(!togglekey[i]){ - if(KeyToSingleChar(i)!='\0'&&displaychars[0]<60){ - for(j=255;j>=displayselected+1;j--){ - displaytext[0][j]=displaytext[0][j-1]; - } - displaytext[0][displayselected]=KeyToSingleChar(i); - if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]); - displayselected++; - displaychars[0]++; - } - if(i==MAC_DELETE_KEY&&displayselected!=0){ - for(j=displayselected-1;j<255;j++){ - displaytext[0][j]=displaytext[0][j+1]; - } - displaytext[0][255]=' '; - displayselected--; - displaychars[0]--; - } - if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){ - displayselected--; - } - if(i==MAC_ARROW_RIGHT_KEY&&displayselected.4){ togglekey[i]=0; @@@ -3075,11 -3921,11 +3082,11 @@@ displaytext[0][j]=displaytext[0][j-1]; } displaytext[0][displayselected]=KeyToSingleChar(i); - if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]); + if(Input::isKeyDown(SDLK_LSHIFT))displaytext[0][displayselected]=Shift(displaytext[0][displayselected]); displayselected++; displaychars[0]++; } - if(i==MAC_DELETE_KEY&&displayselected!=0){ + if(i==SDLK_DELETE&&displayselected!=0){ for(j=displayselected-1;j<255;j++){ displaytext[0][j]=displaytext[0][j+1]; } @@@ -3087,13 -3933,13 +3094,13 @@@ displayselected--; displaychars[0]--; } - if(i==MAC_ARROW_LEFT_KEY&&displayselected!=0){ + if(i==SDLK_LEFT&&displayselected!=0){ displayselected--; } - if(i==MAC_ARROW_RIGHT_KEY&&displayselected.4){ togglekey[i]=0; @@@ -3169,11 -4015,11 +3176,11 @@@ consoletext[0][j]=consoletext[0][j-1]; } consoletext[0][consoleselected]=KeyToSingleChar(i); - if(IsKeyDown(theKeyMap, MAC_SHIFT_KEY))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]); + if(Input::isKeyDown(SDLK_LSHIFT))consoletext[0][consoleselected]=Shift(consoletext[0][consoleselected]); consoleselected++; consolechars[0]++; } - else if(i==MAC_ENTER_KEY){ + else if(i==SDLK_RETURN){ for(j=255;j>=consoleselected+1;j--){ consoletext[0][j]=consoletext[0][j-1]; } @@@ -3181,7 -4027,7 +3188,7 @@@ consoleselected++; consolechars[0]++; } - if(i==MAC_DELETE_KEY&&consoleselected!=0){ + if(i==SDLK_DELETE&&consoleselected!=0){ for(j=consoleselected-1;j<255;j++){ consoletext[0][j]=consoletext[0][j+1]; } @@@ -3189,7 -4035,7 +3196,7 @@@ consoleselected--; consolechars[0]--; } - if(i==MAC_ARROW_UP_KEY){ + if(i==SDLK_UP){ if(archiveselected<14)archiveselected++; for(j=0;j<255;j++){ consolechars[0]=consolechars[archiveselected]; @@@ -3197,7 -4043,7 +3204,7 @@@ consoleselected=consolechars[0]; } } - if(i==MAC_ARROW_DOWN_KEY){ + if(i==SDLK_DOWN){ if(archiveselected>0)archiveselected--; for(j=0;j<255;j++){ consolechars[0]=consolechars[archiveselected]; @@@ -3205,13 -4051,13 +3212,13 @@@ consoleselected=consolechars[0]; } } - if(i==MAC_ARROW_LEFT_KEY&&consoleselected!=0){ + if(i==SDLK_LEFT&&consoleselected!=0){ consoleselected--; } - if(i==MAC_ARROW_RIGHT_KEY&&consoleselected2)newdetail=detail; @@@ -3267,20 -4113,20 +3274,20 @@@ if(winfreeze==0)oldwinfreeze=winfreeze; else oldwinfreeze++; - if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))&&!oldjumpkeydown&&!campaign){ + if((Input::isKeyDown(jumpkey)||Input::isKeyDown(SDLK_SPACE))&&!oldjumpkeydown&&!campaign){ if(winfreeze)winfreeze=0; oldjumpkeydown=1; } - if((IsKeyDown(theKeyMap, MAC_ESCAPE_KEY))&&!campaign&&gameon){ + if((Input::isKeyDown(SDLK_ESCAPE))&&!campaign&&gameon){ if(winfreeze){ mainmenu=9; gameon=0; } } - if((IsKeyDown(theKeyMap, jumpkey)||IsKeyDown(theKeyMap, MAC_SPACE_KEY))){ + if((Input::isKeyDown(jumpkey)||Input::isKeyDown(SDLK_SPACE))){ oldjumpkeydown=1; } - if(!IsKeyDown(theKeyMap, jumpkey)&&!IsKeyDown(theKeyMap, MAC_SPACE_KEY))oldjumpkeydown=0; + if(!Input::isKeyDown(jumpkey)&&!Input::isKeyDown(SDLK_SPACE))oldjumpkeydown=0; if(!freeze&&!winfreeze&&!(mainmenu&&gameon)&&(gameon||!gamestarted)){ @@@ -3318,7 -4164,7 +3325,7 @@@ realdialoguetype=dialoguetype[i]; special=0; } - if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype0&&(dialoguegonethrough[i]==0||!special)&&(special||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue))){ + if((!hostile||(dialoguetype[i]>40&&dialoguetype[i]<50))&&realdialoguetype0&&(dialoguegonethrough[i]==0||!special)&&(special||(Input::isKeyDown(attackkey)&&!oldbuttondialogue))){ if(findDistancefast(&player[0].coords,&player[realdialoguetype].coords)<6||player[realdialoguetype].howactive>=typedead1||(dialoguetype[i]>40&&dialoguetype[i]<50)){ whichdialogue=i; for(j=0;j=numdialogueboxes[whichdialogue]){ @@@ -4507,9 -5404,9 +4514,9 @@@ rotation=dialoguecamerarotation[whichdialogue][indialogue]; rotation2=dialoguecamerarotation2[whichdialogue][indialogue]; if(dialoguetime>0.5) - if((!endkeydown&&(IsKeyDown(theKeyMap, MAC_1_KEY)||IsKeyDown(theKeyMap, MAC_2_KEY)||IsKeyDown(theKeyMap, MAC_3_KEY)||IsKeyDown(theKeyMap, MAC_4_KEY)||IsKeyDown(theKeyMap, MAC_5_KEY) - ||IsKeyDown(theKeyMap, MAC_6_KEY)||IsKeyDown(theKeyMap, MAC_7_KEY)||IsKeyDown(theKeyMap, MAC_8_KEY)||IsKeyDown(theKeyMap, MAC_9_KEY)||IsKeyDown(theKeyMap, MAC_0_KEY) - ||IsKeyDown(theKeyMap, MAC_MINUS_KEY)))||(IsKeyDown(theKeyMap, attackkey)&&!oldbuttondialogue)){ + if((!endkeydown&&(Input::isKeyDown(SDLK_1)||Input::isKeyDown(SDLK_2)||Input::isKeyDown(SDLK_3)||Input::isKeyDown(SDLK_4)||Input::isKeyDown(SDLK_5) + ||Input::isKeyDown(SDLK_6)||Input::isKeyDown(SDLK_7)||Input::isKeyDown(SDLK_8)||Input::isKeyDown(SDLK_9)||Input::isKeyDown(SDLK_0) + ||Input::isKeyDown(SDLK_MINUS)))||(Input::isKeyDown(attackkey)&&!oldbuttondialogue)){ indialogue++; endkeydown=1; if(indialogue=numdialogueboxes[whichdialogue]){ @@@ -4599,11 -5496,120 +4606,11 @@@ } } - if(!IsKeyDown(theKeyMap, attackkey))oldbuttondialogue=0; + if(!Input::isKeyDown(attackkey))oldbuttondialogue=0; else oldbuttondialogue=1; static float keyrefreshdelay=0,bigrefreshdelay=0; - //Net updates - - /*keyrefreshdelay-=multiplier; - bigrefreshdelay-=multiplier; - - if(keyrefreshdelay<=0){ - static int concat[4]; - - concat[0]=player[0].forwardkeydown; - concat[0]=concat[0]*2+player[0].forwardstogglekeydown; - concat[0]=concat[0]*2+player[0].rightkeydown; - concat[0]=concat[0]*2+player[0].leftkeydown; - concat[0]=concat[0]*2+player[0].backkeydown; - concat[0]=concat[0]*2+player[0].jumpkeydown; - concat[0]=concat[0]*2+player[0].jumptogglekeydown; - concat[0]=concat[0]*2+player[0].crouchkeydown; - - concat[1]=player[0].crouchtogglekeydown; - concat[1]=concat[1]*2+player[0].drawkeydown; - concat[1]=concat[1]*2+player[0].drawtogglekeydown; - concat[1]=concat[1]*2+player[0].throwkeydown; - concat[1]=concat[1]*2+player[0].throwtogglekeydown; - concat[1]=concat[1]*2+player[0].attackkeydown; - - //concat[2]=(char)((int)(rotation/2)%180); - - //concat[3]=(char)((int)(rotation2/2)%180); - - chatname[0]=concat[0]-128; - chatname[1]=concat[1]-128; - //chatname[2]=concat[2]-128; - //chatname[3]=concat[3]-128; - int temppoint=2; - memcpy(chatname+temppoint,&rotation,sizeof(float)); - temppoint+=sizeof(float); - memcpy(chatname+temppoint,&rotation2,sizeof(float)); - temppoint+=sizeof(float); - - chatname[temppoint]='\0'; - - //if(!ishost)NetworkSendPlayerMessage( chatname, kMessageType_Keys ); - //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_Keys ); - //keyrefreshdelay=.01; - keyrefreshdelay=.03; - } - - if(bigrefreshdelay<=0){ - for(i=0;i<1;i++){ - /*int temppoint=0; - memcpy(chatname+temppoint,&i,sizeof(int)); - temppoint+=sizeof(int); - memcpy(chatname+temppoint,&player[i].coords.x,sizeof(float)); - temppoint+=sizeof(float); - memcpy(chatname+temppoint,&player[i].coords.y,sizeof(float)); - temppoint+=sizeof(float); - memcpy(chatname+temppoint,&player[i].coords.z,sizeof(float)); - temppoint+=sizeof(float); - memcpy(chatname+temppoint,&player[i].damage,sizeof(float)); - temppoint+=sizeof(float); - memcpy(chatname+temppoint,&player[i].target,sizeof(float)); - temppoint+=sizeof(float); - memcpy(chatname+temppoint,&player[i].targetanimation,sizeof(int)); - temppoint+=sizeof(int); - memcpy(chatname+temppoint,&player[i].currentanimation,sizeof(int)); - temppoint+=sizeof(int); - memcpy(chatname+temppoint,&player[i].velocity.x,sizeof(float)); - temppoint+=sizeof(float); - memcpy(chatname+temppoint,&player[i].velocity.y,sizeof(float)); - temppoint+=sizeof(float); - memcpy(chatname+temppoint,&player[i].velocity.z,sizeof(float)); - temppoint+=sizeof(float); - memcpy(chatname+temppoint,&player[i].targetframe,sizeof(int)); - temppoint+=sizeof(int); - memcpy(chatname+temppoint,&player[i].currentframe,sizeof(int)); - temppoint+=sizeof(int); - memcpy(chatname+temppoint,&player[i].rotation,sizeof(float)); - temppoint+=sizeof(float); - memcpy(chatname+temppoint,&player[i].targetrotation,sizeof(float)); - temppoint+=sizeof(float); - memcpy(chatname+temppoint,&player[i].bloodloss,sizeof(float)); - temppoint+=sizeof(float); - memcpy(chatname+temppoint,&player[i].weaponactive,sizeof(int)); - temppoint+=sizeof(int); - memcpy(chatname+temppoint,&player[i].num_weapons,sizeof(int)); - temppoint+=sizeof(int); - memcpy(chatname+temppoint,&player[i].weaponids[0],sizeof(int)); - temppoint+=sizeof(int); - memcpy(chatname+temppoint,&player[i].weaponids[1],sizeof(int)); - temppoint+=sizeof(int); - memcpy(chatname+temppoint,&player[i].weaponids[2],sizeof(int)); - temppoint+=sizeof(int); - memcpy(chatname+temppoint,&player[i].weaponids[3],sizeof(int)); - temppoint+=sizeof(int); - chatname[temppoint]='\0'; - - sprintf (chatname, "%d %f %f %f %f %f %d %d %f %f %f %d %d %f %f %f",i,player[i].coords.x,player[i].coords.y,player[i].coords.z,player[i].damage,player[i].target, player[i].targetanimation, player[i].currentanimation, player[i].velocity.x, player[i].velocity.y, player[i].velocity.z, player[i].targetframe, player[i].currentframe, player[i].rotation, player[i].targetrotation); - //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerState ); - //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerState ); - - sprintf (chatname, "%d %f %d %d %d %d %d %d %d %d %f",i,player[i].bloodloss, player[i].weaponactive, player[i].num_weapons, player[i].weaponids[0], player[i].weaponids[1], player[i].weaponids[2], player[i].weaponids[3],player[i].dead,player[i].skeleton.free,player[i].permanentdamage); - - //if(ishost)NetworkSendPlayerRelayMessage( chatname, kMessageType_PlayerStateMisc ); - //else NetworkSendPlayerMessage( chatname, kMessageType_PlayerStateMisc ); - } - //bigrefreshdelay=.02; - bigrefreshdelay=.1; - } - }*/ - if(!player[0].jumpkeydown){ player[0].jumptogglekeydown=0; } @@@ -4638,15 -5644,20 +4645,15 @@@ static float temptexdetail; - if(IsKeyDown(theKeyMap, MAC_H_KEY)&&debugmode){ + if(Input::isKeyDown(SDLK_h)&&debugmode){ player[0].damagetolerance=200000; player[0].damage=0; player[0].burnt=0; player[0].permanentdamage=0; player[0].superpermanentdamage=0; - /* - int whichchar; - whichchar = abs(Random()%7); - registrationname[whichchar]+=1; - */ } - if(IsKeyDown(theKeyMap, MAC_J_KEY)&&!envtogglekeydown&&debugmode){ + if(Input::isKeyDown(SDLK_j)&&!envtogglekeydown&&debugmode){ environment++; if(environment>2)environment=0; Setenvironment(environment); @@@ -4655,20 -5666,20 +4662,20 @@@ } - if(!IsKeyDown(theKeyMap, MAC_J_KEY)){ + if(!Input::isKeyDown(SDLK_j)){ envtogglekeydown=0; } - if(IsKeyDown(theKeyMap, MAC_C_KEY)&&!cameratogglekeydown&&debugmode){ + if(Input::isKeyDown(SDLK_c)&&!cameratogglekeydown&&debugmode){ cameramode=1-cameramode; cameratogglekeydown=1; } - if(!IsKeyDown(theKeyMap, MAC_C_KEY)){ + if(!Input::isKeyDown(SDLK_c)){ cameratogglekeydown=0; } - if(IsKeyDown(theKeyMap, MAC_X_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!detailtogglekeydown&&debugmode){ + if(Input::isKeyDown(SDLK_x)&&!Input::isKeyDown(SDLK_LSHIFT)&&!detailtogglekeydown&&debugmode){ if(player[0].num_weapons>0){ if(weapons.type[player[0].weaponids[0]]==sword)weapons.type[player[0].weaponids[0]]=staff; else if(weapons.type[player[0].weaponids[0]]==staff)weapons.type[player[0].weaponids[0]]=knife; @@@ -4690,10 -5701,20 +4697,10 @@@ weapons.length[player[0].weaponids[0]]=.25; } } - - /*for(i=0;i1&&numplayers2)drawmode=0; if(objects.numobjects=numpathpoints)pathpointselected=-1; drawmodetogglekeydown=1; } - if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){ + if(Input::isKeyDown(SDLK_COMMA)&&!Input::isKeyDown(SDLK_LSHIFT)&&!drawmodetogglekeydown&&editorenabled){ pathpointselected--; - if(pathpointselected<=-2)pathpointselected=numpathpoints-1; + if(pathpointselected<=-2) + pathpointselected=numpathpoints-1; drawmodetogglekeydown=1; } - if(IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!drawmodetogglekeydown&&editorenabled){ + if(Input::isKeyDown(SDLK_COMMA)&&Input::isKeyDown(SDLK_LSHIFT)&&!drawmodetogglekeydown&&editorenabled){ if(pathpointselected!=-1){ numpathpoints--; pathpoint[pathpointselected]=pathpoint[numpathpoints]; @@@ -5400,74 -6480,96 +5407,74 @@@ drawmodetogglekeydown=1; } - if(IsKeyDown(theKeyMap, MAC_M_KEY)&&!drawmodetogglekeydown&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&debugmode){ + if(Input::isKeyDown(SDLK_m)&&!drawmodetogglekeydown&&Input::isKeyDown(SDLK_LSHIFT)&&debugmode){ editorenabled=1-editorenabled; if(editorenabled){ player[0].damagetolerance=100000; - player[0].damage=0; - player[0].superpermanentdamage=0; - player[0].bloodloss=0; - player[0].deathbleeding=0; - } - if(!editorenabled){ + } else { player[0].damagetolerance=200; - player[0].damage=0; - player[0].permanentdamage=0; - player[0].superpermanentdamage=0; - player[0].bloodloss=0; - player[0].deathbleeding=0; } + player[0].damage=0; // these lines were in both if and else, but I think they would better fit in the if + player[0].permanentdamage=0; + player[0].superpermanentdamage=0; + player[0].bloodloss=0; + player[0].deathbleeding=0; drawmodetogglekeydown=1; } - if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ + if(Input::isKeyDown(SDLK_LEFT)&&!drawmodetogglekeydown&&editorenabled&&Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){ editortype--; if(editortype==treeleavestype||editortype==10)editortype--; if(editortype<0)editortype=firetype; drawmodetogglekeydown=1; } - if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ + if(Input::isKeyDown(SDLK_RIGHT)&&!drawmodetogglekeydown&&editorenabled&&Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){ editortype++; if(editortype==treeleavestype||editortype==10)editortype++; if(editortype>firetype)editortype=0; drawmodetogglekeydown=1; } - if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ + if(Input::isKeyDown(SDLK_LEFT)&&editorenabled&&!Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){ editorrotation-=multiplier*100; if(editorrotation<-.01)editorrotation=-.01; drawmodetogglekeydown=1; } - if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ + if(Input::isKeyDown(SDLK_RIGHT)&&editorenabled&&!Input::isKeyDown(SDLK_LSHIFT)&&!Input::isKeyDown(SDLK_LCTRL)){ editorrotation+=multiplier*100; drawmodetogglekeydown=1; } - if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ + if(Input::isKeyDown(SDLK_UP)&&editorenabled&&!Input::isKeyDown(SDLK_LCTRL)){ editorsize+=multiplier; drawmodetogglekeydown=1; } - if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ + if(Input::isKeyDown(SDLK_DOWN)&&editorenabled&&!Input::isKeyDown(SDLK_LCTRL)){ editorsize-=multiplier; if(editorsize<.1)editorsize=.1; drawmodetogglekeydown=1; } - if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ + if(Input::isKeyDown(SDLK_LEFT)&&!drawmodetogglekeydown&&editorenabled&&Input::isKeyDown(SDLK_LSHIFT)&&Input::isKeyDown(SDLK_LCTRL)){ mapradius-=multiplier*10; } - if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!drawmodetogglekeydown&&editorenabled&&IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ + if(Input::isKeyDown(SDLK_RIGHT)&&!drawmodetogglekeydown&&editorenabled&&Input::isKeyDown(SDLK_LSHIFT)&&Input::isKeyDown(SDLK_LCTRL)){ mapradius+=multiplier*10; } - /* - if(IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ - mapcenter.x+=multiplier*20; - } - - if(IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&editorenabled&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ - mapcenter.x-=multiplier*20; - } - - if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ - mapcenter.z+=multiplier*20; - } - - if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ - mapcenter.z-=multiplier*20; - } - */ - if(IsKeyDown(theKeyMap, MAC_ARROW_UP_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ + if(Input::isKeyDown(SDLK_UP)&&editorenabled&&Input::isKeyDown(SDLK_LCTRL)){ editorrotation2+=multiplier*100; } - if(IsKeyDown(theKeyMap, MAC_ARROW_DOWN_KEY)&&editorenabled&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)){ + if(Input::isKeyDown(SDLK_DOWN)&&editorenabled&&Input::isKeyDown(SDLK_LCTRL)){ editorrotation2-=multiplier*100; if(editorrotation2<-.01)editorrotation2=-.01; } - if(IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!IsKeyDown(theKeyMap, MAC_SHIFT_KEY)){ + if(Input::isKeyDown(SDLK_DELETE)&&editorenabled&&objects.numobjects&&!drawmodetogglekeydown&&!Input::isKeyDown(SDLK_LSHIFT)){ int closest=-1; float closestdist=-1; float distance; @@@ -5483,11 -6585,11 +5490,11 @@@ } - if(!IsKeyDown(theKeyMap, MAC_M_KEY)&&!IsKeyDown(theKeyMap, MAC_ARROW_LEFT_KEY)&&!IsKeyDown(theKeyMap, MAC_COMMA_KEY)&&!IsKeyDown(theKeyMap, MAC_PERIOD_KEY)&&!IsKeyDown(theKeyMap, MAC_ARROW_RIGHT_KEY)&&!IsKeyDown(theKeyMap, MAC_DELETE_KEY)&&!IsKeyDown(theKeyMap, MAC_P_KEY)){ + if(!Input::isKeyDown(SDLK_m)&&!Input::isKeyDown(SDLK_LEFT)&&!Input::isKeyDown(SDLK_COMMA)&&!Input::isKeyDown(SDLK_PERIOD)&&!Input::isKeyDown(SDLK_RIGHT)&&!Input::isKeyDown(SDLK_DELETE)&&!Input::isKeyDown(SDLK_p)){ drawmodetogglekeydown=0; } - if(IsKeyDown(theKeyMap, MAC_N_KEY)&&!IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){ + if(Input::isKeyDown(SDLK_n)&&!Input::isKeyDown(SDLK_LCTRL)&&!texturesizetogglekeydown&&debugmode){ //if(!player[0].skeleton.free)player[0].damage+=500; player[0].RagDoll(0); //player[0].spurt=1; @@@ -5510,7 -6612,7 +5517,7 @@@ texturesizetogglekeydown=1; } - if(IsKeyDown(theKeyMap, MAC_N_KEY)&&IsKeyDown(theKeyMap, MAC_CONTROL_KEY)&&!texturesizetogglekeydown&&debugmode){ + if(Input::isKeyDown(SDLK_n)&&Input::isKeyDown(SDLK_LCTRL)&&!texturesizetogglekeydown&&debugmode){ int closest=-1; float closestdist=-1; @@@ -5528,13 -6630,13 +5535,13 @@@ //Attack static bool playerrealattackkeydown=0; - if(!buttons[0])oldbutton=0; - if(!IsKeyDown(theKeyMap, attackkey))oldattackkey=0; + if(!Input::isKeyDown(MOUSEBUTTON1)&&!Input::isKeyDown(MOUSEBUTTON2))oldbutton=0; + if(!Input::isKeyDown(attackkey))oldattackkey=0; if(oldattackkey)player[0].attackkeydown=0; if(oldattackkey)playerrealattackkeydown=0; - if(!oldattackkey)playerrealattackkeydown=IsKeyDown(theKeyMap, attackkey); - if((player[0].parriedrecently<=0||player[0].weaponactive==-1)&&(!oldattackkey||(realthreat&&player[0].lastattack!=swordslashanim&&player[0].lastattack!=knifeslashstartanim&&player[0].lastattack!=staffhitanim&&player[0].lastattack!=staffspinhitanim)))player[0].attackkeydown=IsKeyDown(theKeyMap, attackkey); - if(IsKeyDown(theKeyMap, attackkey)&&!oldattackkey&&!player[0].backkeydown){ + if(!oldattackkey)playerrealattackkeydown=Input::isKeyDown(attackkey); + if((player[0].parriedrecently<=0||player[0].weaponactive==-1)&&(!oldattackkey||(realthreat&&player[0].lastattack!=swordslashanim&&player[0].lastattack!=knifeslashstartanim&&player[0].lastattack!=staffhitanim&&player[0].lastattack!=staffspinhitanim)))player[0].attackkeydown=Input::isKeyDown(attackkey); + if(Input::isKeyDown(attackkey)&&!oldattackkey&&!player[0].backkeydown){ for(k=0;k1&&checkdelay<=0){ - checkdelay=.015; - for(k=0;kplayer[k].coords.y-3) - if(player[i].coords.yplayer[k].coords.x-3) - if(player[i].coords.xplayer[k].coords.z-3) - if(player[i].coords.zplayer[k].skeleton.longdead&&player[k].skeleton.free!=2)||player[i].skeleton.free==2){ - stuck=i; - moving=k; - } - else - { - moving=i; - stuck=k; - } - isgood=1; - - if(isgood){ - above[moving]=stuck; - for(l=0;lnumchallengelevels-1)targetlevel=0; loading=1; leveltime=5; slomotogglekeydown=1; } - - /* - if(IsKeyDown(theKeyMap, MAC_Z_KEY)){ - //Respawn - OPENAL_SetPaused(channels[whooshsound], true); - changedelay=0; - for(k=0;k.8&&!player[i].jumpkeydown&&player[i].collided<.8)player[i].targetrotation+=90*(player[i].whichdirection*2-1); - /*for(j=0;jid==i&&(player[j].targetanimation==spinkickanim&&player[j].targetframe<3)){ - player[i].crouchkeydown=1; - } - }*/ if(Random()%2==0/*||player[0].weaponactive!=-1*/||player[i].weaponactive!=-1||player[i].creature==wolftype)player[i].attackkeydown=1; else player[i].attackkeydown=0; if((player[i].isRun())&&Random()%6&&findDistancefast(&player[i].coords,&player[0].coords)>7)player[i].attackkeydown=0; - //if(player[i].attackkeydown&&findDistancefast(&player[i].coords,&player[0].coords)<3&&player[i].targetanimation!=runanim&&!player[0].skeleton.free)player[i].crouchkeydown=1; - /*if(player[0].targetanimation==rabbitkickanim&&!player[0].skeleton.free){ - player[i].attackkeydown=0; - if(player[i].isIdle())player[i].crouchkeydown=1; - player[i].forwardkeydown=0; - player[i].aiupdatedelay=.02; - }*/ if(player[i].aitype!=playercontrolled&&(player[i].isIdle()||player[i].isCrouch()||player[i].isRun())){ target=-2; @@@ -7840,7 -9050,42 +7847,7 @@@ } objects.DoStuff(); - /* - player[0].righthandmorphstart=0; - player[0].righthandmorphend=1; - player[0].lefthandmorphstart=0; - player[0].lefthandmorphend=1; - player[0].headmorphstart=0; - player[0].headmorphend=2;*/ - - /* - if(IsKeyDown( theKeyMap, MAC_P_KEY )){ - if(player[0].righthandmorphend!=1)player[0].righthandmorphness=0; - player[0].righthandmorphend=1; - player[0].targetrighthandmorphness=1; - - if(player[0].lefthandmorphend!=0)player[0].lefthandmorphness=0; - player[0].lefthandmorphend=0; - player[0].targetlefthandmorphness=1; - - if(player[0].headmorphend!=2)player[0].headmorphness=0; - player[0].headmorphend=2; - player[0].targetheadmorphness=1; - } - if(IsKeyDown( theKeyMap, MAC_L_KEY )){ - if(player[0].righthandmorphend!=0)player[0].righthandmorphness=0; - player[0].righthandmorphend=0; - player[0].targetrighthandmorphness=1; - - if(player[0].lefthandmorphend!=1)player[0].lefthandmorphness=0; - player[0].lefthandmorphend=1; - player[0].targetlefthandmorphness=1; - - if(player[0].headmorphend!=0)player[0].headmorphness=0; - player[0].headmorphend=0; - player[0].targetheadmorphness=1; - } - */ + if(numenvsounds!=0) for(j=numenvsounds-1;j>=0;j--){ envsoundlife[j]-=multiplier; @@@ -7891,7 -9136,11 +7898,7 @@@ OPENAL_SetPaused(channels[fireendsound], false); OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + flash(); } if(tutorialstage<51) if(findDistancefast(&temp,&player[0].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[0].coords)<4){ @@@ -7910,7 -9159,11 +7917,7 @@@ player[0].coords=(oldtemp+oldtemp2)/2; - flashr=1; - flashg=1; - flashb=1; - flashamount=1; - flashdelay=1; + flash(); } if(tutorialstage>=14&&tutorialstage<50) if(findDistancefast(&temp,&player[1].coords)>=findDistancefast(&temp,&temp2)-1||findDistancefast(&temp3,&player[1].coords)<4){ @@@ -7992,13 -9245,14 +7999,13 @@@ } } - if(IsKeyDown(theKeyMap, MAC_F1_KEY)&&!freezetogglekeydown){ + if(Input::isKeyDown(SDLK_F1)&&!freezetogglekeydown){ Screenshot(); freezetogglekeydown=1; } } void Game::TickOnce(){ - //if(!console){ if(!mainmenu) if(directing||indialogue==-1){ rotation+=deltah*.7; @@@ -8008,6 -9262,8 +8015,6 @@@ if(rotation2<-70)rotation2=-70; } if(mainmenu)rotation+=multiplier*5; - - //} } void Game::TickOnceAfter(){ @@@ -8085,6 -9341,14 +8092,6 @@@ else musicvolume[1]-=multiplier*450; if(musicselected==stream_music3)musicvolume[2]+=multiplier*450; else musicvolume[2]-=multiplier*450; - /* - if(musicselected==music1)musicvolume[0]+=multiplier*100; - else musicvolume[0]-=multiplier*450; - if(musicselected==music2)musicvolume[1]+=multiplier*150; - else if(player[0].dead)musicvolume[1]-=multiplier*450; - else musicvolume[1]-=multiplier*100; - if(musicselected==music3)musicvolume[2]+=multiplier*450; - else musicvolume[2]-=multiplier*450;*/ for(i=0;i<3;i++){ if(musicvolume[i]<0)musicvolume[i]=0; @@@ -8209,19 -9473,24 +8216,19 @@@ //high scores, awards, win if(campaign){ won=1; - accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice; - accountcampaignchoicesmade[accountactive]++; + accountactive->winCampaignLevel(whichchoice, bonustotal, leveltime); + /*accountcampaignchoices[accountactive][accountactive->getCampaignChoicesMade()]=whichchoice; + accountactive->getCampaignChoicesMade()++; accountcampaignscore[accountactive]+=bonustotal; - scoreadded=1; accountcampaigntime[accountactive]+=leveltime; - if(accountcampaignscore[accountactive]>accountcampaignhighscore[accountactive])accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive]; - - //if(accountprogress[accountactive]accountcampaignhighscore[accountactive]) + accountcampaignhighscore[accountactive]=accountcampaignscore[accountactive];*/ + scoreadded=1; } else { won=1; - if(!debugmode){ - if(bonustotal-startbonustotal>accounthighscore[accountactive][whichlevel])accounthighscore[accountactive][whichlevel]=bonustotal-startbonustotal; - if(accountfasttime[accountactive][whichlevel]==0||leveltimewinLevel(whichlevel,bonustotal-startbonustotal,leveltime); } } } @@@ -8240,9 -9509,21 +8247,9 @@@ if(changedelay!=-999)changedelay-=multiplier/7; if(player[0].dead)targetlevel=whichlevel; if(loading==2&&!campaign){ - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; - loadtime=0; + flash(); - float gLoc[3]={0,0,0}; - float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); + fireSound(firestartsound); if(!player[0].dead&&targetlevel!=whichlevel){ startbonustotal=bonustotal; @@@ -8250,17 -9531,31 +8257,17 @@@ if(!player[0].dead)Loadlevel(targetlevel); if(player[0].dead)Loadlevel(whichlevel); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); + fireSound(); loading=3; } if(loading==2&&targetlevel==whichlevel){ - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + flash(); loadtime=0; float gLoc[3]={0,0,0}; float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); + fireSound(firestartsound); for(i=0;i<255;i++){ mapname[i]='\0'; @@@ -8276,10 -9571,15 +8283,10 @@@ mapname[8]='p'; mapname[9]='s'; mapname[10]=':'; - strcat(mapname,campaignmapname[levelorder[accountcampaignchoicesmade[accountactive]]]);//[campaignchoicewhich[whichchoice]]); + strcat(mapname,campaignmapname[levelorder[accountactive->getCampaignChoicesMade()]]);//[campaignchoicewhich[whichchoice]]); Loadlevel(mapname); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 9999.0f, 99999.0f); - PlaySoundEx( fireendsound, samp[fireendsound], NULL, true); - OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel); - OPENAL_SetVolume(channels[fireendsound], 256); - OPENAL_SetPaused(channels[fireendsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f); + fireSound(); loading=3; } @@@ -8309,14 -9609,25 +8316,14 @@@ if(!stealthloading){ float gLoc[3]={0,0,0}; float vel[3]={0,0,0}; - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f); - PlaySoundEx( firestartsound, samp[firestartsound], NULL, true); - OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel); - OPENAL_SetVolume(channels[firestartsound], 256); - OPENAL_SetPaused(channels[firestartsound], false); - OPENAL_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f); - - flashr=1; - flashg=0; - flashb=0; - flashamount=1; - flashdelay=1; + fireSound(firestartsound); + + flash(); } startbonustotal=0; ifstream ipstream(ConvertFileName(":Data:Campaigns:main.txt")); - //campaignnumlevels=0; - //accountcampaignchoicesmade[accountactive]=0; ipstream.ignore(256,':'); ipstream >> campaignnumlevels; for(i=0;igetCampaignChoicesMade()) + for(i=0;igetCampaignChoicesMade();i++){ + levelorder[i+1]=campaignnextlevel[levelorder[i]][accountactive->getCampaignChoice(i)]; levelvisible[levelorder[i+1]]=1; } int whichlevelstart; - whichlevelstart=accountcampaignchoicesmade[accountactive]-1; + whichlevelstart=accountactive->getCampaignChoicesMade()-1; if(whichlevelstart<0){ campaignchoicenum=1; campaignchoicewhich[0]=0; @@@ -8402,6 -9713,10 +8409,6 @@@ mapname[9]='s'; mapname[10]=':'; - //accountcampaignchoices[accountactive][accountcampaignchoicesmade[accountactive]]=whichchoice; - //accountcampaignchoicesmade[accountactive]++; - - strcat(mapname,campaignmapname[campaignchoicewhich[0]]); whichchoice=0; visibleloading=1; diff --combined Source/OpenGL_Windows.cpp index 8cfe836,618ef47..16b8c82 --- a/Source/OpenGL_Windows.cpp +++ b/Source/OpenGL_Windows.cpp @@@ -61,6 -61,7 +61,6 @@@ static bool save_png(const char * fname #pragma comment(lib, "glaux.lib") #endif -extern bool buttons[3]; extern float multiplier; extern float sps; extern float realmultiplier; @@@ -118,15 -119,20 +118,15 @@@ static SDL_Rect *hardcoded_resolutions[ unsigned int resolutionDepths[8][2] = {0}; -bool selectDetail(int & width, int & height, int & bpp, int & detail); int closestResolution(int width, int height); int resolutionID(int width, int height); void ReportError (char * strError); -void SetupDSpFullScreen(); -void ShutdownDSp(); - void DrawGL(Game & game); void CreateGLWindow (void); Boolean SetUp (Game & game); -void DoKey (SInt8 theKey, SInt8 theCode); void DoUpdate (Game & game); void DoEvent (void); @@@ -190,7 -196,10 +190,7 @@@ static void GLAPIENTRY glDeleteTextures void sdlGetCursorPos(POINT *pt) { - int x, y; - SDL_GetMouseState(&x, &y); - pt->x = x; - pt->y = y; + SDL_GetMouseState(&(pt->x), &(pt->y)); } #define GetCursorPos(x) sdlGetCursorPos(x) #define SetCursorPos(x, y) SDL_WarpMouse(x, y) @@@ -272,6 -281,16 +272,6 @@@ void ReportError (char * strError */ } -void SetupDSpFullScreen () -{ -} - - -void ShutdownDSp () -{ -} - - //----------------------------------------------------------------------------------------------------------------------- // OpenGL Drawing @@@ -287,7 -306,7 +287,7 @@@ void DrawGL (Game & game } -static KeyMap g_theKeys; +/*static KeyMap g_theKeys; void SetKey( int key) { @@@ -302,11 -321,110 +302,11 @@@ void ClearKey( int key void GetKeys( unsigned char theKeys[16]) { memcpy( theKeys, &g_theKeys, 16); -} +}*/ Boolean Button() { - return g_button; -} - - -#define MAX_SDLKEYS SDLK_LAST -static unsigned short KeyTable[MAX_SDLKEYS]; - -static void initSDLKeyTable(void) -{ - memset(KeyTable, 0xFF, sizeof (KeyTable)); - KeyTable[SDLK_BACKSPACE] = MAC_DELETE_KEY; - KeyTable[SDLK_TAB] = MAC_TAB_KEY; - KeyTable[SDLK_RETURN] = MAC_RETURN_KEY; - KeyTable[SDLK_ESCAPE] = MAC_ESCAPE_KEY; - KeyTable[SDLK_SPACE] = MAC_SPACE_KEY; - KeyTable[SDLK_PAGEUP] = MAC_PAGE_UP_KEY; - KeyTable[SDLK_PAGEDOWN] = MAC_PAGE_DOWN_KEY; - KeyTable[SDLK_END] = MAC_END_KEY; - KeyTable[SDLK_HOME] = MAC_HOME_KEY; - KeyTable[SDLK_LEFT] = MAC_ARROW_LEFT_KEY; - KeyTable[SDLK_UP] = MAC_ARROW_UP_KEY; - KeyTable[SDLK_RIGHT] = MAC_ARROW_RIGHT_KEY; - KeyTable[SDLK_DOWN] = MAC_ARROW_DOWN_KEY; - KeyTable[SDLK_INSERT] = MAC_INSERT_KEY; - KeyTable[SDLK_DELETE] = MAC_DEL_KEY; - KeyTable[SDLK_0] = MAC_0_KEY; - KeyTable[SDLK_1] = MAC_1_KEY; - KeyTable[SDLK_2] = MAC_2_KEY; - KeyTable[SDLK_3] = MAC_3_KEY; - KeyTable[SDLK_4] = MAC_4_KEY; - KeyTable[SDLK_5] = MAC_5_KEY; - KeyTable[SDLK_6] = MAC_6_KEY; - KeyTable[SDLK_7] = MAC_7_KEY; - KeyTable[SDLK_8] = MAC_8_KEY; - KeyTable[SDLK_9] = MAC_9_KEY; - KeyTable[SDLK_a] = MAC_A_KEY; - KeyTable[SDLK_b] = MAC_B_KEY; - KeyTable[SDLK_c] = MAC_C_KEY; - KeyTable[SDLK_d] = MAC_D_KEY; - KeyTable[SDLK_e] = MAC_E_KEY; - KeyTable[SDLK_f] = MAC_F_KEY; - KeyTable[SDLK_g] = MAC_G_KEY; - KeyTable[SDLK_h] = MAC_H_KEY; - KeyTable[SDLK_i] = MAC_I_KEY; - KeyTable[SDLK_j] = MAC_J_KEY; - KeyTable[SDLK_k] = MAC_K_KEY; - KeyTable[SDLK_l] = MAC_L_KEY; - KeyTable[SDLK_m] = MAC_M_KEY; - KeyTable[SDLK_n] = MAC_N_KEY; - KeyTable[SDLK_o] = MAC_O_KEY; - KeyTable[SDLK_p] = MAC_P_KEY; - KeyTable[SDLK_q] = MAC_Q_KEY; - KeyTable[SDLK_r] = MAC_R_KEY; - KeyTable[SDLK_s] = MAC_S_KEY; - KeyTable[SDLK_t] = MAC_T_KEY; - KeyTable[SDLK_u] = MAC_U_KEY; - KeyTable[SDLK_v] = MAC_V_KEY; - KeyTable[SDLK_w] = MAC_W_KEY; - KeyTable[SDLK_x] = MAC_X_KEY; - KeyTable[SDLK_y] = MAC_Y_KEY; - KeyTable[SDLK_z] = MAC_Z_KEY; - KeyTable[SDLK_KP0] = MAC_NUMPAD_0_KEY; - KeyTable[SDLK_KP1] = MAC_NUMPAD_1_KEY; - KeyTable[SDLK_KP2] = MAC_NUMPAD_2_KEY; - KeyTable[SDLK_KP3] = MAC_NUMPAD_3_KEY; - KeyTable[SDLK_KP4] = MAC_NUMPAD_4_KEY; - KeyTable[SDLK_KP5] = MAC_NUMPAD_5_KEY; - KeyTable[SDLK_KP6] = MAC_NUMPAD_6_KEY; - KeyTable[SDLK_KP7] = MAC_NUMPAD_7_KEY; - KeyTable[SDLK_KP8] = MAC_NUMPAD_8_KEY; - KeyTable[SDLK_KP9] = MAC_NUMPAD_9_KEY; - KeyTable[SDLK_KP_MULTIPLY] = MAC_NUMPAD_ASTERISK_KEY; - KeyTable[SDLK_KP_PLUS] = MAC_NUMPAD_PLUS_KEY; - KeyTable[SDLK_KP_ENTER] = MAC_NUMPAD_ENTER_KEY; - KeyTable[SDLK_KP_MINUS] = MAC_NUMPAD_MINUS_KEY; - KeyTable[SDLK_KP_PERIOD] = MAC_NUMPAD_PERIOD_KEY; - KeyTable[SDLK_KP_DIVIDE] = MAC_NUMPAD_SLASH_KEY; - KeyTable[SDLK_F1] = MAC_F1_KEY; - KeyTable[SDLK_F2] = MAC_F2_KEY; - KeyTable[SDLK_F3] = MAC_F3_KEY; - KeyTable[SDLK_F4] = MAC_F4_KEY; - KeyTable[SDLK_F5] = MAC_F5_KEY; - KeyTable[SDLK_F6] = MAC_F6_KEY; - KeyTable[SDLK_F7] = MAC_F7_KEY; - KeyTable[SDLK_F8] = MAC_F8_KEY; - KeyTable[SDLK_F9] = MAC_F9_KEY; - KeyTable[SDLK_F10] = MAC_F10_KEY; - KeyTable[SDLK_F11] = MAC_F11_KEY; - KeyTable[SDLK_F12] = MAC_F12_KEY; - KeyTable[SDLK_SEMICOLON] = MAC_SEMICOLON_KEY; - KeyTable[SDLK_PLUS] = MAC_PLUS_KEY; - KeyTable[SDLK_COMMA] = MAC_COMMA_KEY; - KeyTable[SDLK_MINUS] = MAC_MINUS_KEY; - KeyTable[SDLK_PERIOD] = MAC_PERIOD_KEY; - KeyTable[SDLK_SLASH] = MAC_SLASH_KEY; - KeyTable[SDLK_BACKQUOTE] = MAC_TILDE_KEY; - KeyTable[SDLK_LEFTBRACKET] = MAC_LEFTBRACKET_KEY; - KeyTable[SDLK_BACKSLASH] = MAC_BACKSLASH_KEY; - KeyTable[SDLK_RIGHTBRACKET] = MAC_RIGHTBRACKET_KEY; - KeyTable[SDLK_QUOTE] = MAC_APOSTROPHE_KEY; + return SDL_GetMouseState(NULL,NULL)&SDL_BUTTON(SDL_BUTTON_LEFT); } static inline int clamp_sdl_mouse_button(Uint8 button) @@@ -324,6 -442,7 +324,6 @@@ static void sdlEventProc(const SDL_Event &e, Game &game) { int val; - bool skipkey = false; SDLMod mod; switch(e.type) @@@ -333,17 -452,93 +333,17 @@@ game.deltav += e.motion.yrel; return; - case SDL_MOUSEBUTTONDOWN: - { - val = clamp_sdl_mouse_button(e.button.button); - if ((val >= 0) && (val <= 2)) - { - if (val == 0) - g_button = true; - buttons[val] = true; - } - } - return; - - case SDL_MOUSEBUTTONUP: - { - val = clamp_sdl_mouse_button(e.button.button); - if ((val >= 0) && (val <= 2)) - { - if (val == 0) - g_button = false; - buttons[val] = false; - } - } - return; - case SDL_KEYDOWN: - if (e.key.keysym.sym == SDLK_g) - { - if (e.key.keysym.mod & KMOD_CTRL) - { - skipkey = true; - SDL_GrabMode mode = SDL_GRAB_ON; - if ((SDL_GetVideoSurface()->flags & SDL_FULLSCREEN) == 0) - { - mode = SDL_WM_GrabInput(SDL_GRAB_QUERY); - mode = (mode==SDL_GRAB_ON) ? SDL_GRAB_OFF:SDL_GRAB_ON; - } - SDL_WM_GrabInput(mode); - } - } - - else if (e.key.keysym.sym == SDLK_RETURN) - { - if (e.key.keysym.mod & KMOD_ALT) - { - skipkey = true; - SDL_WM_ToggleFullScreen(SDL_GetVideoSurface()); - } - } - - if ((!skipkey) && (e.key.keysym.sym < SDLK_LAST)) - { - if (KeyTable[e.key.keysym.sym] != 0xffff) - SetKey(KeyTable[e.key.keysym.sym]); + if ((e.key.keysym.sym == SDLK_g) && + (e.key.keysym.mod & KMOD_CTRL) && + !(SDL_GetVideoSurface()->flags & SDL_FULLSCREEN) ) { + SDL_WM_GrabInput( ((SDL_WM_GrabInput(SDL_GRAB_QUERY)==SDL_GRAB_ON) ? SDL_GRAB_OFF:SDL_GRAB_ON) ); + } else if ( (e.key.keysym.sym == SDLK_RETURN) && (e.key.keysym.mod & KMOD_ALT) ) { + SDL_WM_ToggleFullScreen(SDL_GetVideoSurface()); } - - mod = SDL_GetModState(); - if (mod & KMOD_CTRL) - SetKey(MAC_CONTROL_KEY); - if (mod & KMOD_ALT) - SetKey(MAC_OPTION_KEY); - if (mod & KMOD_META) - SetKey(MAC_COMMAND_KEY); - if (mod & KMOD_SHIFT) - SetKey(MAC_SHIFT_KEY); - if (mod & KMOD_CAPS) - SetKey(MAC_CAPS_LOCK_KEY); - return; case SDL_KEYUP: - if (e.key.keysym.sym < SDLK_LAST) - { - if (KeyTable[e.key.keysym.sym] != 0xffff) - ClearKey(KeyTable[e.key.keysym.sym]); - } - - mod = SDL_GetModState(); - if ((mod & KMOD_CTRL) == 0) - ClearKey(MAC_CONTROL_KEY); - if ((mod & KMOD_ALT) == 0) - ClearKey(MAC_OPTION_KEY); - if ((mod & KMOD_META) == 0) - ClearKey(MAC_COMMAND_KEY); - if ((mod & KMOD_SHIFT) == 0) - ClearKey(MAC_SHIFT_KEY); - if ((mod & KMOD_CAPS) == 0) - ClearKey(MAC_CAPS_LOCK_KEY); return; } } @@@ -371,12 -566,8 +371,12 @@@ Boolean SetUp (Game & game DefaultSettings(game); - selectDetail(kContextWidth, kContextHeight, kBitsPerPixel, detail); - + if (!SDL_WasInit(SDL_INIT_VIDEO)) + if (SDL_Init(SDL_INIT_VIDEO) == -1) + { + fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError()); + return false; + } if(!LoadSettings(game)) { fprintf(stderr, "Failed to load config, creating default\n"); SaveSettings(game); @@@ -385,48 -576,63 +385,48 @@@ kBitsPerPixel=16; } + if (SDL_GL_LoadLibrary(NULL) == -1) + { + fprintf(stderr, "SDL_GL_LoadLibrary() failed: %s\n", SDL_GetError()); + SDL_Quit(); + return false; + } - selectDetail(kContextWidth, kContextHeight, kBitsPerPixel, detail); - - SetupDSpFullScreen(); - - - if (!SDL_WasInit(SDL_INIT_VIDEO)) - { - if (SDL_Init(SDL_INIT_VIDEO) == -1) - { - fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError()); - return false; - } - - if (SDL_GL_LoadLibrary(NULL) == -1) - { - fprintf(stderr, "SDL_GL_LoadLibrary() failed: %s\n", SDL_GetError()); - SDL_Quit(); - return false; - } - - SDL_Rect **res = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL); - if ( (res == NULL) || (res == ((SDL_Rect **)-1)) || (res[0] == NULL) || (res[0]->w < 640) || (res[0]->h < 480) ) - res = hardcoded_resolutions; + SDL_Rect **res = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL); + if ( (res == NULL) || (res == ((SDL_Rect **)-1)) || (res[0] == NULL) || (res[0]->w < 640) || (res[0]->h < 480) ) + res = hardcoded_resolutions; - // reverse list (it was sorted biggest to smallest by SDL)... - int count; - for (count = 0; res[count]; count++) - { - if ((res[count]->w < 640) || (res[count]->h < 480)) - break; // sane lower limit. - } + // reverse list (it was sorted biggest to smallest by SDL)... + int count; + for (count = 0; res[count]; count++) + { + if ((res[count]->w < 640) || (res[count]->h < 480)) + break; // sane lower limit. + } - static SDL_Rect *resolutions_block = NULL; - resolutions_block = (SDL_Rect*) realloc(resolutions_block, sizeof (SDL_Rect) * count); - resolutions = (SDL_Rect**) realloc(resolutions, sizeof (SDL_Rect *) * (count + 1)); - if ((resolutions_block == NULL) || (resolutions == NULL)) - { - SDL_Quit(); - fprintf(stderr, "Out of memory!\n"); - return false; - } + static SDL_Rect *resolutions_block = NULL; + resolutions_block = (SDL_Rect*) realloc(resolutions_block, sizeof (SDL_Rect) * count); + resolutions = (SDL_Rect**) realloc(resolutions, sizeof (SDL_Rect *) * (count + 1)); + if ((resolutions_block == NULL) || (resolutions == NULL)) + { + SDL_Quit(); + fprintf(stderr, "Out of memory!\n"); + return false; + } - resolutions[count--] = NULL; - for (int i = 0; count >= 0; i++, count--) - { - memcpy(&resolutions_block[count], res[i], sizeof (SDL_Rect)); - resolutions[count] = &resolutions_block[count]; - } + resolutions[count--] = NULL; + for (int i = 0; count >= 0; i++, count--) + { + memcpy(&resolutions_block[count], res[i], sizeof (SDL_Rect)); + resolutions[count] = &resolutions_block[count]; + } - if (cmdline("showresolutions")) - { - printf("Resolutions we think are okay:\n"); - for (int i = 0; resolutions[i]; i++) - printf(" %d x %d\n", (int) resolutions[i]->w, (int) resolutions[i]->h); - } - } + if (cmdline("showresolutions")) + { + printf("Resolutions we think are okay:\n"); + for (int i = 0; resolutions[i]; i++) + printf(" %d x %d\n", (int) resolutions[i]->w, (int) resolutions[i]->h); + } Uint32 sdlflags = SDL_OPENGL; if (!cmdline("windowed")) @@@ -562,6 -768,19 +562,6 @@@ static void DoMouse(Game & game } - - -// -------------------------------------------------------------------------- - -void DoKey (SInt8 theKey, SInt8 theCode) -{ - // do nothing -} - -// -------------------------------------------------------------------------- - - - void DoFrameRate (int update) { static long frames = 0; @@@ -577,9 -796,9 +577,9 @@@ deltaTime /= 1000.0; multiplier=deltaTime; - if(multiplier<.001)multiplier=.001; - if(multiplier>10)multiplier=10; - if(update)frametime = currTime; // reset for next time interval + if(multiplier<.001) multiplier=.001; + if(multiplier>10) multiplier=10; + if(update) frametime = currTime; // reset for next time interval deltaTime = (float) AbsoluteDeltaToDuration (currTime, time); @@@ -843,9 -1062,9 +843,9 @@@ int main(int argc, char **argv LOGFUNC; - memset( &g_theKeys, 0, sizeof( KeyMap)); + //memset( &g_theKeys, 0, sizeof( KeyMap)); - initSDLKeyTable(); + //initSDLKeyTable(); try { @@@ -873,18 -1092,17 +873,18 @@@ game.deltah = 0; game.deltav = 0; SDL_Event e; - // message pump - while( SDL_PollEvent( &e ) ) - { - if( e.type == SDL_QUIT ) + if(!game.isWaiting()) { + // message pump + while( SDL_PollEvent( &e ) ) { - gDone=true; - break; + if( e.type == SDL_QUIT ) + { + gDone=true; + break; + } + sdlEventProc(e, game); } - sdlEventProc(e, game); } - // game DoUpdate(game); @@@ -899,7 -1117,12 +899,12 @@@ } // game is not in focus, give CPU time to other apps by waiting for messages instead of 'peeking' - STUBBED("give up CPU but sniff the event queue"); + SDL_ActiveEvent evt; + SDL_WaitEvent((SDL_Event*)&evt); + if (evt.type == SDL_ACTIVEEVENT && evt.gain == 1) + gameFocused = true; + else if (evt.type == SDL_QUIT) + gDone = true; } } @@@ -908,7 -1131,21 +913,7 @@@ pgame = 0; CleanUp (); -// if(game.registernow){ - if(regnow) - { - #if (defined(__APPLE__) && defined(__MACH__)) - launch_web_browser("http://www.wolfire.com/purchase/lugaru/mac"); - #elif PLATFORM_LINUX - launch_web_browser("http://www.wolfire.com/purchase/lugaru/linux"); - #else - launch_web_browser("http://www.wolfire.com/purchase/lugaru/pc"); - #endif - } - - #if PLATFORM_LINUX // (this may not be necessary any more.) - _exit(0); // !!! FIXME: hack...crashes on exit! - #endif + return 0; } catch (const std::exception& error) @@@ -932,6 -1169,19 +937,6 @@@ // -------------------------------------------------------------------------- - - - bool selectDetail(int & width, int & height, int & bpp, int & detail) - { - bool res = true; - - // currently with SDL, we just use whatever is requested - // and don't care. --ryan. - - - return res; - } - extern int channels[100]; extern OPENAL_SAMPLE * samp[100]; extern OPENAL_STREAM * strm[20]; @@@ -991,15 -1241,25 +996,15 @@@ bool LoadImage(const char * fname, TGAImageRec & tex) { - bool res = true; - if ( tex.data == NULL ) - { return false; - } - - - res = load_image(fname, tex); - - - return res; + else + return load_image(fname, tex); } void ScreenShot(const char * fname) { - save_image(fname); - } diff --combined Source/Settings.cpp index 2ee6ad1,b2c761d..9642cb9 --- a/Source/Settings.cpp +++ b/Source/Settings.cpp @@@ -1,6 -1,6 +1,6 @@@ #include "Settings.h" #include "Game.h" - +#include "Input.h" void DefaultSettings(Game &game) { detail=1; @@@ -31,16 -31,16 +31,16 @@@ vblsync=0; debugmode=0; - game.crouchkey=MAC_SHIFT_KEY; - game.jumpkey=MAC_SPACE_KEY; - game.leftkey=MAC_A_KEY; - game.forwardkey=MAC_W_KEY; - game.backkey=MAC_S_KEY; - game.rightkey=MAC_D_KEY; - game.drawkey=MAC_E_KEY; - game.throwkey=MAC_Q_KEY; - game.attackkey=MAC_MOUSEBUTTON1; - game.chatkey=MAC_T_KEY; + game.crouchkey=SDLK_LSHIFT; + game.jumpkey=SDLK_SPACE; + game.leftkey=SDLK_a; + game.forwardkey=SDLK_w; + game.backkey=SDLK_s; + game.rightkey=SDLK_d; + game.drawkey=SDLK_e; + game.throwkey=SDLK_q; + game.attackkey=MOUSEBUTTON1; + game.chatkey=SDLK_t; } void SaveSettings(Game &game) { @@@ -99,25 -99,25 +99,25 @@@ opstream << "\nVolume:\n"; opstream << volume; opstream << "\nForward key:\n"; - opstream << KeyToChar(game.forwardkey); + opstream << Input::keyToChar(game.forwardkey); opstream << "\nBack key:\n"; - opstream << KeyToChar(game.backkey); + opstream << Input::keyToChar(game.backkey); opstream << "\nLeft key:\n"; - opstream << KeyToChar(game.leftkey); + opstream << Input::keyToChar(game.leftkey); opstream << "\nRight key:\n"; - opstream << KeyToChar(game.rightkey); + opstream << Input::keyToChar(game.rightkey); opstream << "\nJump key:\n"; - opstream << KeyToChar(game.jumpkey); + opstream << Input::keyToChar(game.jumpkey); opstream << "\nCrouch key:\n"; - opstream << KeyToChar(game.crouchkey); + opstream << Input::keyToChar(game.crouchkey); opstream << "\nDraw key:\n"; - opstream << KeyToChar(game.drawkey); + opstream << Input::keyToChar(game.drawkey); opstream << "\nThrow key:\n"; - opstream << KeyToChar(game.throwkey); + opstream << Input::keyToChar(game.throwkey); opstream << "\nAttack key:\n"; - opstream << KeyToChar(game.attackkey); + opstream << Input::keyToChar(game.attackkey); opstream << "\nChat key:\n"; - opstream << KeyToChar(game.chatkey); + opstream << Input::keyToChar(game.chatkey); opstream << "\nDamage bar:\n"; opstream << showdamagebar; opstream << "\nStereoMode:\n"; @@@ -141,7 -141,6 +141,6 @@@ bool LoadSettings(Game &game) printf("Loading config\n"); while(!ipstream.eof()) { ipstream.getline( setting, sizeof(setting) ); - printf("setting : %s\n",setting); // skip blank lines // assume lines starting with spaces are all blank @@@ -214,34 -213,34 +213,34 @@@ } else if ( !strncmp(setting, "Volume", 6) ) { ipstream >> volume; } else if ( !strncmp(setting, "Forward key", 11) ) { - ipstream >> string; + ipstream.getline( string, sizeof(string) ); game.forwardkey = CharToKey(string); } else if ( !strncmp(setting, "Back key", 8) ) { - ipstream >> string; + ipstream.getline( string, sizeof(string) ); game.backkey = CharToKey(string); } else if ( !strncmp(setting, "Left key", 8) ) { - ipstream >> string; + ipstream.getline( string, sizeof(string) ); game.leftkey = CharToKey(string); } else if ( !strncmp(setting, "Right key", 9) ) { - ipstream >> string; + ipstream.getline( string, sizeof(string) ); game.rightkey = CharToKey(string); } else if ( !strncmp(setting, "Jump key", 8) ) { - ipstream >> string; + ipstream.getline( string, sizeof(string) ); game.jumpkey = CharToKey(string); } else if ( !strncmp(setting, "Crouch key", 10) ) { - ipstream >> string; + ipstream.getline( string, sizeof(string) ); game.crouchkey = CharToKey(string); } else if ( !strncmp(setting, "Draw key", 8) ) { - ipstream >> string; + ipstream.getline( string, sizeof(string) ); game.drawkey = CharToKey(string); } else if ( !strncmp(setting, "Throw key", 9) ) { - ipstream >> string; + ipstream.getline( string, sizeof(string) ); game.throwkey = CharToKey(string); } else if ( !strncmp(setting, "Attack key", 10) ) { - ipstream >> string; + ipstream.getline( string, sizeof(string) ); game.attackkey = CharToKey(string); } else if ( !strncmp(setting, "Chat key", 8) ) { - ipstream >> string; + ipstream.getline( string, sizeof(string) ); game.chatkey = CharToKey(string); } else if ( !strncmp(setting, "Damage bar", 10) ) { ipstream >> showdamagebar; diff --combined Source/WinInput.cpp index 8129225,d42ae78..c5a59c3 --- a/Source/WinInput.cpp +++ b/Source/WinInput.cpp @@@ -21,10 -21,9 +21,10 @@@ Foundation, Inc., 59 Temple Place - Sui /**> HEADER FILES <**/ #include "WinInput.h" +#include "SDL.h" #ifdef WIN32 - #include "String.h" + #include #else #include #include @@@ -32,153 -31,822 +32,153 @@@ #endif extern bool keyboardfrozen; -extern bool buttons[3]; /********************> IsKeyDown() <*****/ -Boolean IsKeyDown( unsigned char *keyMap, unsigned short theKey ) -{ - if(keyboardfrozen)return 0; - if(theKey< 0x80 /*1000*/){ - static long keyMapIndex; - static Boolean isKeyDown; - static short bitToCheck; - - // Calculate the key map index - keyMapIndex = keyMap[theKey/8]; - - // Calculate the individual bit to check - bitToCheck = theKey%8; - - // Check the status of the key - isKeyDown = ( keyMapIndex >> bitToCheck ) & 0x01; - - // Return the status of the key - return isKeyDown; - } - else if(theKey==MAC_MOUSEBUTTON1) - return buttons[0]; - else if(theKey==MAC_MOUSEBUTTON2) - return buttons[1]; - - return 0; -} unsigned short CharToKey(const char* which) { - // alphabetic keys - if(!strcasecmp(which,"a")){ - return MAC_A_KEY; - } - if(!strcasecmp(which,"b")){ - return MAC_B_KEY; - } - if(!strcasecmp(which,"c")){ - return MAC_C_KEY; - } - if(!strcasecmp(which,"d")){ - return MAC_D_KEY; - } - if(!strcasecmp(which,"e")){ - return MAC_E_KEY; - } - if(!strcasecmp(which,"f")){ - return MAC_F_KEY; - } - if(!strcasecmp(which,"g")){ - return MAC_G_KEY; - } - if(!strcasecmp(which,"h")){ - return MAC_H_KEY; - } - if(!strcasecmp(which,"i")){ - return MAC_I_KEY; - } - if(!strcasecmp(which,"j")){ - return MAC_J_KEY; - } - if(!strcasecmp(which,"k")){ - return MAC_K_KEY; - } - if(!strcasecmp(which,"l")){ - return MAC_L_KEY; - } - if(!strcasecmp(which,"m")){ - return MAC_M_KEY; - } - if(!strcasecmp(which,"n")){ - return MAC_N_KEY; - } - if(!strcasecmp(which,"o")){ - return MAC_O_KEY; - } - if(!strcasecmp(which,"p")){ - return MAC_P_KEY; - } - if(!strcasecmp(which,"q")){ - return MAC_Q_KEY; - } - if(!strcasecmp(which,"r")){ - return MAC_R_KEY; - } - if(!strcasecmp(which,"s")){ - return MAC_S_KEY; - } - if(!strcasecmp(which,"t")){ - return MAC_T_KEY; - } - if(!strcasecmp(which,"u")){ - return MAC_U_KEY; - } - if(!strcasecmp(which,"v")){ - return MAC_V_KEY; - } - if(!strcasecmp(which,"w")){ - return MAC_W_KEY; - } - if(!strcasecmp(which,"x")){ - return MAC_X_KEY; - } - if(!strcasecmp(which,"y")){ - return MAC_Y_KEY; - } - if(!strcasecmp(which,"z")){ - return MAC_Z_KEY; - } - - // keypad keys - if(!strcasecmp(which,"KP0")){ - return MAC_NUMPAD_0_KEY; - } - if(!strcasecmp(which,"KP1")){ - return MAC_NUMPAD_1_KEY; - } - if(!strcasecmp(which,"KP2")){ - return MAC_NUMPAD_2_KEY; - } - if(!strcasecmp(which,"KP3")){ - return MAC_NUMPAD_3_KEY; - } - if(!strcasecmp(which,"KP4")){ - return MAC_NUMPAD_4_KEY; - } - if(!strcasecmp(which,"KP5")){ - return MAC_NUMPAD_5_KEY; - } - if(!strcasecmp(which,"KP6")){ - return MAC_NUMPAD_6_KEY; - } - if(!strcasecmp(which,"KP7")){ - return MAC_NUMPAD_7_KEY; - } - if(!strcasecmp(which,"KP8")){ - return MAC_NUMPAD_8_KEY; - } - if(!strcasecmp(which,"KP9")){ - return MAC_NUMPAD_9_KEY; - } - - // enter - if(!strcasecmp(which,"enter")){ - return MAC_ENTER_KEY; - } - - // number keys - if(!strcasecmp(which,"0")){ - return MAC_0_KEY; - } - if(!strcasecmp(which,"1")){ - return MAC_1_KEY; - } - if(!strcasecmp(which,"2")){ - return MAC_2_KEY; - } - if(!strcasecmp(which,"3")){ - return MAC_3_KEY; - } - if(!strcasecmp(which,"4")){ - return MAC_4_KEY; - } - if(!strcasecmp(which,"5")){ - return MAC_5_KEY; - } - if(!strcasecmp(which,"6")){ - return MAC_6_KEY; - } - if(!strcasecmp(which,"7")){ - return MAC_7_KEY; - } - if(!strcasecmp(which,"8")){ - return MAC_8_KEY; - } - if(!strcasecmp(which,"9")){ - return MAC_9_KEY; - } - - // function keys - if(!strcasecmp(which,"F1")){ - return MAC_F1_KEY; - } - if(!strcasecmp(which,"F2")){ - return MAC_F2_KEY; - } - if(!strcasecmp(which,"F3")){ - return MAC_F3_KEY; - } - if(!strcasecmp(which,"F4")){ - return MAC_F4_KEY; - } - if(!strcasecmp(which,"F5")){ - return MAC_F5_KEY; - } - if(!strcasecmp(which,"F6")){ - return MAC_F6_KEY; - } - if(!strcasecmp(which,"F7")){ - return MAC_F7_KEY; - } - if(!strcasecmp(which,"F8")){ - return MAC_F8_KEY; - } - if(!strcasecmp(which,"F9")){ - return MAC_F9_KEY; - } - if(!strcasecmp(which,"F10")){ - return MAC_F10_KEY; - } - if(!strcasecmp(which,"F11")){ - return MAC_F11_KEY; - } - if(!strcasecmp(which,"F12")){ - return MAC_F12_KEY; - } - - // escape - if(!strcasecmp(which,"escape")){ - return MAC_ESCAPE_KEY; - } - if(!strcasecmp(which,"backspace")){ - return MAC_DELETE_KEY; - } - if(!strcasecmp(which,"tab")){ - return MAC_TAB_KEY; - } - if(!strcasecmp(which,"`")){ - return MAC_TILDE_KEY; - } - if(!strcasecmp(which,"caps_lock")){ - return MAC_CAPS_LOCK_KEY; - } -// if(which==){ -// return ""; -// } - if(!strcasecmp(which,"command")){ - return MAC_COMMAND_KEY; - } - if(!strcasecmp(which,"option")){ - return MAC_OPTION_KEY; - } - if(!strcasecmp(which,"delete")){ - return MAC_DEL_KEY; - } - if(!strcasecmp(which,"insert")){ - return MAC_INSERT_KEY; - } - if(!strcasecmp(which,"home")){ - return MAC_HOME_KEY; - } - if(!strcasecmp(which,"end")){ - return MAC_END_KEY; - } - if(!strcasecmp(which,"page_up")){ - return MAC_PAGE_UP_KEY; - } - if(!strcasecmp(which,"page_down")){ - return MAC_PAGE_DOWN_KEY; - } - if(!strcasecmp(which,"clear")){ - return MAC_NUMPAD_CLEAR_KEY; - } - - if(!strcasecmp(which,"control")){ - return MAC_CONTROL_KEY; - } - if(!strcasecmp(which,"return")){ - return MAC_RETURN_KEY; - } - if(!strcasecmp(which,"space")){ - return MAC_SPACE_KEY; - } - if(!strcasecmp(which,"shift")){ - return MAC_SHIFT_KEY; - } - if(!strcasecmp(which,"uparrow")){ - return MAC_ARROW_UP_KEY; - } - if(!strcasecmp(which,"downarrow")){ - return MAC_ARROW_DOWN_KEY; - } - if(!strcasecmp(which,"leftarrow")){ - return MAC_ARROW_LEFT_KEY; - } - if(!strcasecmp(which,"rightarrow")){ - return MAC_ARROW_RIGHT_KEY; + for(unsigned short i=0;i