]> git.jsancho.org Git - lugaru.git/commitdiff
Adding back Settings files. (sorry about that).
authorCôme BERNIGAUD <come.bernigaud@gmail.com>
Sun, 6 Jun 2010 03:37:25 +0000 (05:37 +0200)
committerCôme BERNIGAUD <come.bernigaud@gmail.com>
Sun, 6 Jun 2010 03:37:25 +0000 (05:37 +0200)
Some clean up again.
And removing some unused functions (MD5)

Source/Game.h
Source/GameDraw.cpp
Source/GameTick.cpp
Source/MacCompatibility.h
Source/Settings.cpp [new file with mode: 0644]
Source/Settings.h [new file with mode: 0644]

index edf867a1d40a05082bc8a10dc646c281c56badc0..babc7413fff904f0d9ceb9657ae017344d52b0f4 100644 (file)
@@ -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__); } }
index f67ae5f2ba0ce90a2c13828a6b7c161c36b394a3..888a7b452ac9721bbe01fe7392371ffd9877945d 100644 (file)
@@ -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(num<LONGLONGCONST(5000000000000000)){
-               num*=1.85421521;
-       }
-
-       while(num>LONGLONGCONST(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)<multiplier*10||abs(blurness-targetblurness)>2){
                        blurness=targetblurness;
                        targetblurness=(float)(abs(Random()%100))/40;
                }
-               if(blurness<targetblurness)blurness+=multiplier*5;
-               if(blurness>targetblurness)blurness-=multiplier*5;
+               if(blurness<targetblurness) 
+                       blurness+=multiplier*5;
+               else
+                       blurness-=multiplier*5;
 
                //glFinish();
                static XYZ terrainlight;
                static float distance;
-               //if(drawmode==normalmode)ReSizeGLScene(90,.1);
                if(drawmode==normalmode)ReSizeGLScene(90,.1f);
                if(drawmode!=normalmode)glViewport(0,0,texviewwidth,texviewheight);     
                glDepthFunc(GL_LEQUAL);
@@ -359,7 +326,6 @@ int Game::DrawGLScene(StereoSide side)
                        glRotatef(rotation+sin(woozy)*(player[0].damage/player[0].damagetolerance)*5,0,1,0);
                }
                if(cameramode||freeze||winfreeze){
-                       //glRotatef(float(Random()%100)/10*camerashake/*+(woozy*woozy)/10*/,0,0,1);
                        glRotatef(rotation2,1,0,0);
                        glRotatef(rotation,0,1,0);
                }
@@ -367,8 +333,6 @@ int Game::DrawGLScene(StereoSide side)
                if(environment==desertenvironment){
                        glRotatef((float)(abs(Random()%100))/3000-1,1,0,0);
                        glRotatef((float)(abs(Random()%100))/3000-1,0,1,0);
-                       //glRotatef(blurness/40-1,1,0,0);
-                       //glRotatef(blurness/40-1,0,1,0);
                }
                SetUpLight(&light,0);
                glPushMatrix();
@@ -399,19 +363,18 @@ 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,rotation);
-                                                       if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
-                                                               for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
-                                                                       j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
-                                                                       if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
-                                                                               point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
-                                                                               size=.4f;
-                                                                               opacity=.4f;
-                                                                               if(k!=0&&tutoriallevel==1){
-                                                                                       opacity=.2+.2*sin(smoketex*6+i);
-                                                                               }
-                                                                               objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
+                                                       for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
+                                                               j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
+                                                               if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
+                                                                       point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
+                                                                       size=.4f;
+                                                                       opacity=.4f;
+                                                                       if(k!=0&&tutoriallevel==1){
+                                                                               opacity=.2+.2*sin(smoketex*6+i);
                                                                        }
+                                                                       objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
                                                                }
