]> git.jsancho.org Git - lugaru.git/commitdiff
FORMATTED IF STATEMENTS
authorsf17k <sf171k@gmail.com>
Mon, 15 Apr 2013 02:00:24 +0000 (22:00 -0400)
committersf17k <sf171k@gmail.com>
Mon, 15 Apr 2013 02:00:24 +0000 (22:00 -0400)
16 files changed:
Source/Awards.cpp
Source/GameDraw.cpp
Source/GameInitDispose.cpp
Source/GameTick.cpp
Source/Models.cpp
Source/Objects.cpp
Source/OpenGL_Windows.cpp
Source/PhysicsMath.h
Source/Quaternions.h
Source/Settings.cpp
Source/Skybox.cpp
Source/Sprite.cpp
Source/TGALoader.cpp
Source/Terrain.cpp
Source/Weapons.cpp
Source/openal_wrapper.cpp

index 426ad7a334fb28798f3338fdb4ba0c1a39b25aae..c4eb7650330cf6bb0130170943de537812f6231b 100644 (file)
@@ -74,7 +74,8 @@ int award_awards(int *awards)
     }
     bool alldead = true;
     for (i = 1; i < numplayers; i++) {
-        if (player[i].dead != 2)alldead = 0;
+        if (player[i].dead != 2)
+            alldead = 0;
     }
     if (alldead) {
         awards[numawards] = awardalldead;
@@ -82,7 +83,8 @@ int award_awards(int *awards)
     }
     alldead = 1;
     for (i = 1; i < numplayers; i++) {
-        if (player[i].dead != 1)alldead = 0;
+        if (player[i].dead != 1)
+            alldead = 0;
     }
     if (alldead) {
         awards[numawards] = awardnodead;
@@ -122,7 +124,8 @@ int award_awards(int *awards)
     }
     alldead = 1;
     for (i = 1; i < numplayers; i++) {
-        if (player[i].dead != 2)alldead = 0;
+        if (player[i].dead != 2)
+            alldead = 0;
     }
     if (numafterkill > 0 && alldead) {
         awards[numawards] = awardbrutal;
index bb3f00cbe8ae8d06161120bc3264a86382e96867..ee33c5f83e664c1c1590c7b4c085ea2c6f57cd0d 100644 (file)
@@ -172,7 +172,8 @@ int Game::DrawGLScene(StereoSide side)
     if (!mainmenu) {
         if (editorenabled) {
             numboundaries = mapradius * 2;
-            if (numboundaries > 360)numboundaries = 360;
+            if (numboundaries > 360)
+                numboundaries = 360;
             for (i = 0; i < numboundaries; i++) {
                 boundary[i] = 0;
                 boundary[i].z = 1;
@@ -227,7 +228,8 @@ int Game::DrawGLScene(StereoSide side)
         if ((freeze || winfreeze) && ismotionblur && !mainmenu)
             drawmode = radialzoommode;
 
-        if (winfreeze || mainmenu)drawmode = normalmode;
+        if (winfreeze || mainmenu)
+            drawmode = normalmode;
 
 #if PLATFORM_MACOSX
         if (drawmode == glowmode) {
@@ -372,8 +374,10 @@ int Game::DrawGLScene(StereoSide side)
                             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.yaw[j], 0);
-                                    else point = DoRotation(DoRotation(player[k].skeleton.joints[i].position, 0, player[k].yaw, 0) * player[k].scale + player[k].coords - objects.position[j], 0, -objects.yaw[j], 0);
+                                    if (player[k].skeleton.free)
+                                        point = DoRotation(player[k].skeleton.joints[i].position * player[k].scale + player[k].coords - objects.position[j], 0, -objects.yaw[j], 0);
+                                    else
+                                        point = DoRotation(DoRotation(player[k].skeleton.joints[i].position, 0, player[k].yaw, 0) * player[k].scale + player[k].coords - objects.position[j], 0, -objects.yaw[j], 0);
                                     size = .4f;
                                     opacity = .4f;
                                     if (k != 0 && tutoriallevel == 1) {
@@ -465,8 +469,9 @@ int Game::DrawGLScene(StereoSide side)
                         if (i != -1) {
                             player[k].occluded += 1;
                             player[k].lastoccluded = i;
-                        } else
+                        } else {
                             player[k].occluded = 0;
+                        }
                         if (player[k].occluded < 25)
                             player[k].DrawSkeleton();
                     }
@@ -528,8 +533,9 @@ int Game::DrawGLScene(StereoSide side)
                     if (i != -1) {
                         player[k].occluded += 1;
                         player[k].lastoccluded = i;
-                    } else
+                    } else {
                         player[k].occluded = 0;
+                    }
                     if (player[k].occluded < 25)
                         player[k].DrawSkeleton();
                 }
@@ -621,8 +627,10 @@ int Game::DrawGLScene(StereoSide side)
 
             if (tutoriallevel == 1) {
                 tutorialopac = tutorialmaxtime - tutorialstagetime;
-                if (tutorialopac > 1)tutorialopac = 1;
-                if (tutorialopac < 0)tutorialopac = 0;
+                if (tutorialopac > 1)
+                    tutorialopac = 1;
+                if (tutorialopac < 0)
+                    tutorialopac = 0;
 
                 sprintf (string, " ");
                 sprintf (string2, " ");
@@ -703,8 +711,10 @@ int Game::DrawGLScene(StereoSide side)
                     sprintf (string3, " ");
                 }
                 if (tutorialstage == 15) {
-                    if (attackkey == MOUSEBUTTON1)sprintf (string, "Click to attack when you are near an enemy.");
-                    else sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey));
+                    if (attackkey == MOUSEBUTTON1)
+                        sprintf (string, "Click to attack when you are near an enemy.");
+                    else
+                        sprintf (string, "Press %s to attack when you are near an enemy.", Input::keyToChar(attackkey));
                     sprintf (string2, "You can punch by standing still near an enemy and attacking.");
                     sprintf (string3, " ");
                 }
@@ -730,15 +740,19 @@ int Game::DrawGLScene(StereoSide side)
                 }
                 if (tutorialstage == 20) {
                     sprintf (string, "Your most powerful individual attack is the rabbit kick.");
-                    if (attackkey == MOUSEBUTTON1)sprintf (string2, "Run at the enemy while holding the mouse button, and press");
-                    else sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
+                    if (attackkey == MOUSEBUTTON1)
+                        sprintf (string2, "Run at the enemy while holding the mouse button, and press");
+                    else
+                        sprintf (string2, "Run at the enemy while holding %s, and press", Input::keyToChar(attackkey));
                     sprintf (string3, "the jump key (%s) to attack.", Input::keyToChar(jumpkey));
                 }
                 if (tutorialstage == 21) {
                     sprintf (string, "This attack is devastating if timed correctly.");
                     sprintf (string2, "Even if timed incorrectly, it will knock the enemy over.");
-                    if (againbonus)sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
-                    else sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
+                    if (againbonus)
+                        sprintf (string3, "Try rabbit-kicking the imaginary enemy again.");
+                    else
+                        sprintf (string3, "Try rabbit-kicking the imaginary enemy.");
                 }
                 if (tutorialstage == 22) {
                     sprintf (string, "If you sneak behind an enemy unnoticed, you can kill");
@@ -752,8 +766,10 @@ int Game::DrawGLScene(StereoSide side)
                 }
                 if (tutorialstage == 24) {
                     sprintf (string, "You can tackle enemies by running at them animal-style");
-                    if (attackkey == MOUSEBUTTON1)sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey));
-                    else sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey));
+                    if (attackkey == MOUSEBUTTON1)
+                        sprintf (string2, "and pressing jump (%s) or attack(mouse button).", Input::keyToChar(jumpkey));
+                    else
+                        sprintf (string2, "and pressing jump (%s) or attack(%s).", Input::keyToChar(jumpkey), Input::keyToChar(attackkey));
                     sprintf (string3, "This is especially useful when they are running away.");
                 }
                 if (tutorialstage == 25) {
@@ -938,8 +954,10 @@ int Game::DrawGLScene(StereoSide side)
                             tutorialstagetime = 0;
                         tutorialmaxtime = 1;
                         tutorialopac = tutorialmaxtime - tutorialstagetime;
-                        if (tutorialopac > 1)tutorialopac = 1;
-                        if (tutorialopac < 0)tutorialopac = 0;
+                        if (tutorialopac > 1)
+                            tutorialopac = 1;
+                        if (tutorialopac < 0)
+                            tutorialopac = 0;
 
                         sprintf (string, "%s", hotspottext[closest]);
 
@@ -955,9 +973,11 @@ int Game::DrawGLScene(StereoSide side)
                                 text->glPrint(screenwidth / 2 - 7.6 * (i - lastline)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
                                 lastline = i + 1;
                                 line++;
-                                if (string[i] == '\0')done = 1;
+                                if (string[i] == '\0')
+                                    done = 1;
                             }
-                            if (i >= 255)done = 1;
+                            if (i >= 255)
+                                done = 1;
                             i++;
                         }
                     } else if (hotspottype[closest] >= 20 && dialoguegonethrough[hotspottype[closest] - 20] == 0) {
@@ -975,26 +995,26 @@ int Game::DrawGLScene(StereoSide side)
                         dialoguegonethrough[whichdialogue]++;
                         if (dialogueboxsound[whichdialogue][indialogue] != 0) {
                             int whichsoundplay;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 1)whichsoundplay = rabbitchitter;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 2)whichsoundplay = rabbitchitter2;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 3)whichsoundplay = rabbitpainsound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 4)whichsoundplay = rabbitpain1sound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 5)whichsoundplay = rabbitattacksound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 6)whichsoundplay = rabbitattack2sound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 7)whichsoundplay = rabbitattack3sound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 8)whichsoundplay = rabbitattack4sound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 9)whichsoundplay = growlsound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 10)whichsoundplay = growl2sound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 11)whichsoundplay = snarlsound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 12)whichsoundplay = snarl2sound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 13)whichsoundplay = barksound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 14)whichsoundplay = bark2sound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 15)whichsoundplay = bark3sound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == 16)whichsoundplay = barkgrowlsound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == -1)whichsoundplay = fireendsound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == -2)whichsoundplay = firestartsound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == -3)whichsoundplay = consolesuccesssound;
-                            if (dialogueboxsound[whichdialogue][indialogue] == -4)whichsoundplay = consolefailsound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 1) whichsoundplay = rabbitchitter;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 2) whichsoundplay = rabbitchitter2;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 3) whichsoundplay = rabbitpainsound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 4) whichsoundplay = rabbitpain1sound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 5) whichsoundplay = rabbitattacksound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 6) whichsoundplay = rabbitattack2sound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 7) whichsoundplay = rabbitattack3sound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 8) whichsoundplay = rabbitattack4sound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 9) whichsoundplay = growlsound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 10) whichsoundplay = growl2sound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 11) whichsoundplay = snarlsound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 12) whichsoundplay = snarl2sound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 13) whichsoundplay = barksound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 14) whichsoundplay = bark2sound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 15) whichsoundplay = bark3sound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == 16) whichsoundplay = barkgrowlsound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == -1) whichsoundplay = fireendsound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == -2) whichsoundplay = firestartsound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == -3) whichsoundplay = consolesuccesssound;
+                            if (dialogueboxsound[whichdialogue][indialogue] == -4) whichsoundplay = consolefailsound;
                             emit_sound_at(whichsoundplay, player[participantfocus[whichdialogue][indialogue]].coords);
                         }
                     }
@@ -1014,7 +1034,8 @@ int Game::DrawGLScene(StereoSide side)
                 glMatrixMode(GL_MODELVIEW);                                                    // Select The Modelview Matrix
                 glPushMatrix();                                                                                // Store The Modelview Matrix
                 glLoadIdentity();                                                              // Reset The Modelview Matrix
-                if (dialogueboxlocation[whichdialogue][indialogue] == 1)glTranslatef(0, screenheight * 3 / 4, 0);
+                if (dialogueboxlocation[whichdialogue][indialogue] == 1)
+                    glTranslatef(0, screenheight * 3 / 4, 0);
                 glScalef(screenwidth, screenheight / 4, 1);
                 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                 glEnable(GL_BLEND);
@@ -1057,7 +1078,8 @@ int Game::DrawGLScene(StereoSide side)
                 for (i = 0; i < (int)strlen(dialoguename[whichdialogue][indialogue]); i++) {
                     tempname[tempnum] = dialoguename[whichdialogue][indialogue][i];
                     goodchar = 1;
-                    if (dialoguename[whichdialogue][indialogue][i] == '#' || dialoguename[whichdialogue][indialogue][i] == '\0')goodchar = 0;
+                    if (dialoguename[whichdialogue][indialogue][i] == '#' || dialoguename[whichdialogue][indialogue][i] == '\0')
+                        goodchar = 0;
                     if (goodchar)
                         tempnum++;
                     else
@@ -1079,7 +1101,8 @@ int Game::DrawGLScene(StereoSide side)
                 tempnum = 0;
                 for (i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) {
                     tempname[tempnum] = dialoguetext[whichdialogue][indialogue][i];
-                    if (dialoguetext[whichdialogue][indialogue][i] != '#')tempnum++;
+                    if (dialoguetext[whichdialogue][indialogue][i] != '#')
+                        tempnum++;
                 }
 
                 sprintf (string, "%s", tempname);
@@ -1101,9 +1124,11 @@ int Game::DrawGLScene(StereoSide side)
                         }
                         lastline = i + 1;
                         line++;
-                        if (string[i] == '\0')done = 1;
+                        if (string[i] == '\0')
+                            done = 1;
                     }
-                    if (i >= 255)done = 1;
+                    if (i >= 255)
+                        done = 1;
                     i++;
                 }
             }
@@ -1115,7 +1140,8 @@ int Game::DrawGLScene(StereoSide side)
                     else
                         sprintf (string, "Score: %d", (int)accountactive->getCampaignScore() + (int)bonustotal);
                 }
-                if (!campaign)sprintf (string, "Score: %d", (int)bonustotal);
+                if (!campaign)
+                    sprintf (string, "Score: %d", (int)bonustotal);
                 glColor4f(0, 0, 0, 1);
                 text->glPrintOutline(1024 / 40 - 4, 768 / 16 - 4 + 768 * 14 / 16, string, 1, 1.5 * 1.25, 1024, 768);
                 glColor4f(1, 0, 0, 1);
@@ -1221,11 +1247,15 @@ int Game::DrawGLScene(StereoSide side)
                 if (editorenabled) {
                     sprintf (string, "Object size: %f", editorsize);
                     text->glPrint(10, 75, string, 0, .8, 1024, 768);
-                    if (editoryaw >= 0)sprintf (string, "Object yaw: %f", editoryaw);
-                    else sprintf (string, "Object yaw: Random");
+                    if (editoryaw >= 0)
+                        sprintf (string, "Object yaw: %f", editoryaw);
+                    else
+                        sprintf (string, "Object yaw: Random");
                     text->glPrint(10, 90, string, 0, .8, 1024, 768);
-                    if (editorpitch >= 0)sprintf (string, "Object pitch: %f", editorpitch);
-                    else sprintf (string, "Object pitch: Random");
+                    if (editorpitch >= 0)
+                        sprintf (string, "Object pitch: %f", editorpitch);
+                    else
+                        sprintf (string, "Object pitch: Random");
                     text->glPrint(10, 105, string, 0, .8, 1024, 768);
                     sprintf (string, "Object type: %d", editortype);
                     text->glPrint(10, 120, string, 0, .8, 1024, 768);
@@ -1329,9 +1359,12 @@ int Game::DrawGLScene(StereoSide side)
             glScalef(screenwidth, screenheight, 1);
             glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
             glEnable(GL_BLEND);
-            if (player[0].dead)blackout += multiplier * 3;
-            if (player[0].dead == 1)blackout = .4f;
-            if (player[0].dead == 2 && blackout > .6)blackout = .6;
+            if (player[0].dead)
+                blackout += multiplier * 3;
+            if (player[0].dead == 1)
+                blackout = .4f;
+            if (player[0].dead == 2 && blackout > .6)
+                blackout = .6;
             glColor4f(0, 0, 0, blackout);
             if (!player[0].dead) {
                 if ((player[0].bloodloss / player[0].damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
@@ -1342,7 +1375,8 @@ int Game::DrawGLScene(StereoSide side)
                     blackout = player[0].blooddimamount * .3;
                 }
             }
-            if (console)glColor4f(.7, 0, 0, .2);
+            if (console)
+                glColor4f(.7, 0, 0, .2);
             glBegin(GL_QUADS);
             glVertex3f(0,              0,       0.0f);
             glVertex3f(256,    0,       0.0f);
@@ -1360,10 +1394,13 @@ int Game::DrawGLScene(StereoSide side)
         }
 
         if (flashamount > 0 && damageeffects) {
-            if (flashamount > 1)flashamount = 1;
-            if (flashdelay <= 0)flashamount -= multiplier;
+            if (flashamount > 1)
+                flashamount = 1;
+            if (flashdelay <= 0)
+                flashamount -= multiplier;
             flashdelay--;
-            if (flashamount < 0)flashamount = 0;
+            if (flashamount < 0)
+                flashamount = 0;
             glDisable(GL_DEPTH_TEST);                                                  // Disables Depth Testing
             glDisable(GL_CULL_FACE);
             glDisable(GL_LIGHTING);
@@ -1451,7 +1488,8 @@ int Game::DrawGLScene(StereoSide side)
             int numliveplayers = 0;
             center = 0;
             for (i = 0; i < numplayers; i++) {
-                if (!player[i].dead) numliveplayers++;
+                if (!player[i].dead)
+                    numliveplayers++;
             }
 
             int numadd = 0;
@@ -1463,7 +1501,8 @@ int Game::DrawGLScene(StereoSide side)
                 }
             }
             for (i = 0; i < numplayers; i++) {
-                if (!player[i].dead)center += player[i].coords;
+                if (!player[i].dead)
+                    center += player[i].coords;
             }
             center /= numadd + numliveplayers;
 
@@ -1569,12 +1608,18 @@ int Game::DrawGLScene(StereoSide side)
                 if (distcheck < mapviewdist) {
                     glPushMatrix();
                     Maparrowtexture.bind();
-                    if (i == 0)glColor4f(1, 1, 1, opac);
-                    else if (player[i].dead == 2 || player[i].howactive > typesleeping)glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
-                    else if (player[i].dead)glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
-                    else if (player[i].aitype == attacktypecutoff)glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
-                    else if (player[i].aitype == passivetype)glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
-                    else glColor4f(1, 1, 0, 1);
+                    if (i == 0)
+                        glColor4f(1, 1, 1, opac);
+                    else if (player[i].dead == 2 || player[i].howactive > typesleeping)
+                        glColor4f(0, 0, 0, opac * (1 - distcheck / mapviewdist));
+                    else if (player[i].dead)
+                        glColor4f(.3, .3, .3, opac * (1 - distcheck / mapviewdist));
+                    else if (player[i].aitype == attacktypecutoff)
+                        glColor4f(1, 0, 0, opac * (1 - distcheck / mapviewdist));
+                    else if (player[i].aitype == passivetype)
+                        glColor4f(0, 1, 0, opac * (1 - distcheck / mapviewdist));
+                    else
+                        glColor4f(1, 1, 0, 1);
                     glTranslatef(player[i].coords.x / terrain.scale / 256 * -2 + 1, player[i].coords.z / terrain.scale / 256 * 2 - 1, 0);
                     glRotatef(player[i].yaw + 180, 0, 0, 1);
                     glScalef(.005, .005, .005);
@@ -1713,7 +1758,8 @@ int Game::DrawGLScene(StereoSide side)
             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");
+            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);
@@ -1798,7 +1844,8 @@ int Game::DrawGLScene(StereoSide side)
             glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
             glEnable(GL_BLEND);
             if (drawmode == motionblurmode) {
-                if (motionbluramount < .2)motionbluramount = .2;
+                if (motionbluramount < .2)
+                    motionbluramount = .2;
                 //glColor4f(1,1,1,fast_sqrt(multiplier)*2.9*motionbluramount);
                 glColor4f(1, 1, 1, motionbluramount);
                 glPushMatrix();
@@ -1851,8 +1898,10 @@ int Game::DrawGLScene(StereoSide side)
             if (drawmode == doublevisionmode) {
                 static float crosseyedness;
                 crosseyedness = abs(player[0].damage - player[0].superpermanentdamage - (player[0].damagetolerance - player[0].superpermanentdamage) * 1 / 2) / 30;
-                if (crosseyedness > 1)crosseyedness = 1;
-                if (crosseyedness < 0)crosseyedness = 0;
+                if (crosseyedness > 1)
+                    crosseyedness = 1;
+                if (crosseyedness < 0)
+                    crosseyedness = 0;
                 glColor4f(1, 1, 1, 1);
                 glDisable(GL_BLEND);
                 glPushMatrix();
@@ -2024,7 +2073,8 @@ int Game::DrawGLScene(StereoSide side)
 
     weapons.DoStuff();
 
-    if (drawtoggle == 2)drawtoggle = 0;
+    if (drawtoggle == 2)
+        drawtoggle = 0;
 
     if (freeze || winfreeze || (mainmenu && gameon) || (!gameon && gamestarted)) {
         multiplier = tempmult;
@@ -2162,10 +2212,13 @@ void DrawMenu()
 
     //draw screen flash
     if (flashamount > 0) {
-        if (flashamount > 1)flashamount = 1;
-        if (flashdelay <= 0)flashamount -= multiplier;
+        if (flashamount > 1)
+            flashamount = 1;
+        if (flashdelay <= 0)
+            flashamount -= multiplier;
         flashdelay--;
-        if (flashamount < 0)flashamount = 0;
+        if (flashamount < 0)
+            flashamount = 0;
         glDisable(GL_DEPTH_TEST);                                                      // Disables Depth Testing
         glDisable(GL_CULL_FACE);
         glDisable(GL_LIGHTING);
index 827c923e74cdb49da7c009d7839122aaf7bc5a89..db86503fb7e408d5b6493145bfceab375d714f85 100644 (file)
@@ -138,8 +138,10 @@ void Game::newGame()
 
 void Game::deleteGame()
 {
-    if (skybox) delete skybox;
-    if (text) delete text;
+    if (skybox)
+        delete skybox;
+    if (text)
+        delete text;
     terraintexture.destroy();
     terraintexture2.destroy();
     cursortexture.destroy();
@@ -233,8 +235,10 @@ void Game::LoadingScreen()
         deltaTime /= 1000.0;
 
     multiplier = deltaTime;
-    if (multiplier < .001)multiplier = .001;
-    if (multiplier > 10)multiplier = 10;
+    if (multiplier < .001)
+        multiplier = .001;
+    if (multiplier > 10)
+        multiplier = 10;
     if (multiplier > .05) {
         frametime = currTime;  // reset for next time interval
 
@@ -247,7 +251,8 @@ void Game::LoadingScreen()
         loadtime += multiplier * 4;
 
         loadprogress = loadtime;
-        if (loadprogress > 100)loadprogress = 100;
+        if (loadprogress > 100)
+            loadprogress = 100;
 
         //loadprogress=abs(Random()%100);
 
@@ -394,10 +399,13 @@ void Game::LoadingScreen()
         //Text
 
         if (flashamount > 0) {
-            if (flashamount > 1)flashamount = 1;
-            if (flashdelay <= 0)flashamount -= multiplier;
+            if (flashamount > 1)
+                flashamount = 1;
+            if (flashdelay <= 0)
+                flashamount -= multiplier;
             flashdelay--;
-            if (flashamount < 0)flashamount = 0;
+            if (flashamount < 0)
+                flashamount = 0;
             glDisable(GL_DEPTH_TEST);                                                  // Disables Depth Testing
             glDisable(GL_CULL_FACE);
             glDisable(GL_LIGHTING);
@@ -677,7 +685,8 @@ void Game::InitGame()
     Maparrowtexture.load(":Data:Textures:MapArrow.png", 0, 1);
 
     temptexdetail = texdetail;
-    if (texdetail > 2)texdetail = 2;
+    if (texdetail > 2)
+        texdetail = 2;
     Mainmenuitems[0].load(":Data:Textures:Lugaru.png", 0, 0);
     Mainmenuitems[1].load(":Data:Textures:Newgame.png", 0, 0);
     Mainmenuitems[2].load(":Data:Textures:Options.png", 0, 0);
@@ -841,9 +850,12 @@ void Game::LoadStuff()
     viewer = 0;
 
 
-    if (detail)kTextureSize = 1024;
-    if (detail == 1)kTextureSize = 512;
-    if (detail == 0)kTextureSize = 256;
+    if (detail)
+        kTextureSize = 1024;
+    if (detail == 1)
+        kTextureSize = 512;
+    if (detail == 0)
+        kTextureSize = 256;
 
     //Set up distant light
     light.color[0] = .95;
index 806d24e16c63f9af5d5189f22cadcd7d52a25dbd..540360584dcbaff63076a55f75db09122a19911f 100644 (file)
@@ -323,9 +323,12 @@ inline float sq(float n)
 }
 inline float stepTowardf(float from, float to, float by)
 {
-    if (fabs(from - to) < by) return to;
-    else if (from > to) return from - by;
-    else return from + by;
+    if (fabs(from - to) < by)
+        return to;
+    else if (from > to)
+        return from - by;
+    else
+        return from + by;
 }
 
 void playdialogueboxsound()
@@ -422,31 +425,37 @@ bool AddClothes(const char *fileName, GLubyte *array)
     float alphanum;
     //Is it valid?
     if (opened) {
-        if (tintr > 1)tintr = 1;
-        if (tintg > 1)tintg = 1;
-        if (tintb > 1)tintb = 1;
+        if (tintr > 1) tintr = 1;
+        if (tintg > 1) tintg = 1;
+        if (tintb > 1) tintb = 1;
 
-        if (tintr < 0)tintr = 0;
-        if (tintg < 0)tintg = 0;
-        if (tintb < 0)tintb = 0;
+        if (tintr < 0) tintr = 0;
+        if (tintg < 0) tintg = 0;
+        if (tintb < 0) tintb = 0;
 
         int bytesPerPixel = texture.bpp / 8;
 
         int tempnum = 0;
         alphanum = 255;
         for (int i = 0; i < (int)(texture.sizeY * texture.sizeX * bytesPerPixel); i++) {
-            if (bytesPerPixel == 3)alphanum = 255;
-            else if ((i + 1) % 4 == 0)alphanum = texture.data[i];
+            if (bytesPerPixel == 3)
+                alphanum = 255;
+            else if ((i + 1) % 4 == 0)
+                alphanum = texture.data[i];
             //alphanum/=2;
             if ((i + 1) % 4 || bytesPerPixel == 3) {
-                if ((i % 4) == 0)texture.data[i] *= tintr;
-                if ((i % 4) == 1)texture.data[i] *= tintg;
-                if ((i % 4) == 2)texture.data[i] *= tintb;
+                if ((i % 4) == 0)
+                    texture.data[i] *= tintr;
+                if ((i % 4) == 1)
+                    texture.data[i] *= tintg;
+                if ((i % 4) == 2)
+                    texture.data[i] *= tintb;
                 array[tempnum] = (float)array[tempnum] * (1 - alphanum / 255) + (float)texture.data[i] * (alphanum / 255);
                 tempnum++;
             }
         }
-    } else return 0;
+    } else
+        return 0;
     return 1;
 }
 
@@ -1050,7 +1059,8 @@ static void ch_dialogue(const char *args)
         ipstream.ignore(256, ' ');
         ipstream.getline(dialoguetext[numdialogues][i], 128);
         for (int j = 0; j < 128; j++) {
-            if (dialoguetext[numdialogues][i][j] == '\\')dialoguetext[numdialogues][i][j] = '\n';
+            if (dialoguetext[numdialogues][i][j] == '\\')
+                dialoguetext[numdialogues][i][j] = '\n';
         }
         ipstream.ignore(256, ':');
         ipstream >> dialogueboxsound[numdialogues][i];
@@ -1099,7 +1109,8 @@ static void ch_fixdialogue(const char *args)
         ipstream.ignore(256, ' ');
         ipstream.getline(dialoguetext[whichdi][i], 128);
         for (int j = 0; j < 128; j++) {
-            if (dialoguetext[whichdi][i][j] == '\\')dialoguetext[whichdi][i][j] = '\n';
+            if (dialoguetext[whichdi][i][j] == '\\')
+                dialoguetext[whichdi][i][j] = '\n';
         }
         ipstream.ignore(256, ':');
         ipstream >> dialogueboxsound[whichdi][i];
@@ -1375,7 +1386,8 @@ int findPathDist(int start, int end)
             last = closest;
             count++;
         }
-        if (count < smallestcount)smallestcount = count;
+        if (count < smallestcount)
+            smallestcount = count;
     }
     return smallestcount;
 }
@@ -1404,7 +1416,8 @@ int Game::checkcollide(XYZ startpoint, XYZ endpoint)
                      objects.type[i] != firetype) {
                 colviewer = startpoint;
                 coltarget = endpoint;
-                if (objects.model[i].LineCheck(&colviewer, &coltarget, &colpoint, &objects.position[i], &objects.yaw[i]) != -1)return i;
+                if (objects.model[i].LineCheck(&colviewer, &coltarget, &colpoint, &objects.position[i], &objects.yaw[i]) != -1)
+                    return i;
             }
         }
     }
