}
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);
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;
}
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;
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;
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++) {