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;
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);
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);
}
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();
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)
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);
}
+ }
}
}
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);
+ }
}
}
}
}
}
- //}
glPushMatrix();
glEnable(GL_TEXTURE_2D);
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'){
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';
}
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);
{
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;
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'){
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);
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);
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);
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);*/
}
}
}
if(minimap&&indialogue==-1){
- float mapviewdist;
- mapviewdist=20000;
+ float mapviewdist = 20000;
glDisable(GL_DEPTH_TEST);
glColor3f (1.0, 1.0, 1.0); // no coloring
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){
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;
}
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){
if(drawmode==motionblurmode){
glDrawBuffer(GL_FRONT);
glReadBuffer(GL_BACK);
- //myassert(glGetError() == GL_NO_ERROR);
- //glFlush();
}
glColor3f (1.0, 1.0, 1.0); // no coloring
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);
}
}
}
--- /dev/null
+#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;
+}