+                                                       }
                                                }
                                        }
                                        if((player[k].skeleton.free||player[k].howactive>=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<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
-                                                                                       j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
-                                                                                       if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
-                                                                                               if(player[k].skeleton.free)point=DoRotation(player[k].skeleton.joints[i].position*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
-                                                                                               else point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
-                                                                                               size=.4f;
-                                                                                               opacity=.4f;
-                                                                                               if(k!=0&&tutoriallevel==1){
-                                                                                                       opacity=.2+.2*sin(smoketex*6+i);
-                                                                                               }
-                                                                                               objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
+                                                                       for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
+                                                                               j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
+                                                                               if(objects.position[j].y<player[k].coords.y||objects.type[j]==tunneltype||objects.type[j]==weirdtype){
+                                                                                       if(player[k].skeleton.free)point=DoRotation(player[k].skeleton.joints[i].position*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
+                                                                                       else point=DoRotation(DoRotation(player[k].skeleton.joints[i].position,0,player[k].rotation,0)*player[k].scale+player[k].coords-objects.position[j],0,-objects.rotation[j],0);
+                                                                                       size=.4f;
+                                                                                       opacity=.4f;
+                                                                                       if(k!=0&&tutoriallevel==1){
+                                                                                               opacity=.2+.2*sin(smoketex*6+i);
                                                                                        }
+                                                                                       objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
                                                                                }
+                                                                       }
                                                                }
                                                        }
 
@@ -450,14 +412,13 @@ int Game::DrawGLScene(StereoSide side)
                                                                        size=.7;
                                                                        opacity=.4-(player[k].coords.y-terrain.getHeight(player[k].coords.x,player[k].coords.z))/5;
                                                                        terrain.MakeDecal(shadowdecal,point,size,opacity*.7,rotation);
-                                                                       if(terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz])
-                                                                               for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
-                                                                                       j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
-                                                                                       point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
-                                                                                       size=.7;
-                                                                                       opacity=.4f;
-                                                                                       objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
-                                                                               }
+                                                                       for(l=0;l<terrain.patchobjectnum[player[k].whichpatchx][player[k].whichpatchz];l++){
+                                                                               j=terrain.patchobjects[player[k].whichpatchx][player[k].whichpatchz][l];
+                                                                               point=DoRotation(player[k].coords-objects.position[j],0,-objects.rotation[j],0);
+                                                                               size=.7;
+                                                                               opacity=.4f;
+                                                                               objects.model[j].MakeDecal(shadowdecal,&point,&size,&opacity,&rotation);
+                                                                       }
                                                                }
                }
 
@@ -583,7 +544,6 @@ int Game::DrawGLScene(StereoSide side)
                                }
                        }
                }
-               //}
 
                glPushMatrix();
                glEnable(GL_TEXTURE_2D);
@@ -1013,10 +973,9 @@ int Game::DrawGLScene(StereoSide side)
 
                                                        sprintf (string, "%s", hotspottext[closest]);
 
-                                                       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'){
@@ -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<numplayers;i++){
-                               if(!player[i].dead)numliveplayers++;
+                               if(!player[i].dead) numliveplayers++;
                        }
 