@@ -1440,12 +1453,15 @@ int Game::checkcollide(XYZ startpoint, XYZ endpoint, int what)
                 colviewer = startpoint;
                 coltarget = endpoint;
                 //FIXME: i/what
-                if (objects.model[what].LineCheck(&colviewer, &coltarget, &colpoint, &objects.position[what], &objects.yaw[what]) != -1)return i;
+                if (objects.model[what].LineCheck(&colviewer, &coltarget, &colpoint, &objects.position[what], &objects.yaw[what]) != -1)
+                    return i;
             }
         }
     }
 
-    if (what == 1000)if (terrain.lineTerrain(startpoint, endpoint, &colpoint) != -1)return 1000;
+    if (what == 1000)
+        if (terrain.lineTerrain(startpoint, endpoint, &colpoint) != -1)
+            return 1000;
 
     return -1;
 }
@@ -1491,7 +1507,8 @@ void Setenvironment(int which)
 
 
         temptexdetail = texdetail;
-        if (texdetail > 1)texdetail = 4;
+        if (texdetail > 1)
+            texdetail = 4;
         skybox->load(  ":Data:Textures:Skybox(snow):Front.jpg",
                         ":Data:Textures:Skybox(snow):Left.jpg",
                         ":Data:Textures:Skybox(snow):Back.jpg",
@@ -1528,7 +1545,8 @@ void Setenvironment(int which)
 
 
         temptexdetail = texdetail;
-        if (texdetail > 1)texdetail = 4;
+        if (texdetail > 1)
+            texdetail = 4;
         skybox->load(  ":Data:Textures:Skybox(sand):Front.jpg",
                         ":Data:Textures:Skybox(sand):Left.jpg",
                         ":Data:Textures:Skybox(sand):Back.jpg",
@@ -1564,7 +1582,8 @@ void Setenvironment(int which)
 
 
         temptexdetail = texdetail;
-        if (texdetail > 1)texdetail = 4;
+        if (texdetail > 1)
+            texdetail = 4;
         skybox->load(  ":Data:Textures:Skybox(grass):Front.jpg",
                         ":Data:Textures:Skybox(grass):Left.jpg",
                         ":Data:Textures:Skybox(grass):Back.jpg",
@@ -1883,7 +1902,8 @@ void Loadlevel(const char *name)
                     dialoguetext[k][l][m] = 0;
 
                     funpackf(tfile, "Bi", &templength);
-                    if (templength > 64 || templength <= 0)templength = 64;
+                    if (templength > 64 || templength <= 0)
+                        templength = 64;
                     for (m = 0; m < templength; m++) {
                         funpackf(tfile, "Bb", &dialoguename[k][l][m]);
                         if (dialoguename[k][l][m] == '\0')
@@ -2397,10 +2417,14 @@ void doTutorial()
 
             for (int i = 0; i < player[1].skeleton.num_joints; i++) {
                 if (Random() % 2 == 0) {
-                    if (!player[1].skeleton.free)temp2 = (player[1].coords - player[1].oldcoords) / multiplier / 2; //velocity/2;
-                    if (player[1].skeleton.free)temp2 = player[1].skeleton.joints[i].velocity * player[1].scale / 2;
-                    if (!player[1].skeleton.free)temp = DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position, 0, 0, player[1].tilt), player[1].tilt2, 0, 0), 0, player[1].yaw, 0) * player[1].scale + player[1].coords;
-                    if (player[1].skeleton.free)temp = player[1].skeleton.joints[i].position * player[1].scale + player[1].coords;
+                    if (!player[1].skeleton.free)
+                        temp2 = (player[1].coords - player[1].oldcoords) / multiplier / 2; //velocity/2;
+                    if (player[1].skeleton.free)
+                        temp2 = player[1].skeleton.joints[i].velocity * player[1].scale / 2;
+                    if (!player[1].skeleton.free)
+                        temp = DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position, 0, 0, player[1].tilt), player[1].tilt2, 0, 0), 0, player[1].yaw, 0) * player[1].scale + player[1].coords;
+                    if (player[1].skeleton.free)
+                        temp = player[1].skeleton.joints[i].position * player[1].scale + player[1].coords;
                     Sprite::MakeSprite(breathsprite, temp, temp2, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, 1);
                 }
             }
@@ -2430,7 +2454,8 @@ void doTutorial()
             if (bonus == cannon) {
                 bonus = Slicebonus;
                 againbonus = 1;
-            } else againbonus = 0;
+            } else
+                againbonus = 0;
             break;
         case 22:
             tutorialmaxtime = 500;
@@ -2663,10 +2688,14 @@ void doTutorial()
 
             for (int i = 0; i < player[1].skeleton.num_joints; i++) {
                 if (Random() % 2 == 0) {
-                    if (!player[1].skeleton.free)temp2 = (player[1].coords - player[1].oldcoords) / multiplier / 2; //velocity/2;
-                    if (player[1].skeleton.free)temp2 = player[1].skeleton.joints[i].velocity * player[1].scale / 2;
-                    if (!player[1].skeleton.free)temp = DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position, 0, 0, player[1].tilt), player[1].tilt2, 0, 0), 0, player[1].yaw, 0) * player[1].scale + player[1].coords;
-                    if (player[1].skeleton.free)temp = player[1].skeleton.joints[i].position * player[1].scale + player[1].coords;
+                    if (!player[1].skeleton.free)
+                        temp2 = (player[1].coords - player[1].oldcoords) / multiplier / 2; //velocity/2;
+                    if (player[1].skeleton.free)
+                        temp2 = player[1].skeleton.joints[i].velocity * player[1].scale / 2;
+                    if (!player[1].skeleton.free)
+                        temp = DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position, 0, 0, player[1].tilt), player[1].tilt2, 0, 0), 0, player[1].yaw, 0) * player[1].scale + player[1].coords;
+                    if (player[1].skeleton.free)
+                        temp = player[1].skeleton.joints[i].position * player[1].scale + player[1].coords;
                     Sprite::MakeSprite(breathsprite, temp, temp2, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, 1);
                 }
             }
@@ -2684,74 +2713,96 @@ void doTutorial()
         default:
             break;
         }
-        if (tutorialstage <= 51)tutorialstagetime = 0;
+        if (tutorialstage <= 51)
+            tutorialstagetime = 0;
     }
 
     //Tutorial success
     if (tutorialstagetime < tutorialmaxtime - 3) {
         switch (tutorialstage) {
         case 3:
-            if (deltah || deltav)tutorialsuccess += multiplier;
+            if (deltah || deltav)
+                tutorialsuccess += multiplier;
             break;
         case 4:
-            if (player[0].forwardkeydown || player[0].backkeydown || player[0].leftkeydown || player[0].rightkeydown)tutorialsuccess += multiplier;
+            if (player[0].forwardkeydown || player[0].backkeydown || player[0].leftkeydown || player[0].rightkeydown)
+                tutorialsuccess += multiplier;
             break;
         case 5:
-            if (player[0].jumpkeydown)tutorialsuccess = 1;
+            if (player[0].jumpkeydown)
+                tutorialsuccess = 1;
             break;
         case 6:
-            if (player[0].isCrouch())tutorialsuccess = 1;
+            if (player[0].isCrouch())
+                tutorialsuccess = 1;
             break;
         case 7:
-            if (player[0].animTarget == rollanim)tutorialsuccess = 1;
+            if (player[0].animTarget == rollanim)
+                tutorialsuccess = 1;
             break;
         case 8:
-            if (player[0].animTarget == sneakanim)tutorialsuccess += multiplier;
+            if (player[0].animTarget == sneakanim)
+                tutorialsuccess += multiplier;
             break;
         case 9:
-            if (player[0].animTarget == rabbitrunninganim || player[0].animTarget == wolfrunninganim)tutorialsuccess += multiplier;
+            if (player[0].animTarget == rabbitrunninganim || player[0].animTarget == wolfrunninganim)
+                tutorialsuccess += multiplier;
             break;
         case 11:
-            if (player[0].isWallJump())tutorialsuccess = 1;
+            if (player[0].isWallJump())
+                tutorialsuccess = 1;
             break;
         case 12:
-            if (player[0].animTarget == flipanim)tutorialsuccess = 1;
+            if (player[0].animTarget == flipanim)
+                tutorialsuccess = 1;
             break;
         case 15:
-            if (player[0].animTarget == upunchanim || player[0].animTarget == winduppunchanim)tutorialsuccess = 1;
+            if (player[0].animTarget == upunchanim || player[0].animTarget == winduppunchanim)
+                tutorialsuccess = 1;
             break;
         case 16:
-            if (player[0].animTarget == winduppunchanim)tutorialsuccess = 1;
+            if (player[0].animTarget == winduppunchanim)
+                tutorialsuccess = 1;
             break;
         case 17:
-            if (player[0].animTarget == spinkickanim)tutorialsuccess = 1;
+            if (player[0].animTarget == spinkickanim)
+                tutorialsuccess = 1;
             break;
         case 18:
-            if (player[0].animTarget == sweepanim)tutorialsuccess = 1;
+            if (player[0].animTarget == sweepanim)
+                tutorialsuccess = 1;
             break;
         case 19:
-            if (player[0].animTarget == dropkickanim)tutorialsuccess = 1;
+            if (player[0].animTarget == dropkickanim)
+                tutorialsuccess = 1;
             break;
         case 20:
-            if (player[0].animTarget == rabbitkickanim)tutorialsuccess = 1;
+            if (player[0].animTarget == rabbitkickanim)
+                tutorialsuccess = 1;
             break;
         case 21:
-            if (bonus == cannon)tutorialsuccess = 1;
+            if (bonus == cannon)
+                tutorialsuccess = 1;
             break;
         case 22:
-            if (bonus == spinecrusher)tutorialsuccess = 1;
+            if (bonus == spinecrusher)
+                tutorialsuccess = 1;
             break;
         case 23:
-            if (player[0].animTarget == walljumprightkickanim || player[0].animTarget == walljumpleftkickanim)tutorialsuccess = 1;
+            if (player[0].animTarget == walljumprightkickanim || player[0].animTarget == walljumpleftkickanim)
+                tutorialsuccess = 1;
             break;
         case 24:
-            if (player[0].animTarget == rabbittacklinganim)tutorialsuccess = 1;
+            if (player[0].animTarget == rabbittacklinganim)
+                tutorialsuccess = 1;
             break;
         case 25:
-            if (player[0].animTarget == backhandspringanim)tutorialsuccess = 1;
+            if (player[0].animTarget == backhandspringanim)
+                tutorialsuccess = 1;
             break;
         case 28:
-            if (animation[player[0].animTarget].attack == reversed && player[0].feint)tutorialsuccess = 1;
+            if (animation[player[0].animTarget].attack == reversed && player[0].feint)
+                tutorialsuccess = 1;
             break;
         case 29:
             if (player[0].escapednum == 2) {
@@ -2762,10 +2813,12 @@ void doTutorial()
             }
             break;
         case 33:
-            if (animation[player[0].animTarget].attack == reversal)tutorialsuccess = 1;
+            if (animation[player[0].animTarget].attack == reversal)
+                tutorialsuccess = 1;
             break;
         case 34:
-            if (animation[player[0].animTarget].attack == reversal)tutorialsuccess = 1;
+            if (animation[player[0].animTarget].attack == reversal)
+                tutorialsuccess = 1;
             break;
         case 35:
             if (animation[player[0].animTarget].attack == reversal) {
@@ -2776,30 +2829,38 @@ void doTutorial()
             }
             break;
         case 40:
-            if (player[0].num_weapons > 0)tutorialsuccess = 1;
+            if (player[0].num_weapons > 0)
+                tutorialsuccess = 1;
             break;
         case 41:
-            if (player[0].weaponactive == -1 && player[0].num_weapons > 0)tutorialsuccess = 1;
+            if (player[0].weaponactive == -1 && player[0].num_weapons > 0)
+                tutorialsuccess = 1;
             break;
         case 43:
-            if (player[0].animTarget == knifeslashstartanim)tutorialsuccess = 1;
+            if (player[0].animTarget == knifeslashstartanim)
+                tutorialsuccess = 1;
             break;
         case 44:
-            if (animation[player[0].animTarget].attack == reversal)tutorialsuccess = 1;
+            if (animation[player[0].animTarget].attack == reversal)
+                tutorialsuccess = 1;
             break;
         case 45:
-            if (animation[player[0].animTarget].attack == reversal)tutorialsuccess = 1;
+            if (animation[player[0].animTarget].attack == reversal)
+                tutorialsuccess = 1;
             break;
         case 46:
-            if (animation[player[0].animTarget].attack == reversal)tutorialsuccess = 1;
+            if (animation[player[0].animTarget].attack == reversal)
+                tutorialsuccess = 1;
             break;
         case 49:
-            if (player[1].weaponstuck != -1)tutorialsuccess = 1;
+            if (player[1].weaponstuck != -1)
+                tutorialsuccess = 1;
             break;
         default:
             break;
         }
-        if (tutorialsuccess >= 1)tutorialstagetime = tutorialmaxtime - 3;
+        if (tutorialsuccess >= 1)
+            tutorialstagetime = tutorialmaxtime - 3;
 
 
         if (tutorialstagetime == tutorialmaxtime - 3) {
@@ -3026,7 +3087,8 @@ void doDebugKeys()
                 emit_sound_at(splattersound, blah);
                 emit_sound_at(breaksound2, blah, 100.);
 
-                if (player[closest].skeleton.free == 2)player[closest].skeleton.free = 0;
+                if (player[closest].skeleton.free == 2)
+                    player[closest].skeleton.free = 0;
                 player[closest].RagDoll(0);
                 player[closest].dead = 2;
                 player[closest].headless = 1;
@@ -3046,10 +3108,14 @@ void doDebugKeys()
                 emit_sound_at(breaksound2, blah);
 
                 for (int i = 0; i < player[closest].skeleton.num_joints; i++) {
-                    if (!player[closest].skeleton.free)flatvelocity2 = player[closest].velocity;
-                    if (player[closest].skeleton.free)flatvelocity2 = player[closest].skeleton.joints[i].velocity;
-                    if (!player[closest].skeleton.free)flatfacing2 = DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position, 0, 0, player[closest].tilt), player[closest].tilt2, 0, 0), 0, player[closest].yaw, 0) * player[closest].scale + player[closest].coords;
-                    if (player[closest].skeleton.free)flatfacing2 = player[closest].skeleton.joints[i].position * player[closest].scale + player[closest].coords;
+                    if (!player[closest].skeleton.free)
+                        flatvelocity2 = player[closest].velocity;
+                    if (player[closest].skeleton.free)
+                        flatvelocity2 = player[closest].skeleton.joints[i].velocity;
+                    if (!player[closest].skeleton.free)
+                        flatfacing2 = DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position, 0, 0, player[closest].tilt), player[closest].tilt2, 0, 0), 0, player[closest].yaw, 0) * player[closest].scale + player[closest].coords;
+                    if (player[closest].skeleton.free)
+                        flatfacing2 = player[closest].skeleton.joints[i].position * player[closest].scale + player[closest].coords;
                     flatvelocity2.x += (float)(abs(Random() % 100) - 50) / 10;
                     flatvelocity2.y += (float)(abs(Random() % 100) - 50) / 10;
                     flatvelocity2.z += (float)(abs(Random() % 100) - 50) / 10;
@@ -3059,10 +3125,14 @@ void doDebugKeys()
                 }
 
                 for (int i = 0; i < player[closest].skeleton.num_joints; i++) {
-                    if (!player[closest].skeleton.free)flatvelocity2 = player[closest].velocity;
-                    if (player[closest].skeleton.free)flatvelocity2 = player[closest].skeleton.joints[i].velocity;
-                    if (!player[closest].skeleton.free)flatfacing2 = DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position, 0, 0, player[closest].tilt), player[closest].tilt2, 0, 0), 0, player[closest].yaw, 0) * player[closest].scale + player[closest].coords;
-                    if (player[closest].skeleton.free)flatfacing2 = player[closest].skeleton.joints[i].position * player[closest].scale + player[closest].coords;
+                    if (!player[closest].skeleton.free)
+                        flatvelocity2 = player[closest].velocity;
+                    if (player[closest].skeleton.free)
+                        flatvelocity2 = player[closest].skeleton.joints[i].velocity;
+                    if (!player[closest].skeleton.free)
+                        flatfacing2 = DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position, 0, 0, player[closest].tilt), player[closest].tilt2, 0, 0), 0, player[closest].yaw, 0) * player[closest].scale + player[closest].coords;
+                    if (player[closest].skeleton.free)
+                        flatfacing2 = player[closest].skeleton.joints[i].position * player[closest].scale + player[closest].coords;
                     flatvelocity2.x += (float)(abs(Random() % 100) - 50) / 10;
                     flatvelocity2.y += (float)(abs(Random() % 100) - 50) / 10;
                     flatvelocity2.z += (float)(abs(Random() % 100) - 50) / 10;
@@ -3071,10 +3141,14 @@ void doDebugKeys()
                 }
 
                 for (int i = 0; i < player[closest].skeleton.num_joints; i++) {
-                    if (!player[closest].skeleton.free)flatvelocity2 = player[closest].velocity;
-                    if (player[closest].skeleton.free)flatvelocity2 = player[closest].skeleton.joints[i].velocity;
-                    if (!player[closest].skeleton.free)flatfacing2 = DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position, 0, 0, player[closest].tilt), player[closest].tilt2, 0, 0), 0, player[closest].yaw, 0) * player[closest].scale + player[closest].coords;
-                    if (player[closest].skeleton.free)flatfacing2 = player[closest].skeleton.joints[i].position * player[closest].scale + player[closest].coords;
+                    if (!player[closest].skeleton.free)
+                        flatvelocity2 = player[closest].velocity;
+                    if (player[closest].skeleton.free)
+                        flatvelocity2 = player[closest].skeleton.joints[i].velocity;
+                    if (!player[closest].skeleton.free)
+                        flatfacing2 = DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position, 0, 0, player[closest].tilt), player[closest].tilt2, 0, 0), 0, player[closest].yaw, 0) * player[closest].scale + player[closest].coords;
+                    if (player[closest].skeleton.free)
+                        flatfacing2 = player[closest].skeleton.joints[i].position * player[closest].scale + player[closest].coords;
                     flatvelocity2.x += (float)(abs(Random() % 100) - 50) / 10;
                     flatvelocity2.y += (float)(abs(Random() % 100) - 50) / 10;
                     flatvelocity2.z += (float)(abs(Random() % 100) - 50) / 10;
@@ -3083,10 +3157,14 @@ void doDebugKeys()
                 }
 
                 for (int i = 0; i < player[closest].skeleton.num_joints; i++) {
-                    if (!player[closest].skeleton.free)flatvelocity2 = player[closest].velocity;
-                    if (player[closest].skeleton.free)flatvelocity2 = player[closest].skeleton.joints[i].velocity;
-                    if (!player[closest].skeleton.free)flatfacing2 = DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position, 0, 0, player[closest].tilt), player[closest].tilt2, 0, 0), 0, player[closest].yaw, 0) * player[closest].scale + player[closest].coords;
-                    if (player[closest].skeleton.free)flatfacing2 = player[closest].skeleton.joints[i].position * player[closest].scale + player[closest].coords;
+                    if (!player[closest].skeleton.free)
+                        flatvelocity2 = player[closest].velocity;
+                    if (player[closest].skeleton.free)
+                        flatvelocity2 = player[closest].skeleton.joints[i].velocity;
+                    if (!player[closest].skeleton.free)
+                        flatfacing2 = DoRotation(DoRotation(DoRotation(player[closest].skeleton.joints[i].position, 0, 0, player[closest].tilt), player[closest].tilt2, 0, 0), 0, player[closest].yaw, 0) * player[closest].scale + player[closest].coords;
+                    if (player[closest].skeleton.free)
+                        flatfacing2 = player[closest].skeleton.joints[i].position * player[closest].scale + player[closest].coords;
                     flatvelocity2.x += (float)(abs(Random() % 100) - 50) / 10;
                     flatvelocity2.y += (float)(abs(Random() % 100) - 50) / 10;
                     flatvelocity2.z += (float)(abs(Random() % 100) - 50) / 10;
@@ -3201,14 +3279,18 @@ void doDebugKeys()
                     boxcoords.x = player[0].coords.x;
                     boxcoords.z = player[0].coords.z;
                     boxcoords.y = player[0].coords.y - 3;
-                    if (editortype == bushtype)boxcoords.y = player[0].coords.y - .5;
-                    if (editortype == firetype)boxcoords.y = player[0].coords.y - .5;
+                    if (editortype == bushtype)
+                        boxcoords.y = player[0].coords.y - .5;
+                    if (editortype == firetype)
+                        boxcoords.y = player[0].coords.y - .5;
                     //objects.MakeObject(abs(Random()%3),boxcoords,Random()%360);
                     float temprotat, temprotat2;
                     temprotat = editoryaw;
                     temprotat2 = editorpitch;
-                    if (temprotat < 0 || editortype == bushtype)temprotat = Random() % 360;
-                    if (temprotat2 < 0)temprotat2 = Random() % 360;
+                    if (temprotat < 0 || editortype == bushtype)
+                        temprotat = Random() % 360;
+                    if (temprotat2 < 0)
+                        temprotat2 = Random() % 360;
 
                     objects.MakeObject(editortype, boxcoords, (int)temprotat - ((int)temprotat) % 30, (int)temprotat2, editorsize);
                     if (editortype == treetrunktype)
