]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Objects/Person.cpp
Fixed a few parentheses
[lugaru.git] / Source / Objects / Person.cpp
index 85341867ff47754986f6f3caccf750d3ddb073e0..a6f2bc199647fb3b763f41c36c6a85964a8986d9 100644 (file)
@@ -565,8 +565,8 @@ int Person::getIdle()
 {
     if (Dialog::inDialog() && (howactive == typeactive) && (creature == rabbittype))
         return talkidleanim;
-    if (hasvictim && (victim != this->shared_from_this())/*||(id==0&&attackkeydown)*/)
-        if (/*(id==0&&attackkeydown)||*/(!victim->dead && victim->aitype != passivetype &&
+    if (hasvictim && (victim != this->shared_from_this())) {
+        if ((!victim->dead && victim->aitype != passivetype &&
             victim->aitype != searchtype && aitype != passivetype && aitype != searchtype &&
             victim->id < Person::players.size())) {
             if ((aitype == playercontrolled && stunned <= 0 && weaponactive == -1) || pause) {
@@ -588,6 +588,7 @@ int Person::getIdle()
             if (aitype != playercontrolled && stunned <= 0 && creature != wolftype && !pause)
                 return fightsidestep;
         }
+    }
     if ((damage > permanentdamage || damage > damagetolerance * .8 || deathbleeding > 0) && creature != wolftype)
         return hurtidleanim;
     if (howactive == typesitting) return sitanim;
@@ -995,9 +996,9 @@ bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where)
         if (whichtri != -1) {
             // low level geometry math
             p0 = colpoint;
-            p1 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
-            p2 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
-            p3 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
+            p1 = skeleton.drawmodel.getTriangleVertex(whichtri, 0);
+            p2 = skeleton.drawmodel.getTriangleVertex(whichtri, 1);
+            p3 = skeleton.drawmodel.getTriangleVertex(whichtri, 2);
 
             bary.x = distsq(&p0, &p1);
             bary.y = distsq(&p0, &p2);
@@ -1699,7 +1700,7 @@ void Person::DoHead()
 void Person::RagDoll(bool checkcollision)
 {
     static XYZ change;
-    static int l, i;
+    static int i;
     static float speed;
     if (!skeleton.free) {
         if (id == 0)
@@ -1799,16 +1800,15 @@ void Person::RagDoll(bool checkcollision)
 
             whichpatchx = coords.x / (terrain.size / subdivision * terrain.scale);
             whichpatchz = coords.z / (terrain.size / subdivision * terrain.scale);
-            if (terrain.patchobjectnum[whichpatchx][whichpatchz])
-                for (l = 0; l < terrain.patchobjectnum[whichpatchx][whichpatchz]; l++) {
-                    i = terrain.patchobjects[whichpatchx][whichpatchz][l];
-                    lowpoint = coords;
-                    lowpoint.y += 1;
-                    if (SphereCheck(&lowpoint, 3, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw, &Object::objects[i]->model) != -1) {
-                        coords.x = lowpoint.x;
-                        coords.z = lowpoint.z;
-                    }
+            for (unsigned int l = 0; l < terrain.patchobjects[whichpatchx][whichpatchz].size(); l++) {
+                i = terrain.patchobjects[whichpatchx][whichpatchz][l];
+                lowpoint = coords;
+                lowpoint.y += 1;
+                if (SphereCheck(&lowpoint, 3, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw, &Object::objects[i]->model) != -1) {
+                    coords.x = lowpoint.x;
+                    coords.z = lowpoint.z;
                 }
+            }
         }
 
         yaw = 0;
@@ -4255,15 +4255,15 @@ void Person::DoAnimations()
             oldframeCurrent = frameCurrent;
 
             for (unsigned i = 0; i < skeleton.joints.size(); i++) {
-                skeleton.joints[i].velocity = (currentFrame().joints[i].position * (1 - target) + targetFrame().joints[i].position * (target) - skeleton.joints[i].position) / multiplier;
-                skeleton.joints[i].position = currentFrame().joints[i].position * (1 - target) + targetFrame().joints[i].position * (target);
+                skeleton.joints[i].velocity = (currentFrame().joints[i].position * (1 - target) + targetFrame().joints[i].position * target - skeleton.joints[i].position) / multiplier;
+                skeleton.joints[i].position = currentFrame().joints[i].position * (1 - target) + targetFrame().joints[i].position * target;
             }
             offset = currentoffset * (1 - target) + targetoffset * target;
             for (unsigned i = 0; i < skeleton.muscles.size(); i++) {
                 if (skeleton.muscles[i].visible) {
-                    skeleton.muscles[i].rotate1 = skeleton.muscles[i].oldrotate1 * (1 - target) + skeleton.muscles[i].newrotate1 * (target);
-                    skeleton.muscles[i].rotate2 = skeleton.muscles[i].oldrotate2 * (1 - target) + skeleton.muscles[i].newrotate2 * (target);
-                    skeleton.muscles[i].rotate3 = skeleton.muscles[i].oldrotate3 * (1 - target) + skeleton.muscles[i].newrotate3 * (target);
+                    skeleton.muscles[i].rotate1 = skeleton.muscles[i].oldrotate1 * (1 - target) + skeleton.muscles[i].newrotate1 * target;
+                    skeleton.muscles[i].rotate2 = skeleton.muscles[i].oldrotate2 * (1 - target) + skeleton.muscles[i].newrotate2 * target;
+                    skeleton.muscles[i].rotate3 = skeleton.muscles[i].oldrotate3 * (1 - target) + skeleton.muscles[i].newrotate3 * target;
                 }
             }
         }
@@ -4290,7 +4290,6 @@ void Person::DoStuff()
     static XYZ flatfacing;
     static XYZ flatvelocity;
     static float flatvelspeed;
-    static int l;
     static int bloodsize;
     static int startx, starty, endx, endy;
     static GLubyte color;
@@ -4835,16 +4834,15 @@ void Person::DoStuff()
         headpoint = coords;
         if (bloodtoggle && !bled) {
             terrain.MakeDecal(blooddecalslow, headpoint, .8, .5, 0);
-        }
-        if (bloodtoggle && !bled)
-            for (l = 0; l < terrain.patchobjectnum[whichpatchx][whichpatchz]; l++) {
-                int j = terrain.patchobjects[whichpatchx][whichpatchz][l];
+            for (unsigned int l = 0; l < terrain.patchobjects[whichpatchx][whichpatchz].size(); l++) {
+                unsigned int j = terrain.patchobjects[whichpatchx][whichpatchz][l];
                 XYZ point = DoRotation(headpoint - Object::objects[j]->position, 0, -Object::objects[j]->yaw, 0);
                 float size = .8;
                 float opacity = .6;
                 float yaw = 0;
                 Object::objects[j]->model.MakeDecal(blooddecalslow, &point, &size, &opacity, &yaw);
             }
+        }
         bled = 1;
     }
 
@@ -5044,16 +5042,15 @@ void Person::DoStuff()
                     DoBlood(1, 255);
                     if (bloodtoggle && !bled) {
                         terrain.MakeDecal(blooddecal, headpoint, .2 * 1.2, .5, 0);
-                    }
-                    if (bloodtoggle && !bled)
-                        for (l = 0; l < terrain.patchobjectnum[whichpatchx][whichpatchz]; l++) {
-                            int j = terrain.patchobjects[whichpatchx][whichpatchz][l];
+                        for (unsigned int l = 0; l < terrain.patchobjects[whichpatchx][whichpatchz].size(); l++) {
+                            unsigned int j = terrain.patchobjects[whichpatchx][whichpatchz][l];
                             XYZ point = DoRotation(headpoint - Object::objects[j]->position, 0, -Object::objects[j]->yaw, 0);
                             float size = .2 * 1.2;
                             float opacity = .6;
                             float yaw = 0;
                             Object::objects[j]->model.MakeDecal(blooddecal, &point, &size, &opacity, &yaw);
                         }
+                    }
                     bled = 1;
                 }
                 if (dead == 2 && bloodloss >= damagetolerance) {
@@ -5063,16 +5060,15 @@ void Person::DoStuff()
                         DoBlood(1, 255);
                     if (bloodtoggle && !bled) {
                         terrain.MakeDecal(blooddecalslow, headpoint, .8, .5, 0);
-                    }
-                    if (bloodtoggle && !bled)
-                        for (l = 0; l < terrain.patchobjectnum[whichpatchx][whichpatchz]; l++) {
-                            int j = terrain.patchobjects[whichpatchx][whichpatchz][l];
+                        for (unsigned int l = 0; l < terrain.patchobjects[whichpatchx][whichpatchz].size(); l++) {
+                            unsigned int j = terrain.patchobjects[whichpatchx][whichpatchz][l];
                             XYZ point = DoRotation(headpoint - Object::objects[j]->position, 0, -Object::objects[j]->yaw, 0);
                             float size = .8;
                             float opacity = .6;
                             float yaw = 0;
                             Object::objects[j]->model.MakeDecal(blooddecalslow, &point, &size, &opacity, &yaw);
                         }
+                    }
                     bled = 1;
                 }
             }
@@ -6363,9 +6359,9 @@ int Person::DrawSkeleton()
 
             if (playerdetail) {
                 for (unsigned int i = 0; i < skeleton.drawmodel.Triangles.size(); i++) {
-                    XYZ &v0 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]];
-                    XYZ &v1 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]];
-                    XYZ &v2 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]];
+                    const XYZ &v0 = skeleton.drawmodel.getTriangleVertex(i, 0);
+                    const XYZ &v1 = skeleton.drawmodel.getTriangleVertex(i, 1);
+                    const XYZ &v2 = skeleton.drawmodel.getTriangleVertex(i, 2);
                     glVertex3f(v0.x, v0.y, v0.z);
                     glVertex3f(v1.x, v1.y, v1.z);
                     glVertex3f(v1.x, v1.y, v1.z);