Bak wrote: |
(probably better off making the finish line a safe zone so the client will send a packet as soon as he enters) |
Code: Show/Hide local void posUpdate(Player *p, byte *data, int len)
{ race_pdata *rpd; struct C2SPosition *pos = (struct C2SPosition *)data; race_adata *ad = P_ARENA_DATA(p->arena, adkey); rpd = PPDATA(p, pdkey); if (p->arena == NULL) return; if (ad->status <= READY) return; if (rpd->status == PRE_CHECKPOINT) { if(checkPos(CHECKPOINT, pos->x >> 4, pos->y >> 4)) { long dT = current_millis() - ad->startTime; checkPoint(p, dT); } } else if (rpd->status == POST_CHECKPOINT) { if(checkPos(FINISH, pos->x >> 4, pos->y >> 4)) { long dT = current_millis() - ad->startTime; addFinish(p, dT); } } } local int checkPos(int loc,int x, int y) { switch(loc) { case CHECKPOINT: return (abs(x - 506) < 20) && y > 655; break; case FINISH: return (abs(x - 506) < 20) && y < 361; break; } return 0; } |
Bak wrote: |
all current_ticks does is call GetTickCount or gettimeofday... cut out the middle man |