From: sf17k Date: Fri, 6 May 2011 01:20:11 +0000 (-0400) Subject: cleanup X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=483f57f7df7e65f1aacbee8dbcef320ede069a95;p=lugaru.git cleanup --- diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index db565c2..79d8bd1 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -61,7 +61,6 @@ extern long dirID; extern int mainmenu; extern int oldmainmenu; extern bool visibleloading; -extern int loadscreencolor; extern float flashamount,flashr,flashg,flashb; extern int flashdelay; extern int whichjointstartarray[26]; @@ -418,14 +417,6 @@ void Game::LoadingScreen() glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_BLEND); glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1); - //glColor4f(1,1,1,1); - /*if(loadscreencolor==0)glColor4f(1,1,1,1); - if(loadscreencolor==1)glColor4f(1,0,0,1); - if(loadscreencolor==2)glColor4f(0,1,0,1); - if(loadscreencolor==3)glColor4f(0,0,1,1); - if(loadscreencolor==4)glColor4f(1,1,0,1); - if(loadscreencolor==5)glColor4f(1,0,1,1); - */ glPushMatrix(); //glScalef(.25,.25,.25); glBegin(GL_QUADS); @@ -482,13 +473,6 @@ void Game::LoadingScreen() glEnable(GL_BLEND); //glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1); glColor4f(loadprogress/100,loadprogress/100,loadprogress/100,1); - /*if(loadscreencolor==0)glColor4f(1,1,1,1); - if(loadscreencolor==1)glColor4f(1,0,0,1); - if(loadscreencolor==2)glColor4f(0,1,0,1); - if(loadscreencolor==3)glColor4f(0,0,1,1); - if(loadscreencolor==4)glColor4f(1,1,0,1); - if(loadscreencolor==5)glColor4f(1,0,1,1); - */ glPushMatrix(); //glScalef(.25,.25,.25); glBegin(GL_QUADS); @@ -600,7 +584,6 @@ void Game::LoadingScreen() } swap_gl_buffers(); - loadscreencolor=0; } } @@ -641,13 +624,6 @@ void Game::FadeLoadingScreen(float howmuch) glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_BLEND); glColor4f(loadprogress/100,0,0,1); - /*if(loadscreencolor==0)glColor4f(1,1,1,1); - if(loadscreencolor==1)glColor4f(1,0,0,1); - if(loadscreencolor==2)glColor4f(0,1,0,1); - if(loadscreencolor==3)glColor4f(0,0,1,1); - if(loadscreencolor==4)glColor4f(1,1,0,1); - if(loadscreencolor==5)glColor4f(1,0,1,1); - */ glPushMatrix(); //glScalef(.25,.25,.25); glBegin(GL_QUADS); @@ -679,7 +655,6 @@ void Game::FadeLoadingScreen(float howmuch) text.glPrint(280,125,string,1,1,640,480); */ swap_gl_buffers(); - loadscreencolor=0; } @@ -1156,7 +1131,6 @@ void Game::LoadStuff() } } - loadscreencolor=4; LoadingScreen(); for(i=0;i0&&player[0].num_weapons<5) - for(int j=0;j0&&player[0].num_weapons<5) + for(int j=0;jnumpathpoints); + fpackf(tfile, "Bi", game->numpathpoints); for(int j=0;jnumpathpoints;j++){ fpackf(tfile, "Bf Bf Bf Bi", game->pathpoint[j].x, game->pathpoint[j].y, game->pathpoint[j].z, game->numpathpointconnect[j]); - for(int k=0;knumpathpointconnect[j];k++){ + for(int k=0;knumpathpointconnect[j];k++) fpackf(tfile, "Bi", game->pathpointconnect[j][k]); - } } - fpackf(tfile, "Bf Bf Bf Bf", game->mapcenter.x, game->mapcenter.y, game->mapcenter.z, game->mapradius); + fpackf(tfile, "Bf Bf Bf Bf", game->mapcenter.x, game->mapcenter.y, game->mapcenter.z, game->mapradius); - fclose(tfile); + fclose(tfile); } static void ch_cellar(Game *game, const char *args) @@ -1402,7 +1401,7 @@ void Game::Setenvironment(int which) } -void Game::Loadlevel(int which){ +void Game::Loadlevel(int which){ stealthloading=0; whichlevel=which; @@ -1417,7 +1416,7 @@ void Game::Loadlevel(int which){ Loadlevel("mapsave"); } -void Game::Loadlevel(const char *name){ +void Game::Loadlevel(const char *name){ static int oldlevel; int templength; float lamefloat; @@ -1431,27 +1430,30 @@ void Game::Loadlevel(const char *name){ LOG(std::string("Loading level...") + name); - if(!gameon)visibleloading=1; - - if(stealthloading)visibleloading=0; - - if(!stillloading)loadtime=0; + if(!gameon) + visibleloading=1; + if(stealthloading) + visibleloading=0; + if(!stillloading) + loadtime=0; gamestarted=1; numenvsounds=0; //visibleloading=1; - if(tutoriallevel!=-1)tutoriallevel=0; - else tutoriallevel=1; + if(tutoriallevel!=-1) + tutoriallevel=0; + else + tutoriallevel=1; - if(tutoriallevel==1)tutorialstage=0; + if(tutoriallevel==1) + tutorialstage=0; if(tutorialstage==0){ tutorialstagetime=0; tutorialmaxtime=1; } loadingstuff=1; - if(!firstload){ + if(!firstload) oldlevel=50; - } pause_sound(whooshsound); pause_sound(stream_firesound); @@ -1461,29 +1463,21 @@ void Game::Loadlevel(const char *name){ const char *FixedFN = ConvertFileName(buf); int mapvers; - FILE *tfile; + FILE *tfile; tfile=fopen( FixedFN, "rb" ); - if(tfile) - { + if(tfile){ pause_sound(stream_firesound); - - scoreadded=0; windialogue=0; - hostiletime=0; - won=0; - //campaign=0; animation[bounceidleanim].Load((char *)"Idle",middleheight,neutral); numdialogues=0; for(int i=0;i<20;i++) - { dialoguegonethrough[i]=0; - } indialogue=-1; cameramode=0; @@ -1491,10 +1485,13 @@ void Game::Loadlevel(const char *name){ damagedealt=0; damagetaken=0; - if(accountactive)difficulty=accountactive->getDifficulty(); + if(accountactive) + difficulty=accountactive->getDifficulty(); - if(difficulty!=2)minimap=1; - else minimap=0; + if(difficulty!=2) + minimap=1; + else + minimap=0; numhotspots=0; currenthotspot=-1; @@ -1509,9 +1506,7 @@ void Game::Loadlevel(const char *name){ winfreeze=0; for(int i=0;i<100;i++) - { bonusnum[i]=0; - } numfalls=0; numflipfail=0; @@ -1534,84 +1529,83 @@ void Game::Loadlevel(const char *name){ bonus=0; gameon=1; changedelay=0; - if(console) - { + if(console){ emit_sound_np(consolesuccesssound); freeze=0; console=0; } - if(!stealthloading) - { + if(!stealthloading){ terrain.numdecals=0; Sprite::deleteSprites(); for(int i=0;i=15)funpackf(tfile, "Bi", &indemo); - else indemo=0; - if(mapvers>=5)funpackf(tfile, "Bi", &maptype); - else maptype=mapkilleveryone; - if(mapvers>=6)funpackf(tfile, "Bi", &hostile); - else hostile=1; - if(mapvers>=4)funpackf(tfile, "Bf Bf", &viewdistance, &fadestart); + if(mapvers>=15) + funpackf(tfile, "Bi", &indemo); + else + indemo=0; + if(mapvers>=5) + funpackf(tfile, "Bi", &maptype); + else + maptype=mapkilleveryone; + if(mapvers>=6) + funpackf(tfile, "Bi", &hostile); else - { + hostile=1; + if(mapvers>=4) + funpackf(tfile, "Bf Bf", &viewdistance, &fadestart); + else{ viewdistance=100; fadestart=.6; } - if(mapvers>=2)funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb); - else - { + if(mapvers>=2) + funpackf(tfile, "Bb Bf Bf Bf", &skyboxtexture, &skyboxr, &skyboxg, &skyboxb); + else{ skyboxtexture=1; skyboxr=1; skyboxg=1; skyboxb=1; } - if(mapvers>=10)funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb); - else - { + if(mapvers>=10) + funpackf(tfile, "Bf Bf Bf", &skyboxlightr, &skyboxlightg, &skyboxlightb); + else{ skyboxlightr=skyboxr; skyboxlightg=skyboxg; skyboxlightb=skyboxb; } - if(!stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &player[0].coords.x,&player[0].coords.y,&player[0].coords.z,&player[0].rotation,&player[0].targetrotation, &player[0].num_weapons); - if(stealthloading)funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons); + if(!stealthloading) + funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &player[0].coords.x,&player[0].coords.y,&player[0].coords.z,&player[0].rotation,&player[0].targetrotation, &player[0].num_weapons); + if(stealthloading) + funpackf(tfile, "Bf Bf Bf Bf Bf Bi", &lamefloat,&lamefloat,&lamefloat,&lamefloat,&lamefloat, &player[0].num_weapons); player[0].originalcoords=player[0].coords; if(player[0].num_weapons>0&&player[0].num_weapons<5) - { - for(int j=0;j=9) - { funpackf(tfile, "Bi Bi", &player[0].whichskin, &player[0].creature); - } - else - { + else{ player[0].whichskin=0; player[0].creature=rabbittype; } @@ -1634,130 +1625,108 @@ void Game::Loadlevel(const char *name){ player[0].lastattack2=-1; player[0].lastattack3=-1; - if(mapvers>=8) - { + //dialogues + if(mapvers>=8){ funpackf(tfile, "Bi", &numdialogues); - if(numdialogues) - { - for(int k=0;k128||templength<=0)templength=128; - int m; - for(m=0;m64||templength<=0)templength=64; - for(m=0;m128||templength<=0) + templength=128; + int m; + for(m=0;m64||templength<=0)templength=64; + for(m=0;m=7) - { + if(mapvers>=7){ funpackf(tfile, "Bi", &numhotspots); - if(numhotspots) - { - for(int i=0;imaxdistance) - { + if(tempdist>maxdistance){ whichclosest=i; maxdistance=tempdist; } @@ -1765,40 +1734,45 @@ void Game::Loadlevel(const char *name){ objects.radius=fast_sqrt(maxdistance); } - if(visibleloading){loadscreencolor=4; LoadingScreen();} + if(visibleloading) + LoadingScreen(); //mapcenter=objects.center; //mapradius=objects.radius; funpackf(tfile, "Bi", &numplayers); int howmanyremoved=0; bool removeanother=0; - if(numplayers>1&&numplayers1&&numplayers=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive); - else player[i-howmanyremoved].howactive=typeactive; - if(mapvers>=3)funpackf(tfile, "Bf",&player[i-howmanyremoved].scale); - else player[i-howmanyremoved].scale=-1; - if(mapvers>=11)funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile); - else player[i-howmanyremoved].immobile=0; - if(mapvers>=12)funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation); - else player[i-howmanyremoved].rotation=0; + if(mapvers>=5) + funpackf(tfile, "Bi", &player[i-howmanyremoved].howactive); + else + player[i-howmanyremoved].howactive=typeactive; + if(mapvers>=3) + funpackf(tfile, "Bf",&player[i-howmanyremoved].scale); + else + player[i-howmanyremoved].scale=-1; + if(mapvers>=11) + funpackf(tfile, "Bb",&player[i-howmanyremoved].immobile); + else + player[i-howmanyremoved].immobile=0; + if(mapvers>=12) + funpackf(tfile, "Bf",&player[i-howmanyremoved].rotation); + else + player[i-howmanyremoved].rotation=0; player[i-howmanyremoved].targetrotation=player[i-howmanyremoved].rotation; if(player[i-howmanyremoved].num_weapons<0||player[i-howmanyremoved].num_weapons>5){ removeanother=1; howmanyremoved++; } - if(!removeanother) - { - if(player[i-howmanyremoved].num_weapons>0&&player[i-howmanyremoved].num_weapons<5) - { - for(int j=0;j0&&player[i-howmanyremoved].num_weapons<5){ + for(int j=0;j=5)funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]); - else player[i-howmanyremoved].waypointtype[j] = wpkeepwalking; + if(mapvers>=5) + funpackf(tfile, "Bi", &player[i-howmanyremoved].waypointtype[j]); + else + player[i-howmanyremoved].waypointtype[j] = wpkeepwalking; } funpackf(tfile, "Bi", &player[i-howmanyremoved].waypoint); - if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1)player[i-howmanyremoved].waypoint=0; + if(player[i-howmanyremoved].waypoint>player[i-howmanyremoved].numwaypoints-1) + player[i-howmanyremoved].waypoint=0; funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].armorhead, &player[i-howmanyremoved].armorhigh, &player[i-howmanyremoved].armorlow); funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].protectionhead, &player[i-howmanyremoved].protectionhigh, &player[i-howmanyremoved].protectionlow); funpackf(tfile, "Bf Bf Bf", &player[i-howmanyremoved].metalhead, &player[i-howmanyremoved].metalhigh, &player[i-howmanyremoved].metallow); funpackf(tfile, "Bf Bf", &player[i-howmanyremoved].power, &player[i-howmanyremoved].speedmult); - if(mapvers>=4)funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop); - else - { + if(mapvers>=4) + funpackf(tfile, "Bf Bf Bf Bf", &headprop, &bodyprop, &armprop, &legprop); + else{ headprop=1; bodyprop=1; armprop=1; legprop=1; } - if(player[i-howmanyremoved].creature==wolftype) - { + if(player[i-howmanyremoved].creature==wolftype){ player[i-howmanyremoved].proportionhead=1.1*headprop; player[i-howmanyremoved].proportionbody=1.1*bodyprop; player[i-howmanyremoved].proportionarms=1.1*armprop; player[i-howmanyremoved].proportionlegs=1.1*legprop; } - if(player[i-howmanyremoved].creature==rabbittype) - { + if(player[i-howmanyremoved].creature==rabbittype){ player[i-howmanyremoved].proportionhead=1.2*headprop; player[i-howmanyremoved].proportionbody=1.05*bodyprop; player[i-howmanyremoved].proportionarms=1.00*armprop; @@ -1850,10 +1824,8 @@ void Game::Loadlevel(const char *name){ } funpackf(tfile, "Bi", &player[i-howmanyremoved].numclothes); - if(player[i-howmanyremoved].numclothes) - { - for(int k=0;k30||numpathpoints<0) numpathpoints=0; - if(numpathpoints) - { - for(int j=0;jmaxplayers-1)numplayers=maxplayers-1; - for(int i=0;imaxplayers-1) + numplayers=maxplayers-1; + for(int i=0;inumchallengelevels-1)targetlevel=0; + if(targetlevel>numchallengelevels-1) + targetlevel=0; loading=1; leveltime=5; } @@ -3762,7 +3698,8 @@ void Game::doDebugKeys(){ if(Input::isKeyPressed(SDLK_PERIOD)){ pathpointselected++; - if(pathpointselected>=numpathpoints)pathpointselected=-1; + if(pathpointselected>=numpathpoints) + pathpointselected=-1; } if(Input::isKeyPressed(SDLK_COMMA)&&!Input::isKeyDown(SDLK_LSHIFT)){ pathpointselected--; diff --git a/Source/Globals.cpp b/Source/Globals.cpp index db533ec..d97de52 100644 --- a/Source/Globals.cpp +++ b/Source/Globals.cpp @@ -121,7 +121,6 @@ short vRefNum = 0; long dirID = 0; int mainmenu = 0; int oldmainmenu = 0; -int loadscreencolor = 0; int whichjointstartarray[26] = {0}; int whichjointendarray[26] = {0}; int kBitsPerPixel = 0; diff --git a/Source/Models.cpp b/Source/Models.cpp index e51bcfb..4db0b74 100644 --- a/Source/Models.cpp +++ b/Source/Models.cpp @@ -28,7 +28,6 @@ extern XYZ viewer; extern float fadestart; extern float texdetail; extern bool decals; -extern int loadscreencolor; extern Game * pgame; extern bool visibleloading; @@ -481,10 +480,8 @@ bool Model::load(const char *filename,bool texture ) LOG(std::string("Loading model...") + filename); - if(visibleloading){ - loadscreencolor=2; + if(visibleloading) pgame->LoadingScreen(); - } int oldvertexNum,oldTriangleNum; oldvertexNum=vertexNum; @@ -846,10 +843,8 @@ void Model::Rotate(float xang,float yang,float zang) void Model::CalculateNormals(bool facenormalise) { - if(visibleloading){ - loadscreencolor=3; + if(visibleloading) pgame->LoadingScreen(); - } static int i; if(type!=normaltype&&type!=decalstype)return; diff --git a/Source/TGALoader.cpp b/Source/TGALoader.cpp index 89d9b6b..266cdc3 100644 --- a/Source/TGALoader.cpp +++ b/Source/TGALoader.cpp @@ -29,16 +29,13 @@ extern short vRefNum; extern long dirID; extern bool visibleloading; extern Game * pgame; -extern int loadscreencolor; extern bool LoadImage(const char * fname, TGAImageRec & tex); /********************> LoadTGA() <*****/ bool upload_image(const unsigned char* filePath, bool hasalpha) { - if(visibleloading) { - loadscreencolor=1; + if(visibleloading) pgame->LoadingScreen(); - } #if !PLATFORM_MACOSX