]> git.jsancho.org Git - lugaru.git/commitdiff
Fixed lots of errors spotted by cppcheck
authorCôme Chilliet <come@chilliet.eu>
Wed, 23 Nov 2016 16:08:17 +0000 (00:08 +0800)
committerCôme Chilliet <come@chilliet.eu>
Wed, 23 Nov 2016 16:08:17 +0000 (00:08 +0800)
12 files changed:
Source/Account.cpp
Source/Account.h
Source/Animation.h
Source/GameDraw.cpp
Source/GameInitDispose.cpp
Source/GameTick.cpp
Source/MacCompatibility.cpp
Source/Objects.cpp
Source/Person.cpp
Source/Skeleton.cpp
Source/Sprite.cpp
Source/Terrain.cpp

index a42e2f70e8cf76e7857586d974e8756a19e838ae..1ee3242bf0ec3779dc03ed369899bfb0cef681fd 100644 (file)
@@ -30,9 +30,8 @@ extern bool debugmode;
 
 vector<Account*> Account::accounts = vector<Account*>();
 
-Account::Account(string n) : campaignProgress()
+Account::Account(const string& name) : name(name), campaignProgress()
 {
-    name = string(n);
     difficulty = 0;
     progress = 0;
     points = 0;
@@ -43,12 +42,12 @@ Account::Account(string n) : campaignProgress()
     setCurrentCampaign("main");
 }
 
-void Account::setCurrentCampaign(string name)
+void Account::setCurrentCampaign(const string& name)
 {
     currentCampaign = name;
 }
 
