62 lines
1.2 KiB
C
62 lines
1.2 KiB
C
#include "weapon.h"
|
|
#include "pilot.h"
|
|
#include "pause.h"
|
|
|
|
// Main thing with pausing is to allow things based on time to
|
|
// work properly when the toolkit opens a window.
|
|
|
|
int paused = 0; // Are we paused.
|
|
|
|
// From pilot.c
|
|
extern Pilot** pilot_stack;
|
|
extern int pilots;
|
|
// From main.c
|
|
extern unsigned int gtime;
|
|
|
|
static void pilots_pause(void);
|
|
static void pilots_unpause(void);
|
|
|
|
// Pause the game.
|
|
void pause(void) {
|
|
if(paused) return; // Well well.. We are paused already.
|
|
|
|
gtime -= SDL_GetTicks();
|
|
pilots_pause();
|
|
weapons_pause();
|
|
|
|
paused = 0; // We should unpause it.
|
|
}
|
|
|
|
void unpause(void) {
|
|
if(!paused) return; // We are unpaused already.
|
|
|
|
gtime += SDL_GetTicks();
|
|
pilots_unpause();
|
|
weapons_unpause();
|
|
|
|
paused = 0;
|
|
}
|
|
|
|
static void pilots_pause(void) {
|
|
int i, j;
|
|
unsigned int t = SDL_GetTicks();
|
|
for(i = 0; i < pilots; i++) {
|
|
pilot_stack[i]->tcontrol -= t;
|
|
|
|
for(j = 0; j < MAX_AI_TIMERS; j++)
|
|
pilot_stack[i]->timer[j] -= t;
|
|
}
|
|
}
|
|
|
|
static void pilots_unpause(void) {
|
|
int i, j;
|
|
unsigned int t = SDL_GetTicks();
|
|
for(i = 0; i < pilots; i++) {
|
|
pilot_stack[i]->tcontrol += t;
|
|
|
|
for(j = 0; j < MAX_AI_TIMERS; j++)
|
|
pilot_stack[i]->timer[j] += t;
|
|
}
|
|
}
|
|
|