blob: 896b973cac2b54b5f1e6796d64c1b79fd9ce2fd7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#include "timing.h"
inline tick_t getGameCurrentTick(Uint32 startTime_ms) {
/* char buf[128];
sprintf(buf, "SDL_GetTicks()==%i, startTime_ms==%i, TICK_DURATION_MS==%i", SDL_GetTicks(), startTime_ms, TICK_DURATION_MS);
logs(LOG_DEBUG, buf);*/
tick_t t = SDL_GetTicks()-startTime_ms; //FIXME Débordements possibles ?!?
return t/TICK_DURATION_MS;
}
inline int waitForNextTick(Uint32 timeBefore_ms, Uint32 drift_ms) {
int delay_ms;
delay_ms=TICK_DURATION_MS-(SDL_GetTicks()-timeBefore_ms)+drift_ms;
if (delay_ms>0) {
SDL_Delay(delay_ms); //TODO Si le client rame trop, faut décrocher la partie
return delay_ms;
}
return 0;
}
|