-Account* Account::add(string name)
+Account* Account::add(const string& name)
 {
     accounts.push_back(new Account(name));
     return accounts.back();
@@ -196,7 +195,6 @@ Account* Account::loadFile(string filename)
 void Account::saveFile(string filename, Account* accountactive)
 {
     FILE *tfile;
-    unsigned j;
 
     tfile = fopen(ConvertFileName(filename.c_str(), "wb"), "wb" );
     if (tfile) {
@@ -212,9 +210,9 @@ void Account::saveFile(string filename, Account* accountactive)
             fpackf(tfile, "Bi", a->campaignProgress.size());
 
             map<string, CampaignProgress>::const_iterator it;
-            for ( it = a->campaignProgress.begin(); it != a->campaignProgress.end(); ++it) {
+            for (it = a->campaignProgress.begin(); it != a->campaignProgress.end(); ++it) {
                 fpackf(tfile, "Bi",  it->first.size());
-                for (j = 0; j < it->first.size(); j++) {
+                for (unsigned j = 0; j < it->first.size(); j++) {
                     fpackf(tfile, "Bb",  it->first[j]);
                 }
                 fpackf(tfile, "Bf", it->second.time);
@@ -222,26 +220,26 @@ void Account::saveFile(string filename, Account* accountactive)
                 fpackf(tfile, "Bf", it->second.fasttime);
                 fpackf(tfile, "Bf", it->second.highscore);
                 fpackf(tfile, "Bi", it->second.choices.size());
-                for (j = 0; j < it->second.choices.size(); j++) {
+                for (unsigned j = 0; j < it->second.choices.size(); j++) {
                     fpackf(tfile, "Bi", it->second.choices[j]);
                 }
             }
 
             fpackf(tfile, "Bi", a->getCurrentCampaign().size());
-            for (j = 0; j < a->getCurrentCampaign().size(); j++) {
+            for (unsigned j = 0; j < a->getCurrentCampaign().size(); j++) {
                 fpackf(tfile, "Bb", a->getCurrentCampaign()[j]);
             }
 
             fpackf(tfile, "Bf", a->points);
-            for (j = 0; j < 50; j++) {
+            for (unsigned j = 0; j < 50; j++) {
                 fpackf(tfile, "Bf", a->highscore[j]);
                 fpackf(tfile, "Bf", a->fasttime[j]);
             }
-            for (j = 0; j < 60; j++) {
+            for (unsigned j = 0; j < 60; j++) {
                 fpackf(tfile, "Bb",  a->unlocked[j]);
             }
             fpackf(tfile, "Bi",  a->name.size());
-            for (j = 0; j < a->name.size(); j++) {
+            for (unsigned j = 0; j < a->name.size(); j++) {
                 fpackf(tfile, "Bb",  a->name[j]);
             }
         }
index 53d3c945cdcff93f76eff527b773ac1a85235a5f..2d75f559143b1dc0849f20934d6ee5943aa35756 100644 (file)
@@ -45,7 +45,7 @@ class Account
 public:
     static void destroy(int i);
     static Account* destroy(Account* a);
-    static Account* add(std::string name);
+    static Account* add(const std::string& name);
     static Account* get(int i);
     static Account* loadFile(std::string filename);
     static void saveFile(std::string filename, Account* accountactive);
@@ -103,13 +103,13 @@ public:
     std::string getCurrentCampaign() {
         return currentCampaign;
     };
-    void setCurrentCampaign(std::string name);
+    void setCurrentCampaign(const std::string& name);
 
     static int getNbAccounts() {
         return accounts.size();
     };
 private:
-    Account(std::string n = "");
+    Account(const std::string& name = "");
     int difficulty;
     int progress; // progress in challenge levels
     float points;
index ed6f2785854619795c727c9c87a5a66da29d2a75..f5ac6b420b9be8e08ecb0c222edecdd7ed8a2995 100644 (file)
@@ -28,7 +28,6 @@ enum anim_height_type {
     lowheight, middleheight, highheight
 };
 
-
 enum animation_types {
 #define DECLARE_ANIM(id, ...) id,
 #include "Animation.def"
index 93766d36bcb9953d9f345514a387b67f02c6729a..af0eb18561371085d221b4b53572ad92529dfe73 100644 (file)
@@ -931,10 +931,9 @@ int Game::DrawGLScene(StereoSide side)
             //Hot spots
 
             if (numhotspots && (bonustime >= 1 || bonus <= 0 || bonustime < 0) && !tutoriallevel) {
-                int closest = -1;
                 float closestdist = -1;
                 float distance = 0;
-                closest = currenthotspot;
+                int closest = currenthotspot;
                 for (int i = 0; i < numhotspots; i++) {
                     distance = distsq(&Person::players[0]->coords, &hotspot[i]);
                     if (closestdist == -1 || distance < closestdist) {
@@ -1515,8 +1514,6 @@ int Game::DrawGLScene(StereoSide side)
                     }
                 }
             }
-            radius = fast_sqrt(maxdistance);
-
             radius = 110;
 
             glScalef(.25 / radius * 256 * terrain.scale * .4, .25 / radius * 256 * terrain.scale * .4, 1);
index 6daef2b3e1790d99fdd862e62e77523f4de4d847..c19db0293240a3ce7532126b02b6b4d51848bdac 100644 (file)
@@ -162,9 +162,6 @@ void Game::deleteGame()
 
 void LoadSave(const char *fileName, GLuint *textureid, bool mipmap, GLubyte *array, int *skinsize)
 {
-    int i;
-    int bytesPerPixel;
-
     LOGFUNC;
 
     LOG(std::string("Loading (S)...") + fileName);
@@ -172,8 +169,6 @@ void LoadSave(const char *fileName, GLuint *textureid, bool mipmap, GLubyte *arr
     //Load Image
     float temptexdetail = texdetail;
     texdetail = 1;
-    //upload_image( fileName );
-    //LoadTGA( fileName );
 
     // Converting file to something os specific
     char * fixedFN = ConvertFileName(fileName);
@@ -185,16 +180,13 @@ void LoadSave(const char *fileName, GLuint *textureid, bool mipmap, GLubyte *arr
     upload_image( fileNamep , 0);
     texdetail = temptexdetail;
 
-    //Is it valid?
-    if (1 == 1) {
-        bytesPerPixel = texture.bpp / 8;
+    int bytesPerPixel = texture.bpp / 8;
 
-        int tempnum = 0;
-        for (i = 0; i < (int)(texture.sizeY * texture.sizeX * bytesPerPixel); i++) {
-            if ((i + 1) % 4 || bytesPerPixel == 3) {
-                array[tempnum] = texture.data[i];
-                tempnum++;
-            }
+    int tempnum = 0;
+    for (int i = 0; i < (int)(texture.sizeY * texture.sizeX * bytesPerPixel); i++) {
+        if ((i + 1) % 4 || bytesPerPixel == 3) {
+            array[tempnum] = texture.data[i];
+            tempnum++;
         }
     }
 }
@@ -640,10 +632,8 @@ void Game::InitGame()
     LOG("Initializing sound system...");
 
 #if PLATFORM_LINUX
-    int output = -1;
-
     unsigned char rc = 0;
-    output = OPENAL_OUTPUT_ALSA;  // Try alsa first...
+    int output = OPENAL_OUTPUT_ALSA;  // Try alsa first...
     if (cmdline("forceoss"))      //  ...but let user override that.
         output = OPENAL_OUTPUT_OSS;
     else if (cmdline("nosound"))
index c693e1c3fdf9afa040a5d088461f3ed41d823dd9..8a7a54eae021af5b1f6d4a7191fe6fa6bc9f0c30 100644 (file)
@@ -3888,7 +3888,7 @@ void doAerialAcrobatics()
                 }
             }
 
-            if (tempcollide && (/*Person::players[k]->jumptogglekeydown*/1 == 1 || Person::players[k]->aitype != playercontrolled))
+            if (tempcollide)
                 for (int l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) {
                     int i = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
                     lowpoint = Person::players[k]->coords;
@@ -3970,7 +3970,6 @@ void doAerialAcrobatics()
                                                                 if (j <= 6 || j <= 25 && Person::players[k]->animTarget == jumpdownanim)
                                                                     break;
                                                                 if (Person::players[k]->animTarget == jumpupanim || Person::players[k]->animTarget == jumpdownanim) {
-                                                                    lowpoint = DoRotation(objects.model[i].facenormals[whichhit], 0, objects.yaw[k], 0);
                                                                     lowpoint = Person::players[k]->coords;
                                                                     lowpoint.y += (float)j / 13;
                                                                     lowpointtarget = lowpoint + facing * 1.3;
@@ -7196,7 +7195,6 @@ void Game::Tick()
                                  Person::players[i]->animTarget == rollanim ||
                                  Person::players[i]->animTarget == backhandspringanim ||
                                  Person::players[i]->isFlip() ||
-                                 Person::players[i]->isFlip() ||
                                  Person::players[i]->aitype != playercontrolled)) {
                             for (unsigned j = 0; j < weapons.size(); j++) {
                                 if ((weapons[j].velocity.x == 0 && weapons[j].velocity.y == 0 && weapons[j].velocity.z == 0 ||
index 272288a639b09da4b3fd4551d9db6f5e2a8b66be..7d049058f71297a7de57fe463bffbedae3ff4465 100644 (file)
@@ -215,10 +215,8 @@ static inline const char *getPrefPath(void)
 static int locateCorrectCase(char *buf, bool makedirs)
 {
     int rc;
-    char *ptr;
-    char *prevptr;
+    char *ptr = buf;
 
-    ptr = prevptr = buf;
     while (ptr = strchr(ptr + 1, '/')) {
         *ptr = '\0';  /* block this path section off */
         rc = locateOneElement(buf);
index 15eb79377e58e49ed88ae04949674574df86770f..2a8474b238edd41fe7cb25e64ad6fca1a594861a 100644 (file)
@@ -362,152 +362,148 @@ void Objects::Draw()
                 hidden = distsqflat(&viewer, &position[i]) <= playerdist + 3;
                 if (hidden) {
                     distance = 1;
-                    if (distance > 0) {
-                        if (1 == 1 || occluded[i] < 6) {
-                            glMatrixMode(GL_MODELVIEW);
-                            glPushMatrix();
-                            glEnable(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;
-
-                                    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;
-
-                                    roty[i] += rotyvel[i] * multiplier * 4;
-                                }
-                                if (roty[i]) {
-                                    glRotatef(roty[i], 1, 0, 0);
-                                }
-                                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 (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;
-
-                                    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;
-
-                                    roty[i] += rotyvel[i] * multiplier * 4;
-                                }
-                                if (roty[i]) {
-                                    glRotatef(roty[i] / 2, 1, 0, 0);
-                                }
-                                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 (environment == snowyenvironment) {
-                                if (type[i] == treeleavestype) {
-                                    glRotatef((sin(windvar + position[i].x * .3) + .5) * 1.5 * (sin(windvar * 2 + position[i].x * .3) + 1) / 2, 1, 0, 0);
-                                }
-                                if (type[i] == treetrunktype) {
-                                    glRotatef((sin(windvar + position[i].x * .3) + .5)*.5 * (sin(windvar * 2 + position[i].x * .3) + 1) / 2, 1, 0, 0);
-                                }
-                                if (type[i] == bushtype) {
-                                    glRotatef((sin(windvar + position[i].x * .3) + .5) * 4 * (sin(windvar * 2 + position[i].x * .3) + 1) / 2, 1, 0, 0);
-                                }
-                            }
-                            if (environment == grassyenvironment) {
-                                if (type[i] == treeleavestype) {
-                                    glRotatef((sin(windvar + position[i].x * .3) + .5) * 1.5 * .5 * (sin(windvar * 2 + position[i].x * .3) + 1) / 2, 1, 0, 0);
-                                }
-                                if (type[i] == treetrunktype) {
-                                    glRotatef((sin(windvar + position[i].x * .3) + .5)*.5 * .5 * (sin(windvar * 2 + position[i].x * .3) + 1) / 2, 1, 0, 0);
-                                }
-                                if (type[i] == bushtype) {
-                                    glRotatef((sin(windvar + position[i].x * .3) + .5) * 4 * .5 * (sin(windvar * 2 + position[i].x * .3) + 1) / 2, 1, 0, 0);
-                                }
-                            }
-                            glRotatef(yaw[i], 0, 1, 0);
-                            glColor4f(1, 1, 1, distance);
-                            if (type[i] == treeleavestype) {
-                                glDisable(GL_CULL_FACE);
-                                glDisable(GL_LIGHTING);
-                                terrainlight = terrain.getLighting(position[i].x, position[i].z);
-                                glDepthMask(0);
-                                glEnable(GL_BLEND);
-                                glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, .3);
-                                glAlphaFunc(GL_GREATER, 0);
-                                glDisable(GL_ALPHA_TEST);
-                                model[i].drawdifftex(treetextureptr);
-                            }
-                            if (type[i] == bushtype) {
-                                glDisable(GL_CULL_FACE);
-                                glDisable(GL_LIGHTING);
-                                terrainlight = terrain.getLighting(position[i].x, position[i].z);
-                                glDepthMask(0);
-                                glEnable(GL_BLEND);
-                                glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, .3);
-                                glAlphaFunc(GL_GREATER, 0);
-                                glDisable(GL_ALPHA_TEST);
-                                model[i].drawdifftex(bushtextureptr);
-                            }
-                            glPopMatrix();
+                    glMatrixMode(GL_MODELVIEW);
+                    glPushMatrix();
+                    glEnable(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;
+
+                            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;
+
+                            roty[i] += rotyvel[i] * multiplier * 4;
+                        }
+                        if (roty[i]) {
+                            glRotatef(roty[i], 1, 0, 0);
+                        }
+                        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 (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;
+
+                            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;
+
+                            roty[i] += rotyvel[i] * multiplier * 4;
+                        }
+                        if (roty[i]) {
+                            glRotatef(roty[i] / 2, 1, 0, 0);
+                        }
+                        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 (environment == snowyenvironment) {
+                        if (type[i] == treeleavestype) {
+                            glRotatef((sin(windvar + position[i].x * .3) + .5) * 1.5 * (sin(windvar * 2 + position[i].x * .3) + 1) / 2, 1, 0, 0);
+                        }
+                        if (type[i] == treetrunktype) {
+                            glRotatef((sin(windvar + position[i].x * .3) + .5)*.5 * (sin(windvar * 2 + position[i].x * .3) + 1) / 2, 1, 0, 0);
+                        }
+                        if (type[i] == bushtype) {
+                            glRotatef((sin(windvar + position[i].x * .3) + .5) * 4 * (sin(windvar * 2 + position[i].x * .3) + 1) / 2, 1, 0, 0);
+                        }
+                    }
+                    if (environment == grassyenvironment) {
+                        if (type[i] == treeleavestype) {
+                            glRotatef((sin(windvar + position[i].x * .3) + .5) * 1.5 * .5 * (sin(windvar * 2 + position[i].x * .3) + 1) / 2, 1, 0, 0);
+                        }
+                        if (type[i] == treetrunktype) {
+                            glRotatef((sin(windvar + position[i].x * .3) + .5)*.5 * .5 * (sin(windvar * 2 + position[i].x * .3) + 1) / 2, 1, 0, 0);
+                        }
+                        if (type[i] == bushtype) {
+                            glRotatef((sin(windvar + position[i].x * .3) + .5) * 4 * .5 * (sin(windvar * 2 + position[i].x * .3) + 1) / 2, 1, 0, 0);
+                        }
+                    }
+                    glRotatef(yaw[i], 0, 1, 0);
+                    glColor4f(1, 1, 1, distance);
+                    if (type[i] == treeleavestype) {
+                        glDisable(GL_CULL_FACE);
+                        glDisable(GL_LIGHTING);
+                        terrainlight = terrain.getLighting(position[i].x, position[i].z);
+                        glDepthMask(0);
+                        glEnable(GL_BLEND);
+                        glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, .3);
+                        glAlphaFunc(GL_GREATER, 0);
+                        glDisable(GL_ALPHA_TEST);
+                        model[i].drawdifftex(treetextureptr);
+                    }
+                    if (type[i] == bushtype) {
+                        glDisable(GL_CULL_FACE);
+                        glDisable(GL_LIGHTING);
+                        terrainlight = terrain.getLighting(position[i].x, position[i].z);
+                        glDepthMask(0);
+                        glEnable(GL_BLEND);
+                        glColor4f(terrainlight.x, terrainlight.y, terrainlight.z, .3);
+                        glAlphaFunc(GL_GREATER, 0);
+                        glDisable(GL_ALPHA_TEST);
+                        model[i].drawdifftex(bushtextureptr);
                     }
+                    glPopMatrix();
                 }
             }
         }
index 3327f5abc3c139901d5b0f1cd9093c4981b8b67e..55b58c2a0b2d6288d80435cd18efad9de7d6ce8c 100644 (file)
@@ -1018,7 +1018,7 @@ void Person::Reverse()
         victim->animCurrent = knifeslashreversalanim;
         victim->animTarget = knifeslashreversalanim;
     }
-    if (animTarget != knifeslashstartanim && animTarget != staffhitanim && animTarget != staffspinhitanim && animTarget != winduppunchanim && animTarget != wolfslapanim && animTarget != swordslashanim && animTarget != swordslashanim) {
+    if (animTarget != knifeslashstartanim && animTarget != staffhitanim && animTarget != staffspinhitanim && animTarget != winduppunchanim && animTarget != wolfslapanim && animTarget != swordslashanim) {
         victim->targettilt2 = targettilt2;
         victim->frameCurrent = frameCurrent;
         victim->frameTarget = frameTarget;
@@ -1459,7 +1459,6 @@ void Person::RagDoll(bool checkcollision)
             skeleton.joints[i].locked = 0;
             skeleton.joints[i].position = DoRotation(DoRotation(DoRotation(skeleton.joints[i].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0);
             if (!isnormal(skeleton.joints[i].position.x)) skeleton.joints[i].position = DoRotation(skeleton.joints[i].position, 0, yaw, 0);
-            if (!isnormal(skeleton.joints[i].position.x)) skeleton.joints[i].position = skeleton.joints[i].position;
             if (!isnormal(skeleton.joints[i].position.x)) skeleton.joints[i].position = coords;
             skeleton.joints[i].position.y += .1;
             skeleton.joints[i].oldposition = skeleton.joints[i].position;
@@ -5418,7 +5417,7 @@ void Person::DoStuff()
             }
         }
 
-        if (animTarget == jumpupanim || animTarget == crouchstabanim || animTarget == swordgroundstabanim || animTarget == swordfightidlebothanim || animTarget == blockhighleftanim || animTarget == blockhighleftanim) {
+        if (animTarget == jumpupanim || animTarget == crouchstabanim || animTarget == swordgroundstabanim || animTarget == swordfightidlebothanim || animTarget == blockhighleftanim) {
             //close hands and mouth
             if (righthandmorphend != 1 && righthandmorphness == targetrighthandmorphness) {
                 righthandmorphness = 0;
index b951830f5e317a4d99212bb873ff2d859f3eb651..fe99c32f75d977b6abfdc2ac551588461d51e9a2 100644 (file)
@@ -48,7 +48,6 @@ extern bool visibleloading;
 void dealloc2(void* param)
 {
     free(param);
-    param = 0; // FIXME: does this *do* anything???
 }
 
 enum {boneconnect, constraint, muscle};
@@ -553,7 +552,16 @@ void Skeleton::DoGravity(float *scale)
 {
     static int i;
     for (i = 0; i < num_joints; i++) {
-        if (((joints[i].label != leftknee && joints[i].label != rightknee) || lowforward.y > -.1 || joints[i].mass < 5) && ((joints[i].label != rightelbow && joints[i].label != rightelbow) || forward.y < .3))
+        if (
+                (
+                    ((joints[i].label != leftknee) && (joints[i].label != rightknee)) ||
+                    (lowforward.y > -.1) ||
+                    (joints[i].mass < 5)
+                ) && (
+                    ((joints[i].label != leftelbow) && (joints[i].label != rightelbow)) ||
+                    (forward.y < .3)
+                )
+            )
             joints[i].velocity.y += gravity * multiplier / (*scale);
     }
 }
@@ -1088,11 +1096,9 @@ void Skeleton::Load(const char *filename,       const char *lowfilename, const c
             fseek ( tfile, lSize, SEEK_CUR);
         }
 
-        // ???
-        lSize = sizeof(int);
         for (j = 0; j < num_muscles; j++) {
             for (i = 0; i < muscles[j].numverticeslow; i++) {
-                if (muscles[j].numverticeslow && muscles[j].verticeslow[i] < modellow.vertexNum)
+                if (muscles[j].verticeslow[i] < modellow.vertexNum)
                     modellow.owner[muscles[j].verticeslow[i]] = j;
             }
         }
@@ -1422,9 +1428,7 @@ Animation & Animation::operator = (const Animation & ani)
 {
     int i = 0;
 
-    bool allocate = true;
-
-    allocate = ((ani.numframes != numframes) || (ani.joints != joints));
+    bool allocate = ((ani.numframes != numframes) || (ani.joints != joints));
 
     if (allocate)
         deallocate();
@@ -1434,6 +1438,7 @@ Animation & Animation::operator = (const Animation & ani)
     attack = ani.attack;
     joints = ani.joints;
     weapontargetnum = ani.weapontargetnum;
+    offset = ani.offset;
 
     if (allocate)
         position = (XYZ**)malloc(sizeof(XYZ*)*ani.joints);
index 5b7c9e1f935899ee1f4642669bd804d0ab75f934..3d9a50c2730a7e7245a2963fdf8c0a849e56d8e4 100644 (file)
@@ -277,7 +277,7 @@ void Sprite::Draw()
         glPopMatrix();
     }
     tempmult = multiplier;
-    for (unsigned i = sprites.size() - 1; i >= 0; i--) {
+    for (int i = sprites.size() - 1; i >= 0; i--) {
         multiplier = tempmult;
         if (sprites[i]->type != snowsprite) {
             sprites[i]->position += sprites[i]->velocity * multiplier;
@@ -416,7 +416,7 @@ void Sprite::Draw()
             DeleteSprite(i);
     }
     if (check)
-        for (unsigned i = sprites.size() - 1; i >= 0; i--) {
+        for (int i = sprites.size() - 1; i >= 0; i--) {
             sprites[i]->oldposition = sprites[i]->position;
         }
     glAlphaFunc(GL_GREATER, 0.0001);
index a50dd52b9ba02ad389a9aa6267f6584622d978ee..ea3b8028eb55b369648a2cbe9f2c6d54afa82ba2 100644 (file)
@@ -432,34 +432,14 @@ bool Terrain::load(const char *fileName)
 
     texdetail = temptexdetail;
 
-    size = 128;
-    if (1 == 1) {
-        /*if ( texture.bpp == 24 )
-        type = GL_RGB;
-        else
-        type = GL_RGBA;
+    size = texture.sizeX;
 
-        glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-        if(!terraintexture)glGenTextures( 1, &terraintexture );
-        glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
-        glBindTexture( GL_TEXTURE_2D, terraintexture);
-        //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
-        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
-
-        gluBuild2DMipmaps( GL_TEXTURE_2D, type, texture.sizeX, texture.sizeY, type, GL_UNSIGNED_BYTE, texture.data );
-        */
-
-        size = texture.sizeX;
-
-        for (i = 0; i < size; i++) {
-            for (j = 0; j < size; j++) {
-                heightmap[size - 1 - i][j] = (float)((texture.data[(i + (j * size)) * texture.bpp / 8])) / 5;
-            }
+    for (i = 0; i < size; i++) {
+        for (j = 0; j < size; j++) {
+            heightmap[size - 1 - i][j] = (float)((texture.data[(i + (j * size)) * texture.bpp / 8])) / 5;
         }
-
     }
+
     if (visibleloading)
         Game::LoadingScreen();
 
@@ -770,7 +750,6 @@ void Terrain::CalculateNormals()
     for (i = 0; i < size; i++) {
         for (j = 0; j < size; j++) {
             Normalise(&normals[i][j]);
-            normals[i][j] = normals[i][j];
         }
     }
 }