diff --git a/src/options.c b/src/options.c index b50cba1..1ac4b07 100644 --- a/src/options.c +++ b/src/options.c @@ -78,7 +78,7 @@ void opt_menuKeybinds(void) { snprintf(str[j], 64, "%s ", keybindNames[j], key); break; default: - snprintf(str[j], 64, keybindNames[j]); + snprintf(str[j], 64, "%s", keybindNames[j]); break; } } diff --git a/src/pause.c b/src/pause.c index 23bab3b..75b42e5 100644 --- a/src/pause.c +++ b/src/pause.c @@ -65,12 +65,6 @@ static void pilot_pause(void) { pilot_stack[i]->tcontrol -= t; for(j = 0; j < MAX_AI_TIMERS; j++) pilot_stack[i]->timer[j] -= t; - - /* Pause outfits. */ - for(j = 0; j < pilot_stack[i]->noutfits; j++) { - if(pilot_stack[i]->outfits[j].timer > 0) - pilot_stack[i]->outfits[j].timer -= t; - } } } @@ -84,12 +78,6 @@ static void pilot_unpause(void) { pilot_stack[i]->tcontrol += t; for(j = 0; j < MAX_AI_TIMERS; j++) pilot_stack[i]->timer[j] += t; - - /* Pause outfits. */ - for(j = 0; j < pilot_stack[i]->noutfits; j++) { - if(pilot_stack[i]->outfits[j].timer > 0) - pilot_stack[i]->outfits[j].timer += t; - } } } @@ -101,11 +89,6 @@ static void pilot_delay(unsigned int delay) { pilot_stack[i]->tcontrol += delay; for(j = 0; j < MAX_AI_TIMERS; j++) pilot_stack[i]->timer[j] += delay; - - for(j = 0; j < pilot_stack[i]->noutfits; j++) { - if(pilot_stack[i]->outfits[j].timer > 0) - pilot_stack[i]->outfits[j].timer += delay; - } } } diff --git a/src/pilot.c b/src/pilot.c index c015a68..82e2ec0 100644 --- a/src/pilot.c +++ b/src/pilot.c @@ -307,14 +307,8 @@ void pilot_shootStop(Pilot* p, const int secondary) { * @param t Pilot's target. */ static void pilot_shootWeapon(Pilot* p, PilotOutfit* w) { - int quantity, delay; - /* WElll... Trying to shoot when you have no ammo?? FUUU */ - quantity = pilot_oquantity(p,w); - delay = outfit_delay(w->outfit); - /* Check to see if weapon is ready. */ - if((w->timer > 0) && - (SDL_GetTicks() - w->timer) < (unsigned int)(delay/quantity)) + if(w->timer > 0.) return; /* Regular bolt weapons. */ if(outfit_isBolt(w->outfit)) { @@ -383,8 +377,7 @@ static void pilot_shootWeapon(Pilot* p, PilotOutfit* w) { WARN("Shooting unknown weapon type: %s", w->outfit->name); } - /* Update the weapon last used timer. */ - w->timer = SDL_GetTicks(); + w->timer += ((double)outfit_delay(w->outfit) / (double)w->quantity)/1000.; } /** @@ -719,6 +712,7 @@ static void pilot_update(Pilot* pilot, const double dt) { unsigned int t, l; double a, px, py, vx, vy; char buf[16]; + PilotOutfit* o; /* She's dead D: */ if(pilot_isFlag(pilot, PILOT_DEAD)) { @@ -838,6 +832,13 @@ static void pilot_update(Pilot* pilot, const double dt) { } else /* Normal limit. */ limit_speed(&pilot->solid->vel, pilot->speed, dt); } + + /* Update outfits. */ + for(i = 0; i < pilot->noutfits; i++) { + o = &pilot->outfits[i]; + if(o->timer > 0.) + o->timer -= dt; + } } /* Pilot is getting ready or is in, hyperspace. */ diff --git a/src/pilot.h b/src/pilot.h index 687833e..b305504 100644 --- a/src/pilot.h +++ b/src/pilot.h @@ -89,7 +89,7 @@ typedef struct PilotOutfit_ { int quantity; /**< Number of outfits of this type that the pilot has. */ PilotOutfitState state; /**< State of the outfit. */ int beamid; /**< ID of the beam used in this outfit, only for beams. */ - unsigned int timer; /**< Used to store last used weapon time. */ + double timer; /**< Used to store last used weapon time. */ } PilotOutfit; /** diff --git a/src/player.c b/src/player.c index eb30ae0..4949358 100644 --- a/src/player.c +++ b/src/player.c @@ -1046,8 +1046,7 @@ void player_renderGUI(double dt) { delay = outfit_delay(player->secondary->outfit); /* Check to see if weapon is ready. */ - if((player->secondary->timer > 0) && - (SDL_GetTicks() - player->secondary->timer) < (unsigned int)(delay/quantity)) + if(player->secondary->timer > 0.) c = &cGrey; else c = &cConsole;