Code clean up.

This commit is contained in:
Steve 2015-11-13 23:35:51 +00:00
parent 583ff9af05
commit 83407704c6
4 changed files with 7 additions and 7 deletions

View File

@ -413,7 +413,7 @@ static int nearExtractionPoint(void)
self->target = NULL;
for (i = 0, e = candidates[i] ; e != NULL ; i++, e = candidates[i])
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
{
if (e->type == ET_EXTRACTION_POINT)
{
@ -448,7 +448,7 @@ static int nearEnemies(void)
numEnemies = 0;
for (i = 0, e = candidates[i] ; e != NULL ; i++, e = candidates[i])
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
{
if (e->type == ET_FIGHTER && e->side != SIDE_ALLIES)
{

View File

@ -207,11 +207,11 @@ void drawEntities(void)
candidates = getAllEntsWithin(battle.camera.x, battle.camera.y, SCREEN_WIDTH, SCREEN_HEIGHT, NULL);
/* count number of candidates for use with qsort */
for (i = 0, e = candidates[i] ; e != NULL ; i++, e = candidates[i]) {}
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i]) {}
qsort(candidates, i, sizeof(Entity*), drawComparator);
for (i = 0, e = candidates[i] ; e != NULL ; i++, e = candidates[i])
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
{
if (e->active)
{
@ -240,7 +240,7 @@ static void drawTargetRects(Entity *e)
{
SDL_Rect r;
if (e == player->target)
if (player != NULL && e == player->target)
{
r.x = e->x - 32 - battle.camera.x;
r.y = e->y - 32 - battle.camera.y;

View File

@ -58,7 +58,7 @@ static void handleFleeingEntities(void)
candidates = getAllEntsWithin(self->x, self->y, self->w, self->h, self);
for (i = 0, e = candidates[i] ; e != NULL ; i++, e = candidates[i])
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
{
if (e->health > 0 && e->flags & EF_FLEEING && getDistance(e->x, e->y, self->x, self->y) <= 64)
{

View File

@ -299,7 +299,7 @@ static void separate(void)
candidates = getAllEntsWithin(self->x, self->y, self->w, self->h, self);
for (i = 0, e = candidates[i] ; e != NULL ; i++, e = candidates[i])
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
{
if (e->type == ET_FIGHTER)
{