From: Antoine Jacquet Date: Fri, 23 Feb 2007 23:00:00 +0000 (+0100) Subject: version 0.6 X-Git-Tag: v0.6 X-Git-Url: http://royale.zerezo.com/git/?p=zeRace;a=commitdiff_plain;h=a649266e00696290ecf09f15c9dfa09f1cd35244 version 0.6 * added some tracks from pyRacerz (thank you Julien) * fixed network initialization issue for Win32 * fixed function overflow for Win32 * fixed color issue with tires slide * added scripts to easily launch bots --- diff --git a/CHANGELOG b/CHANGELOG index a8daa9a..430e1f4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,12 @@ Change log file for zeRace +version 0.6 (2007-02-24) + * added some tracks from pyRacerz (thank you Julien) + * fixed network initialization issue for Win32 + * fixed function overflow for Win32 + * fixed color issue with tires slide + * added scripts to easily launch bots + version 0.5 (2005-04-16) * added "formula" track (thank you Julien) * added some new car sprites (thank you Julien) diff --git a/Makefile b/Makefile index a359dba..b899460 100644 --- a/Makefile +++ b/Makefile @@ -4,25 +4,25 @@ SDLCONFIG=sdl-config all:zeRace server bot_anticip zeRace:zeRace.c network.h sdl.o car.o tracklist.o $(ICON) - $(CC) -ansi -Wall -o zeRace$(EXT) zeRace.c sdl.o car.o tracklist.o $(ICON) `$(SDLCONFIG) --cflags --libs` -lSDL_net -lSDL_mixer -lSDL_image -lSDL_gfx -L. + $(CC) -o zeRace$(EXT) zeRace.c sdl.o car.o tracklist.o $(ICON) `$(SDLCONFIG) --cflags --libs` -lSDL_net -lSDL_mixer -lSDL_image -lSDL_gfx -L. server:server.c network.h sdl.o car.o tracklist.o - $(CC) -ansi -Wall -o server$(EXT) server.c sdl.o car.o tracklist.o `$(SDLCONFIG) --cflags --libs` -lSDL_net -lSDL_image -L. + $(CC) -o server$(EXT) server.c sdl.o car.o tracklist.o `$(SDLCONFIG) --cflags --libs` -lSDL_net -lSDL_image -L. bot_anticip:bot_anticip.c bot.o sdl.o car.o tracklist.o - $(CC) -ansi -Wall -o bot_anticip$(EXT) bot_anticip.c bot.o sdl.o car.o tracklist.o `$(SDLCONFIG) --cflags --libs` -lSDL_net -lSDL_image -L. + $(CC) -o bot_anticip$(EXT) bot_anticip.c bot.o sdl.o car.o tracklist.o `$(SDLCONFIG) --cflags --libs` -lSDL_net -lSDL_image -L. sdl.o:sdl.c sdl.h - $(CC) -ansi -Wall -c sdl.c `$(SDLCONFIG) --cflags` + $(CC) -c sdl.c `$(SDLCONFIG) --cflags` car.o:car.c car.h sdl.h - $(CC) -ansi -Wall -c car.c `$(SDLCONFIG) --cflags` + $(CC) -c car.c `$(SDLCONFIG) --cflags` tracklist.o:tracklist.c tracklist.h - $(CC) -ansi -Wall -c tracklist.c + $(CC) -c tracklist.c bot.o:bot.c sdl.o car.o tracklist.o - $(CC) -ansi -Wall -c bot.c `$(SDLCONFIG) --cflags` + $(CC) -c bot.c `$(SDLCONFIG) --cflags` icon.o:icon.rc $(WINDRES) -i icon.rc -o icon.o diff --git a/README b/README index 699c954..10f9f9e 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -zeRace 0.5 +zeRace 0.6 site: http://royale.zerezo.com/zerace/ mail: royale@zerezo.com @@ -17,3 +17,20 @@ Then launch as many bots as you want : ./bot_anticip localhost 3600 16 Then you can join your own server in zeRace in the "network game" section. If you are under Windows, replace by "server.exe" and "bot_anticip.exe" in MS-DOS commands. +You can also use the "local-server-with-bots.*" scripts. + +windows: +Take a look at the files stdout.txt and stderr.txt, they can give useful informations. +You need to use the task manager if you want to stop the server. + +syntax: +./server 'server_name' nb_laps network_speed (public|private) (col|nocol) + server_name : the name of the server + nb_laps : the number of laps to complete for each race + network_speed : frequency of network messages (1 for fast network, 10 for slow network...) + private : this server will not be listed in the 'internet games' + col : the server will compute collisions between cars +./bot_anticip host port random + host : host or ip of the server to connect to + port : port number of the server to connect to + random : frequency of random moves (0 = no random moves, 1 = only random, 1000 = 1/1000 random moves) diff --git a/bot_anticip.c b/bot_anticip.c index 424e875..1d5ec2d 100644 --- a/bot_anticip.c +++ b/bot_anticip.c @@ -88,6 +88,60 @@ void bot_ia(char *trackname,struct _car *car,SDL_Surface *fun,int *ku,int *kd,in s=car->speed/3.3+0.4; og=120; } + else if (strcmp(trackname,"wave")==0) + { + a1=150; + a2=130; + o=1.5; + m=0.1; + s=car->speed/3.3+0.4; + og=120; + } + else if (strcmp(trackname,"bio")==0) + { + a1=190; + a2=180; + o=0.3; + m=0.1; + s=car->speed/3.3+0.4; + og=120; + } + else if (strcmp(trackname,"city")==0) + { + a1=150; + a2=130; + o=1.2; + m=0.1; + s=car->speed/3.3+0.4; + og=120; + } + else if (strcmp(trackname,"desert")==0) + { + a1=150; + a2=130; + o=1.0; + m=0.1; + s=car->speed/3.3+0.4; + og=120; + } + else if (strcmp(trackname,"http")==0) + { + a1=190; + a2=170; + o=1.2; + m=0.3; + s=car->speed/3.4+0.4; + og=240; + } + else if (strcmp(trackname,"kart")==0) + { + a1=180; + a2=160; + o=0.8; + m=0.8; + s=car->speed/3.3+0.4; + og=120; + } /* some default values that may work on some tracks */ else { diff --git a/local-server-with-bots.bat b/local-server-with-bots.bat new file mode 100755 index 0000000..9ce4dff --- /dev/null +++ b/local-server-with-bots.bat @@ -0,0 +1,24 @@ +@echo off +echo Launching server... +start server.exe "My private server" 5 1 private col +ping localhost -n 2 > NUL +echo Launching bot(0)... +start bot_anticip.exe localhost 3600 0 +ping localhost -n 2 > NUL +echo Launching bot(5)... +start bot_anticip.exe localhost 3600 5 +ping localhost -n 2 > NUL +echo Launching bot(10)... +start bot_anticip.exe localhost 3600 10 +ping localhost -n 2 > NUL +echo Launching bot(15)... +start bot_anticip.exe localhost 3600 15 +ping localhost -n 2 > NUL +echo Launching bot(20)... +start bot_anticip.exe localhost 3600 20 +ping localhost -n 2 > NUL +echo A local server has been launched with 5 bots. +echo You can now join it with zeRace in the network menu. +echo When you have finished, you can terminate the server with the task manager. +echo. +pause \ No newline at end of file diff --git a/local-server-with-bots.sh b/local-server-with-bots.sh new file mode 100755 index 0000000..5b89fcd --- /dev/null +++ b/local-server-with-bots.sh @@ -0,0 +1,22 @@ +echo 'Launching server...' +./server "My private server" 5 1 private col &>/dev/null & +sleep 1 +echo 'Launching bot(0)...' +./bot_anticip localhost 3600 0 &>/dev/null & +sleep 1 +echo 'Launching bot(5)...' +./bot_anticip localhost 3600 5 &>/dev/null & +sleep 1 +echo 'Launching bot(10)...' +./bot_anticip localhost 3600 10 &>/dev/null & +sleep 1 +echo 'Launching bot(15)...' +./bot_anticip localhost 3600 15 &>/dev/null & +sleep 1 +echo 'Launching bot(20)...' +./bot_anticip localhost 3600 20 &>/dev/null & +sleep 1 +echo A local server has been launched with 5 bots. +echo You can now join it with zeRace in the network menu. +echo When you have finished, you can terminate the server. +echo \ No newline at end of file diff --git a/network.h b/network.h index 1d3b0f7..93ed5a9 100644 --- a/network.h +++ b/network.h @@ -4,4 +4,4 @@ #define MAX_LAG 500 #define MAX_CLIENTS 32 #define PORT "3600" -#define VERSION "0.5" +#define VERSION "0.6" diff --git a/tracks/bio.png b/tracks/bio.png new file mode 100644 index 0000000..dc7eab9 Binary files /dev/null and b/tracks/bio.png differ diff --git a/tracks/bio_function.png b/tracks/bio_function.png new file mode 100644 index 0000000..43c429a Binary files /dev/null and b/tracks/bio_function.png differ diff --git a/tracks/city.png b/tracks/city.png new file mode 100644 index 0000000..f72b026 Binary files /dev/null and b/tracks/city.png differ diff --git a/tracks/city_function.png b/tracks/city_function.png new file mode 100644 index 0000000..c7fe1c1 Binary files /dev/null and b/tracks/city_function.png differ diff --git a/tracks/desert.png b/tracks/desert.png new file mode 100644 index 0000000..cdcdf72 Binary files /dev/null and b/tracks/desert.png differ diff --git a/tracks/desert_function.png b/tracks/desert_function.png new file mode 100644 index 0000000..1f74d2d Binary files /dev/null and b/tracks/desert_function.png differ diff --git a/tracks/formula.png b/tracks/formula.png index 2a64cc3..0fcc252 100644 Binary files a/tracks/formula.png and b/tracks/formula.png differ diff --git a/tracks/http.png b/tracks/http.png new file mode 100644 index 0000000..b24ce58 Binary files /dev/null and b/tracks/http.png differ diff --git a/tracks/http_function.png b/tracks/http_function.png new file mode 100644 index 0000000..a38ede6 Binary files /dev/null and b/tracks/http_function.png differ diff --git a/tracks/kart.png b/tracks/kart.png new file mode 100644 index 0000000..3bdc0b2 Binary files /dev/null and b/tracks/kart.png differ diff --git a/tracks/kart_function.png b/tracks/kart_function.png new file mode 100644 index 0000000..07dc356 Binary files /dev/null and b/tracks/kart_function.png differ diff --git a/tracks/list.txt b/tracks/list.txt index 4baf3ea..8b8f813 100644 --- a/tracks/list.txt +++ b/tracks/list.txt @@ -5,7 +5,7 @@ ICFP Programming Contest 450 655 180 -913 +892 inz first @@ -25,8 +25,8 @@ Royale 435 215 180 -1132 -Royale +1130 +Julien hairpins Hairpins @@ -35,8 +35,8 @@ ICFP Programming Contest 505 665 0 -2824 -ukero +2239 +Julien simple Simple @@ -55,8 +55,68 @@ Royale 678 686 0 -1384 -ukero +1363 +Julien + +bio +Bio +Jujucece +0.1 +930 +500 +270 +1310 +Royale + +city +City +Jujucece +0.1 +106 +358 +90 +595 +anonymous + +desert +Desert +Jujucece +0.1 +680 +487 +80 +1888 +anonymous + +http +HTTP +Jujucece +0.1 +520 +70 +180 +941 +anonymous + +kart +Kart +Jujucece +0.1 +370 +725 +0 +2025 +Royale + +wave +Wave +Jujucece +0.1 +630 +380 +180 +1860 +anonymous formula Formula @@ -65,5 +125,5 @@ Ju 350 330 220 -1294 -inz +790 +FRD diff --git a/tracks/wave.png b/tracks/wave.png new file mode 100644 index 0000000..dc6330f Binary files /dev/null and b/tracks/wave.png differ diff --git a/tracks/wave_function.png b/tracks/wave_function.png new file mode 100644 index 0000000..b56a32c Binary files /dev/null and b/tracks/wave_function.png differ diff --git a/zeRace.c b/zeRace.c index a4f5252..b371de4 100644 --- a/zeRace.c +++ b/zeRace.c @@ -1,5 +1,5 @@ /* - * zeRace 0.5, a funny retro racing game + * zeRace 0.6, a funny retro racing game * http://royale.zerezo.com/zerace/ * * Copyright (C) 2004 Antoine Jacquet @@ -49,6 +49,7 @@ #define C_RED SDL_MapRGB(screen->format,255,0,0) #define C_ORANGE SDL_MapRGB(screen->format,255,200,0) #define C_YELLOW SDL_MapRGB(screen->format,255,255,100) +#define T_BLACK SDL_MapRGB(cir->format,0,0,0) /* tracklist */ struct _tracklist *tracklist; @@ -344,6 +345,21 @@ void zeRace_init() signal(SIGINT,zeRace_exit); signal(SIGTERM,zeRace_exit); + /* initialize SDL */ + if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)<0) + { + fprintf(stderr,"could not initialize SDL : %s\n",SDL_GetError()); + zeRace_exit(); + } + atexit(SDL_Quit); + + /* initialize SDLNet */ + if (SDLNet_Init()==-1) + { + fprintf(stderr,"could not initialize SDLNet : %s\n",SDLNet_GetError()); + zeRace_exit(); + } + /* read the user configuration file */ zeRace_read_config(); @@ -367,19 +383,6 @@ void zeRace_init() srand(time(NULL)); - if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)<0) - { - fprintf(stderr,"could not initialize SDL : %s\n",SDL_GetError()); - zeRace_exit(); - } - atexit(SDL_Quit); - - if (SDLNet_Init()==-1) - { - fprintf(stderr,"could not initialize SDLNet : %s\n",SDLNet_GetError()); - zeRace_exit(); - } - packet=SDLNet_AllocPacket(1024); if (!packet) { @@ -414,7 +417,7 @@ void zeRace_init() /* send the best time for this race to the web server */ -void zeRace_send_time(struct _record record) +void zeRace_send_time(struct _record *record) { IPaddress ip; TCPsocket tcpsock; @@ -438,7 +441,7 @@ void zeRace_send_time(struct _record record) int len,result; /* if the best time is small enought to save all keys, send it */ - if (record.time>=MAXRECORDKEYS) return; + if (record->time>=MAXRECORDKEYS) return; printf("sending time... "); fflush(stdout); @@ -456,8 +459,8 @@ void zeRace_send_time(struct _record record) return; } - temp=(char *)malloc(strlen(msg1)+strlen(config.pseudo)+strlen(msg2)+strlen(config.url)+strlen(msg3)+strlen(tracklist->name)+strlen(msg4)+10+strlen(msg5)+10+strlen(msg6)+10+strlen(msg7)+10+strlen(msg8)+10+strlen(msg9)+strlen(record.keys)+100); - sprintf(temp,"%s%s%s%s%s%s%s%d%s%f%s%f%s%f%s%f%s%s\n",msg1,config.pseudo,msg2,config.url,msg3,tracklist->name,msg4,record.time,msg5,record.x,msg6,record.y,msg7,record.speed,msg8,record.angle,msg9,record.keys); + temp=(char *)malloc(strlen(msg1)+strlen(config.pseudo)+strlen(msg2)+strlen(config.url)+strlen(msg3)+strlen(tracklist->name)+strlen(msg4)+10+strlen(msg5)+10+strlen(msg6)+10+strlen(msg7)+10+strlen(msg8)+10+strlen(msg9)+strlen(record->keys)+100); + sprintf(temp,"%s%s%s%s%s%s%s%d%s%f%s%f%s%f%s%f%s%s\n",msg1,config.pseudo,msg2,config.url,msg3,tracklist->name,msg4,record->time,msg5,record->x,msg6,record->y,msg7,record->speed,msg8,record->angle,msg9,record->keys); len=strlen(temp); result=SDLNet_TCP_Send(tcpsock,temp,len); @@ -634,7 +637,7 @@ void zeRace_launch(int alltime,int go) SDLNet_UDP_Send(udpsock,-1,packet); SDL_Flip(screen); } - zeRace_send_time(best); + zeRace_send_time(&best); free_mem(); return; default: @@ -727,7 +730,7 @@ void zeRace_launch(int alltime,int go) } else /* end of this network race */ { - zeRace_send_time(best); + zeRace_send_time(&best); free_mem(); return; } @@ -939,13 +942,13 @@ void zeRace_launch(int alltime,int go) /* display tires slide */ if (config.tire) { - putpixel(cir,car.x+cos(car.angle)*car.w/3-sin(car.angle)*4,car.y+sin(car.angle)*car.h/3+cos(car.angle)*4,C_BLACK); - putpixel(cir,car.x+cos(car.angle)*car.w/3+sin(car.angle)*4,car.y+sin(car.angle)*car.h/3-cos(car.angle)*4,C_BLACK); + putpixel(cir,car.x+cos(car.angle)*car.w/3-sin(car.angle)*4,car.y+sin(car.angle)*car.h/3+cos(car.angle)*4,T_BLACK); + putpixel(cir,car.x+cos(car.angle)*car.w/3+sin(car.angle)*4,car.y+sin(car.angle)*car.h/3-cos(car.angle)*4,T_BLACK); /* if we are braking the slide is larger */ if (kd) { - putpixel(cir,car.x+cos(car.angle)*car.w/3-sin(car.angle)*3,car.y+sin(car.angle)*car.h/3+cos(car.angle)*3,C_BLACK); - putpixel(cir,car.x+cos(car.angle)*car.w/3+sin(car.angle)*3,car.y+sin(car.angle)*car.h/3-cos(car.angle)*3,C_BLACK); + putpixel(cir,car.x+cos(car.angle)*car.w/3-sin(car.angle)*3,car.y+sin(car.angle)*car.h/3+cos(car.angle)*3,T_BLACK); + putpixel(cir,car.x+cos(car.angle)*car.w/3+sin(car.angle)*3,car.y+sin(car.angle)*car.h/3-cos(car.angle)*3,T_BLACK); } } } @@ -965,7 +968,7 @@ void zeRace_launch(int alltime,int go) { print(screen,WIDTH/2-strlen("Timeout !")*5,HEIGHT/2-10,"Timeout !"); SDL_Flip(screen); - zeRace_send_time(best); + zeRace_send_time(&best); free_mem(); return; }