@@ -3377,7 +3459,8 @@ void doDebugKeys()
                             if (distsq(&pathpoint[i], &player[0].coords) < .5 && i != pathpointselected && !connected) {
                                 alreadyconnected = 0;
                                 for (int j = 0; j < numpathpointconnect[pathpointselected]; j++) {
-                                    if (pathpointconnect[pathpointselected][j] == i)alreadyconnected = 1;
+                                    if (pathpointconnect[pathpointselected][j] == i)
+                                        alreadyconnected = 1;
                                 }
                                 if (!alreadyconnected) {
                                     numpathpointconnect[pathpointselected]++;
@@ -3434,19 +3517,24 @@ void doDebugKeys()
 
             if (Input::isKeyPressed(SDLK_LEFT) && Input::isKeyDown(SDLK_LSHIFT) && !Input::isKeyDown(SDLK_LCTRL)) {
                 editortype--;
-                if (editortype == treeleavestype || editortype == 10)editortype--;
-                if (editortype < 0)editortype = firetype;
+                if (editortype == treeleavestype || editortype == 10)
+                    editortype--;
+                if (editortype < 0)
+                    editortype = firetype;
             }
 
             if (Input::isKeyPressed(SDLK_RIGHT) && Input::isKeyDown(SDLK_LSHIFT) && !Input::isKeyDown(SDLK_LCTRL)) {
                 editortype++;
-                if (editortype == treeleavestype || editortype == 10)editortype++;
-                if (editortype > firetype)editortype = 0;
+                if (editortype == treeleavestype || editortype == 10)
+                    editortype++;
+                if (editortype > firetype)
+                    editortype = 0;
             }
 
             if (Input::isKeyDown(SDLK_LEFT) && !Input::isKeyDown(SDLK_LSHIFT) && !Input::isKeyDown(SDLK_LCTRL)) {
                 editoryaw -= multiplier * 100;
-                if (editoryaw < -.01)editoryaw = -.01;
+                if (editoryaw < -.01)
+                    editoryaw = -.01;
             }
 
             if (Input::isKeyDown(SDLK_RIGHT) && !Input::isKeyDown(SDLK_LSHIFT) && !Input::isKeyDown(SDLK_LCTRL)) {
@@ -3459,7 +3547,8 @@ void doDebugKeys()
 
             if (Input::isKeyDown(SDLK_DOWN) && !Input::isKeyDown(SDLK_LCTRL)) {
                 editorsize -= multiplier;
-                if (editorsize < .1)editorsize = .1;
+                if (editorsize < .1)
+                    editorsize = .1;
             }
 
 
@@ -3476,7 +3565,8 @@ void doDebugKeys()
 
             if (Input::isKeyDown(SDLK_DOWN) && Input::isKeyDown(SDLK_LCTRL)) {
                 editorpitch -= multiplier * 100;
-                if (editorpitch < -.01)editorpitch = -.01;
+                if (editorpitch < -.01)
+                    editorpitch = -.01;
             }
             if (Input::isKeyPressed(SDLK_DELETE) && objects.numobjects && Input::isKeyDown(SDLK_LSHIFT)) {
                 int closest = findClosestObject();
@@ -3491,7 +3581,8 @@ void doJumpReversals()
 {
     for (int k = 0; k < numplayers; k++)
         for (int i = k; i < numplayers; i++) {
-            if (i == k)continue;
+            if (i == k)
+                continue;
             if (     player[k].skeleton.free == 0 &&
                      player[i].skeleton.oldfree == 0 &&
                      (player[i].animTarget == jumpupanim ||
@@ -3700,14 +3791,17 @@ void doAerialAcrobatics()
                                 if (whichhit != -1 && fabs(objects.model[i].facenormals[whichhit].y) < .3) {
                                     player[k].setAnimation(walljumprightanim);
                                     emit_sound_at(movewhooshsound, player[k].coords);
-                                    if (k == 0)pause_sound(whooshsound);
+                                    if (k == 0)
+                                        pause_sound(whooshsound);
 
                                     lowpointtarget = DoRotation(objects.model[i].facenormals[whichhit], 0, objects.yaw[i], 0);
                                     player[k].yaw = -asin(0 - lowpointtarget.x) * 180 / M_PI;
-                                    if (lowpointtarget.z < 0)player[k].yaw = 180 - player[k].yaw;
+                                    if (lowpointtarget.z < 0)
+                                        player[k].yaw = 180 - player[k].yaw;
                                     player[k].targetyaw = player[k].yaw;
                                     player[k].lowyaw = player[k].yaw;
-                                    if (k == 0)numwallflipped++;
+                                    if (k == 0)
+                                        numwallflipped++;
                                 } else {
                                     lowpoint = tempcoords1;
                                     lowpointtarget = lowpoint + player[k].facing * 2;
@@ -3715,14 +3809,17 @@ void doAerialAcrobatics()
                                     if (whichhit != -1 && fabs(objects.model[i].facenormals[whichhit].y) < .3) {
                                         player[k].setAnimation(walljumpbackanim);
                                         emit_sound_at(movewhooshsound, player[k].coords);
-                                        if (k == 0)pause_sound(whooshsound);
+                                        if (k == 0)
+                                            pause_sound(whooshsound);
 
                                         lowpointtarget = DoRotation(objects.model[i].facenormals[whichhit], 0, objects.yaw[i], 0);
                                         player[k].yaw = -asin(0 - lowpointtarget.x) * 180 / M_PI;
-                                        if (lowpointtarget.z < 0)player[k].yaw = 180 - player[k].yaw;
+                                        if (lowpointtarget.z < 0)
+                                            player[k].yaw = 180 - player[k].yaw;
                                         player[k].targetyaw = player[k].yaw;
                                         player[k].lowyaw = player[k].yaw;
-                                        if (k == 0)numwallflipped++;
+                                        if (k == 0)
+                                            numwallflipped++;
                                     } else {
                                         lowpoint = tempcoords1;
                                         lowpointtarget = lowpoint - player[k].facing * 2;
@@ -3730,15 +3827,18 @@ void doAerialAcrobatics()
                                         if (whichhit != -1 && fabs(objects.model[i].facenormals[whichhit].y) < .3) {
                                             player[k].setAnimation(walljumpfrontanim);
                                             emit_sound_at(movewhooshsound, player[k].coords);
-                                            if (k == 0)pause_sound(whooshsound);
+                                            if (k == 0)
+                                                pause_sound(whooshsound);
 
                                             lowpointtarget = DoRotation(objects.model[i].facenormals[whichhit], 0, objects.yaw[i], 0);
                                             player[k].yaw = -asin(0 - lowpointtarget.x) * 180 / M_PI;
-                                            if (lowpointtarget.z < 0)player[k].yaw = 180 - player[k].yaw;
+                                            if (lowpointtarget.z < 0)
+                                                player[k].yaw = 180 - player[k].yaw;
                                             player[k].yaw += 180;
                                             player[k].targetyaw = player[k].yaw;
                                             player[k].lowyaw = player[k].yaw;
-                                            if (k == 0)numwallflipped++;
+                                            if (k == 0)
+                                                numwallflipped++;
                                         }
                                     }
                                 }
@@ -3991,10 +4091,12 @@ void doAttacks()
         }
     }
 
-    if (!hostile || indialogue != -1)player[0].attackkeydown = 0;
+    if (!hostile || indialogue != -1)
+        player[0].attackkeydown = 0;
 
     for (int k = 0; k < numplayers; k++) {
-        if (indialogue != -1)player[k].attackkeydown = 0;
+        if (indialogue != -1)
+            player[k].attackkeydown = 0;
         if (player[k].animTarget != rabbitrunninganim && player[k].animTarget != wolfrunninganim) {
             if (player[k].aitype != playercontrolled)
                 player[k].victim = &player[0];
@@ -4011,7 +4113,8 @@ void doAttacks()
                         player[k].jumppower -= 2;
                     } else {
                         for (int i = 0; i < numplayers; i++) {
-                            if (i == k)continue;
+                            if (i == k)
+                                continue;
                             if (player[i].animTarget == swordslashanim ||
                                     player[i].animTarget == knifeslashstartanim ||
                                     player[i].animTarget == staffhitanim ||
@@ -4023,7 +4126,8 @@ void doAttacks()
                                 }
                         }
                         if (player[k].animTarget != dodgebackanim) {
-                            if (k == 0)numflipped++;
+                            if (k == 0)
+                                numflipped++;
                             player[k].setAnimation(backhandspringanim);
                             player[k].targetyaw = -yaw + 180;
                             if (player[k].leftkeydown)
@@ -4048,7 +4152,8 @@ void doAttacks()
                     player[k].hasvictim = 0;
                     if (numplayers > 1)
                         for (int i = 0; i < numplayers; i++) {
-                            if (i == k || !(k == 0 || i == 0))continue;
+                            if (i == k || !(k == 0 || i == 0))
+                                continue;
                             if (!player[k].hasvictim)
                                 if (animation[player[k].animTarget].attack != reversal) {
                                     //choose an attack
@@ -4318,7 +4423,8 @@ void doAttacks()
                     const bool hasstaff = attackweapon == staff;
                     if (k == 0 && numplayers > 1)
                         for (int i = 0; i < numplayers; i++) {
-                            if (i == k)continue;
+                            if (i == k)
+                                continue;
                             if ((playerrealattackkeydown || player[i].dead || !hasstaff) &&
                                     animation[player[k].animTarget].attack == neutral) {
                                 const float distance = distsq(&player[k].coords, &player[i].coords);
@@ -4442,7 +4548,8 @@ void doAttacks()
                     if (!player[k].hasvictim) {
                         //find victim
                         for (int i = 0; i < numplayers; i++) {
-                            if (i == k || !(i == 0 || k == 0))continue;
+                            if (i == k || !(i == 0 || k == 0))
+                                continue;
                             if (!player[i].skeleton.free) {
                                 if (player[k].hasvictim) {
                                     if (distsq(&player[k].coords, &player[i].coords) <
@@ -4537,8 +4644,10 @@ void doPlayerCollisions()
                                                             if (distsq(&player[i].coords, &player[k].coords)
                                                                     < 3 * sq((player[i].scale + player[k].scale) * 2.5)) {
                                                                 if (player[i].onfire || player[k].onfire) {
-                                                                    if (!player[i].onfire)player[i].CatchFire();
-                                                                    if (!player[k].onfire)player[k].CatchFire();
+                                                                    if (!player[i].onfire)
+                                                                        player[i].CatchFire();
+                                                                    if (!player[k].onfire)
+                                                                        player[k].CatchFire();
                                                                 }
                                                             }
 
@@ -5079,7 +5188,8 @@ void doAI(int i)
                         player[i].lastpathfindpoint2 = -1;
                         player[i].lastpathfindpoint3 = -1;
                         player[i].lastpathfindpoint4 = -1;
-                    } else player[i].laststanding = j;
+                    } else
+                        player[i].laststanding = j;
                 }
             }
             //check out last seen location
@@ -5105,7 +5215,8 @@ void doAI(int i)
                 player[i].throwkeydown = 0;
 
                 if (player[i].avoidcollided > .8 && !player[i].jumpkeydown && player[i].collided < .8) {
-                    if (!player[i].avoidsomething)player[i].targetyaw += 90 * (player[i].whichdirection * 2 - 1);
+                    if (!player[i].avoidsomething)
+                        player[i].targetyaw += 90 * (player[i].whichdirection * 2 - 1);
                     else {
                         XYZ leftpos, rightpos;
                         float leftdist, rightdist;
@@ -5113,8 +5224,10 @@ void doAI(int i)
                         rightpos = player[i].coords - DoRotation(player[i].facing, 0, 90, 0);
                         leftdist = distsq(&leftpos, &player[i].avoidwhere);
                         rightdist = distsq(&rightpos, &player[i].avoidwhere);
-                        if (leftdist < rightdist)player[i].targetyaw += 90;
-                        else player[i].targetyaw -= 90;
+                        if (leftdist < rightdist)
+                            player[i].targetyaw += 90;
+                        else
+                            player[i].targetyaw -= 90;
                     }
                 }
             }
@@ -5864,7 +5977,8 @@ void Game::LoadMenu()
                 strcat(temp, " ");
             name += temp;
             sprintf (temp, "%d:", (int)(((int)accountactive->getFastTime(i) - (int)(accountactive->getFastTime(i)) % 60) / 60));
-            if ((int)(accountactive->getFastTime(i)) % 60 < 10)strcat(temp, "0");
+            if ((int)(accountactive->getFastTime(i)) % 60 < 10)
+                strcat(temp, "0");
             name += temp;
             sprintf (temp, "%d", (int)(accountactive->getFastTime(i)) % 60);
             name += temp;
@@ -5941,12 +6055,18 @@ void MenuTick()
                 fireSound();
                 flash();
                 mainmenu = 3;
-                if (newdetail > 2) newdetail = detail;
-                if (newdetail < 0) newdetail = detail;
-                if (newscreenwidth > 3000) newscreenwidth = screenwidth;
-                if (newscreenwidth < 0) newscreenwidth = screenwidth;
-                if (newscreenheight > 3000) newscreenheight = screenheight;
-                if (newscreenheight < 0) newscreenheight = screenheight;
+                if (newdetail > 2)
+                    newdetail = detail;
+                if (newdetail < 0)
+                    newdetail = detail;
+                if (newscreenwidth > 3000)
+                    newscreenwidth = screenwidth;
+                if (newscreenwidth < 0)
+                    newscreenwidth = screenwidth;
+                if (newscreenheight > 3000)
+                    newscreenheight = screenheight;
+                if (newscreenheight < 0)
+                    newscreenheight = screenheight;
                 break;
             case 3:
                 fireSound();
@@ -6000,15 +6120,18 @@ void MenuTick()
                 break;
             case 1:
                 newdetail++;
-                if (newdetail > 2) newdetail = 0;
+                if (newdetail > 2)
+                    newdetail = 0;
                 break;
             case 2:
                 bloodtoggle++;
-                if (bloodtoggle > 2) bloodtoggle = 0;
+                if (bloodtoggle > 2)
+                    bloodtoggle = 0;
                 break;
             case 3:
                 difficulty++;
-                if (difficulty > 2) difficulty = 0;
+                if (difficulty > 2)
+                    difficulty = 0;
                 break;
             case 4:
                 ismotionblur = !ismotionblur;
@@ -6437,9 +6560,12 @@ void Game::Tick()
     }
 
     if (!mainmenu) {
-        if (hostile == 1)hostiletime += multiplier;
-        else hostiletime = 0;
-        if (!winfreeze)leveltime += multiplier;
+        if (hostile == 1)
+            hostiletime += multiplier;
+        else
+            hostiletime = 0;
+        if (!winfreeze)
+            leveltime += multiplier;
 
         //keys
         if (Input::isKeyPressed(SDLK_v) && debugmode) {
@@ -6757,16 +6883,16 @@ void Game::Tick()
                              Input::isKeyPressed(SDLK_0) ||
                              Input::isKeyPressed(SDLK_MINUS)) {
                         int whichend;
-                        if (Input::isKeyPressed(SDLK_1))whichend = 1;
-                        if (Input::isKeyPressed(SDLK_2))whichend = 2;
-                        if (Input::isKeyPressed(SDLK_3))whichend = 3;
-                        if (Input::isKeyPressed(SDLK_4))whichend = 4;
-                        if (Input::isKeyPressed(SDLK_5))whichend = 5;
-                        if (Input::isKeyPressed(SDLK_6))whichend = 6;
-                        if (Input::isKeyPressed(SDLK_7))whichend = 7;
-                        if (Input::isKeyPressed(SDLK_8))whichend = 8;
-                        if (Input::isKeyPressed(SDLK_9))whichend = 9;
-                        if (Input::isKeyPressed(SDLK_0))whichend = 0;
+                        if (Input::isKeyPressed(SDLK_1)) whichend = 1;
+                        if (Input::isKeyPressed(SDLK_2)) whichend = 2;
+                        if (Input::isKeyPressed(SDLK_3)) whichend = 3;
+                        if (Input::isKeyPressed(SDLK_4)) whichend = 4;
+                        if (Input::isKeyPressed(SDLK_5)) whichend = 5;
+                        if (Input::isKeyPressed(SDLK_6)) whichend = 6;
+                        if (Input::isKeyPressed(SDLK_7)) whichend = 7;
+                        if (Input::isKeyPressed(SDLK_8)) whichend = 8;
+                        if (Input::isKeyPressed(SDLK_9)) whichend = 9;
+                        if (Input::isKeyPressed(SDLK_0)) whichend = 0;
                         if (Input::isKeyPressed(SDLK_MINUS))
                             whichend = -1;
                         if (whichend != -1) {
@@ -6808,16 +6934,16 @@ void Game::Tick()
                              Input::isKeyDown(SDLK_KP9) ||
                              Input::isKeyDown(SDLK_KP0)) {
                         int whichend;
-                        if (Input::isKeyDown(SDLK_KP1))whichend = 1;
-                        if (Input::isKeyDown(SDLK_KP2))whichend = 2;
-                        if (Input::isKeyDown(SDLK_KP3))whichend = 3;
-                        if (Input::isKeyDown(SDLK_KP4))whichend = 4;
-                        if (Input::isKeyDown(SDLK_KP5))whichend = 5;
-                        if (Input::isKeyDown(SDLK_KP6))whichend = 6;
-                        if (Input::isKeyDown(SDLK_KP7))whichend = 7;
-                        if (Input::isKeyDown(SDLK_KP8))whichend = 8;
-                        if (Input::isKeyDown(SDLK_KP9))whichend = 9;
-                        if (Input::isKeyDown(SDLK_KP0))whichend = 0;
+                        if (Input::isKeyDown(SDLK_KP1)) whichend = 1;
+                        if (Input::isKeyDown(SDLK_KP2)) whichend = 2;
+                        if (Input::isKeyDown(SDLK_KP3)) whichend = 3;
+                        if (Input::isKeyDown(SDLK_KP4)) whichend = 4;
+                        if (Input::isKeyDown(SDLK_KP5)) whichend = 5;
+                        if (Input::isKeyDown(SDLK_KP6)) whichend = 6;
+                        if (Input::isKeyDown(SDLK_KP7)) whichend = 7;
+                        if (Input::isKeyDown(SDLK_KP8)) whichend = 8;
+                        if (Input::isKeyDown(SDLK_KP9)) whichend = 9;
+                        if (Input::isKeyDown(SDLK_KP0)) whichend = 0;
                         participantfacing[whichdialogue][indialogue][whichend] = facing;
                     }
                     if (indialogue >= numdialogueboxes[whichdialogue]) {
@@ -7252,8 +7378,10 @@ void Game::Tick()
 
                                                             player[i].weaponactive = 0;
                                                             if (weapons[k].owner != -1) {
-                                                                if (player[i].victim->num_weapons == 1)player[i].victim->num_weapons = 0;
-                                                                else player[i].victim->num_weapons = 1;
+                                                                if (player[i].victim->num_weapons == 1)
+                                                                    player[i].victim->num_weapons = 0;
+                                                                else
+                                                                    player[i].victim->num_weapons = 1;
 
                                                                 player[i].victim->skeleton.longdead = 0;
                                                                 player[i].victim->skeleton.free = 1;
@@ -7273,7 +7401,8 @@ void Game::Tick()
                                                                 footpoint = weapons[k].position;
                                                                 if (player[i].victim->weaponstuck != -1) {
                                                                     if (player[i].victim->weaponids[player[i].victim->weaponstuck] == k) {
-                                                                        if (bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .8, .3);
+                                                                        if (bloodtoggle)
+                                                                            Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .8, .3);
                                                                         weapons[k].bloody = 2;
                                                                         weapons[k].blooddrip = 5;
                                                                         player[i].victim->weaponstuck = -1;
@@ -7282,7 +7411,8 @@ void Game::Tick()
                                                                     }
                                                                 }
                                                                 if (player[i].victim->num_weapons > 0) {
-                                                                    if (player[i].victim->weaponstuck != 0 && player[i].victim->weaponstuck != -1)player[i].victim->weaponstuck = 0;
+                                                                    if (player[i].victim->weaponstuck != 0 && player[i].victim->weaponstuck != -1)
+                                                                        player[i].victim->weaponstuck = 0;
                                                                     if (player[i].victim->weaponids[0] == k)
                                                                         player[i].victim->weaponids[0] = player[i].victim->weaponids[player[i].victim->num_weapons];
                                                                 }
@@ -7363,7 +7493,8 @@ void Game::Tick()
                                 player[i].throwtogglekeydown = 1;
                                 weapons[player[i].weaponids[0]].owner = -1;
                                 weapons[player[i].weaponids[0]].velocity = player[i].velocity * .2;
-                                if (weapons[player[i].weaponids[0]].velocity.x == 0)weapons[player[i].weaponids[0]].velocity.x = .1;
+                                if (weapons[player[i].weaponids[0]].velocity.x == 0)
+                                    weapons[player[i].weaponids[0]].velocity.x = .1;
                                 weapons[player[i].weaponids[0]].tipvelocity = weapons[player[i].weaponids[0]].velocity;
                                 weapons[player[i].weaponids[0]].missed = 1;
                                 weapons[player[i].weaponids[0]].freetime = 0;
@@ -7372,7 +7503,8 @@ void Game::Tick()
                                 player[i].num_weapons--;
                                 if (player[i].num_weapons) {
                                     player[i].weaponids[0] = player[i].weaponids[player[i].num_weapons];
-                                    if (player[i].weaponstuck == player[i].num_weapons)player[i].weaponstuck = 0;
+                                    if (player[i].weaponstuck == player[i].num_weapons)
+                                        player[i].weaponstuck = 0;
                                 }
 
                                 player[i].weaponactive = -1;
@@ -7519,7 +7651,8 @@ void Game::Tick()
                         }
                         if (!player[i].crouchkeydown) {
                             //Uncrouch
-                            if (!player[i].isRun() && player[i].animTarget != sneakanim && i == 0)player[i].superruntoggle = 0;
+                            if (!player[i].isRun() && player[i].animTarget != sneakanim && i == 0)
+                                player[i].superruntoggle = 0;
                             target = -2;
                             if (player[i].isCrouch()) {
                                 if (numplayers > 1)
@@ -7613,8 +7746,10 @@ void Game::Tick()
                                 player[i].velocity += DoRotation(absflatfacing * 5 * multiplier, 0, -90, 0);
                             }
                             player[i].targetyaw -= 90;
-                            if (player[i].forwardkeydown)player[i].targetyaw += 45;
-                            if (player[i].backkeydown)player[i].targetyaw -= 45;
+                            if (player[i].forwardkeydown)
+                                player[i].targetyaw += 45;
+                            if (player[i].backkeydown)
+                                player[i].targetyaw -= 45;
                             movekey = 1;
                         }
                         if ( player[i].leftkeydown) {
@@ -7640,8 +7775,10 @@ void Game::Tick()
                                 player[i].velocity -= DoRotation(absflatfacing * 5 * multiplier, 0, -90, 0);
                             }
                             player[i].targetyaw += 90;
-                            if (player[i].forwardkeydown)player[i].targetyaw -= 45;
-                            if (player[i].backkeydown)player[i].targetyaw += 45;
+                            if (player[i].forwardkeydown)
+                                player[i].targetyaw -= 45;
+                            if (player[i].backkeydown)
+                                player[i].targetyaw += 45;
                             movekey = 1;
                         }
                         if (player[i].backkeydown) {
@@ -7701,8 +7838,10 @@ void Game::Tick()
                                 facing.z = -1;
                                 flatfacing = DoRotation(facing, 0, player[i].targetyaw + 180, 0);
 
-                                if (movekey)player[i].velocity = flatfacing * player[i].speed * 45 * player[i].scale;
-                                if (!movekey)player[i].velocity = 0;
+                                if (movekey)
+                                    player[i].velocity = flatfacing * player[i].speed * 45 * player[i].scale;
+                                if (!movekey)
+                                    player[i].velocity = 0;
 
                                 //Dodge sweep?
                                 target = -2;
@@ -7712,20 +7851,26 @@ void Game::Tick()
                                             if (distsq(&player[j].coords, &player[j].victim->coords) < 3 &&
                                                     player[j].victim == &player[i] &&
                                                     (player[j].animTarget == sweepanim)) {
-                                                if (target >= 0)target = -1;
-                                                else target = j;
+                                                if (target >= 0)
+                                                    target = -1;
+                                                else
+                                                    target = j;
                                             }
                                         }
                                     }
-                                if (target >= 0)player[i].velocity.y = 1;
-                                else if (player[i].crouchkeydown || player[i].aitype != playercontrolled) {
+                                if (target >= 0)
+                                    player[i].velocity.y = 1;
+                                else
+                                    if (player[i].crouchkeydown || player[i].aitype != playercontrolled) {
                                     player[i].velocity.y = 7;
                                     player[i].crouchtogglekeydown = 1;
                                 } else player[i].velocity.y = 5;
 
                                 if (mousejump && i == 0 && debugmode) {
-                                    if (!player[i].isLanding())player[i].tempdeltav = deltav;
-                                    if (player[i].tempdeltav < 0)player[i].velocity.y -= (float)(player[i].tempdeltav) / multiplier / 1000;
+                                    if (!player[i].isLanding())
+                                        player[i].tempdeltav = deltav;
+                                    if (player[i].tempdeltav < 0)
+                                        player[i].velocity.y -= (float)(player[i].tempdeltav) / multiplier / 1000;
                                 }
 
                                 player[i].coords.y += .2;
@@ -7757,7 +7902,8 @@ void Game::Tick()
                                     player[i].jumppower = 0;
                                 }
                             }
-                            if (((floatjump || editorenabled) && debugmode) && i == 0)player[i].velocity.y += multiplier * 30;
+                            if (((floatjump || editorenabled) && debugmode) && i == 0)
+                                player[i].velocity.y += multiplier * 30;
                         }
 
                         if (!movekey) {
@@ -7889,10 +8035,14 @@ void Game::Tick()
 
                         for (int i = 0; i < player[1].skeleton.num_joints; i++) {
                             if (Random() % 2 == 0) {
-                                if (!player[1].skeleton.free)temp2 = (player[1].coords - player[1].oldcoords) / multiplier / 2; //velocity/2;
-                                if (player[1].skeleton.free)temp2 = player[1].skeleton.joints[i].velocity * player[1].scale / 2;
-                                if (!player[1].skeleton.free)temp = DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position, 0, 0, player[1].tilt), player[1].tilt2, 0, 0), 0, player[1].yaw, 0) * player[1].scale + player[1].coords;
-                                if (player[1].skeleton.free)temp = player[1].skeleton.joints[i].position * player[1].scale + player[1].coords;
+                                if (!player[1].skeleton.free)
+                                    temp2 = (player[1].coords - player[1].oldcoords) / multiplier / 2; //velocity/2;
+                                if (player[1].skeleton.free)
+                                    temp2 = player[1].skeleton.joints[i].velocity * player[1].scale / 2;
+                                if (!player[1].skeleton.free)
+                                    temp = DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position, 0, 0, player[1].tilt), player[1].tilt2, 0, 0), 0, player[1].yaw, 0) * player[1].scale + player[1].coords;
+                                if (player[1].skeleton.free)
+                                    temp = player[1].skeleton.joints[i].position * player[1].scale + player[1].coords;
                                 Sprite::MakeSprite(breathsprite, temp, temp2, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, 1);
                             }
                         }
@@ -7901,10 +8051,14 @@ void Game::Tick()
                         for (int i = 0; i < player[1].skeleton.num_joints; i++) {
                             player[1].skeleton.joints[i].velocity = 0;
                             if (Random() % 2 == 0) {
-                                if (!player[1].skeleton.free)temp2 = (player[1].coords - player[1].oldcoords) / multiplier / 2; //velocity/2;
-                                if (player[1].skeleton.free)temp2 = player[1].skeleton.joints[i].velocity * player[1].scale / 2;
-                                if (!player[1].skeleton.free)temp = DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position, 0, 0, player[1].tilt), player[1].tilt2, 0, 0), 0, player[1].yaw, 0) * player[1].scale + player[1].coords;
-                                if (player[1].skeleton.free)temp = player[1].skeleton.joints[i].position * player[1].scale + player[1].coords;
+                                if (!player[1].skeleton.free)
+                                    temp2 = (player[1].coords - player[1].oldcoords) / multiplier / 2; //velocity/2;
+                                if (player[1].skeleton.free)
+                                    temp2 = player[1].skeleton.joints[i].velocity * player[1].scale / 2;
+                                if (!player[1].skeleton.free)
+                                    temp = DoRotation(DoRotation(DoRotation(player[1].skeleton.joints[i].position, 0, 0, player[1].tilt), player[1].tilt2, 0, 0), 0, player[1].yaw, 0) * player[1].scale + player[1].coords;
+                                if (player[1].skeleton.free)
+                                    temp = player[1].skeleton.joints[i].position * player[1].scale + player[1].coords;
                                 Sprite::MakeSprite(breathsprite, temp, temp2, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, 1);
                             }
                         }
@@ -8138,19 +8292,22 @@ void Game::TickOnceAfter()
             if (alldead && !player[0].dead && maptype == mapkilleveryone) {
                 changedelay = 1;
                 targetlevel = whichlevel + 1;
-                if (targetlevel > numchallengelevels - 1)targetlevel = 0;
+                if (targetlevel > numchallengelevels - 1)
+                    targetlevel = 0;
             }
             if (winhotspot || windialogue) {
                 changedelay = 0.1;
                 targetlevel = whichlevel + 1;
-                if (targetlevel > numchallengelevels - 1)targetlevel = 0;
+                if (targetlevel > numchallengelevels - 1)
+                    targetlevel = 0;
             }
 
 
             if (killhotspot) {
                 changedelay = 1;
                 targetlevel = whichlevel + 1;
-                if (targetlevel > numchallengelevels - 1)targetlevel = 0;
+                if (targetlevel > numchallengelevels - 1)
+                    targetlevel = 0;
             }
 
             if (changedelay > 0 && !player[0].dead && !won) {
@@ -8287,8 +8444,10 @@ void Game::TickOnceAfter()
     viewerfacing = facing;
 
     if (!cameramode) {
-        if ((animation[player[0].animTarget].attack != 3 && animation[player[0].animCurrent].attack != 3) || player[0].skeleton.free)target = player[0].coords + player[0].currentoffset * (1 - player[0].target) * player[0].scale + player[0].targetoffset * player[0].target * player[0].scale - player[0].facing * .05;
-        else target = player[0].oldcoords + player[0].currentoffset * (1 - player[0].target) * player[0].scale + player[0].targetoffset * player[0].target * player[0].scale - player[0].facing * .05;
+        if ((animation[player[0].animTarget].attack != 3 && animation[player[0].animCurrent].attack != 3) || player[0].skeleton.free)
+            target = player[0].coords + player[0].currentoffset * (1 - player[0].target) * player[0].scale + player[0].targetoffset * player[0].target * player[0].scale - player[0].facing * .05;
+        else
+            target = player[0].oldcoords + player[0].currentoffset * (1 - player[0].target) * player[0].scale + player[0].targetoffset * player[0].target * player[0].scale - player[0].facing * .05;
         target.y += .1;
         if (player[0].skeleton.free) {
             for (int i = 0; i < player[0].skeleton.num_joints; i++) {
@@ -8302,17 +8461,23 @@ void Game::TickOnceAfter()
             if (findLengthfast(&player[0].velocity) > 400) {
                 cameraspeed = 20 + (findLength(&player[0].velocity) - 20) * .96;
             }
-            if (player[0].skeleton.free == 0 && player[0].animTarget != hanganim && player[0].animTarget != climbanim)target.y += 1.4;
+            if (player[0].skeleton.free == 0 && player[0].animTarget != hanganim && player[0].animTarget != climbanim)
+                target.y += 1.4;
             coltarget = target - cameraloc;
-            if (findLengthfast(&coltarget) < multiplier * multiplier * 400)cameraloc = target;
+            if (findLengthfast(&coltarget) < multiplier * multiplier * 400)
+                cameraloc = target;
             else {
                 Normalise(&coltarget);
-                if (player[0].animTarget != hanganim && player[0].animTarget != climbanim && player[0].animCurrent != climbanim && player[0].currentoffset.x == 0)cameraloc = cameraloc + coltarget * multiplier * cameraspeed;
-                else cameraloc = cameraloc + coltarget * multiplier * 8;
+                if (player[0].animTarget != hanganim && player[0].animTarget != climbanim && player[0].animCurrent != climbanim && player[0].currentoffset.x == 0)
+                    cameraloc = cameraloc + coltarget * multiplier * cameraspeed;
+                else
+                    cameraloc = cameraloc + coltarget * multiplier * 8;
             }
-            if (editorenabled)cameraloc = target;
+            if (editorenabled)
+                cameraloc = target;
             cameradist += multiplier * 5;
-            if (cameradist > 2.3)cameradist = 2.3;
+            if (cameradist > 2.3)
+                cameradist = 2.3;
             viewer = cameraloc - facing * cameradist;
             colviewer = viewer;
             coltarget = cameraloc;
@@ -8322,7 +8487,8 @@ void Game::TickOnceAfter()
                     int i = terrain.patchobjects[player[0].whichpatchx][player[0].whichpatchz][j];
                     colviewer = viewer;
                     coltarget = cameraloc;
-                    if (objects.model[i].LineCheckPossible(&colviewer, &coltarget, &col, &objects.position[i], &objects.yaw[i]) != -1)viewer = col;
+                    if (objects.model[i].LineCheckPossible(&colviewer, &coltarget, &col, &objects.position[i], &objects.yaw[i]) != -1)
+                        viewer = col;
                 }
             if (terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz])
                 for (int j = 0; j < terrain.patchobjectnum[player[0].whichpatchx][player[0].whichpatchz]; j++) {
@@ -8383,17 +8549,22 @@ void Game::TickOnceAfter()
             }
         }
         */
-        if (camerashake > .8)camerashake = .8;
+        if (camerashake > .8)
+            camerashake = .8;
         //if(woozy>10)woozy=10;
         //woozy+=multiplier;
         woozy += multiplier;
-        if (player[0].dead)camerashake = 0;
-        if (player[0].dead)woozy = 0;
+        if (player[0].dead)
+            camerashake = 0;
+        if (player[0].dead)
+            woozy = 0;
         camerashake -= multiplier * 2;
         blackout -= multiplier * 2;
         //if(player[0].isCrouch())woozy-=multiplier*8;
-        if (camerashake < 0)camerashake = 0;
-        if (blackout < 0)blackout = 0;
+        if (camerashake < 0)
+            camerashake = 0;
+        if (blackout < 0)
+            blackout = 0;
         //if(woozy<0)woozy=0;
         if (camerashake) {
             viewer.x += (float)(Random() % 100) * .0005 * camerashake;
index 609d1b1a24b28f3e7d971ff7d5f56533ca76d56c..65d9ff8642ede49391f1883d9ac64fe3bf6c257e 100644 (file)
@@ -42,10 +42,12 @@ int Model::LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
 
     *p1 = *p1 - *move;
     *p2 = *p2 - *move;
-    if (*rotate)*p1 = DoRotation(*p1, 0, -*rotate, 0);
-    if (*rotate)*p2 = DoRotation(*p2, 0, -*rotate, 0);
-    if (!sphere_line_intersection(p1, p2, &boundingspherecenter,
-                                  &boundingsphereradius))return -1;
+    if (*rotate)
+        *p1 = DoRotation(*p1, 0, -*rotate, 0);
+    if (*rotate)
+        *p2 = DoRotation(*p2, 0, -*rotate, 0);
+    if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius))
+        return -1;
     firstintersecting = -1;
 
     for (j = 0; j < TriangleNum; j++) {
@@ -58,7 +60,8 @@ int Model::LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
         }
     }
 
-    if (*rotate)*p = DoRotation(*p, 0, *rotate, 0);
+    if (*rotate)
+        *p = DoRotation(*p, 0, *rotate, 0);
     *p = *p + *move;
     return firstintersecting;
 }
