[Fix] Bug in weapon system timers.
This commit is contained in:
parent
01243e12e3
commit
3fc6514861
1
src/ai.c
1
src/ai.c
@ -626,7 +626,6 @@ static int ai_pshield(lua_State* L) {
|
|||||||
else d = cur_pilot->shield / cur_pilot->shield_max * 100.;
|
else d = cur_pilot->shield / cur_pilot->shield_max * 100.;
|
||||||
|
|
||||||
lua_pushnumber(L, d);
|
lua_pushnumber(L, d);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
src/pause.c
37
src/pause.c
@ -12,15 +12,15 @@ extern int pilot_nstack;
|
|||||||
/* From main.c */
|
/* From main.c */
|
||||||
extern unsigned int gtime;
|
extern unsigned int gtime;
|
||||||
|
|
||||||
static void pilot_nstack_pause(void);
|
static void pilot_pause(void);
|
||||||
static void pilot_nstack_unpause(void);
|
static void pilot_unpause(void);
|
||||||
static void pilot_nstack_delay(unsigned int delay);
|
static void pilot_delay(unsigned int delay);
|
||||||
|
|
||||||
/* Pause the game. */
|
/* Pause the game. */
|
||||||
void pause_game(void) {
|
void pause_game(void) {
|
||||||
if(paused) return; /* Well well.. We are paused already. */
|
if(paused) return; /* Well well.. We are paused already. */
|
||||||
|
|
||||||
pilot_nstack_pause();
|
pilot_pause();
|
||||||
|
|
||||||
paused = 1; /* We should unpause it. */
|
paused = 1; /* We should unpause it. */
|
||||||
}
|
}
|
||||||
@ -28,42 +28,56 @@ void pause_game(void) {
|
|||||||
void unpause_game(void) {
|
void unpause_game(void) {
|
||||||
if(!paused) return; /* We are unpaused already. */
|
if(!paused) return; /* We are unpaused already. */
|
||||||
|
|
||||||
pilot_nstack_unpause();
|
pilot_unpause();
|
||||||
|
|
||||||
paused = 0;
|
paused = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the timers back. */
|
/* Set the timers back. */
|
||||||
void pause_delay(unsigned int delay) {
|
void pause_delay(unsigned int delay) {
|
||||||
pilot_nstack_delay(delay);
|
pilot_delay(delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pilots pausing/unpausing. */
|
/* Pilots pausing/unpausing. */
|
||||||
static void pilot_nstack_pause(void) {
|
static void pilot_pause(void) {
|
||||||
int i, j;
|
int i, j;
|
||||||
unsigned int t = SDL_GetTicks();
|
unsigned int t = SDL_GetTicks();
|
||||||
for(i = 0; i < pilot_nstack; i++) {
|
for(i = 0; i < pilot_nstack; i++) {
|
||||||
pilot_stack[i]->ptimer -= t;
|
pilot_stack[i]->ptimer -= t;
|
||||||
|
|
||||||
|
/* Pause timers. */
|
||||||
pilot_stack[i]->tcontrol -= t;
|
pilot_stack[i]->tcontrol -= t;
|
||||||
for(j = 0; j < MAX_AI_TIMERS; j++)
|
for(j = 0; j < MAX_AI_TIMERS; j++)
|
||||||
pilot_stack[i]->timer[j] -= t;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pilot_nstack_unpause(void) {
|
static void pilot_unpause(void) {
|
||||||
int i, j;
|
int i, j;
|
||||||
unsigned int t = SDL_GetTicks();
|
unsigned int t = SDL_GetTicks();
|
||||||
for(i = 0; i < pilot_nstack; i++) {
|
for(i = 0; i < pilot_nstack; i++) {
|
||||||
pilot_stack[i]->ptimer += t;
|
pilot_stack[i]->ptimer += t;
|
||||||
|
|
||||||
|
/* Rerun timers. */
|
||||||
pilot_stack[i]->tcontrol += t;
|
pilot_stack[i]->tcontrol += t;
|
||||||
for(j = 0; j < MAX_AI_TIMERS; j++)
|
for(j = 0; j < MAX_AI_TIMERS; j++)
|
||||||
pilot_stack[i]->timer[j] += t;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pilot_nstack_delay(unsigned int delay) {
|
static void pilot_delay(unsigned int delay) {
|
||||||
int i, j;
|
int i, j;
|
||||||
for(i = 0; i < pilot_nstack; i++) {
|
for(i = 0; i < pilot_nstack; i++) {
|
||||||
pilot_stack[i]->ptimer += delay;
|
pilot_stack[i]->ptimer += delay;
|
||||||
@ -71,6 +85,11 @@ static void pilot_nstack_delay(unsigned int delay) {
|
|||||||
pilot_stack[i]->tcontrol += delay;
|
pilot_stack[i]->tcontrol += delay;
|
||||||
for(j = 0; j < MAX_AI_TIMERS; j++)
|
for(j = 0; j < MAX_AI_TIMERS; j++)
|
||||||
pilot_stack[i]->timer[j] += delay;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user