From 4ee4eeed40f5f6a5e1811608ca53b2b8bdae5926 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20BERNIGAUD?= Date: Sun, 6 Jun 2010 05:37:25 +0200 Subject: [PATCH] Adding back Settings files. (sorry about that). Some clean up again. And removing some unused functions (MD5) --- Source/Game.h | 9 - Source/GameDraw.cpp | 358 +++++++++++++++++--------------------- Source/GameTick.cpp | 21 --- Source/MacCompatibility.h | 6 - Source/Settings.cpp | 282 ++++++++++++++++++++++++++++++ Source/Settings.h | 42 +++++ 6 files changed, 485 insertions(+), 233 deletions(-) create mode 100644 Source/Settings.cpp create mode 100644 Source/Settings.h diff --git a/Source/Game.h b/Source/Game.h index edf867a..babc741 100644 --- a/Source/Game.h +++ b/Source/Game.h @@ -231,7 +231,6 @@ class Game unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey; bool oldattackkey; - long long MD5_string (char *string); static void LoadTexture(const char *fileName, GLuint *textureid,int mipmap, bool hasalpha); static void LoadTextureSave(const char *fileName, GLuint *textureid,int mipmap,GLubyte *array, int *skinsize); void LoadSave(const char *fileName, GLuint *textureid,bool mipmap,GLubyte *array, int *skinsize); @@ -311,17 +310,9 @@ class Game static __forceinline void swap_gl_buffers(void) { - SDL_GL_SwapBuffers(); - } -#ifdef __GNUC__ -#define LONGLONGCONST(x) (x##ll) -#else -#define LONGLONGCONST(x) (x) -#endif - extern "C" { void UndefinedSymbolToExposeStubbedCode(void); } //#define STUBBED(x) UndefinedSymbolToExposeStubbedCode(); #define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } } diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index f67ae5f..888a7b4 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -171,37 +171,6 @@ void Game::flash() { // shouldn't be that way, these should be attributes and Pe flashdelay=1; } /*********************> DrawGLScene() <*****/ -long long Game::MD5_string (char* string){ - char temp[256]=""; - char temp2[256]=""; - long long num=90814; - - sprintf (temp, "%s",string); - - int i=0; - while (i<256&&temp[i]!='\0'){ - if(temp[i]%3==0)num+=temp[i]*124; - else if(temp[i]%3==1)num-=temp[i]*temp[i]; - else num*=temp[i]; - i++; - } - - num=longlongabs(num); - if(num==0)num+=1452; - - while(numLONGLONGCONST(9900000000000000)){ - num/=1.235421521; - } - - return num; - - //return 1111111111111111; -} - int Game::DrawGLScene(StereoSide side) { static float texcoordwidth,texcoordheight; @@ -322,20 +291,18 @@ int Game::DrawGLScene(StereoSide side) glDrawBuffer(GL_BACK); glReadBuffer(GL_BACK); - /*if(environment==desertenvironment)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, (float)(abs(Random()%100))/50 ); - else glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0); - */ if(abs(blurness-targetblurness)2){ blurness=targetblurness; targetblurness=(float)(abs(Random()%100))/40; } - if(blurnesstargetblurness)blurness-=multiplier*5; + if(blurness=typesleeping)&&player[k].playerdetail) @@ -426,20 +389,19 @@ int Game::DrawGLScene(StereoSide side) opacity=.2+.2*sin(smoketex*6+i)-player[k].skeleton.joints[i].position.y*player[k].scale/5-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/10; } terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation); - if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz]) - for(l=0;l'z'||string[i]<' '||string[i]=='\0'){ @@ -1128,11 +1087,9 @@ int Game::DrawGLScene(StereoSide side) if(dialogueboxlocation[whichdialogue][indialogue]==1)starty=screenheight/16+screenheight*4/5; if(dialogueboxlocation[whichdialogue][indialogue]==2)starty=screenheight*1/5-screenheight/16; -// char tempname[64]; char tempname[264]; bool goodchar; int tempnum=0; -// for(i=0;i<64;i++){ for(i=0;i<264;i++){ tempname[i]='\0'; } @@ -1141,10 +1098,10 @@ int Game::DrawGLScene(StereoSide side) tempname[tempnum]=dialoguename[whichdialogue][indialogue][i]; goodchar=1; if(dialoguename[whichdialogue][indialogue][i]=='#'||dialoguename[whichdialogue][indialogue][i]=='\0')goodchar=0; - //if(tempnum>2)if(tempname[tempnum-2]=='e'&&tempname[tempnum-1]=='r')goodchar=0; - //if(tempnum>2)if(tempname[tempnum]=='r'&&tempname[0]=='a')goodchar=0; - if(goodchar)tempnum++; - else tempname[tempnum]='\0'; + if(goodchar) + tempnum++; + else + tempname[tempnum]='\0'; } sprintf (string, "%s: ", tempname); @@ -1159,7 +1116,6 @@ int Game::DrawGLScene(StereoSide side) { glColor4f(0,0,0,tutorialopac); text.glPrintOutline(startx-2*7.6*strlen(string)*screenwidth/1024-4,starty-4,string,1,1.5*1.25*screenwidth/1024,screenwidth,screenheight); - } tempnum=0; @@ -1168,14 +1124,11 @@ int Game::DrawGLScene(StereoSide side) if(dialoguetext[whichdialogue][indialogue][i]!='#')tempnum++; } - sprintf (string, "%s", tempname); - - int lastline; - int line=0; - bool done=0; - lastline=0; + int lastline = 0; + int line = 0; + bool done = false; i=0; while(!done){ if(string[i]=='\n'||string[i]>'z'||string[i]<' '||string[i]=='\0'){ @@ -1201,8 +1154,10 @@ int Game::DrawGLScene(StereoSide side) if(!tutoriallevel&&!winfreeze&&indialogue==-1&&!mainmenu){ if(campaign){ - if(!scoreadded)sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal);//(int)bonustotal); - if(scoreadded)sprintf (string, "Score: %d", (int)accountactive->getCampaignScore());//(int)bonustotal); + if(scoreadded) + sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()); + else + sprintf (string, "Score: %d", (int)accountactive->getCampaignScore()+(int)bonustotal); } if(!campaign)sprintf (string, "Score: %d", (int)bonustotal); glColor4f(0,0,0,1); @@ -1306,8 +1261,10 @@ int Game::DrawGLScene(StereoSide side) text.glPrint(10,260,string,0,.8,1024,768); - if(editorenabled)sprintf (string, "Map editor enabled."); - if(!editorenabled)sprintf (string, "Map editor Disabled."); + if(editorenabled) + sprintf (string, "Map editor enabled."); + else + sprintf (string, "Map editor disabled."); text.glPrint(10,60,string,0,.8,1024,768); if(editorenabled){ sprintf (string, "Object size: %f",editorsize); @@ -1320,18 +1277,44 @@ int Game::DrawGLScene(StereoSide side) text.glPrint(10,105,string,0,.8,1024,768); sprintf (string, "Object type: %d",editortype); text.glPrint(10,120,string,0,.8,1024,768); - if(editortype==boxtype)sprintf (string, "(box)"); - if(editortype==treetrunktype)sprintf (string, "(tree)"); - if(editortype==walltype)sprintf (string, "(wall)"); - if(editortype==weirdtype)sprintf (string, "(weird)"); - if(editortype==spiketype)sprintf (string, "(spike)"); - if(editortype==rocktype)sprintf (string, "(rock)"); - if(editortype==bushtype)sprintf (string, "(bush)"); - if(editortype==tunneltype)sprintf (string, "(tunnel)"); - if(editortype==chimneytype)sprintf (string, "(chimney)"); - if(editortype==platformtype)sprintf (string, "(platform)"); - if(editortype==cooltype)sprintf (string, "(cool)"); - if(editortype==firetype)sprintf (string, "(fire)"); + switch(editortype) { + case boxtype: + sprintf (string, "(box)"); + break; + case treetrunktype: + sprintf (string, "(tree)"); + break; + case walltype: + sprintf (string, "(wall)"); + break; + case weirdtype: + sprintf (string, "(weird)"); + break; + case spiketype: + sprintf (string, "(spike)"); + break; + case rocktype: + sprintf (string, "(rock)"); + break; + case bushtype: + sprintf (string, "(bush)"); + break; + case tunneltype: + sprintf (string, "(tunnel)"); + break; + case chimneytype: + sprintf (string, "(chimney)"); + break; + case platformtype: + sprintf (string, "(platform)"); + break; + case cooltype: + sprintf (string, "(cool)"); + break; + case firetype: + sprintf (string, "(fire)"); + break; + } text.glPrint(130,120,string,0,.8,1024,768); sprintf (string, "Numplayers: %d",numplayers); @@ -1339,17 +1322,8 @@ int Game::DrawGLScene(StereoSide side) sprintf (string, "Player %d: numwaypoints: %d",numplayers,player[numplayers-1].numwaypoints); text.glPrint(10,140,string,0,.8,1024,768); } - /*sprintf (string, "Coords are: %f %f %f",player[0].coords.x,player[0].coords.y,player[0].coords.z); - text.glPrint(10,200,string,0,.8,1024,768);*/ sprintf (string, "Difficulty: %d",difficulty); text.glPrint(10,240,string,0,.8,1024,768); - /* - sprintf (string, "lasthotspot: %d",hotspottype[numhotspots-1]); - text.glPrint(10,240,string,0,.8,1024,768); - sprintf (string, "killhotspot: %d",killhotspot); - text.glPrint(10,220,string,0,.8,1024,768); - sprintf (string, "winhotspot: %d",winhotspot); - text.glPrint(10,200,string,0,.8,1024,768);*/ } } @@ -1495,8 +1469,7 @@ int Game::DrawGLScene(StereoSide side) } if(minimap&&indialogue==-1){ - float mapviewdist; - mapviewdist=20000; + float mapviewdist = 20000; glDisable(GL_DEPTH_TEST); glColor3f (1.0, 1.0, 1.0); // no coloring @@ -1521,19 +1494,17 @@ int Game::DrawGLScene(StereoSide side) glEnable(GL_BLEND); glColor4f(1,1,1,1); glPushMatrix(); - float opac; - opac=.7; + float opac = .7; XYZ center; float radius; float distcheck; - center=0; int numliveplayers=0; + center = 0; for(i=0;i=60)offset=consoleselected-60; - sprintf (string, " ]"); - text.glPrint(10,30,string,0,1,1024,768); - if(consoleblink){ - sprintf (string, "_"); - text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768); - } - for(i=0;i<15;i++){ - for(j=0;j=60) + offset=consoleselected-60; + sprintf (string, " ]"); + text.glPrint(10,30,string,0,1,1024,768); + if(consoleblink){ + sprintf (string, "_"); + text.glPrint(30+(float)(consoleselected)*10-offset*10,30,string,0,1,1024,768); + } + for(i=0;i<15;i++){ + for(j=0;j> kContextWidth; + } else if ( !strncmp(setting, "Screenheight", 12) ) { + ipstream >> kContextHeight; + } else if ( !strncmp(setting, "Mouse sensitivity", 17) ) { + ipstream >> usermousesensitivity; + } else if ( !strncmp(setting, "Blur", 4) ) { + ipstream >> ismotionblur; + } else if ( !strncmp(setting, "Overall Detail", 14) ) { + ipstream >> detail; + if(detail!=0)kBitsPerPixel=32; + else kBitsPerPixel=16; + } else if ( !strncmp(setting, "Floating jump", 13) ) { + ipstream >> floatjump; + } else if ( !strncmp(setting, "Mouse jump", 10) ) { + ipstream >> mousejump; + } else if ( !strncmp(setting, "Ambient sound", 13) ) { + ipstream >> ambientsound; + } else if ( !strncmp(setting, "Blood ", 6) ) { + ipstream >> bloodtoggle; + } else if ( !strncmp(setting, "Auto slomo", 10) ) { + ipstream >> autoslomo; + } else if ( !strncmp(setting, "Foliage", 7) ) { + ipstream >> foliage; + } else if ( !strncmp(setting, "Music", 5) ) { + ipstream >> musictoggle; + } else if ( !strncmp(setting, "Trilinear", 9) ) { + ipstream >> trilinear; + } else if ( !strncmp(setting, "Decals", 6) ) { + ipstream >> decals; + } else if ( !strncmp(setting, "Invert mouse", 12) ) { + ipstream >> invertmouse; + } else if ( !strncmp(setting, "Gamespeed", 9) ) { + ipstream >> gamespeed; + oldgamespeed=gamespeed; + if(oldgamespeed==0){ + gamespeed=1; + oldgamespeed=1; + } + } else if ( !strncmp(setting, "Difficulty", 10) ) { + ipstream >> difficulty; + } else if ( !strncmp(setting, "Damage effects", 14) ) { + ipstream >> damageeffects; + } else if ( !strncmp(setting, "Text", 4) ) { + ipstream >> texttoggle; + } else if ( !strncmp(setting, "Debug", 5) ) { + ipstream >> debugmode; + } else if ( !strncmp(setting, "VBL Sync", 8) ) { + ipstream >> vblsync; + } else if ( !strncmp(setting, "Show Points", 11) ) { + ipstream >> showpoints; + } else if ( !strncmp(setting, "Always Blur", 11) ) { + ipstream >> alwaysblur; + } else if ( !strncmp(setting, "Immediate mode ", 15) ) { + ipstream >> immediate; + } else if ( !strncmp(setting, "Velocity blur", 13) ) { + ipstream >> velocityblur; + } else if ( !strncmp(setting, "Volume", 6) ) { + ipstream >> volume; + } else if ( !strncmp(setting, "Forward key", 11) ) { + ipstream.getline( string, sizeof(string) ); + game.forwardkey = Input::CharToKey(string); + } else if ( !strncmp(setting, "Back key", 8) ) { + ipstream.getline( string, sizeof(string) ); + game.backkey = Input::CharToKey(string); + } else if ( !strncmp(setting, "Left key", 8) ) { + ipstream.getline( string, sizeof(string) ); + game.leftkey = Input::CharToKey(string); + } else if ( !strncmp(setting, "Right key", 9) ) { + ipstream.getline( string, sizeof(string) ); + game.rightkey = Input::CharToKey(string); + } else if ( !strncmp(setting, "Jump key", 8) ) { + ipstream.getline( string, sizeof(string) ); + game.jumpkey = Input::CharToKey(string); + } else if ( !strncmp(setting, "Crouch key", 10) ) { + ipstream.getline( string, sizeof(string) ); + game.crouchkey = Input::CharToKey(string); + } else if ( !strncmp(setting, "Draw key", 8) ) { + ipstream.getline( string, sizeof(string) ); + game.drawkey = Input::CharToKey(string); + } else if ( !strncmp(setting, "Throw key", 9) ) { + ipstream.getline( string, sizeof(string) ); + game.throwkey = Input::CharToKey(string); + } else if ( !strncmp(setting, "Attack key", 10) ) { + ipstream.getline( string, sizeof(string) ); + game.attackkey = Input::CharToKey(string); + } else if ( !strncmp(setting, "Chat key", 8) ) { + ipstream.getline( string, sizeof(string) ); + game.chatkey = Input::CharToKey(string); + } else if ( !strncmp(setting, "Damage bar", 10) ) { + ipstream >> showdamagebar; + } else if ( !strncmp(setting, "StereoMode", 10) ) { + int i; + ipstream >> i; + stereomode = (StereoMode)i; + } else if ( !strncmp(setting, "StereoSeparation", 16) ) { + ipstream >> stereoseparation; + } else if ( !strncmp(setting, "StereoReverse", 13) ) { + ipstream >> stereoreverse; + } else { + ipstream >> string; + fprintf(stderr, "Unknown config option '%s' with value '%s'. Ignoring.\n", setting, string); + } + + if ( ipstream.fail() ) { + fprintf(stderr, "Error reading config file: EOF reached when trying to read value for setting '%s'.\n", setting); + ipstream.close(); + return false; + } + + if ( ipstream.bad() ) { + fprintf(stderr, "Error reading config file: Failed to read value for setting '%s'.\n", setting); + ipstream.close(); + return false; + } + } + + ipstream.close(); + + if(detail>2)detail=2; + if(detail<0)detail=0; + if(screenwidth<0)screenwidth=640; + if(screenheight<0)screenheight=480; + + return true; +} diff --git a/Source/Settings.h b/Source/Settings.h new file mode 100644 index 0000000..bae9910 --- /dev/null +++ b/Source/Settings.h @@ -0,0 +1,42 @@ +#ifndef SETTINGS_H_ +#define SETTINGS_H_ + +#include "Game.h" + +extern float usermousesensitivity; +extern bool ismotionblur; +extern bool floatjump; +extern bool mousejump; +extern bool ambientsound; +extern int bloodtoggle; +extern bool autoslomo; +extern bool foliage; +extern bool musictoggle; +extern bool trilinear; +extern bool decals; +extern bool invertmouse; +extern float gamespeed; +extern float oldgamespeed; +extern int difficulty; +extern bool damageeffects; +extern bool texttoggle; +extern bool debugmode; +extern bool vblsync; +extern bool showpoints; +extern bool showdamagebar; +extern bool alwaysblur; +extern bool immediate; +extern bool velocityblur; +extern float volume; +extern int detail; +extern int kBitsPerPixel; +extern int kContextWidth; +extern int kContextHeight; +extern float screenwidth,screenheight; + +void DefaultSettings(Game &game); +void SaveSettings(Game &game); +bool LoadSettings(Game &game); + + +#endif -- 2.39.5