@@ -74,11 +77,13 @@ int Model::LineCheckSlide(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
 
     *p1 = *p1 - *move;
     *p2 = *p2 - *move;
-    if (!sphere_line_intersection(p1, p2, &boundingspherecenter,
-                                  &boundingsphereradius))return -1;
+    if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius))
+        return -1;
     firstintersecting = -1;
-    if (*rotate)*p1 = DoRotation(*p1, 0, -*rotate, 0);
-    if (*rotate)*p2 = DoRotation(*p2, 0, -*rotate, 0);
+    if (*rotate)
+        *p1 = DoRotation(*p1, 0, -*rotate, 0);
+    if (*rotate)
+        *p2 = DoRotation(*p2, 0, -*rotate, 0);
 
     for (j = 0; j < TriangleNum; j++) {
         intersecting = LineFacetd(p1, p2, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]], &facenormals[j], &point);
@@ -92,7 +97,8 @@ int Model::LineCheckSlide(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
     distance = abs((facenormals[firstintersecting].x * p2->x) + (facenormals[firstintersecting].y * p2->y) + (facenormals[firstintersecting].z * p2->z) - ((facenormals[firstintersecting].x * vertex[Triangles[firstintersecting].vertex[0]].x) + (facenormals[firstintersecting].y * vertex[Triangles[firstintersecting].vertex[0]].y) + (facenormals[firstintersecting].z * vertex[Triangles[firstintersecting].vertex[0]].z)));
     *p2 -= facenormals[firstintersecting] * distance;
 
-    if (*rotate)*p2 = DoRotation(*p2, 0, *rotate, 0);
+    if (*rotate)
+        *p2 = DoRotation(*p2, 0, *rotate, 0);
     *p2 = *p2 + *move;
     return firstintersecting;
 }
@@ -108,11 +114,13 @@ int Model::LineCheckPossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
 
     *p1 = *p1 - *move;
     *p2 = *p2 - *move;
-    if (!sphere_line_intersection(p1, p2, &boundingspherecenter,
-                                  &boundingsphereradius))return -1;
+    if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius))
+        return -1;
     firstintersecting = -1;
-    if (*rotate)*p1 = DoRotation(*p1, 0, -*rotate, 0);
-    if (*rotate)*p2 = DoRotation(*p2, 0, -*rotate, 0);
+    if (*rotate)
+        *p1 = DoRotation(*p1, 0, -*rotate, 0);
+    if (*rotate)
+        *p2 = DoRotation(*p2, 0, -*rotate, 0);
 
     if (numpossible > 0 && numpossible < TriangleNum)
         for (j = 0; j < numpossible; j++) {
@@ -127,7 +135,8 @@ int Model::LineCheckPossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
             }
         }
 
-    if (*rotate)*p = DoRotation(*p, 0, *rotate, 0);
+    if (*rotate)
+        *p = DoRotation(*p, 0, *rotate, 0);
     *p = *p + *move;
     return firstintersecting;
 }
@@ -143,11 +152,13 @@ int Model::LineCheckSlidePossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *ro
 
     *p1 = *p1 - *move;
     *p2 = *p2 - *move;
-    if (!sphere_line_intersection(p1, p2, &boundingspherecenter,
-                                  &boundingsphereradius))return -1;
+    if (!sphere_line_intersection(p1, p2, &boundingspherecenter, &boundingsphereradius))
+        return -1;
     firstintersecting = -1;
-    if (*rotate)*p1 = DoRotation(*p1, 0, -*rotate, 0);
-    if (*rotate)*p2 = DoRotation(*p2, 0, -*rotate, 0);
+    if (*rotate)
+        *p1 = DoRotation(*p1, 0, -*rotate, 0);
+    if (*rotate)
+        *p2 = DoRotation(*p2, 0, -*rotate, 0);
 
     if (numpossible)
         for (j = 0; j < numpossible; j++) {
@@ -166,7 +177,8 @@ int Model::LineCheckSlidePossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *ro
         *p2 -= facenormals[firstintersecting] * distance;
     }
 
-    if (*rotate)*p2 = DoRotation(*p2, 0, *rotate, 0);
+    if (*rotate)
+        *p2 = DoRotation(*p2, 0, *rotate, 0);
     *p2 = *p2 + *move;
     return firstintersecting;
 }
@@ -186,8 +198,10 @@ int Model::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate)
 
     oldp1 = *p1;
     *p1 = *p1 - *move;
-    if (*rotate)*p1 = DoRotation(*p1, 0, -*rotate, 0);
-    if (distsq(p1, &boundingspherecenter) > radius * radius + boundingsphereradius * boundingsphereradius)return -1;
+    if (*rotate)
+        *p1 = DoRotation(*p1, 0, -*rotate, 0);
+    if (distsq(p1, &boundingspherecenter) > radius * radius + boundingsphereradius * boundingsphereradius)
+        return -1;
 
     for (i = 0; i < 4; i++) {
         for (j = 0; j < TriangleNum; j++) {
@@ -195,16 +209,14 @@ int Model::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate)
             distance = abs((facenormals[j].x * p1->x) + (facenormals[j].y * p1->y) + (facenormals[j].z * p1->z) - ((facenormals[j].x * vertex[Triangles[j].vertex[0]].x) + (facenormals[j].y * vertex[Triangles[j].vertex[0]].y) + (facenormals[j].z * vertex[Triangles[j].vertex[0]].z)));
             if (distance < radius) {
                 point = *p1 - facenormals[j] * distance;
-                if (PointInTriangle( &point, facenormals[j], &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]]))intersecting = 1;
-                if (!intersecting)intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]],
-                                                     &vertex[Triangles[j].vertex[1]],
-                                                     p1, &radius);
-                if (!intersecting)intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[1]],
-                                                     &vertex[Triangles[j].vertex[2]],
-                                                     p1, &radius);
-                if (!intersecting)intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]],
-                                                     &vertex[Triangles[j].vertex[2]],
-                                                     p1, &radius);
+                if (PointInTriangle( &point, facenormals[j], &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]]))
+                    intersecting = 1;
+                if (!intersecting)
+                    intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], p1, &radius);
+                if (!intersecting)
+                    intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]], p1, &radius);
+                if (!intersecting)
+                    intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[2]], p1, &radius);
                 if (intersecting) {
                     *p1 += facenormals[j] * (distance - radius);
                     /*start=*p1;
@@ -222,9 +234,11 @@ int Model::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate)
             }
         }
     }
-    if (*rotate)*p = DoRotation(*p, 0, *rotate, 0);
+    if (*rotate)
+        *p = DoRotation(*p, 0, *rotate, 0);
     *p = *p + *move;
-    if (*rotate)*p1 = DoRotation(*p1, 0, *rotate, 0);
+    if (*rotate)
+        *p1 = DoRotation(*p1, 0, *rotate, 0);
     *p1 += *move;
     return firstintersecting;
 }
@@ -247,7 +261,8 @@ int Model::SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate)
 
     numpossible = 0;
 
-    if (*rotate)*p1 = DoRotation(*p1, 0, -*rotate, 0);
+    if (*rotate)
+        *p1 = DoRotation(*p1, 0, -*rotate, 0);
     if (distsq(p1, &boundingspherecenter) > radius * radius + boundingsphereradius * boundingsphereradius) {
         *p1 = oldp1;
         return -1;
@@ -258,16 +273,14 @@ int Model::SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate)
         distance = abs((facenormals[j].x * p1->x) + (facenormals[j].y * p1->y) + (facenormals[j].z * p1->z) - ((facenormals[j].x * vertex[Triangles[j].vertex[0]].x) + (facenormals[j].y * vertex[Triangles[j].vertex[0]].y) + (facenormals[j].z * vertex[Triangles[j].vertex[0]].z)));
         if (distance < radius) {
             point = *p1 - facenormals[j] * distance;
-            if (PointInTriangle( &point, facenormals[j], &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]]))intersecting = 1;
-            if (!intersecting)intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]],
-                                                 &vertex[Triangles[j].vertex[1]],
-                                                 p1, &radius);
-            if (!intersecting)intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[1]],
-                                                 &vertex[Triangles[j].vertex[2]],
-                                                 p1, &radius);
-            if (!intersecting)intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]],
-                                                 &vertex[Triangles[j].vertex[2]],
-                                                 p1, &radius);
+            if (PointInTriangle( &point, facenormals[j], &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]]))
+                intersecting = 1;
+            if (!intersecting)
+                intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], p1, &radius);
+            if (!intersecting)
+                intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]], p1, &radius);
+            if (!intersecting)
+                intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[2]], p1, &radius);
             if (intersecting) {
                 //if(j>=0&&j<TriangleNum)
                 possible[numpossible] = j;
@@ -279,7 +292,8 @@ int Model::SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate)
             firstintersecting = j;
         }
     }
-    if (*rotate)*p1 = DoRotation(*p1, 0, *rotate, 0);
+    if (*rotate)
+        *p1 = DoRotation(*p1, 0, *rotate, 0);
     *p1 += *move;
     return firstintersecting;
 }
@@ -287,7 +301,8 @@ int Model::SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate)
 
 void Model::UpdateVertexArray()
 {
-    if (type != normaltype && type != decalstype)return;
+    if (type != normaltype && type != decalstype)
+        return;
     static int i;
     static int j;
     if (!flat)
@@ -355,7 +370,8 @@ void Model::UpdateVertexArray()
 
 void Model::UpdateVertexArrayNoTex()
 {
-    if (type != normaltype && type != decalstype)return;
+    if (type != normaltype && type != decalstype)
+        return;
     static int i;
     static int j;
     if (!flat)
@@ -410,7 +426,8 @@ void Model::UpdateVertexArrayNoTex()
 
 void Model::UpdateVertexArrayNoTexNoNorm()
 {
-    if (type != normaltype && type != decalstype)return;
+    if (type != normaltype && type != decalstype)
+        return;
     static int i;
     static int j;
     for (i = 0; i < TriangleNum; i++) {
@@ -807,7 +824,8 @@ void Model::Scale(float xscale, float yscale, float zscale)
 
 void Model::ScaleNormals(float xscale, float yscale, float zscale)
 {
-    if (type != normaltype && type != decalstype)return;
+    if (type != normaltype && type != decalstype)
+        return;
     static int i;
     for (i = 0; i < vertexNum; i++) {
         normals[i].x *= xscale;
@@ -872,7 +890,8 @@ void Model::CalculateNormals(bool facenormalise)
     if (visibleloading)
         Game::LoadingScreen();
     static int i;
-    if (type != normaltype && type != decalstype)return;
+    if (type != normaltype && type != decalstype)
+        return;
 
     for (i = 0; i < vertexNum; i++) {
         normals[i].x = 0;
@@ -894,7 +913,8 @@ void Model::CalculateNormals(bool facenormalise)
         normals[Triangles[i].vertex[2]].x += facenormals[i].x;
         normals[Triangles[i].vertex[2]].y += facenormals[i].y;
         normals[Triangles[i].vertex[2]].z += facenormals[i].z;
-        if (facenormalise)Normalise(&facenormals[i]);
+        if (facenormalise)
+            Normalise(&facenormals[i]);
     }
     for (i = 0; i < vertexNum; i++) {
         Normalise(&normals[i]);
@@ -914,21 +934,30 @@ void Model::drawimmediate()
         &&isnormal(vertex[Triangles[i].vertex[2]].x)&&isnormal(vertex[Triangles[i].vertex[2]].y)&&isnormal(vertex[Triangles[i].vertex[2]].z)){
         */
         glTexCoord2f(Triangles[i].gx[0], Triangles[i].gy[0]);
-        if (color)glColor3f(normals[Triangles[i].vertex[0]].x, normals[Triangles[i].vertex[0]].y, normals[Triangles[i].vertex[0]].z);
-        if (!color && !flat)glNormal3f(normals[Triangles[i].vertex[0]].x, normals[Triangles[i].vertex[0]].y, normals[Triangles[i].vertex[0]].z);
-        if (!color && flat)glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y);
+        if (color)
+            glColor3f(normals[Triangles[i].vertex[0]].x, normals[Triangles[i].vertex[0]].y, normals[Triangles[i].vertex[0]].z);
+        if (!color && !flat)
+            glNormal3f(normals[Triangles[i].vertex[0]].x, normals[Triangles[i].vertex[0]].y, normals[Triangles[i].vertex[0]].z);
+        if (!color && flat)
+            glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y);
         glVertex3f(vertex[Triangles[i].vertex[0]].x, vertex[Triangles[i].vertex[0]].y, vertex[Triangles[i].vertex[0]].z);
 
         glTexCoord2f(Triangles[i].gx[1], Triangles[i].gy[1]);
-        if (color)glColor3f(normals[Triangles[i].vertex[1]].x, normals[Triangles[i].vertex[1]].y, normals[Triangles[i].vertex[1]].z);
-        if (!color && !flat)glNormal3f(normals[Triangles[i].vertex[1]].x, normals[Triangles[i].vertex[1]].y, normals[Triangles[i].vertex[1]].z);
-        if (!color && flat)glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y);
+        if (color)
+            glColor3f(normals[Triangles[i].vertex[1]].x, normals[Triangles[i].vertex[1]].y, normals[Triangles[i].vertex[1]].z);
+        if (!color && !flat)
+            glNormal3f(normals[Triangles[i].vertex[1]].x, normals[Triangles[i].vertex[1]].y, normals[Triangles[i].vertex[1]].z);
+        if (!color && flat)
+            glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y);
         glVertex3f(vertex[Triangles[i].vertex[1]].x, vertex[Triangles[i].vertex[1]].y, vertex[Triangles[i].vertex[1]].z);
 
         glTexCoord2f(Triangles[i].gx[2], Triangles[i].gy[2]);
-        if (color)glColor3f(normals[Triangles[i].vertex[2]].x, normals[Triangles[i].vertex[2]].y, normals[Triangles[i].vertex[2]].z);
-        if (!color && !flat)glNormal3f(normals[Triangles[i].vertex[2]].x, normals[Triangles[i].vertex[2]].y, normals[Triangles[i].vertex[2]].z);
-        if (!color && flat)glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y);
+        if (color)
+            glColor3f(normals[Triangles[i].vertex[2]].x, normals[Triangles[i].vertex[2]].y, normals[Triangles[i].vertex[2]].z);
+        if (!color && !flat)
+            glNormal3f(normals[Triangles[i].vertex[2]].x, normals[Triangles[i].vertex[2]].y, normals[Triangles[i].vertex[2]].z);
+        if (!color && flat)
+            glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y);
         glVertex3f(vertex[Triangles[i].vertex[2]].x, vertex[Triangles[i].vertex[2]].y, vertex[Triangles[i].vertex[2]].z);
         //}
         //}
