[Fix?] Continue in switch case doesn't behave as I thought it did.....

This commit is contained in:
Allanis 2013-11-26 15:49:34 +00:00
parent 29f58fe1e4
commit c8fe8e8eb8

View File

@ -310,6 +310,7 @@ static void weapons_updateLayer(const double dt, const WeaponLayer layer) {
Weapon* w; Weapon* w;
int i; int i;
/* Choose layer. */
switch(layer) { switch(layer) {
case WEAPON_LAYER_BG: case WEAPON_LAYER_BG:
wlayer = wbackLayer; wlayer = wbackLayer;
@ -341,7 +342,7 @@ static void weapons_updateLayer(const double dt, const WeaponLayer layer) {
wlayer[i]->timer -= dt; wlayer[i]->timer -= dt;
if(wlayer[i]->timer < 0.) { if(wlayer[i]->timer < 0.) {
weapon_destroy(wlayer[i], layer); weapon_destroy(wlayer[i], layer);
continue; break;
} }
break; break;
/* Beam weapons handled apart. */ /* Beam weapons handled apart. */
@ -350,7 +351,7 @@ static void weapons_updateLayer(const double dt, const WeaponLayer layer) {
wlayer[i]->timer -= dt; wlayer[i]->timer -= dt;
if(wlayer[i]->timer < 0.) { if(wlayer[i]->timer < 0.) {
weapon_destroy(wlayer[i],layer); weapon_destroy(wlayer[i],layer);
continue; break;
} }
wlayer[i]->lockon -= dt; wlayer[i]->lockon -= dt;
if(wlayer[i]->lockon < 0.) { if(wlayer[i]->lockon < 0.) {
@ -365,11 +366,12 @@ static void weapons_updateLayer(const double dt, const WeaponLayer layer) {
w->outfit->name); w->outfit->name);
break; break;
} }
weapon_update(wlayer[i], dt, layer);
/* Only increment if weapon wasn't deleted. */ /* Only increment if weapon wasn't deleted. */
if(w == wlayer[i]) if(w == wlayer[i]) {
weapon_update(wlayer[i], dt, layer);
i++; i++;
}
} }
} }
@ -505,6 +507,12 @@ static void weapon_update(Weapon* w, const double dt, WeaponLayer layer) {
glTexture* gfx; glTexture* gfx;
Vec2 crash[2]; Vec2 crash[2];
/* Get the sprite direction to speed up calculations. */
if(!outfit_isBeam(w->outfit)) {
gfx = outfit_gfx(w->outfit);
gl_getSpriteFromDir(&wsx, &wsy, gfx, w->solid->dir);
}
for(i = 0; i < pilot_nstack; i++) { for(i = 0; i < pilot_nstack; i++) {
/* Check for player to exist. */ /* Check for player to exist. */
if((i == 0) && (player == NULL)) continue; if((i == 0) && (player == NULL)) continue;
@ -531,8 +539,6 @@ static void weapon_update(Weapon* w, const double dt, WeaponLayer layer) {
/* Smart weapons only collide with their target. */ /* Smart weapons only collide with their target. */
else if(weapon_isSmart(w)) { else if(weapon_isSmart(w)) {
gfx = outfit_gfx(w->outfit);
gl_getSpriteFromDir(&wsx, &wsy, gfx, w->solid->dir);
if((pilot_stack[i]->id == w->target) && if((pilot_stack[i]->id == w->target) &&
CollideSprite(gfx, wsx, wsy, &w->solid->pos, CollideSprite(gfx, wsx, wsy, &w->solid->pos,
pilot_stack[i]->ship->gfx_space, psx, psy, &pilot_stack[i]->solid->pos, pilot_stack[i]->ship->gfx_space, psx, psy, &pilot_stack[i]->solid->pos,
@ -542,11 +548,8 @@ static void weapon_update(Weapon* w, const double dt, WeaponLayer layer) {
return; /* Weapon is destroyed. */ return; /* Weapon is destroyed. */
} }
} }
/* Dumb weapons hit anything not of the same faction. */ /* Dump weapons hit anything not of the same faction. */
else if(!weapon_isSmart(w)) { else {
gfx = outfit_gfx(w->outfit);
gl_getSpriteFromDir(&wsx, &wsy, gfx, w->solid->dir);
if(!areAllies(w->faction, pilot_stack[i]->faction) && if(!areAllies(w->faction, pilot_stack[i]->faction) &&
CollideSprite(gfx, wsx, wsy, &w->solid->pos, CollideSprite(gfx, wsx, wsy, &w->solid->pos,
pilot_stack[i]->ship->gfx_space, psx, psy, &pilot_stack[i]->solid->pos, pilot_stack[i]->ship->gfx_space, psx, psy, &pilot_stack[i]->solid->pos,
@ -557,7 +560,8 @@ static void weapon_update(Weapon* w, const double dt, WeaponLayer layer) {
} }
} }
/* Smart weapons also get to think their next move. */ /* Smart weapons also get to think their next move. */
if(weapon_isSmart(w)) (*w->think)(w,dt); if(weapon_isSmart(w))
(*w->think)(w,dt);
/* Update the solid position. */ /* Update the solid position. */
(*w->solid->update)(w->solid, dt); (*w->solid->update)(w->solid, dt);