blob: fa05df40872889865912d53d0642131a43298c7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#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;
}
inline Uint32 updateDriftOnEventReception(tick_t localCurrentTick, tick_t eventServerTick) {
//FIXME : WTF dans cette gestion de temps ??? Ou est l'implémentation réelle telle que décrite dans archi.txt ??
return localCurrentTick - eventServerTick;
}
|