/* robot configuration */
sprintf(config.pseudo,"\"%s\" bot(%d)",bot_name(),aleas);
- config.color=rand()%12;
+ config.color=rand()%16;
- if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)<0)
+ if (SDL_Init(0)<0)
{
fprintf(stderr,"could not initialize SDL : %s\n",SDL_GetError());
zeRace_exit();
net.keys[net.time+1]='\0';
}
+ /* move the car */
+ move_car(&car,(ku<<3 | kd<<2 | kl<<1 | kr),fun);
+
delay=DELAY;
/* if we are in network mode */
if (udpsock!=NULL)
lastack=clienttime;
}
}
+ else if (strcmp(packet->data,"collision")==0)
+ {
+ net.time=-1;
+ net.keys[0]='\0';
+ lastack=SDLNet_Read32(packet->data+strlen("collision")+1);
+ car.x=(float)SDLNet_Read32(packet->data+strlen("collision")+1+4)/65536-100;
+ car.y=(float)SDLNet_Read32(packet->data+strlen("collision")+1+4+4)/65536-100;
+ car.speed=(float)SDLNet_Read32(packet->data+strlen("collision")+1+4+4+4)/65536-100;
+ car.angle=(float)SDLNet_Read32(packet->data+strlen("collision")+1+4+4+4+4)/65536-100;
+ }
else /* end of this network race */
{
SDL_FreeSurface(cir);
tmp+=strlen(tmp)+1;
SDLNet_Write32(lastack,tmp);
tmp+=4;
+ SDLNet_Write32(car.x,tmp);
+ tmp+=4;
+ SDLNet_Write32(car.y,tmp);
+ tmp+=4;
strcpy(tmp,net.keys);
tmp+=strlen(tmp)+1;
packet->len=(void *)tmp-(void *)packet->data+10;
}
}
- /* move the car */
- move_car(&car,(ku<<3 | kd<<2 | kl<<1 | kr),fun);
-
/* let the system breath */
SDL_Delay(delay);
tmp+=strlen(tmp)+1;
go=*tmp++;
printf("server asked for track : %s\n",tmp);
- while (tracklist->next!=loopcheck) if (strcmp(tracklist->name,tmp)==0) break; else tracklist=tracklist->next;
+ do if (strcmp(tracklist->name,tmp)==0) break; else tracklist=tracklist->next; while (tracklist!=loopcheck);
if (strcmp(tracklist->name,tmp)!=0)
{
fprintf(stderr,"unknown track : %s\n",tmp);