diff options
Diffstat (limited to 'src/GameInitDispose.cpp')
-rw-r--r-- | src/GameInitDispose.cpp | 219 |
1 files changed, 51 insertions, 168 deletions
diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp index c11f3c1..f71cc02 100644 --- a/src/GameInitDispose.cpp +++ b/src/GameInitDispose.cpp @@ -475,113 +475,60 @@ void Game::InitGame() killedinnocent=0; //Haven't shot any civilians yet... if(customlevels){ //Load custom levels - nummissions=1; //Default level in case of load failure - type=randomshoot_type; - possiblegun[0]=handgun1; - possiblegun[1]=handgun2; - possiblegun[2]=shotgun; - numpossibleguns=3; - evilprobability=6; - person[0].whichgun=knife; - person[0].reloads[person[0].whichgun]=6; - if(!gameinprogress)score=0; - timeremaining=50; - difficulty=.8; + ifstream ipstream {"Data/customlevels.txt"}; - ifstream ipstream("Data/customlevels.txt"); - - if(!ipstream) { - - customlevels=0; - - } - - if(ipstream){ - + if (ipstream) { ipstream.ignore(256,'\n');//ignore descriptive text - - ipstream >> nummissions; - - for(int j=0;j<mission+1;j++){ - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> type; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> environment; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> numpossibleguns; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - for(int i=0;i<numpossibleguns;i++){ - - ipstream >> possiblegun[i]; - - } - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> evilprobability; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> person[0].whichgun; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> person[0].reloads[person[0].whichgun]; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> timeremaining; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> difficulty; - - ipstream.ignore(256,'\n'); - - } - - ipstream.close(); - + ipstream >> nummissions; + for(int j = 0; j < mission + 1; j++) { + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> type; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> environment; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> numpossibleguns; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + + for (int i = 0 ;i < numpossibleguns; i++) + ipstream >> possiblegun[i]; + + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> evilprobability; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> person[0].whichgun; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> person[0].reloads[person[0].whichgun]; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> timeremaining; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> difficulty; + ipstream.ignore(256,'\n'); + } + ipstream.close(); + } else { + customlevels=0; } - } if(!customlevels){ //Setup hardcoded default levels @@ -1142,33 +1089,24 @@ void Game::InitGame() if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); path.load((unsigned char *)":Data:Models:path.solid"); - path.Rotate(90,0,0); - path.Scale(.8,.8,.8); - path.CalculateNormals(); - //Fix block radius - - for(int i=0;i<4;i++){ - - blocks[i].boundingspherecenter.x=0; - - blocks[i].boundingspherecenter.z=0; - - blocks[i].boundingsphereradius=0; - - for(int x=0;i<blocks[x].vertexNum;x++){ - - if(findDistancefast(blocks[i].boundingspherecenter,blocks[i].vertex[x])>blocks[i].boundingsphereradius)blocks[i].boundingsphereradius=findDistancefast(blocks[i].boundingspherecenter,blocks[i].vertex[x]); - + // Fix block radius + for (int i = 0; i < 4; i++) { + auto center = blocks[i].boundingspherecenter; + center.x = center.y = center.z = 0; + + float radiusqr = 0.0; + for (int x = 0; x < blocks[i].vertexNum; x++) { + auto distance = findDistancefast(center, + blocks[i].vertex[x]); + if (distance > radiusqr) + radiusqr = distance; } - - blocks[i].boundingsphereradius=sqrt(blocks[i].boundingsphereradius); - + blocks[i].boundingsphereradius = sqrt(radiusqr); } - } mousesensitivity=1; @@ -2120,101 +2058,56 @@ void Game::InitGame() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //light - GLfloat LightAmbient[]= { .3, .3, .3, 1.0f}; - GLfloat LightDiffuse[]= { 1, 1, 1, 1.0f }; - glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); - glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); - glEnable(GL_LIGHT0); - loadingscreenamount+=5; //Load some textures - if(!initialized){ - LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - LoadPersonSpriteTexture(":Data:Textures:Personsprite.png",&personspritetextureptr); - LoadPersonSpriteTexture(":Data:Textures:DeadPersonsprite.png",&deadpersonspritetextureptr); - LoadPersonSpriteTexture(":Data:Textures:Scope.png",&scopetextureptr); - LoadPersonSpriteTexture(":Data:Textures:Flare.png",&flaretextureptr); - sprites.LoadFlareTexture(":Data:Textures:HitFlash.png"); - sprites.LoadMuzzleFlareTexture(":Data:Textures:MuzzleFlash.png"); - sprites.LoadSmokeTexture(":Data:Textures:Smoke.png"); - sprites.LoadBloodTexture(":Data:Textures:Blood.png"); - sprites.LoadRainTexture(":Data:Textures:rain.png"); - sprites.LoadSnowTexture(":Data:Textures:snow.png"); - decals.LoadBulletHoleTexture(":Data:Textures:BulletHole.png"); - decals.LoadCraterTexture(":Data:Textures:Crater.png"); - decals.LoadBloodTexture(":Data:Textures:Blood:Blood1.png",0); - decals.LoadBloodTexture(":Data:Textures:Blood:Blood2.png",1); - decals.LoadBloodTexture(":Data:Textures:Blood:Blood3.png",2); - decals.LoadBloodTexture(":Data:Textures:Blood:Blood4.png",3); - decals.LoadBloodTexture(":Data:Textures:Blood:Blood5.png",4); - decals.LoadBloodTexture(":Data:Textures:Blood:Blood6.png",5); - decals.LoadBloodTexture(":Data:Textures:Blood:Blood7.png",6); - decals.LoadBloodTexture(":Data:Textures:Blood:Blood8.png",7); - decals.LoadBloodTexture(":Data:Textures:Blood:Blood9.png",8); - decals.LoadBloodTexture(":Data:Textures:Blood:Blood10.png",9); - decals.LoadBloodTexture(":Data:Textures:Blood:Blood11.png",10); - } //Setup clip plane equation - eqn[0]=0; - eqn[1]=1; - eqn[2]=0; - eqn[3]=0; - glClearColor(fogcolorr,fogcolorg,fogcolorb,1); if(!initialized)InitMouse(); - //Draw city one frame to fix evil menu bug - if(!initialized)mainmenu=2; - if(!initialized){ - LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - flashamount=1; - flashr=1;flashg=1;flashb=1; - alSourcePlay(gSourceID[soulinsound]); - } initialized=1; @@ -2225,27 +2118,17 @@ void Game::InitGame() GLint swapInt = 1; /* - for(int i=0;i<sprites.howmanysprites;i++){ - sprites.DeleteSprite(0); - } - for(int i=0;i<decals.howmanydecals;i++){ - decals.DeleteDecal(0); - }*/ decals.howmanydecals=0; - sprites.howmanysprites=0; - losedelay=1; - oldscore=score; - } /*********************> InitGL() <*****/ |