@@ -938,14 +967,17 @@ void Model::drawimmediate()
 
 void Model::draw()
 {
-    if (type != normaltype && type != decalstype)return;
+    if (type != normaltype && type != decalstype)
+        return;
 
     glEnableClientState(GL_NORMAL_ARRAY);
     glEnableClientState(GL_VERTEX_ARRAY);
     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 
-    if (!color)glInterleavedArrays( GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
-    if (color)glInterleavedArrays( GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+    if (!color)
+        glInterleavedArrays( GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+    if (color)
+        glInterleavedArrays( GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
     textureptr.bind();
 
 #if PLATFORM_MACOSX
@@ -957,8 +989,10 @@ void Model::draw()
 #endif
 
 
-    if (!color)glDisableClientState(GL_NORMAL_ARRAY);
-    if (color)glDisableClientState(GL_COLOR_ARRAY);
+    if (!color)
+        glDisableClientState(GL_NORMAL_ARRAY);
+    if (color)
+        glDisableClientState(GL_COLOR_ARRAY);
     glDisableClientState(GL_VERTEX_ARRAY);
     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
     //drawimmediate();
@@ -970,8 +1004,10 @@ void Model::drawdifftex(GLuint texture)
     glEnableClientState(GL_NORMAL_ARRAY);
     glEnableClientState(GL_VERTEX_ARRAY);
     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-    if (!color)glInterleavedArrays( GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
-    if (color)glInterleavedArrays( GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+    if (!color)
+        glInterleavedArrays( GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+    if (color)
+        glInterleavedArrays( GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
 
     glBindTexture(GL_TEXTURE_2D, (unsigned long)texture);
     glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
@@ -987,8 +1023,10 @@ void Model::drawdifftex(GLuint texture)
 #endif
 
 
-    if (!color)glDisableClientState(GL_NORMAL_ARRAY);
-    if (color)glDisableClientState(GL_COLOR_ARRAY);
+    if (!color)
+        glDisableClientState(GL_NORMAL_ARRAY);
+    if (color)
+        glDisableClientState(GL_COLOR_ARRAY);
     glDisableClientState(GL_VERTEX_ARRAY);
     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
     //drawdiffteximmediate(texture);
@@ -999,8 +1037,10 @@ void Model::drawdifftex(Texture texture)
     glEnableClientState(GL_NORMAL_ARRAY);
     glEnableClientState(GL_VERTEX_ARRAY);
     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-    if (!color)glInterleavedArrays( GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
-    if (color)glInterleavedArrays( GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+    if (!color)
+        glInterleavedArrays( GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+    if (color)
+        glInterleavedArrays( GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
 
     texture.bind();
     glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
@@ -1016,8 +1056,10 @@ void Model::drawdifftex(Texture texture)
 #endif
 
 
-    if (!color)glDisableClientState(GL_NORMAL_ARRAY);
-    if (color)glDisableClientState(GL_COLOR_ARRAY);
+    if (!color)
+        glDisableClientState(GL_NORMAL_ARRAY);
+    if (color)
+        glDisableClientState(GL_COLOR_ARRAY);
     glDisableClientState(GL_VERTEX_ARRAY);
     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
     //drawdiffteximmediate(texture);
@@ -1034,21 +1076,30 @@ void Model::drawdiffteximmediate(GLuint texture)
         &&isnormal(vertex[Triangles[i].vertex[1]].x)&&isnormal(vertex[Triangles[i].vertex[1]].y)&&isnormal(vertex[Triangles[i].vertex[1]].z)
         &&isnormal(vertex[Triangles[i].vertex[2]].x)&&isnormal(vertex[Triangles[i].vertex[2]].y)&&isnormal(vertex[Triangles[i].vertex[2]].z)){
         */glTexCoord2f(Triangles[i].gx[0], Triangles[i].gy[0]);
-        if (color)glColor3f(normals[Triangles[i].vertex[0]].x, normals[Triangles[i].vertex[0]].y, normals[Triangles[i].vertex[0]].z);
-        if (!color && !flat)glNormal3f(normals[Triangles[i].vertex[0]].x, normals[Triangles[i].vertex[0]].y, normals[Triangles[i].vertex[0]].z);
-        if (!color && flat)glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y);
+        if (color)
+            glColor3f(normals[Triangles[i].vertex[0]].x, normals[Triangles[i].vertex[0]].y, normals[Triangles[i].vertex[0]].z);
+        if (!color && !flat)
+            glNormal3f(normals[Triangles[i].vertex[0]].x, normals[Triangles[i].vertex[0]].y, normals[Triangles[i].vertex[0]].z);
+        if (!color && flat)
+            glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y);
         glVertex3f(vertex[Triangles[i].vertex[0]].x, vertex[Triangles[i].vertex[0]].y, vertex[Triangles[i].vertex[0]].z);
 
         glTexCoord2f(Triangles[i].gx[1], Triangles[i].gy[1]);
-        if (color)glColor3f(normals[Triangles[i].vertex[1]].x, normals[Triangles[i].vertex[1]].y, normals[Triangles[i].vertex[1]].z);
-        if (!color && !flat)glNormal3f(normals[Triangles[i].vertex[1]].x, normals[Triangles[i].vertex[1]].y, normals[Triangles[i].vertex[1]].z);
-        if (!color && flat)glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y);
+        if (color)
+            glColor3f(normals[Triangles[i].vertex[1]].x, normals[Triangles[i].vertex[1]].y, normals[Triangles[i].vertex[1]].z);
+        if (!color && !flat)
+            glNormal3f(normals[Triangles[i].vertex[1]].x, normals[Triangles[i].vertex[1]].y, normals[Triangles[i].vertex[1]].z);
+        if (!color && flat)
+            glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y);
         glVertex3f(vertex[Triangles[i].vertex[1]].x, vertex[Triangles[i].vertex[1]].y, vertex[Triangles[i].vertex[1]].z);
 
         glTexCoord2f(Triangles[i].gx[2], Triangles[i].gy[2]);
-        if (color)glColor3f(normals[Triangles[i].vertex[2]].x, normals[Triangles[i].vertex[2]].y, normals[Triangles[i].vertex[2]].z);
-        if (!color && !flat)glNormal3f(normals[Triangles[i].vertex[2]].x, normals[Triangles[i].vertex[2]].y, normals[Triangles[i].vertex[2]].z);
-        if (!color && flat)glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y);
+        if (color)
+            glColor3f(normals[Triangles[i].vertex[2]].x, normals[Triangles[i].vertex[2]].y, normals[Triangles[i].vertex[2]].z);
+        if (!color && !flat)
+            glNormal3f(normals[Triangles[i].vertex[2]].x, normals[Triangles[i].vertex[2]].y, normals[Triangles[i].vertex[2]].z);
+        if (!color && flat)
+            glNormal3f(facenormals[i].x, facenormals[i].y, facenormals[i].y);
         glVertex3f(vertex[Triangles[i].vertex[2]].x, vertex[Triangles[i].vertex[2]].y, vertex[Triangles[i].vertex[2]].z);
         //}
         //}
@@ -1059,7 +1110,8 @@ void Model::drawdiffteximmediate(GLuint texture)
 void Model::drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloodtexture2, Texture breaktexture)
 {
     if (decals) {
-        if (type != decalstype)return;
+        if (type != decalstype)
+            return;
         static int i, j;
         static float distancemult;
         static int lasttype;
@@ -1075,9 +1127,11 @@ void Model::drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloo
         glDisable(GL_CULL_FACE);
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
         glDepthMask(0);
-        if (numdecals > max_model_decals)numdecals = max_model_decals;
+        if (numdecals > max_model_decals)
+            numdecals = max_model_decals;
         for (i = 0; i < numdecals; i++) {
-            if (decaltype[i] == blooddecalfast && decalalivetime[i] < 2)decalalivetime[i] = 2;
+            if (decaltype[i] == blooddecalfast && decalalivetime[i] < 2)
+                decalalivetime[i] = 2;
 
             if (decaltype[i] == shadowdecal && decaltype[i] != lasttype) {
                 shadowtexture.bind();
@@ -1116,12 +1170,15 @@ void Model::drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloo
             }
             if (decaltype[i] == breakdecal) {
                 glColor4f(1, 1, 1, decalopacity[i]);
-                if (decalalivetime[i] > 58)glColor4f(1, 1, 1, decalopacity[i] * (60 - decalalivetime[i]) / 2);
+                if (decalalivetime[i] > 58)
+                    glColor4f(1, 1, 1, decalopacity[i] * (60 - decalalivetime[i]) / 2);
             }
             if ((decaltype[i] == blooddecal || decaltype[i] == blooddecalfast || decaltype[i] == blooddecalslow)) {
                 glColor4f(1, 1, 1, decalopacity[i]);
-                if (decalalivetime[i] < 4)glColor4f(1, 1, 1, decalopacity[i]*decalalivetime[i]*.25);
-                if (decalalivetime[i] > 58)glColor4f(1, 1, 1, decalopacity[i] * (60 - decalalivetime[i]) / 2);
+                if (decalalivetime[i] < 4)
+                    glColor4f(1, 1, 1, decalopacity[i]*decalalivetime[i]*.25);
+                if (decalalivetime[i] > 58)
+                    glColor4f(1, 1, 1, decalopacity[i] * (60 - decalalivetime[i]) / 2);
             }
             lasttype = decaltype[i];
             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
@@ -1139,10 +1196,14 @@ void Model::drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloo
         }
         for (i = numdecals - 1; i >= 0; i--) {
             decalalivetime[i] += multiplier;
-            if (decaltype[i] == blooddecalslow)decalalivetime[i] -= multiplier * 2 / 3;
-            if (decaltype[i] == blooddecalfast)decalalivetime[i] += multiplier * 4;
-            if (decaltype[i] == shadowdecal)DeleteDecal(i);
-            if ((decaltype[i] == blooddecal || decaltype[i] == blooddecalfast || decaltype[i] == blooddecalslow) && decalalivetime[i] >= 60)DeleteDecal(i);
+            if (decaltype[i] == blooddecalslow)
+                decalalivetime[i] -= multiplier * 2 / 3;
+            if (decaltype[i] == blooddecalfast)
+                decalalivetime[i] += multiplier * 4;
+            if (decaltype[i] == shadowdecal)
+                DeleteDecal(i);
+            if ((decaltype[i] == blooddecal || decaltype[i] == blooddecalfast || decaltype[i] == blooddecalslow) && decalalivetime[i] >= 60)
+                DeleteDecal(i);
         }
         glAlphaFunc(GL_GREATER, 0.0001);
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -1152,7 +1213,8 @@ void Model::drawdecals(Texture shadowtexture, Texture bloodtexture, Texture bloo
 void Model::DeleteDecal(int which)
 {
     if (decals) {
-        if (type != decalstype)return;
+        if (type != decalstype)
+            return;
         decaltype[which] = decaltype[numdecals - 1];
         decalposition[which] = decalposition[numdecals - 1];
         for (int i = 0; i < 3; i++) {
@@ -1170,7 +1232,8 @@ void Model::DeleteDecal(int which)
 void Model::MakeDecal(int atype, XYZ *where, float *size, float *opacity, float *rotation)
 {
     if (decals) {
-        if (type != decalstype)return;
+        if (type != decalstype)
+            return;
 
         static float placex, placez;
         static XYZ rot;
@@ -1236,7 +1299,8 @@ void Model::MakeDecal(int atype, XYZ *where, float *size, float *opacity, float
                                                     decaltexcoords[numdecals][j][1] = rot.z + .5;
                                                 }
                                             }
-                                            if (numdecals < max_model_decals - 1)numdecals++;
+                                            if (numdecals < max_model_decals - 1)
+                                                numdecals++;
                                         }
                         }
                     }
@@ -1247,7 +1311,8 @@ void Model::MakeDecal(int atype, XYZ *where, float *size, float *opacity, float
 void Model::MakeDecal(int atype, XYZ where, float size, float opacity, float rotation)
 {
     if (decals) {
-        if (type != decalstype)return;
+        if (type != decalstype)
+            return;
 
         static float placex, placez;
         static XYZ rot;
@@ -1313,7 +1378,8 @@ void Model::MakeDecal(int atype, XYZ where, float size, float opacity, float rot
                                                     decaltexcoords[numdecals][j][1] = rot.z + .5;
                                                 }
                                             }
-                                            if (numdecals < max_model_decals - 1)numdecals++;
+                                            if (numdecals < max_model_decals - 1)
+                                                numdecals++;
                                         }
                         }
                     } else if (distance < .02 && abs(facenormals[i].x) > abs(facenormals[i].y) && abs(facenormals[i].x) > abs(facenormals[i].z)) {
@@ -1370,7 +1436,8 @@ void Model::MakeDecal(int atype, XYZ where, float size, float opacity, float rot
                                                     decaltexcoords[numdecals][j][1] = rot.z + .5;
                                                 }
                                             }
-                                            if (numdecals < max_model_decals - 1)numdecals++;
+                                            if (numdecals < max_model_decals - 1)
+                                                numdecals++;
                                         }
                         }
                     } else if (distance < .02 && abs(facenormals[i].z) > abs(facenormals[i].y) && abs(facenormals[i].z) > abs(facenormals[i].x)) {
@@ -1427,7 +1494,8 @@ void Model::MakeDecal(int atype, XYZ where, float size, float opacity, float rot
                                                     decaltexcoords[numdecals][j][1] = rot.z + .5;
                                                 }
                                             }
-                                            if (numdecals < max_model_decals - 1)numdecals++;
+                                            if (numdecals < max_model_decals - 1)
+                                                numdecals++;
                                         }
                         }
                     }
@@ -1445,25 +1513,32 @@ void Model::deallocate()
 {
     int i = 0, j = 0;
 
-    if (owner)free(owner);
+    if (owner)
+        free(owner);
     owner = 0;
 
-    if (possible)free(possible);
+    if (possible)
+        free(possible);
     possible = 0;
 
-    if (vertex)free(vertex);
+    if (vertex)
+        free(vertex);
     vertex = 0;
 
-    if (normals)free(normals);
+    if (normals)
+        free(normals);
     normals = 0;
 
-    if (facenormals)free(facenormals);
+    if (facenormals)
+        free(facenormals);
     facenormals = 0;
 
-    if (Triangles)free(Triangles);
+    if (Triangles)
+        free(Triangles);
     Triangles = 0;
 
-    if (vArray)free(vArray);
+    if (vArray)
+        free(vArray);
     vArray = 0;
 
 
index df5f1bcabb58561c6622b3eab9db1e18dbabfd90..6f3d3c08f44a5f981fdbb72d5a1f900538f1bd9b 100644 (file)
@@ -53,7 +53,8 @@ bool  Objects::checkcollide(XYZ startpoint, XYZ endpoint, int which)
         if (type[i] != treeleavestype && type[i] != treetrunktype && type[i] != bushtype && type[i] != firetype && i != which) {
             colviewer = startpoint;
             coltarget = endpoint;
-            if (model[i].LineCheck(&colviewer, &coltarget, &colpoint, &position[i], &yaw[i]) != -1)return 1;
+            if (model[i].LineCheck(&colviewer, &coltarget, &colpoint, &position[i], &yaw[i]) != -1)
+                return 1;
         }
     }
 
@@ -96,10 +97,13 @@ void Objects::Draw()
                 hidden = !(distsqflat(&viewer, &position[i]) > playerdist + 3 || (type[i] != bushtype && type[i] != treeleavestype));
                 if (!hidden) {
 
-                    if (detail == 2 && distance > viewdistance * viewdistance / 4 && environment == desertenvironment)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness );
-                    else glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 );
+                    if (detail == 2 && distance > viewdistance * viewdistance / 4 && environment == desertenvironment)
+                        glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness );
+                    else
+                        glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 );
                     distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
-                    if (distance > 1)distance = 1;
+                    if (distance > 1)
+                        distance = 1;
                     if (distance > 0) {
 
                         /*if(checkcollide(viewer,DoRotation(model[i].vertex[model[i].vertexNum],0,yaw[i],0)*scale[i]+position[i],i)){
@@ -109,33 +113,39 @@ void Objects::Draw()
                         if (occluded[i] < 6) {
                             glMatrixMode(GL_MODELVIEW);                                                        // Select The Modelview Matrix
                             glPushMatrix();
-                            if (!model[i].color)glEnable(GL_LIGHTING);
-                            else glDisable(GL_LIGHTING);
+                            if (!model[i].color)
+                                glEnable(GL_LIGHTING);
+                            else
+                                glDisable(GL_LIGHTING);
                             glDepthMask(1);
                             glTranslatef(position[i].x, position[i].y, position[i].z);
                             if (type[i] == bushtype) {
                                 messedwith[i] -= multiplier;
                                 if (rotxvel[i] || rotx[i]) {
-                                    if (rotx[i] > 0)rotxvel[i] -= multiplier * 8 * fabs(rotx[i]);
-                                    if (rotx[i] < 0)rotxvel[i] += multiplier * 8 * fabs(rotx[i]);
-                                    if (rotx[i] > 0)rotxvel[i] -= multiplier * 4;
-                                    if (rotx[i] < 0)rotxvel[i] += multiplier * 4;
-                                    if (rotxvel[i] > 0)rotxvel[i] -= multiplier * 4;
-                                    if (rotxvel[i] < 0)rotxvel[i] += multiplier * 4;
-                                    if (fabs(rotx[i]) < multiplier * 4)rotx[i] = 0;
-                                    if (fabs(rotxvel[i]) < multiplier * 4)rotxvel[i] = 0;
+                                    if (rotx[i] > 0) rotxvel[i] -= multiplier * 8 * fabs(rotx[i]);
+                                    if (rotx[i] < 0) rotxvel[i] += multiplier * 8 * fabs(rotx[i]);
+                                    if (rotx[i] > 0) rotxvel[i] -= multiplier * 4;
+                                    if (rotx[i] < 0) rotxvel[i] += multiplier * 4;
+                                    if (rotxvel[i] > 0) rotxvel[i] -= multiplier * 4;
+                                    if (rotxvel[i] < 0) rotxvel[i] += multiplier * 4;
+                                    if (fabs(rotx[i]) < multiplier * 4)
+                                        rotx[i] = 0;
+                                    if (fabs(rotxvel[i]) < multiplier * 4)
+                                        rotxvel[i] = 0;
 
                                     rotx[i] += rotxvel[i] * multiplier * 4;
                                 }
                                 if (rotyvel[i] || roty[i]) {
-                                    if (roty[i] > 0)rotyvel[i] -= multiplier * 8 * fabs(roty[i]);
-                                    if (roty[i] < 0)rotyvel[i] += multiplier * 8 * fabs(roty[i]);
-                                    if (roty[i] > 0)rotyvel[i] -= multiplier * 4;
-                                    if (roty[i] < 0)rotyvel[i] += multiplier * 4;
-                                    if (rotyvel[i] > 0)rotyvel[i] -= multiplier * 4;
-                                    if (rotyvel[i] < 0)rotyvel[i] += multiplier * 4;
-                                    if (fabs(roty[i]) < multiplier * 4)roty[i] = 0;
-                                    if (fabs(rotyvel[i]) < multiplier * 4)rotyvel[i] = 0;
+                                    if (roty[i] > 0) rotyvel[i] -= multiplier * 8 * fabs(roty[i]);
+                                    if (roty[i] < 0) rotyvel[i] += multiplier * 8 * fabs(roty[i]);
+                                    if (roty[i] > 0) rotyvel[i] -= multiplier * 4;
+                                    if (roty[i] < 0) rotyvel[i] += multiplier * 4;
+                                    if (rotyvel[i] > 0) rotyvel[i] -= multiplier * 4;
+                                    if (rotyvel[i] < 0) rotyvel[i] += multiplier * 4;
+                                    if (fabs(roty[i]) < multiplier * 4)
+                                        roty[i] = 0;
+                                    if (fabs(rotyvel[i]) < multiplier * 4)
+                                        rotyvel[i] = 0;
 
                                     roty[i] += rotyvel[i] * multiplier * 4;
                                 }
@@ -145,35 +155,43 @@ void Objects::Draw()
                                 if (rotx[i]) {
                                     glRotatef(-rotx[i], 0, 0, 1);
                                 }
-                                if (rotx[i] > 10)rotx[i] = 10;
-                                if (rotx[i] < -10)rotx[i] = -10;
-                                if (roty[i] > 10)roty[i] = 10;
-                                if (roty[i] < -10)roty[i] = -10;
+                                if (rotx[i] > 10)
+                                    rotx[i] = 10;
+                                if (rotx[i] < -10)
+                                    rotx[i] = -10;
+                                if (roty[i] > 10)
+                                    roty[i] = 10;
+                                if (roty[i] < -10)
+                                    roty[i] = -10;
                             }
                             if (type[i] == treetrunktype || type[i] == treeleavestype) {
                                 if (type[i] == treetrunktype || environment == 2) {
                                     messedwith[i] -= multiplier;
                                     if (rotxvel[i] || rotx[i]) {
-                                        if (rotx[i] > 0)rotxvel[i] -= multiplier * 8 * fabs(rotx[i]);
-                                        if (rotx[i] < 0)rotxvel[i] += multiplier * 8 * fabs(rotx[i]);
-                                        if (rotx[i] > 0)rotxvel[i] -= multiplier * 4;
-                                        if (rotx[i] < 0)rotxvel[i] += multiplier * 4;
-                                        if (rotxvel[i] > 0)rotxvel[i] -= multiplier * 4;
-                                        if (rotxvel[i] < 0)rotxvel[i] += multiplier * 4;
-                                        if (fabs(rotx[i]) < multiplier * 4)rotx[i] = 0;
-                                        if (fabs(rotxvel[i]) < multiplier * 4)rotxvel[i] = 0;
+                                        if (rotx[i] > 0) rotxvel[i] -= multiplier * 8 * fabs(rotx[i]);
+                                        if (rotx[i] < 0) rotxvel[i] += multiplier * 8 * fabs(rotx[i]);
+                                        if (rotx[i] > 0) rotxvel[i] -= multiplier * 4;
+                                        if (rotx[i] < 0) rotxvel[i] += multiplier * 4;
+                                        if (rotxvel[i] > 0) rotxvel[i] -= multiplier * 4;
+                                        if (rotxvel[i] < 0) rotxvel[i] += multiplier * 4;
+                                        if (fabs(rotx[i]) < multiplier * 4)
+                                            rotx[i] = 0;
+                                        if (fabs(rotxvel[i]) < multiplier * 4)
+                                            rotxvel[i] = 0;
 
                                         rotx[i] += rotxvel[i] * multiplier * 4;
                                     }
                                     if (rotyvel[i] || roty[i]) {
-                                        if (roty[i] > 0)rotyvel[i] -= multiplier * 8 * fabs(roty[i]);
-                                        if (roty[i] < 0)rotyvel[i] += multiplier * 8 * fabs(roty[i]);
-                                        if (roty[i] > 0)rotyvel[i] -= multiplier * 4;
-                                        if (roty[i] < 0)rotyvel[i] += multiplier * 4;
-                                        if (rotyvel[i] > 0)rotyvel[i] -= multiplier * 4;
-                                        if (rotyvel[i] < 0)rotyvel[i] += multiplier * 4;
-                                        if (fabs(roty[i]) < multiplier * 4)roty[i] = 0;
-                                        if (fabs(rotyvel[i]) < multiplier * 4)rotyvel[i] = 0;
+                                        if (roty[i] > 0) rotyvel[i] -= multiplier * 8 * fabs(roty[i]);
+                                        if (roty[i] < 0) rotyvel[i] += multiplier * 8 * fabs(roty[i]);
+                                        if (roty[i] > 0) rotyvel[i] -= multiplier * 4;
+                                        if (roty[i] < 0) rotyvel[i] += multiplier * 4;
+                                        if (rotyvel[i] > 0) rotyvel[i] -= multiplier * 4;
+                                        if (rotyvel[i] < 0) rotyvel[i] += multiplier * 4;
+                                        if (fabs(roty[i]) < multiplier * 4)
+                                            roty[i] = 0;
+                                        if (fabs(rotyvel[i]) < multiplier * 4)
+                                            rotyvel[i] = 0;
 
                                         roty[i] += rotyvel[i] * multiplier * 4;
                                     }
@@ -183,33 +201,41 @@ void Objects::Draw()
                                     if (rotx[i]) {
                                         glRotatef(-rotx[i] / 6, 0, 0, 1);
                                     }
-                                    if (rotx[i] > 10)rotx[i] = 10;
-                                    if (rotx[i] < -10)rotx[i] = -10;
-                                    if (roty[i] > 10)roty[i] = 10;
-                                    if (roty[i] < -10)roty[i] = -10;
+                                    if (rotx[i] > 10)
+                                        rotx[i] = 10;
+                                    if (rotx[i] < -10)
+                                        rotx[i] = -10;
+                                    if (roty[i] > 10)
+                                        roty[i] = 10;
+                                    if (roty[i] < -10)
+                                        roty[i] = -10;
                                 } else {
                                     messedwith[i] -= multiplier;
                                     if (rotxvel[i] || rotx[i]) {
-                                        if (rotx[i] > 0)rotxvel[i] -= multiplier * 8 * fabs(rotx[i]);
-                                        if (rotx[i] < 0)rotxvel[i] += multiplier * 8 * fabs(rotx[i]);
-                                        if (rotx[i] > 0)rotxvel[i] -= multiplier * 4;
-                                        if (rotx[i] < 0)rotxvel[i] += multiplier * 4;
-                                        if (rotxvel[i] > 0)rotxvel[i] -= multiplier * 4;
-                                        if (rotxvel[i] < 0)rotxvel[i] += multiplier * 4;
-                                        if (fabs(rotx[i]) < multiplier * 4)rotx[i] = 0;
-                                        if (fabs(rotxvel[i]) < multiplier * 4)rotxvel[i] = 0;
+                                        if (rotx[i] > 0) rotxvel[i] -= multiplier * 8 * fabs(rotx[i]);
+                                        if (rotx[i] < 0) rotxvel[i] += multiplier * 8 * fabs(rotx[i]);
+                                        if (rotx[i] > 0) rotxvel[i] -= multiplier * 4;
+                                        if (rotx[i] < 0) rotxvel[i] += multiplier * 4;
+                                        if (rotxvel[i] > 0) rotxvel[i] -= multiplier * 4;
+                                        if (rotxvel[i] < 0) rotxvel[i] += multiplier * 4;
+                                        if (fabs(rotx[i]) < multiplier * 4)
+                                            rotx[i] = 0;
+                                        if (fabs(rotxvel[i]) < multiplier * 4)
+                                            rotxvel[i] = 0;
 
                                         rotx[i] += rotxvel[i] * multiplier * 4;
                                     }
                                     if (rotyvel[i] || roty[i]) {
-                                        if (roty[i] > 0)rotyvel[i] -= multiplier * 8 * fabs(roty[i]);
-                                        if (roty[i] < 0)rotyvel[i] += multiplier * 8 * fabs(roty[i]);
-                                        if (roty[i] > 0)rotyvel[i] -= multiplier * 4;
-                                        if (roty[i] < 0)rotyvel[i] += multiplier * 4;
-                                        if (rotyvel[i] > 0)rotyvel[i] -= multiplier * 4;
-                                        if (rotyvel[i] < 0)rotyvel[i] += multiplier * 4;
-                                        if (fabs(roty[i]) < multiplier * 4)roty[i] = 0;
-                                        if (fabs(rotyvel[i]) < multiplier * 4)rotyvel[i] = 0;
+                                        if (roty[i] > 0) rotyvel[i] -= multiplier * 8 * fabs(roty[i]);
+                                        if (roty[i] < 0) rotyvel[i] += multiplier * 8 * fabs(roty[i]);
+                                        if (roty[i] > 0) rotyvel[i] -= multiplier * 4;
+                                        if (roty[i] < 0) rotyvel[i] += multiplier * 4;
+                                        if (rotyvel[i] > 0) rotyvel[i] -= multiplier * 4;
+                                        if (rotyvel[i] < 0) rotyvel[i] += multiplier * 4;
+                                        if (fabs(roty[i]) < multiplier * 4)
+                                            roty[i] = 0;
+                                        if (fabs(rotyvel[i]) < multiplier * 4)
+                                            rotyvel[i] = 0;
 
                                         roty[i] += rotyvel[i] * multiplier * 4;
                                     }
@@ -219,10 +245,14 @@ void Objects::Draw()
                                     if (rotx[i]) {
                                         glRotatef(-rotx[i] / 4, 0, 0, 1);
                                     }
-                                    if (rotx[i] > 10)rotx[i] = 10;
-                                    if (rotx[i] < -10)rotx[i] = -10;
-                                    if (roty[i] > 10)roty[i] = 10;
-                                    if (roty[i] < -10)roty[i] = -10;
+                                    if (rotx[i] > 10)
+                                        rotx[i] = 10;
+                                    if (rotx[i] < -10)
+                                        rotx[i] = -10;
+                                    if (roty[i] > 10)
+                                        roty[i] = 10;
+                                    if (roty[i] < -10)
+                                        roty[i] = -10;
                                 }
 
                             }
@@ -254,7 +284,8 @@ void Objects::Draw()
                                 }
                             }
                             glRotatef(yaw[i], 0, 1, 0);
-                            if (distance > 1)distance = 1;
+                            if (distance > 1)
+                                distance = 1;
                             glColor4f((1 - shadowed[i]) / 2 + .5, (1 - shadowed[i]) / 2 + .5, (1 - shadowed[i]) / 2 + .5, distance);
                             if (distance >= 1) {
                                 glDisable(GL_BLEND);
@@ -283,7 +314,8 @@ void Objects::Draw()
                                 terrainlight = terrain.getLighting(position[i].x, position[i].z);
                                 if (!hidden) {
                                     glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
-                                    if (distance < 1)glAlphaFunc(GL_GREATER, 0.2);
+                                    if (distance < 1)
+                                        glAlphaFunc(GL_GREATER, 0.2);
                                 }
                                 if (hidden) {
                                     glDepthMask(0);
@@ -299,7 +331,8 @@ void Objects::Draw()
                                 terrainlight = terrain.getLighting(position[i].x, position[i].z);
                                 if (!hidden) {
                                     glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, distance);
-                                    if (distance < 1)glAlphaFunc(GL_GREATER, 0.2);
+                                    if (distance < 1)
+                                        glAlphaFunc(GL_GREATER, 0.2);
                                 }
                                 if (hidden) {
                                     glDepthMask(0);
@@ -341,26 +374,30 @@ void Objects::Draw()
                             if (type[i] == bushtype) {
                                 messedwith[i] -= multiplier;
                                 if (rotxvel[i] || rotx[i]) {
-                                    if (rotx[i] > 0)rotxvel[i] -= multiplier * 8 * fabs(rotx[i]);
-                                    if (rotx[i] < 0)rotxvel[i] += multiplier * 8 * fabs(rotx[i]);
-                                    if (rotx[i] > 0)rotxvel[i] -= multiplier * 4;
-                                    if (rotx[i] < 0)rotxvel[i] += multiplier * 4;
-                                    if (rotxvel[i] > 0)rotxvel[i] -= multiplier * 4;
-                                    if (rotxvel[i] < 0)rotxvel[i] += multiplier * 4;
-                                    if (fabs(rotx[i]) < multiplier * 4)rotx[i] = 0;
-                                    if (fabs(rotxvel[i]) < multiplier * 4)rotxvel[i] = 0;
+                                    if (rotx[i] > 0) rotxvel[i] -= multiplier * 8 * fabs(rotx[i]);
+                                    if (rotx[i] < 0) rotxvel[i] += multiplier * 8 * fabs(rotx[i]);
+                                    if (rotx[i] > 0) rotxvel[i] -= multiplier * 4;
+                                    if (rotx[i] < 0) rotxvel[i] += multiplier * 4;
+                                    if (rotxvel[i] > 0) rotxvel[i] -= multiplier * 4;
+                                    if (rotxvel[i] < 0) rotxvel[i] += multiplier * 4;
+                                    if (fabs(rotx[i]) < multiplier * 4)
+                                        rotx[i] = 0;
+                                    if (fabs(rotxvel[i]) < multiplier * 4)
+                                        rotxvel[i] = 0;
 
                                     rotx[i] += rotxvel[i] * multiplier * 4;
                                 }
                                 if (rotyvel[i] || roty[i]) {
-                                    if (roty[i] > 0)rotyvel[i] -= multiplier * 8 * fabs(roty[i]);
-                                    if (roty[i] < 0)rotyvel[i] += multiplier * 8 * fabs(roty[i]);
-                                    if (roty[i] > 0)rotyvel[i] -= multiplier * 4;
-                                    if (roty[i] < 0)rotyvel[i] += multiplier * 4;
-                                    if (rotyvel[i] > 0)rotyvel[i] -= multiplier * 4;
-                                    if (rotyvel[i] < 0)rotyvel[i] += multiplier * 4;
-                                    if (fabs(roty[i]) < multiplier * 4)roty[i] = 0;
-                                    if (fabs(rotyvel[i]) < multiplier * 4)rotyvel[i] = 0;
+                                    if (roty[i] > 0) rotyvel[i] -= multiplier * 8 * fabs(roty[i]);
+                                    if (roty[i] < 0) rotyvel[i] += multiplier * 8 * fabs(roty[i]);
+                                    if (roty[i] > 0) rotyvel[i] -= multiplier * 4;
+                                    if (roty[i] < 0) rotyvel[i] += multiplier * 4;
+                                    if (rotyvel[i] > 0) rotyvel[i] -= multiplier * 4;
+                                    if (rotyvel[i] < 0) rotyvel[i] += multiplier * 4;
+                                    if (fabs(roty[i]) < multiplier * 4)
+                                        roty[i] = 0;
+                                    if (fabs(rotyvel[i]) < multiplier * 4)
+                                        rotyvel[i] = 0;
 
                                     roty[i] += rotyvel[i] * multiplier * 4;
                                 }
@@ -370,34 +407,42 @@ void Objects::Draw()
                                 if (rotx[i]) {
                                     glRotatef(-rotx[i], 0, 0, 1);
                                 }
-                                if (rotx[i] > 10)rotx[i] = 10;
-                                if (rotx[i] < -10)rotx[i] = -10;
-                                if (roty[i] > 10)roty[i] = 10;
-                                if (roty[i] < -10)roty[i] = -10;
+                                if (rotx[i] > 10)
+                                    rotx[i] = 10;
+                                if (rotx[i] < -10)
+                                    rotx[i] = -10;
+                                if (roty[i] > 10)
+                                    roty[i] = 10;
+                                if (roty[i] < -10)
+                                    roty[i] = -10;
                             }
                             if (type[i] == treetrunktype || type[i] == treeleavestype) {
                                 messedwith[i] -= multiplier;
                                 if (rotxvel[i] || rotx[i]) {
-                                    if (rotx[i] > 0)rotxvel[i] -= multiplier * 8 * fabs(rotx[i]);
-                                    if (rotx[i] < 0)rotxvel[i] += multiplier * 8 * fabs(rotx[i]);
-                                    if (rotx[i] > 0)rotxvel[i] -= multiplier * 4;
-                                    if (rotx[i] < 0)rotxvel[i] += multiplier * 4;
-                                    if (rotxvel[i] > 0)rotxvel[i] -= multiplier * 4;
-                                    if (rotxvel[i] < 0)rotxvel[i] += multiplier * 4;
-                                    if (fabs(rotx[i]) < multiplier * 4)rotx[i] = 0;
-                                    if (fabs(rotxvel[i]) < multiplier * 4)rotxvel[i] = 0;
+                                    if (rotx[i] > 0) rotxvel[i] -= multiplier * 8 * fabs(rotx[i]);
+                                    if (rotx[i] < 0) rotxvel[i] += multiplier * 8 * fabs(rotx[i]);
+                                    if (rotx[i] > 0) rotxvel[i] -= multiplier * 4;
+                                    if (rotx[i] < 0) rotxvel[i] += multiplier * 4;
+                                    if (rotxvel[i] > 0) rotxvel[i] -= multiplier * 4;
+                                    if (rotxvel[i] < 0) rotxvel[i] += multiplier * 4;
+                                    if (fabs(rotx[i]) < multiplier * 4)
+                                        rotx[i] = 0;
+                                    if (fabs(rotxvel[i]) < multiplier * 4)
+                                        rotxvel[i] = 0;
 
                                     rotx[i] += rotxvel[i] * multiplier * 4;
                                 }
                                 if (rotyvel[i] || roty[i]) {
-                                    if (roty[i] > 0)rotyvel[i] -= multiplier * 8 * fabs(roty[i]);
-                                    if (roty[i] < 0)rotyvel[i] += multiplier * 8 * fabs(roty[i]);
-                                    if (roty[i] > 0)rotyvel[i] -= multiplier * 4;
-                                    if (roty[i] < 0)rotyvel[i] += multiplier * 4;
-                                    if (rotyvel[i] > 0)rotyvel[i] -= multiplier * 4;
-                                    if (rotyvel[i] < 0)rotyvel[i] += multiplier * 4;
-                                    if (fabs(roty[i]) < multiplier * 4)roty[i] = 0;
-                                    if (fabs(rotyvel[i]) < multiplier * 4)rotyvel[i] = 0;
+                                    if (roty[i] > 0) rotyvel[i] -= multiplier * 8 * fabs(roty[i]);
+                                    if (roty[i] < 0) rotyvel[i] += multiplier * 8 * fabs(roty[i]);
+                                    if (roty[i] > 0) rotyvel[i] -= multiplier * 4;
+                                    if (roty[i] < 0) rotyvel[i] += multiplier * 4;
+                                    if (rotyvel[i] > 0) rotyvel[i] -= multiplier * 4;
+                                    if (rotyvel[i] < 0) rotyvel[i] += multiplier * 4;
+                                    if (fabs(roty[i]) < multiplier * 4)
+                                        roty[i] = 0;
+                                    if (fabs(rotyvel[i]) < multiplier * 4)
+                                        rotyvel[i] = 0;
 
                                     roty[i] += rotyvel[i] * multiplier * 4;
                                 }
@@ -407,10 +452,14 @@ void Objects::Draw()
                                 if (rotx[i]) {
                                     glRotatef(-rotx[i] / 2, 0, 0, 1);
                                 }
-                                if (rotx[i] > 10)rotx[i] = 10;
-                                if (rotx[i] < -10)rotx[i] = -10;
-                                if (roty[i] > 10)roty[i] = 10;
-                                if (roty[i] < -10)roty[i] = -10;
+                                if (rotx[i] > 10)
+                                    rotx[i] = 10;
+                                if (rotx[i] < -10)
+                                    rotx[i] = -10;
+                                if (roty[i] > 10)
+                                    roty[i] = 10;
+                                if (roty[i] < -10)
+                                    roty[i] = -10;
                             }
                             if (environment == snowyenvironment) {
                                 if (type[i] == treeleavestype) {
@@ -465,7 +514,8 @@ void Objects::Draw()
             }
         }
     }
-    if (environment == desertenvironment)glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 );
+    if (environment == desertenvironment)
+        glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 );
     glEnable(GL_ALPHA_TEST);
     SetUpLight(&light, 0);
 }
@@ -485,16 +535,19 @@ void Objects::MakeObject(int atype, XYZ where, float ayaw, float ascale)
 {
     if ((atype != treeleavestype && atype != bushtype) || foliage == 1) {
         scale[numobjects] = ascale;
-        if (atype == treeleavestype)scale[numobjects] += fabs((float)(Random() % 100) / 900) * ascale;
+        if (atype == treeleavestype)
+            scale[numobjects] += fabs((float)(Random() % 100) / 900) * ascale;
 
         onfire[numobjects] = 0;
         flamedelay[numobjects] = 0;
         type[numobjects] = atype;
 
-        if (atype == firetype)onfire[numobjects] = 1;
+        if (atype == firetype)
+            onfire[numobjects] = 1;
 
         position[numobjects] = where;
-        if (atype == bushtype)position[numobjects].y = terrain.getHeight(position[numobjects].x, position[numobjects].z) - .3;
+        if (atype == bushtype)
+            position[numobjects].y = terrain.getHeight(position[numobjects].x, position[numobjects].z) - .3;
         yaw[numobjects] = ayaw;
 
         rotxvel[numobjects] = 0;
@@ -502,30 +555,30 @@ void Objects::MakeObject(int atype, XYZ where, float ayaw, float ascale)
         rotx[numobjects] = 0;
         roty[numobjects] = 0;
 
-        if (atype == boxtype)model[numobjects].loaddecal((char *)":Data:Models:Box.solid", 0);
-        if (atype == cooltype)model[numobjects].loaddecal((char *)":Data:Models:Cool.solid", 0);
-        if (atype == walltype)model[numobjects].loaddecal((char *)":Data:Models:Wall.solid", 0);
-        if (atype == tunneltype)model[numobjects].loaddecal((char *)":Data:Models:Tunnel.solid", 0);
-        if (atype == chimneytype)model[numobjects].loaddecal((char *)":Data:Models:Chimney.solid", 0);
-        if (atype == spiketype)model[numobjects].load((char *)":Data:Models:Spike.solid", 0);
-        if (atype == weirdtype)model[numobjects].loaddecal((char *)":Data:Models:Weird.solid", 0);
-        if (atype == rocktype)model[numobjects].loaddecal((char *)":Data:Models:Rock.solid", 0);
-        if (atype == treetrunktype)model[numobjects].load((char *)":Data:Models:Treetrunk.solid", 0);
-        if (atype == treeleavestype)model[numobjects].load((char *)":Data:Models:Leaves.solid", 0);
-        if (atype == bushtype)model[numobjects].load((char *)":Data:Models:Bush.solid", 0);
-
-        if (atype == boxtype)friction[numobjects] = 1.5;
-        if (atype == cooltype)friction[numobjects] = 1.5;
-        if (atype == walltype)friction[numobjects] = 1.5;
-        if (atype == platformtype)friction[numobjects] = 1.5;
-        if (atype == tunneltype)friction[numobjects] = 1.5;
-        if (atype == chimneytype)friction[numobjects] = 1.5;
-        if (atype == rocktype)friction[numobjects] = .5;
-        if (atype == rocktype && ascale > .5)friction[numobjects] = 1.5;
-        if (atype == weirdtype)friction[numobjects] = 1.5;
-        if (atype == spiketype)friction[numobjects] = .4;
-        if (atype == treetrunktype)friction[numobjects] = .4;
-        if (atype == treeleavestype)friction[numobjects] = 0;
+        if (atype == boxtype)           model[numobjects].loaddecal((char *)":Data:Models:Box.solid", 0);
+        if (atype == cooltype)          model[numobjects].loaddecal((char *)":Data:Models:Cool.solid", 0);
+        if (atype == walltype)          model[numobjects].loaddecal((char *)":Data:Models:Wall.solid", 0);
+        if (atype == tunneltype)        model[numobjects].loaddecal((char *)":Data:Models:Tunnel.solid", 0);
+        if (atype == chimneytype)       model[numobjects].loaddecal((char *)":Data:Models:Chimney.solid", 0);
+        if (atype == spiketype)         model[numobjects].load((char *)":Data:Models:Spike.solid", 0);
+        if (atype == weirdtype)         model[numobjects].loaddecal((char *)":Data:Models:Weird.solid", 0);
+        if (atype == rocktype)          model[numobjects].loaddecal((char *)":Data:Models:Rock.solid", 0);
+        if (atype == treetrunktype)     model[numobjects].load((char *)":Data:Models:Treetrunk.solid", 0);
+        if (atype == treeleavestype)    model[numobjects].load((char *)":Data:Models:Leaves.solid", 0);
+        if (atype == bushtype)          model[numobjects].load((char *)":Data:Models:Bush.solid", 0);
+
+        if (atype == boxtype)           friction[numobjects] = 1.5;
+        if (atype == cooltype)          friction[numobjects] = 1.5;
+        if (atype == walltype)          friction[numobjects] = 1.5;
+        if (atype == platformtype)      friction[numobjects] = 1.5;
+        if (atype == tunneltype)        friction[numobjects] = 1.5;
+        if (atype == chimneytype)       friction[numobjects] = 1.5;
+        if (atype == rocktype)          friction[numobjects] = .5;
+        if (atype == rocktype && ascale>.5) friction[numobjects] = 1.5;
+        if (atype == weirdtype)         friction[numobjects] = 1.5;
+        if (atype == spiketype)         friction[numobjects] = .4;
+        if (atype == treetrunktype)     friction[numobjects] = .4;
+        if (atype == treeleavestype)    friction[numobjects] = 0;
 
         if (atype == platformtype) {
             model[numobjects].loaddecal((char *)":Data:Models:Platform.solid", 0);
@@ -551,11 +604,13 @@ void Objects::MakeObject(int atype, XYZ where, float ayaw, float ascale)
         model[numobjects].ScaleNormals(-1, -1, -1);
 
         if (atype == treetrunktype && position[numobjects].y < terrain.getHeight(position[numobjects].x, position[numobjects].z) + 1) {
-            if (detail == 2)terrain.MakeDecal(shadowdecalpermanent, position[numobjects], 2, .4, 0);
+            if (detail == 2)
+                terrain.MakeDecal(shadowdecalpermanent, position[numobjects], 2, .4, 0);
         }
 
         if (atype == bushtype && position[numobjects].y < terrain.getHeight(position[numobjects].x, position[numobjects].z) + 1) {
-            if (detail == 2)terrain.MakeDecal(shadowdecalpermanent, position[numobjects], 1, .4, 0);
+            if (detail == 2)
+                terrain.MakeDecal(shadowdecalpermanent, position[numobjects], 1, .4, 0);
         }
 
         if (atype != treeleavestype && atype != bushtype && atype != firetype)
@@ -569,16 +624,19 @@ void Objects::MakeObject(int atype, XYZ where, float ayaw, float apitch, float a
 {
     if ((atype != treeleavestype && atype != bushtype) || foliage == 1) {
         scale[numobjects] = ascale;
-        if (atype == treeleavestype)scale[numobjects] += fabs((float)(Random() % 100) / 900) * ascale;
+        if (atype == treeleavestype)
+            scale[numobjects] += fabs((float)(Random() % 100) / 900) * ascale;
 
         onfire[numobjects] = 0;
         flamedelay[numobjects] = 0;
         type[numobjects] = atype;
 
-        if (atype == firetype)onfire[numobjects] = 1;
+        if (atype == firetype)
+            onfire[numobjects] = 1;
 
         position[numobjects] = where;
-        if (atype == bushtype)position[numobjects].y = terrain.getHeight(position[numobjects].x, position[numobjects].z) - .3;
+        if (atype == bushtype)
+            position[numobjects].y = terrain.getHeight(position[numobjects].x, position[numobjects].z) - .3;
         /*if(atype==firetype){
         if(position[numobjects].y<terrain.getHeight(position[numobjects].x,position[numobjects].z)-.3)
         position[numobjects].y=terrain.getHeight(position[numobjects].x,position[numobjects].z)-.3;
@@ -591,32 +649,33 @@ void Objects::MakeObject(int atype, XYZ where, float ayaw, float apitch, float a
         rotx[numobjects] = 0;
         roty[numobjects] = 0;
 
-        if (atype == boxtype)model[numobjects].loaddecal((char *)":Data:Models:Box.solid", 0);
-        if (atype == cooltype)model[numobjects].loaddecal((char *)":Data:Models:Cool.solid", 0);
-        if (atype == walltype)model[numobjects].loaddecal((char *)":Data:Models:Wall.solid", 0);
-        if (atype == tunneltype)model[numobjects].loaddecal((char *)":Data:Models:Tunnel.solid", 0);
-        if (atype == chimneytype)model[numobjects].loaddecal((char *)":Data:Models:Chimney.solid", 0);
-        if (atype == spiketype)model[numobjects].load((char *)":Data:Models:Spike.solid", 0);
-        if (atype == weirdtype)model[numobjects].loaddecal((char *)":Data:Models:Weird.solid", 0);
-        if (atype == rocktype)model[numobjects].loaddecal((char *)":Data:Models:Rock.solid", 0);
-        if (atype == treetrunktype)model[numobjects].load((char *)":Data:Models:Treetrunk.solid", 0);
-        if (atype == treeleavestype)model[numobjects].load((char *)":Data:Models:Leaves.solid", 0);
-        if (atype == bushtype)model[numobjects].load((char *)":Data:Models:Bush.solid", 0);
-
-        if (atype == boxtype)friction[numobjects] = 1.5;
-        if (atype == cooltype)friction[numobjects] = 1.5;
-        if (atype == walltype)friction[numobjects] = 1.5;
-        if (atype == platformtype)friction[numobjects] = 1.5;
-        if (atype == tunneltype)friction[numobjects] = 1.5;
-        if (atype == chimneytype)friction[numobjects] = 1.5;
-        if (atype == rocktype)friction[numobjects] = .5;
-        if (atype == rocktype && ascale > .5)friction[numobjects] = 1.5;
-        if (atype == weirdtype)friction[numobjects] = 1.5;
-        if (atype == spiketype)friction[numobjects] = .4;
-        if (atype == treetrunktype)friction[numobjects] = .4;
-        if (atype == treeleavestype)friction[numobjects] = 0;
-
-        if (friction[numobjects] == 1.5 && fabs(apitch) > 5)friction[numobjects] = .5;
+        if (atype == boxtype)           model[numobjects].loaddecal((char *)":Data:Models:Box.solid", 0);
+        if (atype == cooltype)          model[numobjects].loaddecal((char *)":Data:Models:Cool.solid", 0);
+        if (atype == walltype)          model[numobjects].loaddecal((char *)":Data:Models:Wall.solid", 0);
+        if (atype == tunneltype)        model[numobjects].loaddecal((char *)":Data:Models:Tunnel.solid", 0);
+        if (atype == chimneytype)       model[numobjects].loaddecal((char *)":Data:Models:Chimney.solid", 0);
+        if (atype == spiketype)         model[numobjects].load((char *)":Data:Models:Spike.solid", 0);
+        if (atype == weirdtype)         model[numobjects].loaddecal((char *)":Data:Models:Weird.solid", 0);
+        if (atype == rocktype)          model[numobjects].loaddecal((char *)":Data:Models:Rock.solid", 0);
+        if (atype == treetrunktype)     model[numobjects].load((char *)":Data:Models:Treetrunk.solid", 0);
+        if (atype == treeleavestype)    model[numobjects].load((char *)":Data:Models:Leaves.solid", 0);
+        if (atype == bushtype)          model[numobjects].load((char *)":Data:Models:Bush.solid", 0);
+
+        if (atype == boxtype)           friction[numobjects] = 1.5;
+        if (atype == cooltype)          friction[numobjects] = 1.5;
+        if (atype == walltype)          friction[numobjects] = 1.5;
+        if (atype == platformtype)      friction[numobjects] = 1.5;
+        if (atype == tunneltype)        friction[numobjects] = 1.5;
+        if (atype == chimneytype)       friction[numobjects] = 1.5;
+        if (atype == rocktype)          friction[numobjects] = .5;
+        if (atype == rocktype && ascale>.5) friction[numobjects] = 1.5;
+        if (atype == weirdtype)         friction[numobjects] = 1.5;
+        if (atype == spiketype)         friction[numobjects] = .4;
+        if (atype == treetrunktype)     friction[numobjects] = .4;
+        if (atype == treeleavestype)    friction[numobjects] = 0;
+
+        if (friction[numobjects] == 1.5 && fabs(apitch) > 5)
+            friction[numobjects] = .5;
 
         if (atype == platformtype) {
             model[numobjects].loaddecal((char *)":Data:Models:Platform.solid", 0);
@@ -643,11 +702,13 @@ void Objects::MakeObject(int atype, XYZ where, float ayaw, float apitch, float a
         model[numobjects].ScaleNormals(-1, -1, -1);
 
         if (atype == treetrunktype && position[numobjects].y < terrain.getHeight(position[numobjects].x, position[numobjects].z) + 1) {
-            if (detail == 2)terrain.MakeDecal(shadowdecalpermanent, position[numobjects], 2, .4, 0);
+            if (detail == 2)
+                terrain.MakeDecal(shadowdecalpermanent, position[numobjects], 2, .4, 0);
         }
 
         if (atype == bushtype && position[numobjects].y < terrain.getHeight(position[numobjects].x, position[numobjects].z) + 1) {
-            if (detail == 2)terrain.MakeDecal(shadowdecalpermanent, position[numobjects], 1, .4, 0);
+            if (detail == 2)
+                terrain.MakeDecal(shadowdecalpermanent, position[numobjects], 1, .4, 0);
         }
 
         if (atype != treeleavestype && atype != bushtype && atype != firetype)
@@ -665,11 +726,15 @@ void Objects::DoStuff()
         Sprite::MakeSprite(weaponshinesprite, position[i],position[i]*0, 1,1,1, 5, 1);
         }*/
 
-        if (type[i] == firetype)onfire[i] = 1;
+        if (type[i] == firetype)
+            onfire[i] = 1;
         if (onfire[i]) {
-            if (type[i] == bushtype)flamedelay[i] -= multiplier * 3;
-            if (type[i] == firetype)flamedelay[i] -= multiplier * 3;
-            if (type[i] == treeleavestype)flamedelay[i] -= multiplier * 4;
+            if (type[i] == bushtype)
+                flamedelay[i] -= multiplier * 3;
+            if (type[i] == firetype)
+                flamedelay[i] -= multiplier * 3;
+            if (type[i] == treeleavestype)
+                flamedelay[i] -= multiplier * 4;
             while (flamedelay[i] < 0 && onfire[i]) {
                 flamedelay[i] += .006;
                 if (type[i] == bushtype || type[i] == firetype) {
@@ -699,7 +764,8 @@ void Objects::DoShadows()
     int i, j, k, l;
     static XYZ testpoint, testpoint2, terrainpoint, lightloc, col;
     lightloc = light.location;
-    if (!skyboxtexture)lightloc = 0;
+    if (!skyboxtexture)
+        lightloc = 0;
     lightloc.y += 10;
     Normalise(&lightloc);
     int patchx, patchz;
index a0ace20b7ac291148281b2d202ae3841fc8c20bb..59f8490cd91880e90cfa2e41e42fde1eaf43bb06 100644 (file)
@@ -452,9 +452,12 @@ void DoFrameRate (int update)
         deltaTime /= 1000.0;
 
     multiplier = deltaTime;
-    if (multiplier < .001) multiplier = .001;
-    if (multiplier > 10) multiplier = 10;
-    if (update) frametime = currTime;  // reset for next time interval
+    if (multiplier < .001)
+        multiplier = .001;
+    if (multiplier > 10)
+        multiplier = 10;
+    if (update)
+        frametime = currTime;  // reset for next time interval
 
     deltaTime = (float) AbsoluteDeltaToDuration (currTime, time);
 
@@ -479,20 +482,26 @@ void DoUpdate ()
     static float oldmult;
 
     DoFrameRate(1);
-    if (multiplier > .6)multiplier = .6;
+    if (multiplier > .6)
+        multiplier = .6;
 
     fps = 1 / multiplier;
 
     count = multiplier * sps;
-    if (count < 2)count = 2;
+    if (count < 2)
+        count = 2;
 
     realmultiplier = multiplier;
     multiplier *= gamespeed;
-    if (difficulty == 1)multiplier *= .9;
-    if (difficulty == 0)multiplier *= .8;
-
-    if (loading == 4)multiplier *= .00001;
-    if (slomo && !mainmenu)multiplier *= slomospeed;
+    if (difficulty == 1)
+        multiplier *= .9;
+    if (difficulty == 0)
+        multiplier *= .8;
+
+    if (loading == 4)
+        multiplier *= .00001;
+    if (slomo && !mainmenu)
+        multiplier *= slomospeed;
     oldmult = multiplier;
     multiplier /= (float)count;
 
@@ -638,9 +647,11 @@ char *calcBaseDir(const char *argv0)
     }
 
     envr = getenv("PATH");
-    if (!envr) return NULL;
+    if (!envr)
+        return NULL;
     envr = strdup(envr);
-    if (!envr) return NULL;
+    if (!envr)
+        return NULL;
     retval = findBinaryInPath(argv0, envr);
     free(envr);
     return(retval);
index 70821b916988174368b96549ea27c7c5a16e237f..fdf7d40c7fc2528a510657c658a45abe6c73711c 100644 (file)
@@ -128,14 +128,18 @@ inline    float Vector::Magnitude(void)
 inline void  Vector::Normalize(void)
 {
     float m = (float) sqrt(x * x + y * y + z * z);
-    if (m <= tol) m = 1;
+    if (m <= tol)
+        m = 1;
     x /= m;
     y /= m;
     z /= m;
 
-    if (fabs(x) < tol) x = 0.0f;
-    if (fabs(y) < tol) y = 0.0f;
-    if (fabs(z) < tol) z = 0.0f;
+    if (fabs(x) < tol)
+        x = 0.0f;
+    if (fabs(y) < tol)
+        y = 0.0f;
+    if (fabs(z) < tol)
+        z = 0.0f;
 }
 
 inline void  Vector::Reverse(void)
@@ -324,7 +328,8 @@ inline      Matrix3x3       Matrix3x3::Inverse(void)
                 e31 * e12 * e23 -
                 e31 * e22 * e13;
 
-    if (d == 0) d = 1;
+    if (d == 0)
+        d = 1;
 
     return     Matrix3x3(      (e22 * e33 - e23 * e32) / d,
                         -(e12 * e33 - e13 * e32) / d,
index cfa2bace88ab4ff0fb5c057400f6501c45898bf3..4e96bc70f6873e88d044573ec34731395ce11378 100644 (file)
@@ -226,7 +226,8 @@ inline void XYZ::vec(Vector add)
 
 inline bool XYZ::operator==(XYZ add)
 {
-    if (x == add.x && y == add.y && z == add.z)return 1;
+    if (x == add.x && y == add.y && z == add.z)
+        return 1;
     return 0;
 }
 
@@ -250,7 +251,8 @@ inline float fast_sqrt (register float arg)
     // Can replace with slower return std::sqrt(arg);
     register float result;
 
-    if (arg == 0.0) return 0.0;
+    if (arg == 0.0)
+        return 0.0;
 
     asm {
         frsqrte                result, arg                     // Calculate Square root
@@ -401,12 +403,12 @@ inline bool sphere_line_intersection (
     //~ static float x , y , z;
     static float a, b, c, /*mu,*/ i ;
 
-    if (x1 > x3 + r && x2 > x3 + r)return(0);
-    if (x1 < x3 - r && x2 < x3 - r)return(0);
-    if (y1 > y3 + r && y2 > y3 + r)return(0);
-    if (y1 < y3 - r && y2 < y3 - r)return(0);
-    if (z1 > z3 + r && z2 > z3 + r)return(0);
-    if (z1 < z3 - r && z2 < z3 - r)return(0);
+    if (x1 > x3 + r && x2 > x3 + r) return(0);
+    if (x1 < x3 - r && x2 < x3 - r) return(0);
+    if (y1 > y3 + r && y2 > y3 + r) return(0);
+    if (y1 < y3 - r && y2 < y3 - r) return(0);
+    if (z1 > z3 + r && z2 > z3 + r) return(0);
+    if (z1 < z3 - r && z2 < z3 - r) return(0);
     a =  square(x2 - x1) + square(y2 - y1) + square(z2 - z1);
     b =  2 * ( (x2 - x1) * (x1 - x3)
                + (y2 - y1) * (y1 - y3)
@@ -439,12 +441,12 @@ inline bool sphere_line_intersection (
     //~ static float x , y , z;
     static float a, b, c, /*mu,*/ i ;
 
-    if (p1->x > p3->x + *r && p2->x > p3->x + *r)return(0);
-    if (p1->x < p3->x - *r && p2->x < p3->x - *r)return(0);
-    if (p1->y > p3->y + *r && p2->y > p3->y + *r)return(0);
-    if (p1->y < p3->y - *r && p2->y < p3->y - *r)return(0);
-    if (p1->z > p3->z + *r && p2->z > p3->z + *r)return(0);
-    if (p1->z < p3->z - *r && p2->z < p3->z - *r)return(0);
+    if (p1->x > p3->x + *r && p2->x > p3->x + *r) return(0);
+    if (p1->x < p3->x - *r && p2->x < p3->x - *r) return(0);
+    if (p1->y > p3->y + *r && p2->y > p3->y + *r) return(0);
+    if (p1->y < p3->y - *r && p2->y < p3->y - *r) return(0);
+    if (p1->z > p3->z + *r && p2->z > p3->z + *r) return(0);
+    if (p1->z < p3->z - *r && p2->z < p3->z - *r) return(0);
     a =  square(p2->x - p1->x) + square(p2->y - p1->y) + square(p2->z - p1->z);
     b =  2 * ( (p2->x - p1->x) * (p1->x - p3->x)
                + (p2->y - p1->y) * (p1->y - p3->y)
index 9b99459ad3f8d70eb3830be0020e24457a7e0041..54bba7a0ec01fbf1ca731ac9c6e8f60c9b67f4fa 100644 (file)
@@ -49,12 +49,18 @@ void DefaultSettings()
 
 void SaveSettings()
 {
-    if (newdetail < 0) newdetail = 0;
-    if (newdetail > 2) newdetail = 2;
-    if (newscreenwidth > 3000) newscreenwidth = screenwidth;
-    if (newscreenwidth < 0) newscreenwidth = screenwidth;
-    if (newscreenheight > 3000) newscreenheight = screenheight;
-    if (newscreenheight < 0) newscreenheight = screenheight;
+    if (newdetail < 0)
+        newdetail = 0;
+    if (newdetail > 2)
+        newdetail = 2;
+    if (newscreenwidth > 3000)
+        newscreenwidth = screenwidth;
+    if (newscreenwidth < 0)
+        newscreenwidth = screenwidth;
+    if (newscreenheight > 3000)
+        newscreenheight = screenheight;
+    if (newscreenheight < 0)
+        newscreenheight = screenheight;
     ofstream opstream(ConvertFileName(":Data:config.txt", "w"));
     opstream << "Screenwidth:\n";
     opstream << newscreenwidth;
@@ -87,7 +93,8 @@ void SaveSettings()
     opstream << "\nInvert mouse:\n";
     opstream << invertmouse;
     opstream << "\nGamespeed:\n";
-    if (oldgamespeed == 0)oldgamespeed = 1;
+    if (oldgamespeed == 0)
+        oldgamespeed = 1;
     opstream << oldgamespeed;
     opstream << "\nDifficulty(0,1,2) higher=harder:\n";
     opstream << difficulty;
@@ -158,7 +165,8 @@ bool LoadSettings()
 
         // skip blank lines
         // assume lines starting with spaces are all blank
-        if ( strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t') continue;
+        if ( strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t')
+            continue;
         //~ printf("setting : %s\n",setting);
 
         if ( ipstream.eof() || ipstream.fail() ) {
@@ -178,8 +186,10 @@ bool LoadSettings()
             ipstream >> ismotionblur;
         } else if ( !strncmp(setting, "Overall Detail", 14) ) {
             ipstream >> detail;
-            if (detail != 0)kBitsPerPixel = 32;
-            else kBitsPerPixel = 16;
+            if (detail != 0)
+                kBitsPerPixel = 32;
+            else
+                kBitsPerPixel = 16;
         } else if ( !strncmp(setting, "Floating jump", 13) ) {
             ipstream >> floatjump;
         } else if ( !strncmp(setting, "Mouse jump", 10) ) {
@@ -290,10 +300,14 @@ bool LoadSettings()
 
     ipstream.close();
 
-    if (detail > 2)detail = 2;
-    if (detail < 0)detail = 0;
-    if (screenwidth < 0)screenwidth = 640;
-    if (screenheight < 0)screenheight = 480;
+    if (detail > 2)
+        detail = 2;
+    if (detail < 0)
+        detail = 0;
+    if (screenwidth < 0)
+        screenwidth = 640;
+    if (screenheight < 0)
+        screenheight = 480;
 
     return true;
 }
index 776d05e0e8c8e0b005227ce37a608584f44efdaa..cb9505e61f6590ec896a631a463f05033c07fc79 100644 (file)
@@ -52,9 +52,12 @@ void SkyBox::draw()
     M[13] = 0;
     M[14] = 0;
     glLoadMatrixf(M);
-    if (environment == 2)glScalef(1 + blurness / 1000, 1, 1 + blurness / 1000);
-    if (environment != 2)glColor3f(.85 * skyboxr, .85 * skyboxg, .95 * skyboxb);
-    else glColor3f(1 * skyboxr, .95 * skyboxg, .95 * skyboxb);
+    if (environment == 2)
+        glScalef(1 + blurness / 1000, 1, 1 + blurness / 1000);
+    if (environment != 2)
+        glColor3f(.85 * skyboxr, .85 * skyboxg, .95 * skyboxb);
+    else
+        glColor3f(1 * skyboxr, .95 * skyboxg, .95 * skyboxb);
 
     if (!skyboxtexture) {
         glDisable(GL_TEXTURE_2D);
@@ -64,7 +67,8 @@ void  SkyBox::draw()
     glDisable(GL_CULL_FACE);
     glEnable(GL_BLEND);
     glDisable(GL_LIGHTING);
-    if (skyboxtexture)glEnable(GL_TEXTURE_2D);
+    if (skyboxtexture)
+        glEnable(GL_TEXTURE_2D);
     glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
     front.bind();
     glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
index c3ac298cc958685170bac4ee845731d5a3f5a9ec..174caa6a9d5fb73c74c016409733b7b66893ae87 100644 (file)
@@ -142,10 +142,14 @@ void Sprite::Draw()
                 break;
             case splintersprite :
                 if (lastspecial != sprites[i]->special) {
-                    if (sprites[i]->special == 0)splintertexture.bind();
-                    if (sprites[i]->special == 1)leaftexture.bind();
-                    if (sprites[i]->special == 2)snowflaketexture.bind();
-                    if (sprites[i]->special == 3)toothtexture.bind();
+                    if (sprites[i]->special == 0)
+                        splintertexture.bind();
+                    if (sprites[i]->special == 1)
+                        leaftexture.bind();
+                    if (sprites[i]->special == 2)
+                        snowflaketexture.bind();
+                    if (sprites[i]->special == 3)
+                        toothtexture.bind();
                     if (!blend) {
                         blend = 1;
                         glAlphaFunc(GL_GREATER, 0.0001);
@@ -193,11 +197,15 @@ void Sprite::Draw()
         else
             distancemult = (viewdistsquared - (distsq(&viewer, &sprites[i]->position) - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
         if (sprites[i]->type == flamesprite) {
-            if (distancemult >= 1) glColor4f(sprites[i]->color[0], sprites[i]->color[1], sprites[i]->color[2], sprites[i]->opacity);
-            else glColor4f(sprites[i]->color[0], sprites[i]->color[1], sprites[i]->color[2], sprites[i]->opacity * distancemult);
+            if (distancemult >= 1)
+                glColor4f(sprites[i]->color[0], sprites[i]->color[1], sprites[i]->color[2], sprites[i]->opacity);
+            else
+                glColor4f(sprites[i]->color[0], sprites[i]->color[1], sprites[i]->color[2], sprites[i]->opacity * distancemult);
         } else {
-            if (distancemult >= 1) glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->opacity);
-            else glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->opacity * distancemult);
+            if (distancemult >= 1)
+                glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->opacity);
+            else
+                glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->opacity * distancemult);
         }
         lasttype = sprites[i]->type;
         lastspecial = sprites[i]->special;
@@ -223,26 +231,35 @@ void Sprite::Draw()
         glRotatef(sprites[i]->rotation, 0, 0, 1);
 
         if ((sprites[i]->type == flamesprite || sprites[i]->type == weaponflamesprite || sprites[i]->type == weaponshinesprite || sprites[i]->type == bloodflamesprite)) {
-            if (sprites[i]->alivetime < .14)glScalef(sprites[i]->alivetime / .14, sprites[i]->alivetime / .14, sprites[i]->alivetime / .14);
+            if (sprites[i]->alivetime < .14)
+                glScalef(sprites[i]->alivetime / .14, sprites[i]->alivetime / .14, sprites[i]->alivetime / .14);
         }
         if (sprites[i]->type == smoketype || sprites[i]->type == snowsprite || sprites[i]->type == weaponshinesprite || sprites[i]->type == breathsprite) {
             if (sprites[i]->alivetime < .3) {
-                if (distancemult >= 1)glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->opacity * sprites[i]->alivetime / .3);
-                if (distancemult < 1)glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->opacity * distancemult * sprites[i]->alivetime / .3);
+                if (distancemult >= 1)
+                    glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->opacity * sprites[i]->alivetime / .3);
+                if (distancemult < 1)
+                    glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->opacity * distancemult * sprites[i]->alivetime / .3);
             }
         }
         if (sprites[i]->type == splintersprite && sprites[i]->special > 0 && sprites[i]->special != 3) {
             if (sprites[i]->alivetime < .2) {
-                if (distancemult >= 1) glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->alivetime / .2);
-                else glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], distancemult * sprites[i]->alivetime / .2);
+                if (distancemult >= 1)
+                    glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->alivetime / .2);
+                else
+                    glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], distancemult * sprites[i]->alivetime / .2);
             } else {
-                if (distancemult >= 1) glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], 1);
-                else glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], 1);
+                if (distancemult >= 1)
+                    glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], 1);
+                else
+                    glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], 1);
             }
         }
         if (sprites[i]->type == splintersprite && (sprites[i]->special == 0 || sprites[i]->special == 3)) {
-            if (distancemult >= 1) glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], 1);
-            else glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], 1);
+            if (distancemult >= 1)
+                glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], 1);
+            else
+                glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], 1);
         }
 
         glBegin(GL_TRIANGLES);
