Index: game.c
===================================================================
RCS file: /home/cvs/tunneler/tunneler/game.c,v
retrieving revision 1.2
diff -u -r1.2 game.c
--- game.c	20 Jan 2005 19:06:19 -0000	1.2
+++ game.c	20 Jan 2005 21:02:05 -0000
@@ -8,6 +8,7 @@
 _u8	surface[SURFACE_WIDTH][SURFACE_HEIGHT];
 BULLET	bullets;
 SPOS	sprites;
+BOT     ferda;
 
 #define	IF_INTERSEC(x1,y1,w1,h1,x2,y2,w2,h2) \
 	if (((x1)+(w1) > (x2)) && ((y1)+(h1) > (y2)) && ((x1) <= (x2)+(w2)) && ((y1) <= (y2)+(h2)))
@@ -242,9 +243,8 @@
 }
 
 /* 
-   	FERDA
+   	FERDA (da ultimate NPC)
 */
-#if 0
 void	runferda(void)
 {
 	BOT	*b = &ferda;
@@ -252,19 +252,25 @@
 	_s16	x_add, y_add;
 	SPOS 	new_pos = b->current_pos, *np = &new_pos, *cp = &(b->current_pos);
 
-	printf("mypos: %d %d\n", b->x, b->y);
+	/*printf("mypos: %d %d\n", b->x, b->y);*/
 	surface_drc_sprite(cp, G_DIRT, G_EMPTY);
 	for (i=0; i<8; i+=2) {
-		conv_angle(i, b->speed, &x_add, &y_add);
+		conv_angle(i, 24 /* b->speed, but wider radius */, &x_add, &y_add);
 		conv_coords(b->x+x_add, b->y+y_add, 1, gfx_home, np);
-		if (! surface_calc_collision(np, G_STONE|G_PLAYER|G_HOME)) {
-			eat = surface_calc_collision(np, G_DIRT);
-			if (eat < min) {
-				min = eat;
-				best = i;
-			} 
-			if (eat > max) 
-				max = eat;
+
+		if (surface_calc_collision(np, G_STONE|G_PLAYER|G_HOME))
+			continue;
+
+		eat = surface_calc_collision(np, G_DIRT);
+		if (eat == np->sprite->width * np->sprite->height /* all dirt */)
+			continue;
+
+		if (eat < min) {
+			min = eat;
+			best = i;
+		}
+		if (eat > max) {
+			max = eat;
 		}
 	}
 	
@@ -277,7 +283,6 @@
 		surface_drc_sprite(cp, G_STONE, 0);
 	}
 }
-#endif
 
 
 #define	MIN(a,b) ((a)<(b)?(a):(b))	/*predefinovat na inlajn! */
@@ -522,6 +527,30 @@
 }
 
 
+void    init_ferda(BOT *bot)
+{
+	while (1) {
+		bot->x = mkrand((SURFACE_WIDTH - 40) * XPOINTS_PERCHAR);
+		bot->y = mkrand((SURFACE_HEIGHT - 20) * YPOINTS_PERCHAR);
+		conv_coords(bot->x, bot->y, 1, gfx_home, &(bot->current_pos));
+		if (!surface_calc_collision(&(bot->current_pos), G_STONE|G_HOME))
+			break;
+	}
+	bot->speed = 4;
+	bot->current_pos.gfxid = GFX_HOME_ID;
+	bot->current_pos.color = 7;
+	bot->dir = 0;
+	add_to_list_end(sprites, (&(bot->current_pos)));
+}
+
+void    init_players(void)
+{
+	init_list(players);
+
+	if (do_ferda) init_ferda(&ferda);
+}
+
+
 void	init_player(plr_t *p, _u32 id)
 {
 	p->tank.score = 0;
Index: game.h
===================================================================
RCS file: /home/cvs/tunneler/tunneler/game.h,v
retrieving revision 1.2
diff -u -r1.2 game.h
--- game.h	20 Jan 2005 19:06:19 -0000	1.2
+++ game.h	20 Jan 2005 20:30:13 -0000
@@ -77,12 +77,10 @@
 	TANK	*owner;
 } BULLET;
 
-#if 0
 typedef struct _bot_t {
 	SPOS	current_pos;
 	_u16	x, y, speed, dir;
 } BOT;
-#endif
 
 
 extern	_u8 surface[SURFACE_WIDTH][SURFACE_HEIGHT];
@@ -92,6 +90,7 @@
 void	player_move (struct _plr_t *p, _u8 direction, _u8 speed, _u8 firing);
 void	calc_view(TANK *t, VIEWPOINT *v);
 void	init_surface (void);
+void	init_players (void);
 void	init_player (struct _plr_t *p, _u32 id);
 void	finit_player (struct _plr_t *p);
 void	runferda(void);
Index: server.c
===================================================================
RCS file: /home/cvs/tunneler/tunneler/server.c,v
retrieving revision 1.2
diff -u -r1.2 server.c
--- server.c	20 Jan 2005 19:06:19 -0000	1.2
+++ server.c	20 Jan 2005 20:35:47 -0000
@@ -21,6 +21,9 @@
 plr_t 	players;
 _u16	num_players;
 
+/* Options */
+int     do_ferda = 0;
+
 GFXOBJ	*gfx_tank, *gfx_bullet, *gfx_home, *gfx_explosion;
 
 /**********/
@@ -118,6 +121,7 @@
 	foreachsafe(p, n, players)
 		send_update(p);
 	bullets_update();
+	if (do_ferda) runferda();
 			
 	tv.tv_sec = 0;
 	tv.tv_usec = TICKMS*1000;
@@ -160,7 +164,7 @@
 	FD_SET(server->fd, &fdr);
 
 	init_surface();
-	init_list(players);
+	init_players();
 	num_players = 0;
 	tv.tv_sec = tv.tv_usec = 0;
 
@@ -190,7 +194,7 @@
 	CONSOLE("tunneler server udp-%03d resolution %dx%d starting ...", version, VIEWPNT_WIDTH, VIEWPNT_HEIGHT);
 
 	if (argc < 3) {
-		printf("tunneler server -- 2005,ment\nusage: %s <udp_port> <tcp_port>\n", argv[0]);
+		printf("tunneler server -- 2005,ment\nusage: %s <udp_port> <tcp_port> [opts]\n", argv[0]);
 		exit(1);
 	}
 	gfx_tank = load_gfxobj("tank", 8);
@@ -199,6 +203,7 @@
 	gfx_home = load_gfxobj("home", 2);
 
 	srandom(time(NULL));
+
 	uport = atoi(argv[1]);
 	tport = atoi(argv[2]);
 	while (1) {
@@ -212,8 +217,11 @@
 			break;
 		}
 	}
-	
 	CONSOLE("bound ports %d/tcp and %d/udp", tport, uport);
+
+	/* Options */
+	do_ferda = (argv[3] && strchr(argv[3], 'f') != NULL);
+
 	mainloop();
 	return 0;
 }
Index: server.h
===================================================================
RCS file: /home/cvs/tunneler/tunneler/server.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 server.h
--- server.h	20 Jan 2005 17:39:53 -0000	1.1.1.1
+++ server.h	20 Jan 2005 20:34:54 -0000
@@ -22,6 +22,8 @@
 extern	plr_t players;
 extern _u32 tick;
 
+extern int do_ferda;
+
 #define MAXPLAYERS	8
 #define GAME_INIT	1
 #define GAME_RUN	2
