From: Côme Chilliet Date: Sun, 20 Nov 2016 17:13:49 +0000 (+0800) Subject: Fixed a lot of warnings X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=8e94b0e0f79e8fc55ace5699ffe039462d9e155d;p=lugaru.git Fixed a lot of warnings --- diff --git a/Source/Account.cpp b/Source/Account.cpp index a087158..ce8838b 100644 --- a/Source/Account.cpp +++ b/Source/Account.cpp @@ -59,7 +59,7 @@ Account* Account::add(string name) Account* Account::get(int i) { - if ((i >= 0) && (i < accounts.size())) { + if ((i >= 0) && (i < int(accounts.size()))) { return accounts[i]; } else return NULL; diff --git a/Source/Awards.cpp b/Source/Awards.cpp index 160ec45..9243cf4 100644 --- a/Source/Awards.cpp +++ b/Source/Awards.cpp @@ -79,13 +79,13 @@ int maxalarmed; int award_awards(int *awards) { - int numawards = 0, i; + int numawards = 0; if (damagetaken == 0 && Person::players[0]->bloodloss == 0) { awards[numawards] = awardflawless; numawards++; } bool alldead = true; - for (i = 1; i < Person::players.size(); i++) { + for (unsigned i = 1; i < Person::players.size(); i++) { if (Person::players[i]->dead != 2) alldead = 0; } @@ -94,7 +94,7 @@ int award_awards(int *awards) numawards++; } alldead = 1; - for (i = 1; i < Person::players.size(); i++) { + for (unsigned i = 1; i < Person::players.size(); i++) { if (Person::players[i]->dead != 1) alldead = 0; } @@ -130,12 +130,12 @@ int award_awards(int *awards) awards[numawards] = awardacrobat; numawards++; } - if (numthrowkill == Person::players.size() - 1) { + if (numthrowkill == (int(Person::players.size()) - 1)) { awards[numawards] = awardlongrange; numawards++; } alldead = 1; - for (i = 1; i < Person::players.size(); i++) { + for (unsigned i = 1; i < Person::players.size(); i++) { if (Person::players[i]->dead != 2) alldead = 0; } diff --git a/Source/Game.cpp b/Source/Game.cpp index 2f88d34..a70776f 100644 --- a/Source/Game.cpp +++ b/Source/Game.cpp @@ -134,10 +134,10 @@ std::string displaytext[15] = {}; float displaytime[15] = {}; float displayblinkdelay = 0; bool displayblink = 0; -int displayselected = 0; +unsigned displayselected = 0; float consoleblinkdelay = 0; bool consoleblink = 0; -int consoleselected = 0; +unsigned consoleselected = 0; unsigned short crouchkey = 0, jumpkey = 0, forwardkey = 0, backkey = 0, leftkey = 0, rightkey = 0, drawkey = 0, throwkey = 0, attackkey = 0; unsigned short consolekey = 0; @@ -157,7 +157,7 @@ void Game::fireSound(int sound) emit_sound_at(sound); } -void Game::inputText(string& str, int* charselected) +void Game::inputText(string& str, unsigned* charselected) { SDL_Event evenement; diff --git a/Source/Game.h b/Source/Game.h index 6469091..b75d709 100644 --- a/Source/Game.h +++ b/Source/Game.h @@ -140,10 +140,10 @@ extern std::string displaytext[15]; extern float displaytime[15]; extern float displayblinkdelay; extern bool displayblink; -extern int displayselected; +extern unsigned displayselected; extern float consoleblinkdelay; extern bool consoleblink; -extern int consoleselected; +extern unsigned consoleselected; extern int oldenvironment; extern int targetlevel; @@ -175,7 +175,7 @@ int checkcollide(XYZ startpoint, XYZ endpoint, int what); void fireSound(int sound = fireendsound); void setKeySelected(); -void inputText(std::string& str, int* charselected); +void inputText(std::string& str, unsigned* charselected); void flash(); } diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index 7d9eb8b..56fa29e 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -137,7 +137,7 @@ int Game::DrawGLScene(StereoSide side) { static float texcoordwidth, texcoordheight; static float texviewwidth, texviewheight; - static int i, j, l; + static int l; static XYZ checkpoint; static float tempmult; float tutorialopac; @@ -175,7 +175,7 @@ int Game::DrawGLScene(StereoSide side) numboundaries = mapradius * 2; if (numboundaries > 360) numboundaries = 360; - for (i = 0; i < numboundaries; i++) { + for (int i = 0; i < numboundaries; i++) { boundary[i] = 0; boundary[i].z = 1; boundary[i] = mapcenter + DoRotation(boundary[i] * mapradius, 0, i * (360 / ((float)(numboundaries))), 0); @@ -335,7 +335,7 @@ int Game::DrawGLScene(StereoSide side) for (unsigned k = 0; k < Person::players.size(); k++) { if (!Person::players[k]->skeleton.free && Person::players[k]->playerdetail && Person::players[k]->howactive < typesleeping) if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y + Person::players[k]->scale * 3, Person::players[k]->coords.z, Person::players[k]->scale * 7) && Person::players[k]->occluded < 25) - for (i = 0; i < Person::players[k]->skeleton.num_joints; i++) { + for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) { if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin) { point = DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords; size = .4f; @@ -345,7 +345,7 @@ int Game::DrawGLScene(StereoSide side) } terrain.MakeDecal(shadowdecal, point, size, opacity, rotation); for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) { - j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l]; + int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l]; if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) { point = DoRotation(DoRotation(Person::players[k]->skeleton.joints[i].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0); size = .4f; @@ -360,7 +360,7 @@ int Game::DrawGLScene(StereoSide side) } if ((Person::players[k]->skeleton.free || Person::players[k]->howactive >= typesleeping) && Person::players[k]->playerdetail) if (frustum.SphereInFrustum(Person::players[k]->coords.x, Person::players[k]->coords.y, Person::players[k]->coords.z, Person::players[k]->scale * 5) && Person::players[k]->occluded < 25) - for (i = 0; i < Person::players[k]->skeleton.num_joints; i++) { + for (int i = 0; i < Person::players[k]->skeleton.num_joints; i++) { if (Person::players[k]->skeleton.joints[i].label == leftknee || Person::players[k]->skeleton.joints[i].label == rightknee || Person::players[k]->skeleton.joints[i].label == groin || Person::players[k]->skeleton.joints[i].label == leftelbow || Person::players[k]->skeleton.joints[i].label == rightelbow || Person::players[k]->skeleton.joints[i].label == neck) { if (Person::players[k]->skeleton.free) point = Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords; @@ -373,7 +373,7 @@ int Game::DrawGLScene(StereoSide side) } terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation); for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) { - j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l]; + int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l]; if (objects.position[j].y < Person::players[k]->coords.y || objects.type[j] == tunneltype || objects.type[j] == weirdtype) { if (Person::players[k]->skeleton.free) point = DoRotation(Person::players[k]->skeleton.joints[i].position * Person::players[k]->scale + Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0); @@ -397,7 +397,7 @@ int Game::DrawGLScene(StereoSide side) opacity = .4 - (Person::players[k]->coords.y - terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z)) / 5; terrain.MakeDecal(shadowdecal, point, size, opacity * .7, rotation); for (l = 0; l < terrain.patchobjectnum[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz]; l++) { - j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l]; + int j = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l]; point = DoRotation(Person::players[k]->coords - objects.position[j], 0, -objects.yaw[j], 0); size = .7; opacity = .4f; @@ -463,6 +463,7 @@ int Game::DrawGLScene(StereoSide side) if (distance >= .5) { checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords; checkpoint.y += 1; + int i; if (!Person::players[k]->occluded == 0) i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded); if (i == -1 || Person::players[k]->occluded == 0) @@ -527,6 +528,7 @@ int Game::DrawGLScene(StereoSide side) if (distance >= .5) { checkpoint = DoRotation(Person::players[k]->skeleton.joints[abs(Random() % Person::players[k]->skeleton.num_joints)].position, 0, Person::players[k]->yaw, 0) * Person::players[k]->scale + Person::players[k]->coords; checkpoint.y += 1; + int i; if (!Person::players[k]->occluded == 0) i = checkcollide(viewer, checkpoint, Person::players[k]->lastoccluded); if (i == -1 || Person::players[k]->occluded == 0) @@ -569,7 +571,7 @@ int Game::DrawGLScene(StereoSide side) for (unsigned k = 0; k < Person::players.size(); k++) { if (Person::players[k]->numwaypoints > 1) { glBegin(GL_LINE_LOOP); - for (i = 0; i < Person::players[k]->numwaypoints; i++) { + for (int i = 0; i < Person::players[k]->numwaypoints; i++) { glVertex3f(Person::players[k]->waypoints[i].x, Person::players[k]->waypoints[i].y + .5, Person::players[k]->waypoints[i].z); } glEnd(); @@ -581,7 +583,7 @@ int Game::DrawGLScene(StereoSide side) glColor4f(0, 1, 0, 1); for (unsigned k = 0; int(k) < numpathpoints; k++) { if (numpathpointconnect[k]) { - for (i = 0; i < numpathpointconnect[k]; i++) { + for (int i = 0; i < numpathpointconnect[k]; i++) { glBegin(GL_LINE_LOOP); glVertex3f(pathpoint[k].x, pathpoint[k].y + .5, pathpoint[k].z); glVertex3f(pathpoint[pathpointconnect[k][i]].x, pathpoint[pathpointconnect[k][i]].y + .5, pathpoint[pathpointconnect[k][i]].z); @@ -935,7 +937,7 @@ int Game::DrawGLScene(StereoSide side) float closestdist = -1; float distance = 0; closest = currenthotspot; - for (i = 0; i < numhotspots; i++) { + for (int i = 0; i < numhotspots; i++) { distance = distsq(&Person::players[0]->coords, &hotspot[i]); if (closestdist == -1 || distance < closestdist) { if (distsq(&Person::players[0]->coords, &hotspot[i]) < hotspotsize[i] && ((hotspottype[i] <= 10 && hotspottype[i] >= 0) || (hotspottype[i] <= 40 && hotspottype[i] >= 20))) { @@ -962,7 +964,7 @@ int Game::DrawGLScene(StereoSide side) int lastline = 0; int line = 0; bool done = false; - i = 0; + int i = 0; while (!done) { if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') { glColor4f(0, 0, 0, tutorialopac); @@ -980,7 +982,7 @@ int Game::DrawGLScene(StereoSide side) } } else if (hotspottype[closest] >= 20 && dialoguegonethrough[hotspottype[closest] - 20] == 0) { whichdialogue = hotspottype[closest] - 20; - for (j = 0; j < numdialogueboxes[whichdialogue]; j++) { + for (int j = 0; j < numdialogueboxes[whichdialogue]; j++) { Person::players[participantfocus[whichdialogue][j]]->coords = participantlocation[whichdialogue][participantfocus[whichdialogue][j]]; Person::players[participantfocus[whichdialogue][j]]->yaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]]; Person::players[participantfocus[whichdialogue][j]]->targetyaw = participantyaw[whichdialogue][participantfocus[whichdialogue][j]]; @@ -1069,11 +1071,11 @@ int Game::DrawGLScene(StereoSide side) char tempname[264]; bool goodchar; int tempnum = 0; - for (i = 0; i < 264; i++) { + for (int i = 0; i < 264; i++) { tempname[i] = '\0'; } - for (i = 0; i < (int)strlen(dialoguename[whichdialogue][indialogue]); i++) { + for (int 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') @@ -1097,7 +1099,7 @@ int Game::DrawGLScene(StereoSide side) } tempnum = 0; - for (i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) { + for (int i = 0; i < (int)strlen(dialoguetext[whichdialogue][indialogue]) + 1; i++) { tempname[tempnum] = dialoguetext[whichdialogue][indialogue][i]; if (dialoguetext[whichdialogue][indialogue][i] != '#') tempnum++; @@ -1108,7 +1110,7 @@ int Game::DrawGLScene(StereoSide side) int lastline = 0; int line = 0; bool done = false; - i = 0; + int i = 0; while (!done) { if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') { if (dialogueboxcolor[whichdialogue][indialogue][0] + dialogueboxcolor[whichdialogue][indialogue][1] + dialogueboxcolor[whichdialogue][indialogue][2] < 1.5) { @@ -1434,9 +1436,9 @@ int Game::DrawGLScene(StereoSide side) displaytime[0] = 0; glEnable(GL_TEXTURE_2D); glColor4f(1, 1, 1, 1); - for (i = 1; i < 15; i++) + for (unsigned i = 1; i < 15; i++) if (displaytime[i] < 4) - for (j = 0; j < displaytext[i].size(); j++) { + for (unsigned j = 0; j < displaytext[i].size(); j++) { glColor4f(1, 1, 1, 4 - displaytime[i]); sprintf (string, "%c", displaytext[i][j]); text->glPrint(30 + j * 10, 30 + i * 20 + (screenheight - 330), string, 0, 1, screenwidth, screenheight); @@ -1475,20 +1477,20 @@ int Game::DrawGLScene(StereoSide side) float distcheck; int numliveplayers = 0; center = 0; - for (i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { if (!Person::players[i]->dead) numliveplayers++; } int numadd = 0; - for (i = 0; i < objects.numobjects; i++) { + for (int i = 0; i < objects.numobjects; i++) { if (objects.type[i] == treetrunktype || objects.type[i] == boxtype) { center += objects.position[i]; numadd++; } } - for (i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { if (!Person::players[i]->dead) center += Person::players[i]->coords; } @@ -1499,14 +1501,14 @@ int Game::DrawGLScene(StereoSide side) float maxdistance = 0; float tempdist; //~ int whichclosest; - for (i = 0; i < objects.numobjects; i++) { + for (int i = 0; i < objects.numobjects; i++) { tempdist = distsq(¢er, &objects.position[i]); if (tempdist > maxdistance) { //~ whichclosest=i; maxdistance = tempdist; } } - for (i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { if (!Person::players[i]->dead) { tempdist = distsq(¢er, &Person::players[i]->coords); if (tempdist > maxdistance) { @@ -1525,7 +1527,7 @@ int Game::DrawGLScene(StereoSide side) glPopMatrix(); glRotatef(Person::players[0]->lookyaw * -1 + 180, 0, 0, 1); glTranslatef(-(center.x / terrain.scale / 256 * -2 + 1), (center.z / terrain.scale / 256 * -2 + 1), 0); - for (i = 0; i < objects.numobjects; i++) { + for (int i = 0; i < objects.numobjects; i++) { if (objects.type[i] == treetrunktype) { distcheck = distsq(&Person::players[0]->coords, &objects.position[i]); if (distcheck < mapviewdist) { @@ -1573,7 +1575,7 @@ int Game::DrawGLScene(StereoSide side) } if (editorenabled) { Mapcircletexture.bind(); - for (i = 0; i < numboundaries; i++) { + for (int i = 0; i < numboundaries; i++) { glColor4f(0, 0, 0, opac / 3); glPushMatrix(); glTranslatef(boundary[i].x / terrain.scale / 256 * -2 + 1, boundary[i].z / terrain.scale / 256 * 2 - 1, 0); @@ -1591,7 +1593,7 @@ int Game::DrawGLScene(StereoSide side) glPopMatrix(); } } - for (i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { distcheck = distsq(&Person::players[0]->coords, &Person::players[i]->coords); if (distcheck < mapviewdist) { glPushMatrix(); @@ -1743,7 +1745,8 @@ int Game::DrawGLScene(StereoSide side) char temp[255]; - for (i = 0; i < 255; i++)string[i] = '\0'; + for (int 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) @@ -1756,7 +1759,7 @@ int Game::DrawGLScene(StereoSide side) int awards[award_count]; int numawards = award_awards(awards); - for (i = 0; i < numawards && i < 6; i++) + for (int i = 0; i < numawards && i < 6; i++) text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 90 - 40 * i, award_names[awards[i]], 1, 2, 1024, 768); } @@ -1982,7 +1985,7 @@ int Game::DrawGLScene(StereoSide side) glPopMatrix(); } if (drawmode == radialzoommode) { - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { //glRotatef((float)i*.1,0,0,1); glColor4f(1, 1, 1, 1 / ((float)i + 1)); glPushMatrix(); @@ -2023,8 +2026,8 @@ int Game::DrawGLScene(StereoSide side) sprintf (string, "_"); text->glPrint(30 + (float)(consoleselected) * 10 - offset * 10, 30, string, 0, 1, 1024, 768); } - for (i = 0; i < 15; i++) - for (j = 0; j < consoletext[i].size(); j++) { + for (unsigned i = 0; i < 15; i++) + for (unsigned j = 0; j < consoletext[i].size(); j++) { glColor4f(1, 1, 1, 1 - (float)(i) / 16); sprintf (string, "%c", consoletext[i][j]); text->glPrint(30 + j * 10 - offset * 10, 30 + i * 20, string, 0, 1, 1024, 768); diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 8b7b267..c5f953f 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -4808,7 +4808,7 @@ void doPlayerCollisions() } } -void doAI(int i) +void doAI(unsigned i) { static bool connected; if (Person::players[i]->aitype != playercontrolled && indialogue == -1) { @@ -5402,7 +5402,7 @@ void doAI(int i) if (Person::players[i]->ally < 0) { int closest = -1; float closestdist = -1; - for (int k = 0; k < weapons.size(); k++) + for (unsigned k = 0; k < weapons.size(); k++) if (weapons[k].owner == -1) { float distance = distsq(&Person::players[i]->coords, &weapons[k].position); if (closestdist == -1 || distance < closestdist) { @@ -5514,7 +5514,7 @@ void doAI(int i) } //go for weapon on the ground if (Person::players[i]->wentforweapon < 3) - for (int k = 0; k < weapons.size(); k++) + for (unsigned k = 0; k < weapons.size(); k++) if (Person::players[i]->creature != wolftype) if (Person::players[i]->num_weapons == 0 && weapons[k].owner == -1 && @@ -6033,8 +6033,6 @@ void MenuTick() static int oldmainmenu = mainmenu; - char sbuf[256]; - if (Input::MouseClicked() && (selected >= 0)) { // handling of the left mouse clic in menus set>::iterator newscreenresolution; switch (mainmenu) { @@ -6628,8 +6626,9 @@ void Game::Tick() if (talkdelay <= 0 && indialogue == -1 && animation[Person::players[0]->animTarget].height != highheight) for (int i = 0; i < numdialogues; i++) { - int realdialoguetype; + unsigned realdialoguetype; bool special; + /* FIXME - Seems like modulo done with ifs */ if (dialoguetype[i] > 49) { realdialoguetype = dialoguetype[i] - 50; special = 1; @@ -6953,7 +6952,7 @@ void Game::Tick() } if (dialoguetype[whichdialogue] > 49 && dialoguetype[whichdialogue] < 60) { hostile = 1; - for (int i = 1; i < Person::players.size(); i++) { + for (unsigned i = 1; i < Person::players.size(); i++) { Person::players[i]->aitype = attacktypecutoff; } } @@ -7201,7 +7200,7 @@ void Game::Tick() Person::players[i]->isFlip() || Person::players[i]->isFlip() || Person::players[i]->aitype != playercontrolled)) { - for (int j = 0; j < weapons.size(); j++) { + for (unsigned j = 0; j < weapons.size(); j++) { if ((weapons[j].velocity.x == 0 && weapons[j].velocity.y == 0 && weapons[j].velocity.z == 0 || Person::players[i]->aitype == playercontrolled) && weapons[j].owner == -1 && @@ -7226,7 +7225,7 @@ void Game::Tick() Person::players[i]->aitype == playercontrolled) && weapons[j].owner == -1 || Person::players[i]->victim && - weapons[j].owner == Person::players[i]->victim->id) + weapons[j].owner == int(Person::players[i]->victim->id)) if (distsqflat(&Person::players[i]->coords, &weapons[j].position) < 2 && Person::players[i]->weaponactive == -1) if (distsq(&Person::players[i]->coords, &weapons[j].position) < 1 || Person::players[i]->victim) { if (weapons[j].getType() != staff) @@ -7254,13 +7253,13 @@ void Game::Tick() Person::players[i]->throwtogglekeydown = 1; Person::players[i]->hasvictim = 0; - for (int k = 0; k < weapons.size(); k++) { + for (unsigned k = 0; k < weapons.size(); k++) { if (Person::players[i]->weaponactive == -1) if ((weapons[k].velocity.x == 0 && weapons[k].velocity.y == 0 && weapons[k].velocity.z == 0 || Person::players[i]->aitype == playercontrolled) && weapons[k].owner == -1 || Person::players[i]->victim && - weapons[k].owner == Person::players[i]->victim->id) + weapons[k].owner == int(Person::players[i]->victim->id)) if (distsqflat(&Person::players[i]->coords, &weapons[k].position) < 3 && Person::players[i]->weaponactive == -1) { if (weapons[k].getType() != staff) @@ -8216,7 +8215,7 @@ void Game::TickOnceAfter() winhotspot = true; int numalarmed = 0; - for (int i = 1; i < Person::players.size(); i++) + for (unsigned i = 1; i < Person::players.size(); i++) if (!Person::players[i]->dead && Person::players[i]->aitype == attacktypecutoff && Person::players[i]->surprised <= 0) numalarmed++; if (numalarmed > maxalarmed) @@ -8228,7 +8227,7 @@ void Game::TickOnceAfter() targetlevel = whichlevel; } alldead = true; - for (int i = 1; i < Person::players.size(); i++) { + for (unsigned i = 1; i < Person::players.size(); i++) { if (!Person::players[i]->dead && Person::players[i]->howactive < typedead1) { alldead = false; break; diff --git a/Source/Lights.cpp b/Source/Lights.cpp index b8332c3..40a24f5 100644 --- a/Source/Lights.cpp +++ b/Source/Lights.cpp @@ -25,9 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void SetUpLight(Light* whichsource, int whichlight) { static float qattenuation[] = {0.0002f}; - static float cattenuation[] = {1.5f}; - static float lattenuation[] = {0.5f}; - static float zattenuation[] = {0.0f}; //Initialize lights if (whichlight == 0) { diff --git a/Source/MacCompatibility.cpp b/Source/MacCompatibility.cpp index eb626ba..dca10d8 100644 --- a/Source/MacCompatibility.cpp +++ b/Source/MacCompatibility.cpp @@ -150,8 +150,6 @@ Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b) static int locateOneElement(char *buf) { char *ptr; - char **rc; - char **i; DIR *dirp; //if (PHYSFS_exists(buf)) diff --git a/Source/Menu.cpp b/Source/Menu.cpp index 8737a78..1484434 100644 --- a/Source/Menu.cpp +++ b/Source/Menu.cpp @@ -272,6 +272,9 @@ void Menu::drawItems() glEnable(GL_TEXTURE_2D); } break; + default: + case MenuItem::NONE: + break; } } } diff --git a/Source/Models.cpp b/Source/Models.cpp index fdf2675..41d5d5c 100644 --- a/Source/Models.cpp +++ b/Source/Models.cpp @@ -245,7 +245,7 @@ int Model::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate) int Model::SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate) { - static int i, j; + static int j; static float distance; static float olddistance; static int intersecting; diff --git a/Source/Objects.cpp b/Source/Objects.cpp index 572f16b..407030a 100644 --- a/Source/Objects.cpp +++ b/Source/Objects.cpp @@ -84,7 +84,7 @@ void Objects::SphereCheckPossible(XYZ *p1, float radius) void Objects::Draw() { static float distance; - static int i, j; + static int i; static XYZ moved, terrainlight; bool hidden; diff --git a/Source/Person.cpp b/Source/Person.cpp index eff5867..23238a5 100644 --- a/Source/Person.cpp +++ b/Source/Person.cpp @@ -923,7 +923,7 @@ void Person::Reverse() } victim->weaponactive = -1; - for (int j = 0; j < Person::players.size(); j++) { + for (unsigned j = 0; j < Person::players.size(); j++) { Person::players[j]->wentforweapon = 0; } } @@ -953,7 +953,7 @@ void Person::Reverse() } victim->weaponactive = -1; - for (int j = 0; j < Person::players.size(); j++) { + for (unsigned j = 0; j < Person::players.size(); j++) { Person::players[j]->wentforweapon = 0; } } @@ -982,7 +982,7 @@ void Person::Reverse() } victim->weaponactive = -1; - for (int j = 0; j < Person::players.size(); j++) { + for (unsigned j = 0; j < Person::players.size(); j++) { Person::players[j]->wentforweapon = 0; } } @@ -1011,7 +1011,7 @@ void Person::Reverse() } victim->weaponactive = -1; - for (int j = 0; j < Person::players.size(); j++) { + for (unsigned j = 0; j < Person::players.size(); j++) { Person::players[j]->wentforweapon = 0; } } @@ -1094,7 +1094,7 @@ void Person::Reverse() victim->weaponstuck = 0; } victim->weaponactive = -1; - for (int i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { Person::players[i]->wentforweapon = 0; } } @@ -1137,7 +1137,7 @@ void Person::Reverse() weaponstuck = 0; } weaponactive = -1; - for (int i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { Person::players[i]->wentforweapon = 0; } @@ -1410,8 +1410,7 @@ void Person::DoHead() skeleton.specialforward[0] = facing; //skeleton.specialforward[0]=DoRotation(facing,0,yaw,0); - static int i; - for (i = 0; i < skeleton.num_muscles; i++) { + for (int i = 0; i < skeleton.num_muscles; i++) { if (skeleton.muscles[i].visible && (skeleton.muscles[i].parent1->label == head || skeleton.muscles[i].parent2->label == head)) { skeleton.FindRotationMuscle(i, animTarget); } @@ -1457,7 +1456,7 @@ void Person::RagDoll(bool checkcollision) if (!isnormal(tilt)) tilt = 0; if (!isnormal(tilt2)) tilt2 = 0; - for (i = 0; i < skeleton.num_joints; i++) { + for (int i = 0; i < skeleton.num_joints; i++) { skeleton.joints[i].delay = 0; 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); @@ -1469,7 +1468,7 @@ void Person::RagDoll(bool checkcollision) skeleton.joints[i].realoldposition = skeleton.joints[i].position * scale + coords; } - for (i = 0; i < skeleton.num_joints; i++) { + for (int i = 0; i < skeleton.num_joints; i++) { skeleton.joints[i].velocity = 0; skeleton.joints[i].velchange = 0; } @@ -1490,7 +1489,7 @@ void Person::RagDoll(bool checkcollision) speed *= speedmult; - for (i = 0; i < skeleton.num_joints; i++) { + for (int i = 0; i < skeleton.num_joints; i++) { if ((animation[animCurrent].attack != reversed || animCurrent == swordslashreversedanim) && animCurrent != rabbitkickanim && !isLanding() && !wasLanding() && animation[animCurrent].height == animation[animTarget].height) skeleton.joints[i].velocity = velocity / scale + facing * 5 + DoRotation(DoRotation(DoRotation((animation[animTarget].position[i][frameTarget] - animation[animCurrent].position[i][frameCurrent]) * speed, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0); else @@ -1543,7 +1542,7 @@ void Person::RagDoll(bool checkcollision) updatedelay = 0; velocity = 0; - for (i = 0; i < skeleton.num_joints; i++) { + for (int i = 0; i < skeleton.num_joints; i++) { velocity += skeleton.joints[i].velocity * scale; } velocity /= skeleton.num_joints; @@ -1567,7 +1566,7 @@ void Person::RagDoll(bool checkcollision) weaponstuck = 0; } weaponactive = -1; - for (i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { Person::players[i]->wentforweapon = 0; } } @@ -1685,7 +1684,6 @@ void Person::setAnimation(int animation) void Person::DoAnimations() { if (!skeleton.free) { - int i = 0; static float oldtarget; if (isIdle() && animCurrent != getIdle()) @@ -1837,12 +1835,12 @@ void Person::DoAnimations() } if (animation[animTarget].label[frameTarget] == 4 && (weaponactive == -1 || (animTarget != knifeslashstartanim && animTarget != knifethrowanim && animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != knifefollowanim))) { if (animation[animTarget].attack != neutral) { - i = abs(Random() % 3); - if (i == 0) + unsigned r = abs(Random() % 3); + if (r == 0) whichsound = lowwhooshsound; - if (i == 1) + if (r == 1) whichsound = midwhooshsound; - if (i == 2) + if (r == 2) whichsound = highwhooshsound; } if (animation[animTarget].attack == neutral) @@ -1879,18 +1877,18 @@ void Person::DoAnimations() int whichsound = -1; if (animation[animTarget].label[frameTarget] == 4 && aitype != playercontrolled) { if (animation[animTarget].attack != neutral) { - i = abs(Random() % 4); + unsigned r = abs(Random() % 4); if (creature == rabbittype) { - if (i == 0) whichsound = rabbitattacksound; - if (i == 1) whichsound = rabbitattack2sound; - if (i == 2) whichsound = rabbitattack3sound; - if (i == 3) whichsound = rabbitattack4sound; + if (r == 0) whichsound = rabbitattacksound; + if (r == 1) whichsound = rabbitattack2sound; + if (r == 2) whichsound = rabbitattack3sound; + if (r == 3) whichsound = rabbitattack4sound; } if (creature == wolftype) { - if (i == 0) whichsound = barksound; - if (i == 1) whichsound = bark2sound; - if (i == 2) whichsound = bark3sound; - if (i == 3) whichsound = barkgrowlsound; + if (r == 0) whichsound = barksound; + if (r == 1) whichsound = bark2sound; + if (r == 2) whichsound = bark3sound; + if (r == 3) whichsound = barkgrowlsound; } speechdelay = .3; } @@ -1918,7 +1916,7 @@ void Person::DoAnimations() frameTarget++; if (animTarget == removeknifeanim && animation[animTarget].label[frameCurrent] == 5) { - for (i = 0; i < weapons.size(); i++) { + for (unsigned i = 0; i < weapons.size(); i++) { if (weapons[i].owner == -1) if (distsqflat(&coords, &weapons[i].position) < 4 && weaponactive == -1) { if (distsq(&coords, &weapons[i].position) >= 1) { @@ -1939,20 +1937,20 @@ void Person::DoAnimations() } if (animTarget == crouchremoveknifeanim && animation[animTarget].label[frameCurrent] == 5) { - for (i = 0; i < weapons.size(); i++) { + for (unsigned i = 0; i < weapons.size(); i++) { bool willwork = true; if (weapons[i].owner != -1) if (Person::players[weapons[i].owner]->weaponstuck != -1) - if (Person::players[weapons[i].owner]->weaponids[Person::players[weapons[i].owner]->weaponstuck] == i) + if (Person::players[weapons[i].owner]->weaponids[Person::players[weapons[i].owner]->weaponstuck] == int(i)) if (Person::players[weapons[i].owner]->num_weapons > 1) willwork = 0; - if ((weapons[i].owner == -1) || (hasvictim && weapons[i].owner == victim->id && victim->skeleton.free)) + if ((weapons[i].owner == -1) || (hasvictim && (weapons[i].owner == int(victim->id)) && victim->skeleton.free)) if (willwork && distsqflat(&coords, &weapons[i].position) < 3 && weaponactive == -1) { if (distsq(&coords, &weapons[i].position) < 1 || hasvictim) { bool fleshstuck = false; if (weapons[i].owner != -1) if (victim->weaponstuck != -1) { - if (victim->weaponids[victim->weaponstuck] == i) { + if (victim->weaponids[victim->weaponstuck] == int(i)) { fleshstuck = true; } } @@ -1990,7 +1988,7 @@ void Person::DoAnimations() footvel = 0; footpoint = weapons[i].position; if (victim->weaponstuck != -1) { - if (victim->weaponids[victim->weaponstuck] == i) { + if (victim->weaponids[victim->weaponstuck] == int(i)) { if (bloodtoggle) Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .8, .3); weapons[i].bloody = 2; @@ -2001,7 +1999,7 @@ void Person::DoAnimations() if (victim->num_weapons > 0) { if (victim->weaponstuck != 0 && victim->weaponstuck != -1) victim->weaponstuck = 0; - if (victim->weaponids[0] == i) + if (victim->weaponids[0] == int(i)) victim->weaponids[0] = victim->weaponids[victim->num_weapons]; } @@ -2080,7 +2078,7 @@ void Person::DoAnimations() targetloc = velocity; Normalise(&targetloc); targetloc += coords; - for (i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { if (i != id) if (distsq(&targetloc, &Person::players[i]->coords) < closestdist || closestdist == 0) { closestdist = distsq(&targetloc, &Person::players[i]->coords); @@ -2145,7 +2143,7 @@ void Person::DoAnimations() relative.y = 0; Normalise(&relative); relative = DoRotation(relative, 0, -90, 0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 40; } victim->jointVel(head) += relative * damagemult * 200; @@ -2181,7 +2179,7 @@ void Person::DoAnimations() relative.y -= 1; Normalise(&relative); relative = DoRotation(relative, 0, 90, 0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 20; } victim->jointVel(head) += relative * damagemult * 100; @@ -2212,7 +2210,7 @@ void Person::DoAnimations() relative.y = 0; Normalise(&relative); relative = DoRotation(relative, 0, -90, 0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 40; } victim->jointVel(head) += relative * damagemult * 200; @@ -2248,7 +2246,7 @@ void Person::DoAnimations() relative.y = 0; Normalise(&relative); relative = DoRotation(relative, 0, 90, 0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 40; } victim->jointVel(head) += relative * damagemult * 200; @@ -2278,7 +2276,7 @@ void Person::DoAnimations() relative = victim->coords - coords; relative.y = 0; Normalise(&relative); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 30; } victim->jointVel(head) += relative * damagemult * 100; @@ -2300,7 +2298,7 @@ void Person::DoAnimations() victim->skeleton.broken = 0; victim->skeleton.spinny = 1; - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velchange = 0; victim->skeleton.joints[i].delay = 0; victim->skeleton.joints[i].locked = 0; @@ -2311,7 +2309,7 @@ void Person::DoAnimations() relative = 0; relative.y = 1; Normalise(&relative); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity.y = relative.y * 10; victim->skeleton.joints[i].position.y += relative.y * .3; victim->skeleton.joints[i].oldposition.y += relative.y * .3; @@ -2334,7 +2332,7 @@ void Person::DoAnimations() relative = victim->coords - coords; relative.y = 0; Normalise(&relative); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 90; } victim->Puff(abdomen); @@ -2361,7 +2359,7 @@ void Person::DoAnimations() victim->skeleton.broken = 0; victim->skeleton.spinny = 1; - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velchange = 0; //victim->skeleton.joints[i].delay=0; victim->skeleton.joints[i].locked = 0; @@ -2371,7 +2369,7 @@ void Person::DoAnimations() Normalise(&relative); relative.y += .3; Normalise(&relative); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 20; } if (!victim->dead) @@ -2458,7 +2456,7 @@ void Person::DoAnimations() victim->skeleton.free = 1; victim->skeleton.broken = 0; - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velchange = 0; victim->skeleton.joints[i].locked = 0; //victim->skeleton.joints[i].velocity=0; @@ -2548,7 +2546,7 @@ void Person::DoAnimations() victim->skeleton.free = 1; victim->skeleton.broken = 0; - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velchange = 0; victim->skeleton.joints[i].locked = 0; //victim->skeleton.joints[i].velocity=0; @@ -2595,7 +2593,7 @@ void Person::DoAnimations() relative = victim->coords - coords; relative.y = 0; Normalise(&relative); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity = relative * 30; } victim->jointVel(head) += relative * damagemult * 150; @@ -2642,7 +2640,7 @@ void Person::DoAnimations() Normalise(&relative); relative.y = .3; Normalise(&relative); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity = relative * 5; } victim->jointVel(abdomen) += relative * damagemult * 400; @@ -2860,7 +2858,7 @@ void Person::DoAnimations() victim->weaponstuck = 0; } victim->weaponactive = -1; - for (i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { Person::players[i]->wentforweapon = 0; } @@ -2888,7 +2886,7 @@ void Person::DoAnimations() relative = DoRotation(relative, 0, 90, 0); relative.y -= 1; Normalise(&relative); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 60; } victim->jointVel(head) += relative * damagemult * 230; @@ -2921,7 +2919,7 @@ void Person::DoAnimations() relative.y = 0; Normalise(&relative); relative = DoRotation(relative, 0, -90, 0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 40; } victim->jointVel(head) += relative * damagemult * 220; @@ -2953,7 +2951,7 @@ void Person::DoAnimations() victim->skeleton.free = 1; victim->skeleton.broken = 0; - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velchange = 0; victim->skeleton.joints[i].locked = 0; //victim->skeleton.joints[i].velocity=0; @@ -2969,14 +2967,14 @@ void Person::DoAnimations() relative.y = -1; Normalise(&relative); if (!victim->dead) { - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity = relative * damagemult * 40; } //FootLand(1,2); victim->jointVel(abdomen) += relative * damagemult * 40; } if (victim->dead) { - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity = relative * damagemult * abs(Random() % 20); } //FootLand(1,2); @@ -3011,7 +3009,7 @@ void Person::DoAnimations() DoBlood(.2, 250); } victim->RagDoll(0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 40; } victim->jointVel(head) += relative * damagemult * 200; @@ -3030,7 +3028,7 @@ void Person::DoAnimations() } else { if (victim->damage >= victim->damagetolerance) victim->RagDoll(0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 10; } victim->jointVel(abdomen) += relative * damagemult * 200; @@ -3071,12 +3069,12 @@ void Person::DoAnimations() if (animation[victim->animTarget].height == middleheight || animation[victim->animCurrent].height == middleheight || victim->damage >= victim->damagetolerance - 40) { victim->RagDoll(0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 15; } relative = DoRotation(relative, 0, -90, 0); relative.y += .1; - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle) victim->skeleton.joints[i].velocity = relative * 80; } @@ -3086,11 +3084,11 @@ void Person::DoAnimations() } else { if (victim->damage >= victim->damagetolerance) victim->RagDoll(0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 10; } relative = DoRotation(relative, 0, -90, 0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { if (victim->skeleton.joints[i].label == leftfoot || victim->skeleton.joints[i].label == rightfoot || victim->skeleton.joints[i].label == leftankle || victim->skeleton.joints[i].label == rightankle) victim->skeleton.joints[i].velocity += relative * damagemult * 80; } @@ -3134,7 +3132,7 @@ void Person::DoAnimations() relative.y = 0; Normalise(&relative); //relative=DoRotation(relative,0,-90,0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 40; } victim->jointVel(abdomen) += relative * damagemult * 200; @@ -3147,7 +3145,7 @@ void Person::DoAnimations() if ((animTarget == swordslashreversalanim || animTarget == knifeslashreversalanim || animTarget == staffhitreversalanim || animTarget == staffspinhitreversalanim) && animation[animTarget].label[frameCurrent] == 5) { if (victim->weaponactive != -1 && victim->num_weapons > 0) { - if (weapons[victim->weaponids[victim->weaponactive]].owner == victim->id) { + if (weapons[victim->weaponids[victim->weaponactive]].owner == int(victim->id)) { weapons[victim->weaponids[victim->weaponactive]].owner = id; weaponactive = 0; if (num_weapons > 0) { @@ -3180,7 +3178,7 @@ void Person::DoAnimations() relative.y = 0; Normalise(&relative); //relative=DoRotation(relative,0,-90,0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 30; } victim->jointVel(abdomen) += relative * damagemult * 200; @@ -3211,7 +3209,7 @@ void Person::DoAnimations() relative.y = 0; Normalise(&relative); //relative=DoRotation(relative,0,-90,0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 30; } victim->jointVel(abdomen) += relative * damagemult * 200; @@ -3229,7 +3227,7 @@ void Person::DoAnimations() Normalise(&relative); //relative*=-1; relative.y -= .1; - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 70; } victim->jointVel(lefthand) *= .1; @@ -3281,7 +3279,7 @@ void Person::DoAnimations() Normalise(&relative); //relative*=-1; relative.y -= .1; - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 70; } victim->jointVel(lefthand) *= .1 - 1; @@ -3313,7 +3311,7 @@ void Person::DoAnimations() relative.y = 0; Normalise(&relative); relative = DoRotation(relative, 0, -90, 0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 40; } victim->jointVel(abdomen) += relative * damagemult * 200; @@ -3334,7 +3332,7 @@ void Person::DoAnimations() Normalise(&relative); if (victim->id == 0) relative /= 30; - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 40; } //victim->DoDamage(1000); @@ -3418,12 +3416,12 @@ void Person::DoAnimations() if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && animation[animTarget].label[frameCurrent] == 6) { escapednum = 0; victim->velocity = 0; - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity = 0; } if (animTarget == knifefollowanim) { victim->RagDoll(0); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity = 0; } } @@ -3476,7 +3474,7 @@ void Person::DoAnimations() if (hasvictim && animTarget == swordsneakattackanim && animation[animTarget].label[frameCurrent] == 6) { escapednum = 0; victim->velocity = 0; - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity = 0; } if (weaponactive != -1) { @@ -3545,7 +3543,7 @@ void Person::DoAnimations() relative = DoRotation(relative, 0, 90, 0); relative.y = .5; Normalise(&relative); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 20; } victim->jointVel(head) += relative * damagemult * 200; @@ -3566,7 +3564,7 @@ void Person::DoAnimations() relative = DoRotation(relative, 0, 90, 0); relative.y = .5; Normalise(&relative); - for (i = 0; i < victim->skeleton.num_joints; i++) { + for (int i = 0; i < victim->skeleton.num_joints; i++) { victim->skeleton.joints[i].velocity += relative * damagemult * 20; } victim->jointVel(head) += relative * damagemult * 200; @@ -3680,7 +3678,7 @@ void Person::DoAnimations() float closestdist = -1; float distance; if (Person::players.size() > 1) - for (i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { if (id != i && Person::players[i]->coords.y < coords.y && !Person::players[i]->skeleton.free) { distance = distsq(&Person::players[i]->coords, &coords); if (closestdist == -1 || distance < closestdist) { @@ -3738,7 +3736,7 @@ void Person::DoAnimations() float closestdist = -1; float distance; if (Person::players.size() > 1) - for (i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { if (id != i && Person::players[i]->coords.y < coords.y && !Person::players[i]->skeleton.free) { distance = distsq(&Person::players[i]->coords, &coords); if (closestdist == -1 || distance < closestdist) { @@ -4034,18 +4032,18 @@ void Person::DoAnimations() } if (animCurrent != oldanimCurrent || animTarget != oldanimTarget || ((frameCurrent != oldframeCurrent || frameTarget != oldframeTarget) && !calcrot)) { //Old rotates - for (i = 0; i < skeleton.num_joints; i++) { + for (int i = 0; i < skeleton.num_joints; i++) { skeleton.joints[i].position = animation[animCurrent].position[i][frameCurrent]; } skeleton.FindForwards(); - for (i = 0; i < skeleton.num_muscles; i++) { + for (int i = 0; i < skeleton.num_muscles; i++) { if (skeleton.muscles[i].visible) { skeleton.FindRotationMuscle(i, animTarget); } } - for (i = 0; i < skeleton.num_muscles; i++) { + for (int i = 0; i < skeleton.num_muscles; i++) { if (skeleton.muscles[i].visible) { if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100)) skeleton.muscles[i].oldrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100; @@ -4057,18 +4055,18 @@ void Person::DoAnimations() } //New rotates - for (i = 0; i < skeleton.num_joints; i++) { + for (int i = 0; i < skeleton.num_joints; i++) { skeleton.joints[i].position = animation[animTarget].position[i][frameTarget]; } skeleton.FindForwards(); - for (i = 0; i < skeleton.num_muscles; i++) { + for (int i = 0; i < skeleton.num_muscles; i++) { if (skeleton.muscles[i].visible) { skeleton.FindRotationMuscle(i, animTarget); } } - for (i = 0; i < skeleton.num_muscles; i++) { + for (int i = 0; i < skeleton.num_muscles; i++) { if (skeleton.muscles[i].visible) { if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100)) skeleton.muscles[i].newrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100; @@ -4093,12 +4091,12 @@ void Person::DoAnimations() oldframeTarget = frameTarget; oldframeCurrent = frameCurrent; - for (i = 0; i < skeleton.num_joints; i++) { + for (int i = 0; i < skeleton.num_joints; i++) { skeleton.joints[i].velocity = (animation[animCurrent].position[i][frameCurrent] * (1 - target) + animation[animTarget].position[i][frameTarget] * (target) - skeleton.joints[i].position) / multiplier; skeleton.joints[i].position = animation[animCurrent].position[i][frameCurrent] * (1 - target) + animation[animTarget].position[i][frameTarget] * (target); } offset = currentoffset * (1 - target) + targetoffset * target; - for (i = 0; i < skeleton.num_muscles; i++) { + for (int i = 0; i < skeleton.num_muscles; 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); @@ -4340,7 +4338,7 @@ void Person::DoStuff() weaponstuck = 0; } weaponactive = -1; - for (i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { Person::players[i]->wentforweapon = 0; } @@ -4358,7 +4356,7 @@ void Person::DoStuff() } dead = 2; if (animTarget == knifefollowedanim && !skeleton.free) { - for (i = 0; i < skeleton.num_joints; i++) { + for (int i = 0; i < skeleton.num_joints; i++) { skeleton.joints[i].velocity = 0; skeleton.joints[i].velocity.y = -2; } @@ -4766,7 +4764,7 @@ void Person::DoStuff() weaponstuck = 0; } weaponactive = -1; - for (i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { Person::players[i]->wentforweapon = 0; } } @@ -4808,7 +4806,7 @@ void Person::DoStuff() dead = 0; skeleton.free = 1; damage -= 20; - for (i = 0; i < skeleton.num_joints; i++) { + for (int i = 0; i < skeleton.num_joints; i++) { skeleton.joints[i].velocity = 0; } } @@ -4832,7 +4830,7 @@ void Person::DoStuff() weaponstuck = 0; } weaponactive = -1; - for (i = 0; i < Person::players.size(); i++) { + for (unsigned i = 0; i < Person::players.size(); i++) { Person::players[i]->wentforweapon = 0; } } @@ -4902,7 +4900,7 @@ void Person::DoStuff() //velocity=jointVel(groin)*scale; velocity = 0; - for (i = 0; i < skeleton.num_joints; i++) { + for (int i = 0; i < skeleton.num_joints; i++) { velocity += skeleton.joints[i].velocity * scale; } velocity /= skeleton.num_joints; @@ -5020,7 +5018,7 @@ void Person::DoStuff() //if(middle.y>0)targetoffset.y=middle.y+1; - for (i = 0; i < skeleton.num_joints; i++) { + for (int i = 0; i < skeleton.num_joints; i++) { tempanimation.position[i][0] = skeleton.joints[i].position; tempanimation.position[i][0] = DoRotation(tempanimation.position[i][0], 0, -yaw, 0); } @@ -5111,7 +5109,7 @@ void Person::DoStuff() if (middle.y > 0 && animTarget != rollanim) targetoffset.y = middle.y + 1; - for (i = 0; i < skeleton.num_joints; i++) { + for (int i = 0; i < skeleton.num_joints; i++) { tempanimation.position[i][0] = skeleton.joints[i].position; tempanimation.position[i][0] = DoRotation(tempanimation.position[i][0], 0, -yaw, 0); } @@ -6023,7 +6021,7 @@ int Person::DrawSkeleton() skeleton.drawmodelclothes.vertex[i] = 0; skeleton.drawmodelclothes.vertex[i].y = 999; } - for (i = 0; i < skeleton.num_muscles; i++) { + for (int i = 0; i < skeleton.num_muscles; i++) { // convenience renames const int p1 = skeleton.muscles[i].parent1->label; const int p2 = skeleton.muscles[i].parent2->label; diff --git a/Source/Person.h b/Source/Person.h index 734d873..4b165fb 100644 --- a/Source/Person.h +++ b/Source/Person.h @@ -232,7 +232,7 @@ public: int creature; - int id; + unsigned id; Skeleton skeleton; diff --git a/Source/Quaternions.cpp b/Source/Quaternions.cpp index b73b047..c5f7545 100644 --- a/Source/Quaternions.cpp +++ b/Source/Quaternions.cpp @@ -280,8 +280,7 @@ bool PointInTriangle(Vector *p, Vector normal, float p11, float p12, float p13, bool LineFacet(Vector p1, Vector p2, Vector pa, Vector pb, Vector pc, Vector *p) { static float d; - static float a1, a2, a3; - static float total, denom, mu; + static float denom, mu; static Vector n, pa1, pa2, pa3; //Calculate the parameters for the plane @@ -393,8 +392,7 @@ bool PointInTriangle(XYZ *p, XYZ normal, XYZ *p1, XYZ *p2, XYZ *p3) bool LineFacet(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ *p) { static float d; - static float a1, a2, a3; - static float total, denom, mu; + static float denom, mu; static XYZ n, pa1, pa2, pa3; //Calculate the parameters for the plane @@ -425,8 +423,7 @@ bool LineFacet(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ *p) float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ *p) { static float d; - static float a1, a2, a3; - static float total, denom, mu; + static float denom, mu; static XYZ n, pa1, pa2, pa3; //Calculate the parameters for the plane @@ -457,8 +454,7 @@ float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ *p) float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ n, XYZ *p) { static float d; - static float a1, a2, a3; - static float total, denom, mu; + static float denom, mu; static XYZ pa1, pa2, pa3; //Calculate the parameters for the plane @@ -484,8 +480,7 @@ float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ n, XYZ *p) float LineFacetd(XYZ *p1, XYZ *p2, XYZ *pa, XYZ *pb, XYZ *pc, XYZ *p) { static float d; - static float a1, a2, a3; - static float total, denom, mu; + static float denom, mu; static XYZ pa1, pa2, pa3, n; //Calculate the parameters for the plane @@ -516,8 +511,7 @@ float LineFacetd(XYZ *p1, XYZ *p2, XYZ *pa, XYZ *pb, XYZ *pc, XYZ *p) float LineFacetd(XYZ *p1, XYZ *p2, XYZ *pa, XYZ *pb, XYZ *pc, XYZ *n, XYZ *p) { static float d; - static float a1, a2, a3; - static float total, denom, mu; + static float denom, mu; static XYZ pa1, pa2, pa3; //Calculate the parameters for the plane diff --git a/Source/Quaternions.h b/Source/Quaternions.h index 29f82d7..3b1ff46 100644 --- a/Source/Quaternions.h +++ b/Source/Quaternions.h @@ -23,11 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef _QUATERNIONS_H_ #define _QUATERNIONS_H_ -#ifndef WIN32 -#pragma mark - -#endif - -//#include "Carbon.h" #include "math.h" #include "PhysicsMath.h" #include "gamegl.h" diff --git a/Source/Skeleton.cpp b/Source/Skeleton.cpp index 35fb1f7..0d7e95f 100644 --- a/Source/Skeleton.cpp +++ b/Source/Skeleton.cpp @@ -185,7 +185,7 @@ float Skeleton::DoConstraints(XYZ *coords, float *scale) XYZ bounceness; const int numrepeats = 3; float groundlevel = .15; - int i, j, k, l, m; + int i, j, k, m; XYZ temp; XYZ terrainnormal; int whichhit; @@ -834,16 +834,11 @@ void Skeleton::Load(const char *filename, const char *lowfilename, const c int parentID; FILE *tfile; float lSize; - int i, j, tempmuscle; - - int newload; + int i, j; int edit; LOGFUNC; - - newload = 0; - num_models = 7; // load various models @@ -934,7 +929,6 @@ void Skeleton::Load(const char *filename, const char *lowfilename, const c } // read num_muscles - tempmuscle = num_muscles; funpackf(tfile, "Bi", &num_muscles); // allocate memory @@ -943,12 +937,9 @@ void Skeleton::Load(const char *filename, const char *lowfilename, const c delete [] muscles; //dealloc2(muscles); muscles = (Muscle*)new Muscle[num_muscles]; //malloc(sizeof(Muscle)*num_muscles); - newload = 1; - // for each muscle... for (i = 0; i < num_muscles; i++) { // read info - tempmuscle = muscles[i].numvertices; funpackf(tfile, "Bf Bf Bf Bf Bf Bi Bi", &muscles[i].length, &muscles[i].targetlength, &muscles[i].minlength, &muscles[i].maxlength, &muscles[i].strength, &muscles[i].type, &muscles[i].numvertices); // allocate memory for vertices @@ -1071,7 +1062,6 @@ void Skeleton::Load(const char *filename, const char *lowfilename, const c fseek(tfile, lSize, SEEK_CUR); // read numverticeslow - tempmuscle = muscles[i].numverticeslow; funpackf(tfile, "Bi", &muscles[i].numverticeslow); if (muscles[i].numverticeslow) { @@ -1185,7 +1175,6 @@ void Skeleton::Load(const char *filename, const char *lowfilename, const c fseek(tfile, lSize, SEEK_CUR); // read numverticesclothes - tempmuscle = muscles[i].numverticesclothes; funpackf(tfile, "Bi", &muscles[i].numverticesclothes); // read verticesclothes diff --git a/Source/Sprite.cpp b/Source/Sprite.cpp index 14a0e9e..b03128c 100644 --- a/Source/Sprite.cpp +++ b/Source/Sprite.cpp @@ -57,7 +57,7 @@ vector Sprite::sprites = vector(); //Functions void Sprite::Draw() { - int i, j, k; + int k; static float M[16]; static XYZ point; static float distancemult; @@ -97,7 +97,7 @@ void Sprite::Draw() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(0); glAlphaFunc(GL_GREATER, 0.0001); - for (i = 0; i < sprites.size(); i++) { + for (unsigned i = 0; i < sprites.size(); i++) { if (lasttype != sprites[i]->type) { switch (sprites[i]->type) { case cloudsprite: @@ -279,7 +279,7 @@ void Sprite::Draw() glPopMatrix(); } tempmult = multiplier; - for (i = sprites.size() - 1; i >= 0; i--) { + for (unsigned i = sprites.size() - 1; i >= 0; i--) { multiplier = tempmult; if (sprites[i]->type != snowsprite) { sprites[i]->position += sprites[i]->velocity * multiplier; @@ -330,7 +330,7 @@ void Sprite::Draw() float rotationpoint; int whichtri; - for (j = 0; j < Person::players.size(); j++) { + for (unsigned j = 0; j < Person::players.size(); j++) { if (!spritehit && Person::players[j]->dead && sprites[i]->alivetime > .1) { where = sprites[i]->oldposition; where -= Person::players[j]->coords; @@ -359,7 +359,7 @@ void Sprite::Draw() if (whichpatchx > 0 && whichpatchz > 0 && whichpatchx < subdivision && whichpatchz < subdivision) if (terrain.patchobjectnum[whichpatchx][whichpatchz]) { if (!spritehit) - for (j = 0; j < terrain.patchobjectnum[whichpatchx][whichpatchz]; j++) { + for (int j = 0; j < terrain.patchobjectnum[whichpatchx][whichpatchz]; j++) { k = terrain.patchobjects[whichpatchx][whichpatchz][j]; start = sprites[i]->oldposition; end = sprites[i]->position; @@ -418,7 +418,7 @@ void Sprite::Draw() DeleteSprite(i); } if (check) - for (i = sprites.size() - 1; i >= 0; i--) { + for (unsigned i = sprites.size() - 1; i >= 0; i--) { sprites[i]->oldposition = sprites[i]->position; } glAlphaFunc(GL_GREATER, 0.0001); diff --git a/Source/Stereo.cpp b/Source/Stereo.cpp index 378942a..59e4f0f 100644 --- a/Source/Stereo.cpp +++ b/Source/Stereo.cpp @@ -57,15 +57,13 @@ bool CanInitStereo(StereoMode mode) void InitStereo(StereoMode mode) { switch (mode) { + default: case stereoNone: - glDisable( GL_STENCIL_TEST); - return; case stereoAnaglyph: - glDisable( GL_STENCIL_TEST); + glDisable(GL_STENCIL_TEST); return; case stereoHorizontalInterlaced: case stereoVerticalInterlaced: - fprintf(stderr, "Screen width is %i, height is %i\n", kContextWidth, kContextHeight); // Setup stencil buffer @@ -122,7 +120,6 @@ void InitStereo(StereoMode mode) glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); - } } @@ -155,4 +152,4 @@ const char* StereoModeName(StereoMode mode) return "(error)"; break; } -} \ No newline at end of file +} diff --git a/Source/Terrain.cpp b/Source/Terrain.cpp index 9441af0..b010bd5 100644 --- a/Source/Terrain.cpp +++ b/Source/Terrain.cpp @@ -52,9 +52,7 @@ int Terrain::lineTerrain(XYZ p1, XYZ p2, XYZ *p) static int firstintersecting; static XYZ point; static int startx, starty; - static float slope; static int endx, endy; - static int numtris = (size - 1) * (size - 1) * 2; static float highest, lowest; firstintersecting = -1; @@ -203,7 +201,6 @@ void Terrain::UpdateTransparencyother(int whichx, int whichy) { static XYZ vertex; static int i, j, a, b, c, d, patch_size, stepsize; - static float distance; patch_size = size / subdivision; @@ -862,7 +859,6 @@ void Terrain::drawpatchotherother(int whichx, int whichy, float opacity) float Terrain::getHeight(float pointx, float pointz) { - static float height1, height2; static int tilex, tiley; static XYZ startpoint, endpoint, intersect, triangle[3], average; @@ -918,7 +914,6 @@ float Terrain::getHeight(float pointx, float pointz) float Terrain::getHeightExtrude(float pointx, float pointz, float point2x, float point2z) { - static float height1, height2; static int tilex, tiley; static XYZ startpoint, endpoint, intersect, triangle[3], average; @@ -1131,11 +1126,10 @@ void Terrain::draw(int layer) void Terrain::drawdecals() { if (decals) { - static int i, j; + static int i; static float distancemult; static int lasttype; - static float patch_size = size / subdivision * scale; static float viewdistsquared; static bool blend; diff --git a/Source/Text.cpp b/Source/Text.cpp index 06ff6cd..3cf6151 100644 --- a/Source/Text.cpp +++ b/Source/Text.cpp @@ -26,8 +26,6 @@ extern TGAImageRec texture; void Text::LoadFontTexture(const char *fileName) { - GLuint type; - LOGFUNC; LOG(std::string("Loading font texture...") + fileName); diff --git a/Source/Weapons.cpp b/Source/Weapons.cpp index 776711e..a5b5723 100644 --- a/Source/Weapons.cpp +++ b/Source/Weapons.cpp @@ -214,12 +214,12 @@ void Weapon::DoStuff(int i) } if (velocity.x || velocity.y || velocity.z) { - for (int j = 0; j < Person::players.size(); j++) { + for (unsigned j = 0; j < Person::players.size(); j++) { footvel = 0; footpoint = DoRotation((Person::players[j]->jointPos(abdomen) + Person::players[j]->jointPos(neck)) / 2, 0, Person::players[j]->yaw, 0) * Person::players[j]->scale + Person::players[j]->coords; if (owner == -1 && distsqflat(&position, &Person::players[j]->coords) < 1.5 && distsq(&position, &Person::players[j]->coords) < 4 && Person::players[j]->weaponstuck == -1 && - !Person::players[j]->skeleton.free && j != oldowner) { + !Person::players[j]->skeleton.free && (int(j) != oldowner)) { if ((Person::players[j]->aitype != attacktypecutoff || abs(Random() % 6) == 0 || (Person::players[j]->animTarget != backhandspringanim && Person::players[j]->animTarget != rollanim && Person::players[j]->animTarget != flipanim && Random() % 2 == 0)) && !missed) { if ( (Person::players[j]->creature == wolftype && Random() % 3 != 0 && Person::players[j]->weaponactive == -1 && (Person::players[j]->isIdle() || Person::players[j]->isRun() || Person::players[j]->animTarget == walkanim)) || (Person::players[j]->creature == rabbittype && Random() % 2 == 0 && Person::players[j]->aitype == attacktypecutoff && Person::players[j]->weaponactive == -1)) {