@@ -268,7 +285,8 @@ void Sprite::Draw()
             sprites[i]->position += sprites[i]->velocity * multiplier;
             sprites[i]->velocity += windvector * multiplier;
         }
-        if (sprites[i]->type == flamesprite || sprites[i]->type == smoketype)sprites[i]->position += windvector * multiplier / 2;
+        if (sprites[i]->type == flamesprite || sprites[i]->type == smoketype)
+            sprites[i]->position += windvector * multiplier / 2;
         if ((sprites[i]->type == flamesprite || sprites[i]->type == weaponflamesprite || sprites[i]->type == weaponshinesprite || sprites[i]->type == bloodflamesprite))
             multiplier *= sprites[i]->speed * .7;
         sprites[i]->alivetime += multiplier;
@@ -281,8 +299,9 @@ void Sprite::Draw()
         if (sprites[i]->type == breathsprite) {
             sprites[i]->opacity -= multiplier / 2;
             sprites[i]->size += multiplier / 2;
-            if (findLength(&sprites[i]->velocity) <= multiplier)sprites[i]->velocity = 0;
-            else {
+            if (findLength(&sprites[i]->velocity) <= multiplier) {
+                sprites[i]->velocity = 0;
+            } else {
                 XYZ slowdown;
                 slowdown = sprites[i]->velocity * -1;
                 Normalise(&slowdown);
@@ -295,12 +314,12 @@ void Sprite::Draw()
             sprites[i]->rotation += multiplier * 360;
             sprites[i]->position.y -= multiplier;
             sprites[i]->position += windvector * multiplier;
-            if (sprites[i]->position.y < tempviewer.y - 6)sprites[i]->position.y += 12;
-            if (sprites[i]->position.y > tempviewer.y + 6)sprites[i]->position.y -= 12;
-            if (sprites[i]->position.z < tempviewer.z - 6)sprites[i]->position.z += 12;
-            if (sprites[i]->position.z > tempviewer.z + 6)sprites[i]->position.z -= 12;
-            if (sprites[i]->position.x < tempviewer.x - 6)sprites[i]->position.x += 12;
-            if (sprites[i]->position.x > tempviewer.x + 6)sprites[i]->position.x -= 12;
+            if (sprites[i]->position.y < tempviewer.y - 6) sprites[i]->position.y += 12;
+            if (sprites[i]->position.y > tempviewer.y + 6) sprites[i]->position.y -= 12;
+            if (sprites[i]->position.z < tempviewer.z - 6) sprites[i]->position.z += 12;
+            if (sprites[i]->position.z > tempviewer.z + 6) sprites[i]->position.z -= 12;
+            if (sprites[i]->position.x < tempviewer.x - 6) sprites[i]->position.x += 12;
+            if (sprites[i]->position.x > tempviewer.x + 6) sprites[i]->position.x -= 12;
         }
         if (sprites[i]->type == bloodsprite) {
             bool spritehit = 0;
@@ -315,11 +334,13 @@ void Sprite::Draw()
                     if (!spritehit && player[j].dead && sprites[i]->alivetime > .1) {
                         where = sprites[i]->oldposition;
                         where -= player[j].coords;
-                        if (!player[j].skeleton.free)where = DoRotation(where, 0, -player[j].yaw, 0);
+                        if (!player[j].skeleton.free)
+                            where = DoRotation(where, 0, -player[j].yaw, 0);
                         startpoint = where;
                         where = sprites[i]->position;
                         where -= player[j].coords;
-                        if (!player[j].skeleton.free)where = DoRotation(where, 0, -player[j].yaw, 0);
+                        if (!player[j].skeleton.free)
+                            where = DoRotation(where, 0, -player[j].yaw, 0);
                         endpoint = where;
 
                         movepoint = 0;
@@ -344,7 +365,8 @@ void Sprite::Draw()
                                 end = sprites[i]->position;
                                 if (!spritehit)
                                     if (objects.model[k].LineCheck(&start, &end, &colpoint, &objects.position[k], &objects.yaw[k]) != -1) {
-                                        if (detail == 2 || (detail == 1 && abs(Random() % 4) == 0) || (detail == 0 && abs(Random() % 8) == 0))objects.model[k].MakeDecal(blooddecalfast, DoRotation(colpoint - objects.position[k], 0, -objects.yaw[k], 0), sprites[i]->size * 1.6/*+abs((float)(Random()%100))/2400*/, .5, Random() % 360);
+                                        if (detail == 2 || (detail == 1 && abs(Random() % 4) == 0) || (detail == 0 && abs(Random() % 8) == 0))
+                                            objects.model[k].MakeDecal(blooddecalfast, DoRotation(colpoint - objects.position[k], 0, -objects.yaw[k], 0), sprites[i]->size * 1.6/*+abs((float)(Random()%100))/2400*/, .5, Random() % 360);
                                         DeleteSprite(i);
                                         spritehit = 1;
                                     }
@@ -360,8 +382,10 @@ void Sprite::Draw()
         if (sprites[i]->type == splintersprite) {
             sprites[i]->rotation += sprites[i]->rotatespeed * multiplier;
             sprites[i]->opacity -= multiplier / 2;
-            if (sprites[i]->special == 0 || sprites[i]->special == 2 || sprites[i]->special == 3)sprites[i]->velocity.y += gravity * multiplier;
-            if (sprites[i]->special == 1)sprites[i]->velocity.y += gravity * multiplier * .5;
+            if (sprites[i]->special == 0 || sprites[i]->special == 2 || sprites[i]->special == 3)
+                sprites[i]->velocity.y += gravity * multiplier;
+            if (sprites[i]->special == 1)
+                sprites[i]->velocity.y += gravity * multiplier * .5;
         }
         if (sprites[i]->type == flamesprite || sprites[i]->type == weaponflamesprite || sprites[i]->type == weaponshinesprite || sprites[i]->type == bloodflamesprite) {
             sprites[i]->rotation += multiplier * sprites[i]->rotatespeed;
@@ -379,15 +403,19 @@ void Sprite::Draw()
             sprites[i]->color[0] -= multiplier;
             sprites[i]->color[1] -= multiplier;
             sprites[i]->color[2] -= multiplier;
-            if (sprites[i]->color[0] < .6)sprites[i]->color[0] = .6;
-            if (sprites[i]->color[1] < .6)sprites[i]->color[1] = .6;
-            if (sprites[i]->color[2] < .6)sprites[i]->color[2] = .6;
+            if (sprites[i]->color[0] < .6)
+                sprites[i]->color[0] = .6;
+            if (sprites[i]->color[1] < .6)
+                sprites[i]->color[1] = .6;
+            if (sprites[i]->color[2] < .6)
+                sprites[i]->color[2] = .6;
             sprites[i]->size += multiplier;
             sprites[i]->velocity = 0;
             sprites[i]->velocity.y = 1.5;
             sprites[i]->rotation += multiplier * sprites[i]->rotatespeed / 5;
         }
-        if (sprites[i]->opacity <= 0 || sprites[i]->size <= 0)DeleteSprite(i);
+        if (sprites[i]->opacity <= 0 || sprites[i]->size <= 0)
+            DeleteSprite(i);
     }
     if (check)
         for (i = sprites.size() - 1; i >= 0; i--) {
index 81697d19c76f2f6dce762006fbc0c68435e69bb0..fdb2afa006df53a06823d7d993b06fef163fdc8a 100644 (file)
@@ -74,11 +74,13 @@ bool upload_image(const unsigned char* filePath, bool hasalpha)
     //err = FSMakeFSSpec (0, 0, (const unsigned char*)filePath, &fsspec);
     err = FSMakeFSSpec (0, 0, filePath, &fsspec);
     //err=FSPathMakeFSSpec((const UInt8*)filePath,&fsspec,&isdir);*/
-    if (err)return;
+    if (err)
+        return;
 
     GraphicsImportComponent gi;
     err = GetGraphicsImporterForFile(&fsspec, &gi);
-    if (err)return;
+    if (err)
+        return;
 
     Rect natbounds;
     cr = GraphicsImportGetNaturalBounds(gi, &natbounds);
@@ -94,7 +96,8 @@ bool upload_image(const unsigned char* filePath, bool hasalpha)
     GWorldPtr gw;
     err = QTNewGWorldFromPtr(&gw, k32ARGBPixelFormat, &natbounds, NULL, NULL,
                              0, texture.data, 4 * natbounds.right);
-    if (err)return;
+    if (err)
+        return;
 
     cr = GraphicsImportSetGWorld(gi, gw, NULL);
 
@@ -106,7 +109,8 @@ bool upload_image(const unsigned char* filePath, bool hasalpha)
     cr = GraphicsImportDraw(gi);
 
     err = CloseComponent(gi);
-    if (err)return;
+    if (err)
+        return;
 
     /*glTexImage2D(textureTarget, 0, GL_RGBA, natbounds.right, natbounds.top, 0,
     GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buf);
index 58a31f919f8d543ce518684a93abe53a9e58db2f..b09f806296404c569cd3ad88e5ad2488fe81fcfe 100644 (file)
@@ -82,20 +82,28 @@ int Terrain::lineTerrain(XYZ p1, XYZ p2, XYZ *p)
         starty = i;
     }
 
-    if (startx < 0)startx = 0;
-    if (starty < 0)starty = 0;
-    if (endx > size - 1)endx = size - 1;
-    if (endy > size - 1)endy = size - 1;
+    if (startx < 0)
+        startx = 0;
+    if (starty < 0)
+        starty = 0;
+    if (endx > size - 1)
+        endx = size - 1;
+    if (endy > size - 1)
+        endy = size - 1;
 
     for (i = startx; i <= endx; i++) {
         for (j = starty; j <= endy; j++) {
             highest = -1000;
             lowest = 1000;
             for (k = 0; k < 2; k++) {
-                if (heightmap[i + k][j] > highest)highest = heightmap[i + k][j];
-                if (heightmap[i + k][j] < lowest)lowest = heightmap[i + k][j];
-                if (heightmap[i + k][j + 1] > highest)highest = heightmap[i + k][j + 1];
-                if (heightmap[i + k][j + 1] < lowest)lowest = heightmap[i + k][j + 1];
+                if (heightmap[i + k][j] > highest)
+                    highest = heightmap[i + k][j];
+                if (heightmap[i + k][j] < lowest)
+                    lowest = heightmap[i + k][j];
+                if (heightmap[i + k][j + 1] > highest)
+                    highest = heightmap[i + k][j + 1];
+                if (heightmap[i + k][j + 1] < lowest)
+                    lowest = heightmap[i + k][j + 1];
             }
             if ((p1.y <= highest || p2.y <= highest) && (p1.y >= lowest || p2.y >= lowest)) {
                 triangles[0].x = i;
@@ -164,7 +172,8 @@ void Terrain::UpdateTransparency(int whichx, int whichy)
                 vertex.z = j * scale;
                 vertex.y = heightmap[i][j] * scale;
                 distance = distsq(&viewer, &vertex);
-                if (distance > viewdistsquared)distance = viewdistsquared;
+                if (distance > viewdistsquared)
+                    distance = viewdistsquared;
                 colors[i][j][3] = (viewdistsquared - (distance - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
             }
         }
@@ -242,7 +251,8 @@ void Terrain::UpdateTransparencyotherother(int whichx, int whichy)
                 vertex.z = j * scale;
                 vertex.y = heightmap[i][j] * scale;
                 distance = distsq(&viewer, &vertex);
-                if (distance > viewdistsquared)distance = viewdistsquared;
+                if (distance > viewdistsquared)
+                    distance = viewdistsquared;
                 colors[i][j][3] = (viewdistsquared - (distance - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
             }
         }
@@ -350,12 +360,15 @@ void Terrain::UpdateVertexArray(int whichx, int whichy)
     minypatch[whichx][whichy] = 10000;
     for (a = 0; a < size / subdivision; a++) {
         for (b = 0; b < size / subdivision; b++) {
-            if (heightmap[(size / subdivision)*whichx + a][(size / subdivision)*whichy + b]*scale > maxypatch[whichx][whichy]) maxypatch[whichx][whichy] = heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale;
-            if (heightmap[(size / subdivision)*whichx + a][(size / subdivision)*whichy + b]*scale < minypatch[whichx][whichy]) minypatch[whichx][whichy] = heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale;
+            if (heightmap[(size / subdivision)*whichx + a][(size / subdivision)*whichy + b]*scale > maxypatch[whichx][whichy])
+                maxypatch[whichx][whichy] = heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale;
+            if (heightmap[(size / subdivision)*whichx + a][(size / subdivision)*whichy + b]*scale < minypatch[whichx][whichy])
+                minypatch[whichx][whichy] = heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale;
         }
     }
     heightypatch[whichx][whichy] = (maxypatch[whichx][whichy] - minypatch[whichx][whichy]);
-    if (heightypatch[whichx][whichy] < size / subdivision * scale)heightypatch[whichx][whichy] = size / subdivision * scale;
+    if (heightypatch[whichx][whichy] < size / subdivision * scale)
+        heightypatch[whichx][whichy] = size / subdivision * scale;
     avgypatch[whichx][whichy] = (minypatch[whichx][whichy] + maxypatch[whichx][whichy]) / 2;
 
     for (i = whichx * size / subdivision; i < (whichx + 1)*size / subdivision - 1; i++) {
@@ -419,7 +432,8 @@ bool Terrain::load(const char *fileName)
         }
     }
     texture.bpp = 24;
-    if (visibleloading) Game::LoadingScreen();
+    if (visibleloading)
+        Game::LoadingScreen();
 
     texdetail = temptexdetail;
 
@@ -451,7 +465,8 @@ bool Terrain::load(const char *fileName)
         }
 
     }
-    if (visibleloading) Game::LoadingScreen();
+    if (visibleloading)
+        Game::LoadingScreen();
 
     float slopeness;
 
@@ -460,7 +475,8 @@ bool Terrain::load(const char *fileName)
             textureness[i][j] = -1;
         }
     }
-    if (visibleloading) Game::LoadingScreen();
+    if (visibleloading)
+        Game::LoadingScreen();
 
 
     for (i = 0; i < size; i++) {
@@ -476,7 +492,8 @@ bool Terrain::load(const char *fileName)
                     slopeness = heightmap[i][j] - heightmap[i][j - 1];
                 }
                 opacityother[i][j] = slopeness * slopeness * 2;
-                if (opacityother[i][j] > 1)opacityother[i][j] = 1;
+                if (opacityother[i][j] > 1)
+                    opacityother[i][j] = 1;
                 opacityother[i][j] -= (float)abs(Random() % 100) / 300;
             }
             if (environment == desertenvironment) {
@@ -484,7 +501,8 @@ bool Terrain::load(const char *fileName)
                     slopeness = heightmap[i][j] - heightmap[i][j - 1];
                 }
                 opacityother[i][j] = slopeness * slopeness * 2;
-                if (opacityother[i][j] > 1)opacityother[i][j] = 1;
+                if (opacityother[i][j] > 1)
+                    opacityother[i][j] = 1;
                 opacityother[i][j] -= (float)abs(Random() % 100) / 300;
             }
             if (environment == grassyenvironment) {
@@ -501,12 +519,14 @@ bool Terrain::load(const char *fileName)
                     slopeness = heightmap[i][j] - heightmap[i][j + 1];
                 }
                 opacityother[i][j] = slopeness * slopeness * 10;
-                if (opacityother[i][j] > 1)opacityother[i][j] = 1;
+                if (opacityother[i][j] > 1)
+                    opacityother[i][j] = 1;
                 opacityother[i][j] -= (float)abs(Random() % 100) / 100;
             }
         }
     }
-    if (visibleloading) Game::LoadingScreen();
+    if (visibleloading)
+        Game::LoadingScreen();
 
     for (i = 0; i < size; i++) {
         for (j = 0; j < size; j++) {
@@ -518,7 +538,8 @@ bool Terrain::load(const char *fileName)
             }
         }
     }
-    if (visibleloading) Game::LoadingScreen();
+    if (visibleloading)
+        Game::LoadingScreen();
 
     /*float total;
     int todivide;
@@ -544,38 +565,55 @@ bool Terrain::load(const char *fileName)
 
     for (i = 0; i < size; i++) {
         for (j = 0; j < size; j++) {
-            if (opacityother[i][j] < .1)opacityother[i][j] = 0;
+            if (opacityother[i][j] < .1)
+                opacityother[i][j] = 0;
             if (textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == -1) {
-                if (!opacityother[i][j])textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = allfirst;
-                if (opacityother[i][j] == 1)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = allsecond;
+                if (!opacityother[i][j])
+                    textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = allfirst;
+                if (opacityother[i][j] == 1)
+                    textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = allsecond;
             }
-            if (opacityother[i][j] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-            if (opacityother[i][j] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+            if (opacityother[i][j] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+                textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+            if (opacityother[i][j] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+                textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
 
             x = i;
             y = j;
             if (i > 0) {
                 i--;
-                if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
-                if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+                    textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+                    textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+                    textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+                    textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
 
                 if (j > 0) {
                     j--;
-                    if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                    if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                    if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
-                    if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                    if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+                        textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                    if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+                        textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                    if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+                        textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                    if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+                        textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
                     j++;
                 }
 
                 if (j < size - 1) {
                     j++;
-                    if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                    if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                    if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
-                    if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                    if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+                        textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                    if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+                        textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                    if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+                        textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                    if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+                        textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
                     j--;
                 }
                 i++;
@@ -583,26 +621,38 @@ bool Terrain::load(const char *fileName)
 
             if (i < size - 1) {
                 i++;
-                if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
-                if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+                    textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+                    textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+                    textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+                    textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
 
                 if (j > 0) {
                     j--;
-                    if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                    if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                    if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
-                    if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                    if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+                        textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                    if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+                        textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                    if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+                        textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                    if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+                        textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
                     j++;
                 }
 
                 if (j < size - 1) {
                     j++;
-                    if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                    if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                    if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
-                    if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                    if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+                        textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                    if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+                        textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                    if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+                        textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                    if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+                        textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
                     j--;
                 }
                 i--;
@@ -610,25 +660,34 @@ bool Terrain::load(const char *fileName)
 
             if (j > 0) {
                 j--;
-                if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
-                if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+                    textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+                    textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+                    textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+                    textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
                 j++;
             }
 
             if (j < size - 1) {
                 j++;
-                if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
-                if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
-                if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                if (opacityother[x][y] && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allfirst)
+                    textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                if (opacityother[x][y] != 1 && textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] == allsecond)
+                    textureness[(int)(i * subdivision / size)][(int)(j * subdivision / size)] = mixed;
+                if (opacityother[i][j] && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allfirst)
+                    textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
+                if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
+                    textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
                 j--;
 
             }
         }
     }
-    if (visibleloading) Game::LoadingScreen();
+    if (visibleloading)
+        Game::LoadingScreen();
 
     patch_size = size / subdivision;
     patch_elements = (patch_size) * (patch_size) * 54;
@@ -723,7 +782,8 @@ void Terrain::CalculateNormals()
 
 void Terrain::drawpatch(int whichx, int whichy, float opacity)
 {
-    if (opacity >= 1)glDisable(GL_BLEND);
+    if (opacity >= 1)
+        glDisable(GL_BLEND);
     if (opacity < 1) {
         glEnable(GL_BLEND);
         UpdateTransparency(whichx, whichy);
@@ -809,7 +869,8 @@ float Terrain::getHeight(float pointx, float pointz)
     pointx /= scale;
     pointz /= scale;
 
-    if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)return 0;
+    if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+        return 0;
 
     startpoint.x = pointx;
     startpoint.y = -1000;
@@ -866,8 +927,10 @@ float Terrain::getHeightExtrude(float pointx, float pointz, float point2x, float
     point2x /= scale;
     point2z /= scale;
 
-    if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)return 0;
-    if (point2x >= size - 1 || point2z >= size - 1 || point2x <= 0 || point2z <= 0)return 0;
+    if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+        return 0;
+    if (point2x >= size - 1 || point2z >= size - 1 || point2x <= 0 || point2z <= 0)
+        return 0;
 
     startpoint.x = point2x;
     startpoint.y = -1000;
@@ -931,7 +994,8 @@ float Terrain::getOpacity(float pointx, float pointz)
     pointx /= scale;
     pointz /= scale;
 
-    if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)return 0;
+    if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+        return 0;
 
     tilex = pointx;
     tiley = pointz;
@@ -951,7 +1015,8 @@ XYZ Terrain::getNormal(float pointx, float pointz)
     pointz /= scale;
 
     height1 = 0;
-    if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)return height1;
+    if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+        return height1;
     tilex = pointx;
     tiley = pointz;
 
@@ -971,7 +1036,8 @@ XYZ Terrain::getLighting(float pointx, float pointz)
     pointz /= scale;
 
     height1 = 0;
-    if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)return height1;
+    if (pointx >= size - 1 || pointz >= size - 1 || pointx <= 0 || pointz <= 0)
+        return height1;
     tilex = pointx;
     tiley = pointz;
 
@@ -1002,14 +1068,18 @@ void Terrain::draw(int layer)
 
     //Only nearby blocks
     beginx = (viewer.x - viewdistance) / (patch_size) - 1;
-    if (beginx < 0)beginx = 0;
+    if (beginx < 0)
+        beginx = 0;
     beginz = (viewer.z - viewdistance) / (patch_size) - 1;
-    if (beginz < 0)beginz = 0;
+    if (beginz < 0)
+        beginz = 0;
 
     endx = (viewer.x + viewdistance) / (patch_size) + 1;
-    if (endx > subdivision)endx = subdivision;
+    if (endx > subdivision)
+        endx = subdivision;
     endz = (viewer.z + viewdistance) / (patch_size) + 1;
-    if (endz > subdivision)endz = subdivision;
+    if (endz > subdivision)
+        endz = subdivision;
 
     if (!layer) {
         for (i = beginx; i < endx; i++) {
@@ -1079,7 +1149,8 @@ void Terrain::drawdecals()
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
         glDepthMask(0);
         for (i = 0; i < numdecals; i++) {
-            if (decaltype[i] == blooddecalfast && decalalivetime[i] < 2)decalalivetime[i] = 2;
+            if (decaltype[i] == blooddecalfast && decalalivetime[i] < 2)
+                decalalivetime[i] = 2;
             if ((decaltype[i] == shadowdecal || decaltype[i] == shadowdecalpermanent) && decaltype[i] != lasttype) {
                 shadowtexture.bind();
                 if (!blend) {
@@ -1122,31 +1193,39 @@ void Terrain::drawdecals()
             }
             if (decaltype[i] == shadowdecal || decaltype[i] == shadowdecalpermanent) {
                 distancemult = (viewdistsquared - (distsq(&viewer, &decalposition[i]) - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
-                if (distancemult >= 1)glColor4f(1, 1, 1, decalopacity[i]);
-                if (distancemult < 1)glColor4f(1, 1, 1, decalopacity[i]*distancemult);
+                if (distancemult >= 1)
+                    glColor4f(1, 1, 1, decalopacity[i]);
+                if (distancemult < 1)
+                    glColor4f(1, 1, 1, decalopacity[i]*distancemult);
             }
             if (decaltype[i] == footprintdecal || decaltype[i] == bodyprintdecal) {
                 distancemult = (viewdistsquared - (distsq(&viewer, &decalposition[i]) - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
                 if (distancemult >= 1) {
                     glColor4f(1, 1, 1, decalopacity[i]);
-                    if (decalalivetime[i] > 3)glColor4f(1, 1, 1, decalopacity[i] * (5 - decalalivetime[i]) / 2);
+                    if (decalalivetime[i] > 3)
+                        glColor4f(1, 1, 1, decalopacity[i] * (5 - decalalivetime[i]) / 2);
                 }
                 if (distancemult < 1) {
                     glColor4f(1, 1, 1, decalopacity[i]*distancemult);
-                    if (decalalivetime[i] > 3)glColor4f(1, 1, 1, decalopacity[i] * (5 - decalalivetime[i]) / 2 * distancemult);
+                    if (decalalivetime[i] > 3)
+                        glColor4f(1, 1, 1, decalopacity[i] * (5 - decalalivetime[i]) / 2 * distancemult);
                 }
             }
             if ((decaltype[i] == blooddecal || decaltype[i] == blooddecalfast || decaltype[i] == blooddecalslow)) {
                 distancemult = (viewdistsquared - (distsq(&viewer, &decalposition[i]) - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
                 if (distancemult >= 1) {
                     glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i]);
-                    if (decalalivetime[i] < 4)glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i]*decalalivetime[i]*.25);
-                    if (decalalivetime[i] > 58)glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i] * (60 - decalalivetime[i]) / 2);
+                    if (decalalivetime[i] < 4)
+                        glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i]*decalalivetime[i]*.25);
+                    if (decalalivetime[i] > 58)
+                        glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i] * (60 - decalalivetime[i]) / 2);
                 }
                 if (distancemult < 1) {
                     glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i]*distancemult);
-                    if (decalalivetime[i] < 4)glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i]*decalalivetime[i]*distancemult * .25);
-                    if (decalalivetime[i] > 58)glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i] * (60 - decalalivetime[i]) / 2 * distancemult);
+                    if (decalalivetime[i] < 4)
+                        glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i]*decalalivetime[i]*distancemult * .25);
+                    if (decalalivetime[i] > 58)
+                        glColor4f(decalbrightness[i], decalbrightness[i], decalbrightness[i], decalopacity[i] * (60 - decalalivetime[i]) / 2 * distancemult);
                 }
             }
             lasttype = decaltype[i];
@@ -1165,12 +1244,18 @@ void Terrain::drawdecals()
         }
         for (i = numdecals - 1; i >= 0; i--) {
             decalalivetime[i] += multiplier;
-            if (decaltype[i] == blooddecalslow)decalalivetime[i] -= multiplier * 2 / 3;
-            if (decaltype[i] == blooddecalfast)decalalivetime[i] += multiplier * 4;
-            if (decaltype[i] == shadowdecal)DeleteDecal(i);
-            if (decaltype[i] == footprintdecal && decalalivetime[i] >= 5)DeleteDecal(i);
-            if (decaltype[i] == bodyprintdecal && decalalivetime[i] >= 5)DeleteDecal(i);
-            if ((decaltype[i] == blooddecal || decaltype[i] == blooddecalfast || decaltype[i] == blooddecalslow) && decalalivetime[i] >= 60)DeleteDecal(i);
+            if (decaltype[i] == blooddecalslow)
+                decalalivetime[i] -= multiplier * 2 / 3;
+            if (decaltype[i] == blooddecalfast)
+                decalalivetime[i] += multiplier * 4;
+            if (decaltype[i] == shadowdecal)
+                DeleteDecal(i);
+            if (decaltype[i] == footprintdecal && decalalivetime[i] >= 5)
+                DeleteDecal(i);
+            if (decaltype[i] == bodyprintdecal && decalalivetime[i] >= 5)
+                DeleteDecal(i);
+            if ((decaltype[i] == blooddecal || decaltype[i] == blooddecalfast || decaltype[i] == blooddecalslow) && decalalivetime[i] >= 60)
+                DeleteDecal(i);
         }
         glAlphaFunc(GL_GREATER, 0.0001);
     }
@@ -1282,13 +1367,15 @@ void Terrain::MakeDecalLock(int type, XYZ where, int whichx, int whichy, float s
 
         rot = getLighting(where.x, where.z);
         decalbrightness[numdecals] = (rot.x + rot.y + rot.z) / 3;
-        if (decalbrightness[numdecals] < .4)decalbrightness[numdecals] = .4;
+        if (decalbrightness[numdecals] < .4)
+            decalbrightness[numdecals] = .4;
 
         if (environment == grassyenvironment) {
             decalbrightness[numdecals] *= .6;
         }
 
-        if (decalbrightness[numdecals] > 1)decalbrightness[numdecals] = 1;
+        if (decalbrightness[numdecals] > 1)
+            decalbrightness[numdecals] = 1;
         decalbright = decalbrightness[numdecals];
 
         decalposition[numdecals] = where;
@@ -1344,7 +1431,8 @@ void Terrain::MakeDecalLock(int type, XYZ where, int whichx, int whichy, float s
             if (!(decaltexcoords[numdecals][0][1] < 0 && decaltexcoords[numdecals][1][1] < 0 && decaltexcoords[numdecals][2][1] < 0))
                 if (!(decaltexcoords[numdecals][0][0] > 1 && decaltexcoords[numdecals][1][0] > 1 && decaltexcoords[numdecals][2][0] > 1))
                     if (!(decaltexcoords[numdecals][0][1] > 1 && decaltexcoords[numdecals][1][1] > 1 && decaltexcoords[numdecals][2][1] > 1))
-                        if (numdecals < max_decals - 1)numdecals++;
+                        if (numdecals < max_decals - 1)
+                            numdecals++;
 
         decalbrightness[numdecals] = decalbright;
 
@@ -1401,7 +1489,8 @@ void Terrain::MakeDecalLock(int type, XYZ where, int whichx, int whichy, float s
             if (!(decaltexcoords[numdecals][0][1] < 0 && decaltexcoords[numdecals][1][1] < 0 && decaltexcoords[numdecals][2][1] < 0))
                 if (!(decaltexcoords[numdecals][0][0] > 1 && decaltexcoords[numdecals][1][0] > 1 && decaltexcoords[numdecals][2][0] > 1))
                     if (!(decaltexcoords[numdecals][0][1] > 1 && decaltexcoords[numdecals][1][1] > 1 && decaltexcoords[numdecals][2][1] > 1))
-                        if (numdecals < max_decals - 1)numdecals++;
+                        if (numdecals < max_decals - 1)
+                            numdecals++;
     }
 }
 
@@ -1423,19 +1512,21 @@ void Terrain::DoLighting()
             */
             brightness = dotproduct(&lightloc, &normals[i][j]);
 
-            if (brightness > 1)brightness = 1;
-            if (brightness < 0)brightness = 0;
+            if (brightness > 1)
+                brightness = 1;
+            if (brightness < 0)
+                brightness = 0;
 
             colors[i][j][0] = light.color[0] * brightness + light.ambient[0];
             colors[i][j][1] = light.color[1] * brightness + light.ambient[1];
             colors[i][j][2] = light.color[2] * brightness + light.ambient[2];
 
-            if (colors[i][j][0] > 1)colors[i][j][0] = 1;
-            if (colors[i][j][1] > 1)colors[i][j][1] = 1;
-            if (colors[i][j][2] > 1)colors[i][j][2] = 1;
-            if (colors[i][j][0] < 0)colors[i][j][0] = 0;
-            if (colors[i][j][1] < 0)colors[i][j][1] = 0;
-            if (colors[i][j][2] < 0)colors[i][j][2] = 0;
+            if (colors[i][j][0] > 1) colors[i][j][0] = 1;
+            if (colors[i][j][1] > 1) colors[i][j][1] = 1;
+            if (colors[i][j][2] > 1) colors[i][j][2] = 1;
+            if (colors[i][j][0] < 0) colors[i][j][0] = 0;
+            if (colors[i][j][1] < 0) colors[i][j][1] = 0;
+            if (colors[i][j][2] < 0) colors[i][j][2] = 0;
         }
     }
 
@@ -1524,28 +1615,33 @@ void Terrain::DoShadows()
                         }
                     }
                 }