-                       int numadd;
-                       numadd=0;
+                       int numadd = 0;
 
                        for(i=0;i<objects.numobjects;i++){
                                if(objects.type[i]==treetrunktype||objects.type[i]==boxtype){
@@ -1772,16 +1743,14 @@ int Game::DrawGLScene(StereoSide side)
                        glEnable(GL_TEXTURE_2D);
 
                        //Awards
-                       int numawards;
+                       int numawards = 0;
                        int awards[30];
-                       numawards=0;
 
                        if(damagetaken==0&&player[0].bloodloss==0){
                                awards[numawards]=awardflawless;
                                numawards++;
                        }
-                       bool alldead;
-                       alldead=1;
+                       bool alldead = true;
                        for(i=1;i<numplayers;i++){              
                                if(player[i].dead!=2)alldead=0;
                        }
@@ -1850,59 +1819,58 @@ int Game::DrawGLScene(StereoSide side)
                                numawards++;
                        }
 
+                       //Win Screen Won Victory
 
-                                               //Win Screen Won Victory
-
-                                               glEnable(GL_TEXTURE_2D);
-                                               glColor4f(1,1,1,1);
-                                               sprintf (string, "Level Cleared!");
-                                               text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
-
-                                               sprintf (string, "Score:     %d",(int)(bonustotal-startbonustotal));
-                                               text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
-
-                                               if(!campaign)sprintf (string, "Press Escape to return to menu or Space to continue");
-                                               if(campaign)sprintf (string, "Press Escape or Space to continue");
-                                               text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
-
-                                               char temp[255];
-
-                                               for(i=0;i<255;i++)string[i]='\0';
-                                               sprintf (temp, "Time:      %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
-                                               strcat(string,temp);
-                                               if((int)(leveltime)%60<10)strcat(string,"0");
-                                               sprintf (temp, "%d",(int)(leveltime)%60);
-                                               strcat(string,temp);
-                                               text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
-
-                                               for(i=0;i<numawards;i++){
-                                                       if(i<6){
-                                                               if(awards[i]==awardklutz)sprintf (string, "Suicidal");
-                                                               if(awards[i]==awardflawless)sprintf (string, "Flawless!");
-                                                               if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
-                                                               if(awards[i]==awardnodead)sprintf (string, "Merciful");
-                                                               if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
-                                                               if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
-                                                               if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
-                                                               if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
-                                                               if(awards[i]==awardcoward)sprintf (string, "Coward");
-                                                               if(awards[i]==awardevasion)sprintf (string, "Escape artist");
-                                                               if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
-                                                               if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
-                                                               if(awards[i]==awardbrutal)sprintf (string, "Brutal");
-                                                               if(awards[i]==awardhyper)sprintf (string, "Hyper");
-                                                               if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
-                                                               if(awards[i]==awardrambo)sprintf (string, "Rambo");
-                                                               if(awards[i]==awardfast)sprintf (string, "Fast");
-                                                               if(awards[i]==awardrealfast)sprintf (string, "Real fast");
-                                                               if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
-                                                               if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
-                                                               if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
-                                                               text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
-                                                       }
-                                               }
-
-                                               //drawmode=normalmode;
+                       glEnable(GL_TEXTURE_2D);
+                       glColor4f(1,1,1,1);
+                       sprintf (string, "Level Cleared!");
+                       text.glPrintOutlined(1024/2-strlen(string)*10,768*7/8,string,1,2,1024,768);
+
+                       sprintf (string, "Score:     %d",(int)(bonustotal-startbonustotal));
+                       text.glPrintOutlined(1024/30,768*6/8,string,1,2,1024,768);
+
+                       if(campaign)
+                               sprintf (string, "Press Escape or Space to continue");
+                       else
+                               sprintf (string, "Press Escape to return to menu or Space to continue");
+                       text.glPrintOutlined(640/2-strlen(string)*5,480*1/16,string,1,1,640,480);
+
+                       char temp[255];
+
+                       for(i=0;i<255;i++)string[i]='\0';
+                       sprintf (temp, "Time:      %d:",(int)(((int)leveltime-(int)(leveltime)%60)/60));
+                       strcat(string,temp);
+                       if((int)(leveltime)%60<10)strcat(string,"0");
+                       sprintf (temp, "%d",(int)(leveltime)%60);
+                       strcat(string,temp);
+                       text.glPrintOutlined(1024/30,768*6/8-40,string,1,2,1024,768);
+
+                       for(i=0;i<numawards;i++){
+                               if(i<6){
+                                       if(awards[i]==awardklutz)sprintf (string, "Suicidal");
+                                       if(awards[i]==awardflawless)sprintf (string, "Flawless!");
+                                       if(awards[i]==awardalldead)sprintf (string, "Take no prisoners");
+                                       if(awards[i]==awardnodead)sprintf (string, "Merciful");
+                                       if(awards[i]==awardstealth)sprintf (string, "One with the shadows!");
+                                       if(awards[i]==awardswordsman)sprintf (string, "Swordsman");
+                                       if(awards[i]==awardkungfu)sprintf (string, "Unarmed!");
+                                       if(awards[i]==awardknifefighter)sprintf (string, "Knife fighter");
+                                       if(awards[i]==awardcoward)sprintf (string, "Coward");
+                                       if(awards[i]==awardevasion)sprintf (string, "Escape artist");
+                                       if(awards[i]==awardacrobat)sprintf (string, "Gymnast");
+                                       if(awards[i]==awardlongrange)sprintf (string, "Blade slinger");
+                                       if(awards[i]==awardbrutal)sprintf (string, "Brutal");
+                                       if(awards[i]==awardhyper)sprintf (string, "Hyper");
+                                       if(awards[i]==awardaikido)sprintf (string, "Aikido master!");
+                                       if(awards[i]==awardrambo)sprintf (string, "Rambo");
+                                       if(awards[i]==awardfast)sprintf (string, "Fast");
+                                       if(awards[i]==awardrealfast)sprintf (string, "Real fast");
+                                       if(awards[i]==awarddamnfast)sprintf (string, "Damn fast");
+                                       if(awards[i]==awardstrategy)sprintf (string, "Divide and conquer");
+                                       if(awards[i]==awardbojutsu)sprintf (string, "Bojutsu");
+                                       text.glPrintOutlined(1024/30,768*6/8-90-40*i,string,1,2,1024,768);
+                               }
+                       }
                }
 
                if(drawmode!=normalmode){
@@ -1954,8 +1922,6 @@ int Game::DrawGLScene(StereoSide side)
                        if(drawmode==motionblurmode){
                                glDrawBuffer(GL_FRONT);
                                glReadBuffer(GL_BACK);
-                               //myassert(glGetError() == GL_NO_ERROR);
-                               //glFlush();
                        }
                        glColor3f (1.0, 1.0, 1.0); // no coloring
 
@@ -2158,23 +2124,21 @@ int Game::DrawGLScene(StereoSide side)
                if(console){
                        glEnable(GL_TEXTURE_2D);
                        glColor4f(1,1,1,1);
-                       if(console){
-                               int offset;
-                               offset=0;
-                               if(consoleselected>=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<consolechars[i];j++){
-                                               glColor4f(1,1,1,1-(float)(i)/16);
-                                               if(j<consolechars[i]){
-                                                       sprintf (string, "%c",consoletext[i][j]);
-                                                       text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
-                                               }
+                       int offset = 0;
+                       if(consoleselected>=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<consolechars[i];j++){
+                                       glColor4f(1,1,1,1-(float)(i)/16);
+                                       if(j<consolechars[i]){
+                                               sprintf (string, "%c",consoletext[i][j]);
+                                               text.glPrint(30+j*10-offset*10,30+i*20,string,0,1,1024,768);
                                        }
                                }
                        }
index f8322fdc7422b3c07540c685e7c28390258586f0..2e3cd8303aff75a4b43154f37f172671104dc70a 100644 (file)
@@ -49,7 +49,6 @@ extern float texscale;
 extern Terrain terrain;
 extern OPENAL_SAMPLE *samp[100];
 extern int channels[100];
-//extern Sprites sprites;
 extern int kTextureSize;
 extern float screenwidth,screenheight;
 extern float gravity;
@@ -1574,26 +1573,6 @@ void     Game::Loadlevel(int which){
        whichlevel=which;
 }
 
-/*char * Game::MD5_string (unsigned char *string){
-char temp[50];
-char temp2[100];
-
-strcpy(temp2,(const char *)string);
-strcat((char *)temp2,(const char *)"Lugaru");
-sprintf (temp, "%d",strlen((char *)temp2));
-strcat((char *)temp2,temp);
-
-MD5 context;
-unsigned int len = strlen ( (char *)temp2);
-
-context.update   ((unsigned char *)temp2, len);
-context.finalize ();
-
-return context.hex_digest();
-}*/
-
-
-
 void   Game::Loadlevel(char *name){
        int i,j,k,l,m;
        static int oldlevel;
index 1b6894001ffedf604aecaec76cd59625c8c68731..e9b2905f714219e2b6d98ac65311450913a442a6 100644 (file)
@@ -112,12 +112,6 @@ char* ConvertFileName( const char* orgfilename, const char *mode = "rb" );
 
 #define fopen( a, b) fopen(ConvertFileName(a, b), b)
 
-__forceinline long long longlongabs( long long f)
-{
-       if (f < 0)
-               return -f;
-       return f;
-}
 #endif
 #endif
 
diff --git a/Source/Settings.cpp b/Source/Settings.cpp
new file mode 100644 (file)
index 0000000..26a404c
--- /dev/null
@@ -0,0 +1,282 @@
+#include "Settings.h"
+#include "Game.h"
+#include "Input.h"
+
+void DefaultSettings(Game &game) {
+       detail=1;
+       ismotionblur=0;
+       usermousesensitivity=1;
+       kContextWidth=640;
+       kContextHeight=480;
+       kBitsPerPixel = 32;
+       floatjump=0;
+       autoslomo=1;
+       decals=1;
+       invertmouse=0;
+       bloodtoggle=0;
+       foliage=1;
+       musictoggle=1;
+       trilinear=1;
+       gamespeed=1;
+       difficulty=1;
+       damageeffects=0;
+       texttoggle=1;
+       alwaysblur=0;
+       showpoints=0;
+       showdamagebar=0;
+       immediate=0;
+       velocityblur=0;
+       volume = 0.8f;
+       ambientsound=1;
+       vblsync=0;
+       debugmode=0;
+       
+       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) {
+       ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
+       opstream << "Screenwidth:\n";
+       opstream << game.newscreenwidth;
+       opstream << "\nScreenheight:\n";
+       opstream << game.newscreenheight;
+       opstream << "\nMouse sensitivity:\n";
+       opstream << usermousesensitivity;
+       opstream << "\nBlur(0,1):\n";
+       opstream << ismotionblur;
+       opstream << "\nOverall Detail(0,1,2) higher=better:\n";
+       opstream << game.newdetail;
+       opstream << "\nFloating jump:\n";
+       opstream << floatjump;
+       opstream << "\nMouse jump:\n";
+       opstream << mousejump;
+       opstream << "\nAmbient sound:\n";
+       opstream << ambientsound;
+       opstream << "\nBlood (0,1,2):\n";
+       opstream << bloodtoggle;
+       opstream << "\nAuto slomo:\n";
+       opstream << autoslomo;
+       opstream << "\nFoliage:\n";
+       opstream << foliage;
+       opstream << "\nMusic:\n";
+       opstream << musictoggle;
+       opstream << "\nTrilinear:\n";
+       opstream << trilinear;
+       opstream << "\nDecals(shadows,blood puddles,etc):\n";
+       opstream << decals;
+       opstream << "\nInvert mouse:\n";
+       opstream << invertmouse;
+       opstream << "\nGamespeed:\n";
+       if(oldgamespeed==0)oldgamespeed=1;
+       opstream << oldgamespeed;
+       opstream << "\nDifficulty(0,1,2) higher=harder:\n";
+       opstream << difficulty;
+       opstream << "\nDamage effects(blackout, doublevision):\n";
+       opstream << damageeffects;
+       opstream << "\nText:\n";
+       opstream << texttoggle;
+       opstream << "\nDebug:\n";
+       opstream << debugmode;
+       opstream << "\nVBL Sync:\n";
+       opstream << vblsync;
+       opstream << "\nShow Points:\n";
+       opstream << showpoints;
+       opstream << "\nAlways Blur:\n";
+       opstream << alwaysblur;
+       opstream << "\nImmediate mode (turn on on G5):\n";
+       opstream << immediate;
+       opstream << "\nVelocity blur:\n";
+       opstream << velocityblur;
+       opstream << "\nVolume:\n";
+       opstream << volume;
+       opstream << "\nForward key:\n";
+       opstream << Input::keyToChar(game.forwardkey);
+       opstream << "\nBack key:\n";
+       opstream << Input::keyToChar(game.backkey);
+       opstream << "\nLeft key:\n";
+       opstream << Input::keyToChar(game.leftkey);
+       opstream << "\nRight key:\n";
+       opstream << Input::keyToChar(game.rightkey);
+       opstream << "\nJump key:\n";
+       opstream << Input::keyToChar(game.jumpkey);
+       opstream << "\nCrouch key:\n";
+       opstream << Input::keyToChar(game.crouchkey);
+       opstream << "\nDraw key:\n";
+       opstream << Input::keyToChar(game.drawkey);
+       opstream << "\nThrow key:\n";
+       opstream << Input::keyToChar(game.throwkey);
+       opstream << "\nAttack key:\n";
+       opstream << Input::keyToChar(game.attackkey);
+       opstream << "\nChat key:\n";
+       opstream << Input::keyToChar(game.chatkey);
+       opstream << "\nDamage bar:\n";
+       opstream << showdamagebar;
+       opstream << "\nStereoMode:\n";
+       opstream << stereomode;
+       opstream << "\nStereoSeparation:\n";
+       opstream << stereoseparation;
+       opstream << "\nStereoReverse:\n";
+       opstream << stereoreverse;
+       opstream.close();
+}
+
+bool LoadSettings(Game &game) {
+       ifstream ipstream(ConvertFileName(":Data:config.txt"), std::ios::in);
+       if ( !ipstream || ipstream.fail() ) {
+               printf("Config file not found\n");
+               return false;
+       }
+       char setting[256];
+       char string[256];
+       
+       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
+               if ( strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t') continue;
+
+               if ( ipstream.eof() || ipstream.fail() ) {
+                       fprintf(stderr, "Error reading config file: Got setting name '%s', but value can't be read\n", setting);
+                       ipstream.close();                       
+                       return false;
+               }
+               
+       
+               if ( !strncmp(setting, "Screenwidth", 11) ) {
+                       ipstream >> 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 (file)
index 0000000..bae9910
--- /dev/null
@@ -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