X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FObjects%2FPerson.cpp;h=8bd82698909fede4bdd2b22ccee6bb71b74e2bb8;hb=45cf5fc2505a098e6500e9ab2e8a0d003521db76;hp=bc54a0df073f2b4a0491265f1dcf80ac0418c793;hpb=6cb245d6d347e0f610b2851d08273087fff9c0d0;p=lugaru.git diff --git a/Source/Objects/Person.cpp b/Source/Objects/Person.cpp index bc54a0d..8bd8269 100644 --- a/Source/Objects/Person.cpp +++ b/Source/Objects/Person.cpp @@ -1772,20 +1772,19 @@ void Person::RagDoll(bool checkcollision) } if (checkcollision) { - XYZ average; XYZ lowpoint; XYZ colpoint; - int howmany; - average = 0; - howmany = 0; - for (unsigned j = 0; j < skeleton.joints.size(); j++) { - average += skeleton.joints[j].position; - howmany++; - } - average /= howmany; - coords += average * scale; - for (unsigned j = 0; j < skeleton.joints.size(); j++) { - skeleton.joints[j].position -= average; + if (!skeleton.joints.empty()) { + XYZ average; + average = 0; + for (unsigned j = 0; j < skeleton.joints.size(); j++) { + average += skeleton.joints[j].position; + } + average /= skeleton.joints.size(); + coords += average * scale; + for (unsigned j = 0; j < skeleton.joints.size(); j++) { + skeleton.joints[j].position -= average; + } } whichpatchx = coords.x / (terrain.size / subdivision * terrain.scale); @@ -4287,8 +4286,6 @@ void Person::DoStuff() static XYZ flatvelocity; static float flatvelspeed; static int i, l; - static XYZ average; - static int howmany; static int bloodsize; static int startx, starty, endx, endy; static GLubyte color; @@ -4387,7 +4384,7 @@ void Person::DoStuff() } while (flamedelay < 0 && onfire) { flamedelay += .006; - howmany = fabs(Random() % (skeleton.joints.size())); + int howmany = fabs(Random() % (skeleton.joints.size())); if (skeleton.free) { flatvelocity = skeleton.joints[howmany].velocity * scale / 2; flatfacing = skeleton.joints[howmany].position * scale + coords; @@ -4400,7 +4397,7 @@ void Person::DoStuff() while (flamedelay < 0 && !onfire && tutoriallevel == 1 && id != 0) { flamedelay += .05; - howmany = fabs(Random() % (skeleton.joints.size())); + int howmany = fabs(Random() % (skeleton.joints.size())); if (skeleton.free) { flatvelocity = skeleton.joints[howmany].velocity * scale / 2; flatfacing = skeleton.joints[howmany].position * scale + coords; @@ -5002,18 +4999,19 @@ void Person::DoStuff() award_bonus(id, deepimpact); DoDamage(damageamount / ((protectionhigh + protectionhead + protectionlow) / 3)); + XYZ average; average = 0; - howmany = 0; - for (unsigned j = 0; j < skeleton.joints.size(); j++) { - average += skeleton.joints[j].position; - howmany++; - } - average /= howmany; - coords += average * scale; - for (unsigned j = 0; j < skeleton.joints.size(); j++) { - skeleton.joints[j].position -= average; + if (!skeleton.joints.empty()) { + for (unsigned j = 0; j < skeleton.joints.size(); j++) { + average += skeleton.joints[j].position; + } + average /= skeleton.joints.size(); + coords += average * scale; + for (unsigned j = 0; j < skeleton.joints.size(); j++) { + skeleton.joints[j].position -= average; + } + average /= multiplier; } - average /= multiplier; velocity = 0; for (unsigned i = 0; i < skeleton.joints.size(); i++) { @@ -5316,7 +5314,7 @@ void Person::DoStuff() addEnvSound(coords, 4 * findLength(&velocity)); } - int howmany; + int howmany = 0; if (environment == grassyenvironment) howmany = findLength(&velocity) * 4; if (environment == snowyenvironment) @@ -5376,7 +5374,7 @@ void Person::DoStuff() addEnvSound(coords, 4 * findLength(&velocity)); } - int howmany; + int howmany = 0; if (environment == grassyenvironment) howmany = findLength(&velocity) * 4; if (environment == snowyenvironment)