-                if (visibleloading) Game::LoadingScreen();
+                if (visibleloading)
+                    Game::LoadingScreen();
             }
             brightness = dotproduct(&lightloc, &normals[i][j]);
-            if (shadowed)brightness *= 1 - shadowed;
+            if (shadowed)
+                brightness *= 1 - shadowed;
 
-            if (brightness > 1)brightness = 1;
-            if (brightness < 0)brightness = 0;
+            if (brightness > 1)
+                brightness = 1;
+            if (brightness < 0)
+                brightness = 0;
 
             colors[i][j][0] = light.color[0] * brightness + light.ambient[0];
             colors[i][j][1] = light.color[1] * brightness + light.ambient[1];
             colors[i][j][2] = light.color[2] * brightness + light.ambient[2];
 
-            if (colors[i][j][0] > 1)colors[i][j][0] = 1;
-            if (colors[i][j][1] > 1)colors[i][j][1] = 1;
-            if (colors[i][j][2] > 1)colors[i][j][2] = 1;
-            if (colors[i][j][0] < 0)colors[i][j][0] = 0;
-            if (colors[i][j][1] < 0)colors[i][j][1] = 0;
-            if (colors[i][j][2] < 0)colors[i][j][2] = 0;
+            if (colors[i][j][0] > 1) colors[i][j][0] = 1;
+            if (colors[i][j][1] > 1) colors[i][j][1] = 1;
+            if (colors[i][j][2] > 1) colors[i][j][2] = 1;
+            if (colors[i][j][0] < 0) colors[i][j][0] = 0;
+            if (colors[i][j][1] < 0) colors[i][j][1] = 0;
+            if (colors[i][j][2] < 0) colors[i][j][2] = 0;
         }
     }
 
-    if (visibleloading) Game::LoadingScreen();
+    if (visibleloading)
+        Game::LoadingScreen();
 
     //Smooth shadows
     for (i = 0; i < size; i++) {
index 144d9cc31334fbd1c3ae5c97947e3a3fc06ba4f1..1784f3327e5e8490e8fec413ccb8f83008a8f677 100644 (file)
@@ -238,7 +238,8 @@ void Weapon::DoStuff(int i)
 
                             player[j].aitype = attacktypecutoff;
                         } else {
-                            if (j != 0) numthrowkill++;
+                            if (j != 0)
+                                numthrowkill++;
                             player[j].num_weapons++;
                             player[j].weaponstuck = player[j].num_weapons - 1;
                             if (normaldotproduct(player[j].facing, velocity) > 0)
@@ -282,7 +283,9 @@ void Weapon::DoStuff(int i)
                             else
                                 award_bonus(0, Bullseyebonus);
                         }
-                    } else missed = 1;
+                    } else {
+                        missed = 1;
+                    }
                 }
             }
         }
@@ -371,7 +374,8 @@ void Weapon::DoStuff(int i)
             bigtilt = 0;
             bigtilt2 = 0;
             bigrotation = 0;
-            if (temppoint1.x > temppoint2.x) rotation1 = 360 - rotation1;
+            if (temppoint1.x > temppoint2.x)
+                rotation1 = 360 - rotation1;
         }
 
     }
@@ -462,8 +466,10 @@ void Weapon::DoStuff(int i)
                                 bounceness = 0;
                             frictionness = abs(normaldotproduct(velocity, terrainnormal));
                             velocity -= bounceness;
-                            if (1 - friction * frictionness > 0)velocity *= 1 - friction * frictionness;
-                            else velocity = 0;
+                            if (1 - friction * frictionness > 0)
+                                velocity *= 1 - friction * frictionness;
+                            else
+                                velocity = 0;
                             velocity += bounceness * elasticity;
 
                             if (findLengthfast(&bounceness) > 1) {
@@ -486,11 +492,14 @@ void Weapon::DoStuff(int i)
                             tippoint += terrainnormal * .002;
 
                             bounceness = terrainnormal * findLength(&tipvelocity) * (abs(normaldotproduct(tipvelocity, terrainnormal)));
-                            if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness))bounceness = 0;
+                            if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness))
+                                bounceness = 0;
                             frictionness = abs(normaldotproduct(tipvelocity, terrainnormal));
                             tipvelocity -= bounceness;
-                            if (1 - friction * frictionness > 0)tipvelocity *= 1 - friction * frictionness;
-                            else tipvelocity = 0;
+                            if (1 - friction * frictionness > 0)
+                                tipvelocity *= 1 - friction * frictionness;
+                            else
+                                tipvelocity = 0;
                             tipvelocity += bounceness * elasticity;
 
                             if (findLengthfast(&bounceness) > 1) {
@@ -519,11 +528,14 @@ void Weapon::DoStuff(int i)
                                     ReflectVector(&velocity, &terrainnormal);
 
                                     bounceness = terrainnormal * findLength(&velocity) * (abs(normaldotproduct(velocity, terrainnormal)));
-                                    if (findLengthfast(&velocity) < findLengthfast(&bounceness))bounceness = 0;
+                                    if (findLengthfast(&velocity) < findLengthfast(&bounceness))
+                                        bounceness = 0;
                                     frictionness = abs(normaldotproduct(velocity, terrainnormal));
                                     velocity -= bounceness;
-                                    if (1 - friction * frictionness > 0)velocity *= 1 - friction * frictionness;
-                                    else velocity = 0;
+                                    if (1 - friction * frictionness > 0)
+                                        velocity *= 1 - friction * frictionness;
+                                    else
+                                        velocity = 0;
                                     velocity += bounceness * elasticity;
 
                                     if (findLengthfast(&bounceness) > 1) {
@@ -551,11 +563,14 @@ void Weapon::DoStuff(int i)
                                     ReflectVector(&tipvelocity, &terrainnormal);
 
                                     bounceness = terrainnormal * findLength(&tipvelocity) * (abs(normaldotproduct(tipvelocity, terrainnormal)));
-                                    if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness))bounceness = 0;
+                                    if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness))
+                                        bounceness = 0;
                                     frictionness = abs(normaldotproduct(tipvelocity, terrainnormal));
                                     tipvelocity -= bounceness;
-                                    if (1 - friction * frictionness > 0)tipvelocity *= 1 - friction * frictionness;
-                                    else tipvelocity = 0;
+                                    if (1 - friction * frictionness > 0)
+                                        tipvelocity *= 1 - friction * frictionness;
+                                    else
+                                        tipvelocity = 0;
                                     tipvelocity += bounceness * elasticity;
 
                                     if (findLengthfast(&bounceness) > 1) {
@@ -624,13 +639,18 @@ void Weapon::DoStuff(int i)
                 ReflectVector(&velocity, &terrainnormal);
                 position += terrainnormal * .002;
                 bounceness = terrainnormal * findLength(&velocity) * (abs(normaldotproduct(velocity, terrainnormal)));
-                if (findLengthfast(&velocity) < findLengthfast(&bounceness))bounceness = 0;
+                if (findLengthfast(&velocity) < findLengthfast(&bounceness))
+                    bounceness = 0;
                 frictionness = abs(normaldotproduct(velocity, terrainnormal));
                 velocity -= bounceness;
-                if (1 - friction * frictionness > 0)velocity *= 1 - friction * frictionness;
-                else velocity = 0;
-                if (terrain.getOpacity(position.x, position.z) < .2)velocity += bounceness * elasticity * .3;
-                else velocity += bounceness * elasticity;
+                if (1 - friction * frictionness > 0)
+                    velocity *= 1 - friction * frictionness;
+                else
+                    velocity = 0;
+                if (terrain.getOpacity(position.x, position.z) < .2)
+                    velocity += bounceness * elasticity * .3;
+                else
+                    velocity += bounceness * elasticity;
 
                 if (findLengthfast(&bounceness) > 1) {
                     int whichsound;
@@ -673,13 +693,18 @@ void Weapon::DoStuff(int i)
                 ReflectVector(&tipvelocity, &terrainnormal);
                 tippoint += terrainnormal * .002;
                 bounceness = terrainnormal * findLength(&tipvelocity) * (abs(normaldotproduct(tipvelocity, terrainnormal)));
-                if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness))bounceness = 0;
+                if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness))
+                    bounceness = 0;
                 frictionness = abs(normaldotproduct(tipvelocity, terrainnormal));
                 tipvelocity -= bounceness;
-                if (1 - friction * frictionness > 0)tipvelocity *= 1 - friction * frictionness;
-                else tipvelocity = 0;
-                if (terrain.getOpacity(tippoint.x, tippoint.z) < .2)tipvelocity += bounceness * elasticity * .3;
-                else tipvelocity += bounceness * elasticity;
+                if (1 - friction * frictionness > 0)
+                    tipvelocity *= 1 - friction * frictionness;
+                else
+                    tipvelocity = 0;
+                if (terrain.getOpacity(tippoint.x, tippoint.z) < .2)
+                    tipvelocity += bounceness * elasticity * .3;
+                else
+                    tipvelocity += bounceness * elasticity;
 
                 if (findLengthfast(&bounceness) > 1) {
                     int whichsound;
@@ -725,20 +750,29 @@ void Weapon::DoStuff(int i)
                 ReflectVector(&velocity, &terrainnormal);
                 //mid+=terrainnormal*.002;
                 bounceness = terrainnormal * findLength(&velocity) * (abs(normaldotproduct(velocity, terrainnormal)));
-                if (findLengthfast(&velocity) < findLengthfast(&bounceness))bounceness = 0;
+                if (findLengthfast(&velocity) < findLengthfast(&bounceness))
+                    bounceness = 0;
                 frictionness = abs(normaldotproduct(velocity, terrainnormal));
                 velocity -= bounceness;
-                if (1 - friction * frictionness > 0)velocity *= 1 - friction * frictionness;
-                else velocity = 0;
-                if (terrain.getOpacity(mid.x, mid.z) < .2)velocity += bounceness * elasticity * .3;
-                else velocity += bounceness * elasticity;
+                if (1 - friction * frictionness > 0)
+                    velocity *= 1 - friction * frictionness;
+                else
+                    velocity = 0;
+                if (terrain.getOpacity(mid.x, mid.z) < .2)
+                    velocity += bounceness * elasticity * .3;
+                else
+                    velocity += bounceness * elasticity;
 
                 if (findLengthfast(&bounceness) > 1) {
                     int whichsound;
                     if (terrain.getOpacity(mid.x, mid.z) > .2) {
-                        if (type == staff)whichsound = footstepsound3 + abs(Random() % 2);
-                        if (type != staff)whichsound = clank1sound + abs(Random() % 4);
-                    } else whichsound = footstepsound + abs(Random() % 2);
+                        if (type == staff)
+                            whichsound = footstepsound3 + abs(Random() % 2);
+                        if (type != staff)
+                            whichsound = clank1sound + abs(Random() % 4);
+                    } else {
+                        whichsound = footstepsound + abs(Random() % 2);
+                    }
                     emit_sound_at(whichsound, mid,
                                   findLengthfast(&bounceness)
                                   * (terrain.getOpacity(position.x, position.z) > .2
@@ -760,20 +794,29 @@ void Weapon::DoStuff(int i)
                 ReflectVector(&tipvelocity, &terrainnormal);
                 //mid+=terrainnormal*.002;
                 bounceness = terrainnormal * findLength(&tipvelocity) * (abs(normaldotproduct(tipvelocity, terrainnormal)));
-                if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness))bounceness = 0;
+                if (findLengthfast(&tipvelocity) < findLengthfast(&bounceness))
+                    bounceness = 0;
                 frictionness = abs(normaldotproduct(tipvelocity, terrainnormal));
                 tipvelocity -= bounceness;
-                if (1 - friction * frictionness > 0)tipvelocity *= 1 - friction * frictionness;
-                else tipvelocity = 0;
-                if (terrain.getOpacity(mid.x, mid.z) < .2)tipvelocity += bounceness * elasticity * .3;
-                else tipvelocity += bounceness * elasticity;
+                if (1 - friction * frictionness > 0)
+                    tipvelocity *= 1 - friction * frictionness;
+                else
+                    tipvelocity = 0;
+                if (terrain.getOpacity(mid.x, mid.z) < .2)
+                    tipvelocity += bounceness * elasticity * .3;
+                else
+                    tipvelocity += bounceness * elasticity;
 
                 if (findLengthfast(&bounceness) > 1) {
                     int whichsound;
                     if (terrain.getOpacity(mid.x, mid.z) > .2) {
-                        if (type == staff)whichsound = footstepsound3 + abs(Random() % 2);
-                        if (type != staff)whichsound = clank1sound + abs(Random() % 4);
-                    } else whichsound = footstepsound + abs(Random() % 2);
+                        if (type == staff)
+                            whichsound = footstepsound3 + abs(Random() % 2);
+                        if (type != staff)
+                            whichsound = clank1sound + abs(Random() % 4);
+                    } else {
+                        whichsound = footstepsound + abs(Random() % 2);
+                    }
                     emit_sound_at(whichsound, mid,
                                   findLengthfast(&bounceness)
                                   * (terrain.getOpacity(position.x, position.z) > .2
@@ -805,7 +848,8 @@ void Weapon::DoStuff(int i)
             bigtilt = 0;
             bigtilt2 = 0;
             bigrotation = 0;
-            if (temppoint1.x > temppoint2.x)rotation1 = 360 - rotation1;
+            if (temppoint1.x > temppoint2.x)
+                rotation1 = 360 - rotation1;
 
             //Stop moving
             if (findLengthfast(&velocity) < .3 && findLengthfast(&tipvelocity) < .3 && hitsomething) {
@@ -823,8 +867,10 @@ void Weapon::DoStuff(int i)
     if (blooddrip && bloody) {
         blooddripdelay -= blooddrip * multiplier / 2;
         blooddrip -= multiplier;
-        if (blooddrip < 0) blooddrip = 0;
-        if (blooddrip > 5) blooddrip = 5;
+        if (blooddrip < 0)
+            blooddrip = 0;
+        if (blooddrip > 5)
+            blooddrip = 5;
         if (blooddripdelay < 0 && bloodtoggle) {
             blooddripdelay = 1;
             XYZ bloodvel;
@@ -1006,7 +1052,8 @@ void Weapon::Draw()
             lastdrawnbigtilt2 = bigtilt2;
             lastdrawnsmallrotation = smallrotation;
             lastdrawnsmallrotation2 = smallrotation2;
-            if (owner != -1)lastdrawnanim = player[owner].animCurrent;
+            if (owner != -1)
+                lastdrawnanim = player[owner].animCurrent;
         }
         if (owner != -1) {
             glMatrixMode(GL_MODELVIEW);                                                        // Select The Modelview Matrix
index 589901276b6b541aa1ccf6581078a3de257befbd..cc7ffc55443f433009fd62b5ed50381c7ad5b660 100644 (file)
@@ -144,7 +144,8 @@ static void set_channel_position(const int channel, const float x,
 
 AL_API void OPENAL_3D_Listener_SetAttributes(const float *pos, const float *vel, float fx, float fy, float fz, float tx, float ty, float tz)
 {
-    if (!initialized) return;
+    if (!initialized)
+        return;
     if (pos != NULL) {
         alListener3f(AL_POSITION, pos[0], pos[1], -pos[2]);
         listener_position[0] = pos[0];
@@ -166,8 +167,10 @@ AL_API void OPENAL_3D_Listener_SetAttributes(const float *pos, const float *vel,
 
 AL_API signed char OPENAL_3D_SetAttributes(int channel, const float *pos, const float *vel)
 {
-    if (!initialized) return false;
-    if ((channel < 0) || (channel >= num_channels)) return false;
+    if (!initialized)
+        return false;
+    if ((channel < 0) || (channel >= num_channels))
+        return false;
 
     if (pos != NULL)
         set_channel_position(channel, pos[0], pos[1], -pos[2]);
@@ -179,8 +182,10 @@ AL_API signed char OPENAL_3D_SetAttributes(int channel, const float *pos, const
 
 AL_API signed char OPENAL_3D_SetAttributes_(int channel, const XYZ &pos, const float *vel)
 {
-    if (!initialized) return false;
-    if ((channel < 0) || (channel >= num_channels)) return false;
+    if (!initialized)
+        return false;
+    if ((channel < 0) || (channel >= num_channels))
+        return false;
 
     set_channel_position(channel, pos.x, pos.y, -pos.z);
 
@@ -189,8 +194,10 @@ AL_API signed char OPENAL_3D_SetAttributes_(int channel, const XYZ &pos, const f
 
 AL_API signed char OPENAL_Init(int mixrate, int maxsoftwarechannels, unsigned int flags)
 {
-    if (initialized) return false;
-    if (maxsoftwarechannels == 0) return false;
+    if (initialized)
+        return false;
+    if (maxsoftwarechannels == 0)
+        return false;
 
     if (flags != 0)  // unsupported.
         return false;
@@ -236,7 +243,8 @@ AL_API signed char OPENAL_Init(int mixrate, int maxsoftwarechannels, unsigned in
 
 AL_API void OPENAL_Close()
 {
-    if (!initialized) return;
+    if (!initialized)
+        return;
 
     ALCcontext *ctx = alcGetCurrentContext();
     if (ctx) {
@@ -262,15 +270,19 @@ AL_API void OPENAL_Close()
 
 static OPENAL_SAMPLE *OPENAL_GetCurrentSample(int channel)
 {
-    if (!initialized) return NULL;
-    if ((channel < 0) || (channel >= num_channels)) return NULL;
+    if (!initialized)
+        return NULL;
+    if ((channel < 0) || (channel >= num_channels))
+        return NULL;
     return impl_channels[channel].sample;
 }
 
 static signed char OPENAL_GetPaused(int channel)
 {
-    if (!initialized) return false;
-    if ((channel < 0) || (channel >= num_channels)) return false;
+    if (!initialized)
+        return false;
+    if ((channel < 0) || (channel >= num_channels))
+        return false;
     if (impl_channels[channel].startpaused)
         return(true);
 
@@ -281,8 +293,10 @@ static signed char OPENAL_GetPaused(int channel)
 
 static unsigned int OPENAL_GetLoopMode(int channel)
 {
-    if (!initialized) return 0;
-    if ((channel < 0) || (channel >= num_channels)) return 0;
+    if (!initialized)
+        return 0;
+    if ((channel < 0) || (channel >= num_channels))
+        return 0;
     ALint loop = 0;
     alGetSourceiv(impl_channels[channel].sid, AL_LOOPING, &loop);
     if (loop)
@@ -292,8 +306,10 @@ static unsigned int OPENAL_GetLoopMode(int channel)
 
 static signed char OPENAL_IsPlaying(int channel)
 {
-    if (!initialized) return false;
-    if ((channel < 0) || (channel >= num_channels)) return false;
+    if (!initialized)
+        return false;
+    if ((channel < 0) || (channel >= num_channels))
+        return false;
     ALint state = 0;
     alGetSourceiv(impl_channels[channel].sid, AL_SOURCE_STATE, &state);
     return((state == AL_PLAYING) ? true : false);
@@ -301,9 +317,12 @@ static signed char OPENAL_IsPlaying(int channel)
 
 static int OPENAL_PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused)
 {
-    if (!initialized) return -1;
-    if (sptr == NULL) return -1;
-    if (dsp != NULL) return -1;
+    if (!initialized)
+        return -1;
+    if (sptr == NULL)
+        return -1;
+    if (dsp != NULL)
+        return -1;
     if (channel == OPENAL_FREE) {
         for (int i = 0; i < num_channels; i++) {
             ALint state = 0;
@@ -315,7 +334,8 @@ static int OPENAL_PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *
         }
     }
 
-    if ((channel < 0) || (channel >= num_channels)) return -1;
+    if ((channel < 0) || (channel >= num_channels))
+        return -1;
     alSourceStop(impl_channels[channel].sid);
     impl_channels[channel].sample = sptr;
     alSourcei(impl_channels[channel].sid, AL_BUFFER, sptr->bid);
@@ -341,7 +361,8 @@ static void *decode_to_pcm(const char *_fname, ALenum &format, ALsizei &size, AL
     char *fname = (char *) alloca(strlen(_fname) + 16);
     strcpy(fname, _fname);
     char *ptr = strchr(fname, '.');
-    if (ptr) *ptr = '\0';
+    if (ptr)
+        *ptr = '\0';
     strcat(fname, ".ogg");
 
     // just in case...
@@ -417,11 +438,16 @@ static void *decode_to_pcm(const char *_fname, ALenum &format, ALsizei &size, AL
 
 AL_API OPENAL_SAMPLE *OPENAL_Sample_Load(int index, const char *name_or_data, unsigned int mode, int offset, int length)
 {
-    if (!initialized) return NULL;
-    if (index != OPENAL_FREE) return NULL;  // this is all the game does...
-    if (offset != 0) return NULL;  // this is all the game does...
-    if (length != 0) return NULL;  // this is all the game does...
-    if ((mode != OPENAL_HW3D) && (mode != OPENAL_2D)) return NULL;  // this is all the game does...
+    if (!initialized)
+        return NULL;
+    if (index != OPENAL_FREE)
+        return NULL;  // this is all the game does...
+    if (offset != 0)
+        return NULL;  // this is all the game does...
+    if (length != 0)
+        return NULL;  // this is all the game does...
+    if ((mode != OPENAL_HW3D) && (mode != OPENAL_2D))
+        return NULL;  // this is all the game does...
 
     OPENAL_SAMPLE *retval = NULL;
     ALuint bufferName = 0;
@@ -452,7 +478,8 @@ AL_API OPENAL_SAMPLE *OPENAL_Sample_Load(int index, const char *name_or_data, un
 
 AL_API void OPENAL_Sample_Free(OPENAL_SAMPLE *sptr)
 {
-    if (!initialized) return;
+    if (!initialized)
+        return;
     if (sptr) {
         for (int i = 0; i < num_channels; i++) {
             if (impl_channels[i].sample == sptr) {
@@ -469,24 +496,30 @@ AL_API void OPENAL_Sample_Free(OPENAL_SAMPLE *sptr)
 
 static signed char OPENAL_Sample_SetMode(OPENAL_SAMPLE *sptr, unsigned int mode)
 {
-    if (!initialized) return false;
-    if ((mode != OPENAL_LOOP_NORMAL) && (mode != OPENAL_LOOP_OFF)) return false;
-    if (!sptr) return false;
+    if (!initialized)
+        return false;
+    if ((mode != OPENAL_LOOP_NORMAL) && (mode != OPENAL_LOOP_OFF))
+        return false;
+    if (!sptr)
+        return false;
     sptr->mode = mode;
     return true;
 }
 
 AL_API signed char OPENAL_SetFrequency(int channel, int freq)
 {
-    if (!initialized) return false;
+    if (!initialized)
+        return false;
     if (channel == OPENAL_ALL) {
         for (int i = 0; i < num_channels; i++)
             OPENAL_SetFrequency(i, freq);
         return true;
     }
 
-    if ((channel < 0) || (channel >= num_channels)) return false;
-    if (freq == 8012)  // hack
+    if ((channel < 0) || (channel >= num_channels))
+        return false;
+    if (freq == 8012)
+        // hack
         alSourcef(impl_channels[channel].sid, AL_PITCH, 8012.0f / 44100.0f);
     else
         alSourcef(impl_channels[channel].sid, AL_PITCH, 1.0f);
@@ -495,7 +528,8 @@ AL_API signed char OPENAL_SetFrequency(int channel, int freq)
 
 AL_API signed char OPENAL_SetVolume(int channel, int vol)
 {
-    if (!initialized) return false;
+    if (!initialized)
+        return false;
 
     if (channel == OPENAL_ALL) {
         for (int i = 0; i < num_channels; i++)
@@ -503,10 +537,13 @@ AL_API signed char OPENAL_SetVolume(int channel, int vol)
         return true;
     }
 
-    if ((channel < 0) || (channel >= num_channels)) return false;
+    if ((channel < 0) || (channel >= num_channels))
+        return false;
 
-    if (vol < 0) vol = 0;
-    else if (vol > 255) vol = 255;
+    if (vol < 0)
+        vol = 0;
+    else if (vol > 255)
+        vol = 255;
     ALfloat gain = ((ALfloat) vol) / 255.0f;
     alSourcef(impl_channels[channel].sid, AL_GAIN, gain);
     return true;
@@ -514,7 +551,8 @@ AL_API signed char OPENAL_SetVolume(int channel, int vol)
 
 AL_API signed char OPENAL_SetPaused(int channel, signed char paused)
 {
-    if (!initialized) return false;
+    if (!initialized)
+        return false;
 
     if (channel == OPENAL_ALL) {
         for (int i = 0; i < num_channels; i++)
@@ -522,7 +560,8 @@ AL_API signed char OPENAL_SetPaused(int channel, signed char paused)
         return true;
     }
 
-    if ((channel < 0) || (channel >= num_channels)) return false;
+    if ((channel < 0) || (channel >= num_channels))
+        return false;
 
     ALint state = 0;
     if (impl_channels[channel].startpaused)
@@ -541,14 +580,16 @@ AL_API signed char OPENAL_SetPaused(int channel, signed char paused)
 
 AL_API void OPENAL_SetSFXMasterVolume(int volume)
 {
-    if (!initialized) return;
+    if (!initialized)
+        return;
     ALfloat gain = ((ALfloat) volume) / 255.0f;
     alListenerf(AL_GAIN, gain);
 }
 
 AL_API signed char OPENAL_StopSound(int channel)
 {
-    if (!initialized) return false;
+    if (!initialized)
+        return false;
 
     if (channel == OPENAL_ALL) {
         for (int i = 0; i < num_channels; i++)
@@ -556,7 +597,8 @@ AL_API signed char OPENAL_StopSound(int channel)
         return true;
     }
 
-    if ((channel < 0) || (channel >= num_channels)) return false;
+    if ((channel < 0) || (channel >= num_channels))
+        return false;
     alSourceStop(impl_channels[channel].sid);
     impl_channels[channel].startpaused = false;
     return true;
@@ -569,7 +611,8 @@ AL_API void OPENAL_Stream_Close(OPENAL_STREAM *stream)
 
 static OPENAL_SAMPLE *OPENAL_Stream_GetSample(OPENAL_STREAM *stream)
 {
-    if (!initialized) return NULL;
+    if (!initialized)
+        return NULL;
     return (OPENAL_SAMPLE *) stream;
 }
 
@@ -580,7 +623,8 @@ static int OPENAL_Stream_PlayEx(int channel, OPENAL_STREAM *stream, OPENAL_DSPUN
 
 static signed char OPENAL_Stream_Stop(OPENAL_STREAM *stream)
 {
-    if (!initialized) return false;
+    if (!initialized)
+        return false;
     for (int i = 0; i < num_channels; i++) {
         if (impl_channels[i].sample == (OPENAL_SAMPLE *) stream) {
             alSourceStop(impl_channels[i].sid);
@@ -597,7 +641,8 @@ AL_API signed char OPENAL_Stream_SetMode(OPENAL_STREAM *stream, unsigned int mod
 
 AL_API void OPENAL_Update()
 {
-    if (!initialized) return;
+    if (!initialized)
+        return;
     alcProcessContext(alcGetCurrentContext());
 }