Update of /cvsroot/netrek/server/Vanilla/robots In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv26631/robots Modified Files: basep.c inl.c inlcmds.c inlcomm.c inldefs.h mars.c marsdefs.h marsmove.c newbie.c pret.c puck.c puckmove.c rmove.c roboshar.c robotII.c Added Files: puckmove.h roboshar.h Log Message: merge from jerub darcs 2006-05-12 Index: mars.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/mars.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mars.c 22 Apr 2006 02:16:46 -0000 1.3 +++ mars.c 12 May 2006 03:44:49 -0000 1.4 @@ -14,15 +14,15 @@ #include "copyright.h" #include <stdio.h> #include <stdlib.h> -#include <sys/types.h> -#include <sys/time.h> +#include <time.h> #include <signal.h> -#include <setjmp.h> +#include <unistd.h> #include "defs.h" #include "struct.h" #include "data.h" -#include "marsdefs.h" #include "proto.h" +#include "roboshar.h" +#include "marsdefs.h" #define DOG_STATS ".dog_players" @@ -54,6 +54,7 @@ int closefast; /* approach speed (soft turn) */ void cleanup(); +void config(); void greeting() { @@ -106,7 +107,7 @@ openmem(1); readsysdefaults(); - sprintf(DogStats,"%s/%s\0",LOCALSTATEDIR,DOG_STATS); + sprintf(DogStats,"%s/%s",LOCALSTATEDIR,DOG_STATS); if ( (pno = pickslot(QU_ROBOT)) < 0) exit(0); me = &players[pno]; @@ -153,7 +154,7 @@ } -config() +void config() { int i; FILE* f; @@ -195,7 +196,7 @@ #define IND 0 - sprintf(TournMap_File,"%s/%s\0",SYSCONFDIR,TOURNMAP); + sprintf(TournMap_File,"%s/%s",SYSCONFDIR,TOURNMAP); f = fopen(TournMap_File,"r"); if (f == NULL) { Index: basep.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/basep.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- basep.c 22 Apr 2006 02:16:46 -0000 1.2 +++ basep.c 12 May 2006 03:44:48 -0000 1.3 @@ -27,6 +27,8 @@ #include "defs.h" #include "struct.h" #include "data.h" +#include "proto.h" +#include "roboshar.h" #include "basepdefs.h" int debug=0; @@ -72,8 +74,13 @@ void cleanup(int); void checkmess(int); -int start_internal(); -int obliterate(); +int rprog(char *login, char *monitor); +void start_internal(); +void exitRobot(); +void obliterate(int wflag, char kreason); +void check_robots_only(); +void startrobot(int num, char *s, char *h, char *log, int dg, int base, int def); +void fix_planets(); void reaper(sig) @@ -95,7 +102,6 @@ int team = 4; int pno; int class; /* ship class 8/9/91 TC */ - int i; if (gethostname(hostname, 64) != 0) { perror("gethostname"); @@ -106,6 +112,7 @@ getpath(); (void) SIGNAL(SIGCHLD, reaper); openmem(1); + do_message_post_set(check_command); strcpy(robot_host,REMOTEHOST); readsysdefaults(); SIGNAL(SIGALRM, checkmess); /*the def signal is needed - MK */ @@ -165,7 +172,6 @@ void checkmess(int unused) { int shmemKey = PKEY; - int i; HANDLE_SIG(SIGALRM,checkmess); me->p_ghostbuster = 0; /* keep ghostbuster away */ @@ -208,10 +214,10 @@ /* check to see if all robots in the game. If so tell them to exit */ -check_robots_only() +void check_robots_only() { - register i; - register struct player *j; + int i; + struct player *j; for (i = 0, j = players; i < MAXPLAYER; i++, j++) { if (j->p_status == PFREE) @@ -233,9 +239,7 @@ /* this is by no means foolproof */ -int -rprog(login, monitor) - char *login, *monitor; +int rprog(char *login, char *monitor) { int v; @@ -249,10 +253,10 @@ /* here we want to make sure everything is fuel and repair */ -fix_planets() +void fix_planets() { - register i; - register struct planet *j; + int i; + struct planet *j; oldplanets = (struct planet *) malloc(sizeof(struct planet) * MAXPLANETS); MCOPY(planets, oldplanets, sizeof(struct planet) * MAXPLANETS); @@ -266,8 +270,8 @@ int num_players() { - register i; - register struct player *j; + int i; + struct player *j; int c = 0; for (i = 0, j = players; i < MAXPLAYER; i++, j++) if (j->p_status != PFREE) @@ -280,7 +284,7 @@ char *comm; struct message *mess; { - register i; + int i; int sv; char buf[80], team[10], query[20], host[60], log[4], extra[80], desc[32]; int num; @@ -311,10 +315,10 @@ num = 1; def = 1; } else - return; + return 0; } else { /* Start iggy, hoser, ... */ if (sv == 2) start_internal(team); - return; + return 0; } } if (strncmp(team, "fed", 3) == 0) { @@ -335,17 +339,17 @@ strcpy(team, "-To"); } else { messOne(255,roboname,from,"Unknown team name \"%s\"", team); - return; + return 0; } if (num_players() + num > MAXPLAYER) { messOne(255,roboname,from,"Too many players, sorry."); - return; + return 0; } #ifdef nodef if (teami == players[from].p_team) { messOne(255,roboname,from,"Wrong team, pal."); - return; + return 0; } #endif @@ -382,13 +386,14 @@ messAll(255,roboname,buf); startrobot(num, team, sv >= 4 ? host : NULL, sv > 4 ? log : NULL, dg, base, def); + return 0; } char * namearg() { - register i, k = 0; - register struct player *j; + int i, k = 0; + struct player *j; char *name; int namef = 1; @@ -413,16 +418,12 @@ } } -int -startrobot(num, s, h, log, dg, base, def) - int num; - char *s, *h, *log; - int dg, base, def; +void startrobot(int num, char *s, char *h, char *log, int dg, int base, int def) { char *remotehost; char command[256]; char logc[256]; - register i; + int i; if (h) remotehost = h; @@ -457,16 +458,16 @@ if (fork() == 0) { SIGNAL(SIGALRM, SIG_DFL); - execl("/bin/sh", "sh", "-c", command, 0); + execl("/bin/sh", "sh", "-c", command, (char *) NULL); perror("basep'execl"); _exit(1); } sleep(5); } - return 1; + return; } -start_internal(type) +void start_internal(type) char *type; { char *argv[6]; @@ -530,7 +531,7 @@ exitRobot(); } -exitRobot() +void exitRobot() { SIGNAL(SIGALRM, SIG_IGN); if (me != NULL && me->p_team != ALLTEAM) { @@ -549,13 +550,10 @@ } -obliterate(wflag, kreason) - int wflag; - char kreason; +void obliterate(int wflag, char kreason) { /* 0 = do nothing to war status, 1= make war with all, 2= make peace with all */ struct player *j; - int i, k; /* clear torps and plasmas out */ MZERO(torps, sizeof(struct torp) * MAXPLAYER * (MAXTORP + MAXPLASMA)); Index: rmove.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/rmove.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- rmove.c 23 Apr 2006 12:47:45 -0000 1.2 +++ rmove.c 12 May 2006 03:44:49 -0000 1.3 @@ -3,11 +3,14 @@ #include "copyright.h" #include <stdio.h> +#include <stdlib.h> #include <signal.h> #include <math.h> #include "defs.h" #include "struct.h" #include "data.h" +#include "proto.h" +#include "roboshar.h" #define SIZEOF(s) (sizeof (s) / sizeof (*(s))) @@ -115,6 +118,12 @@ u_char getcourse(); char *robo_message(); char *termie_message(); /* added 8/2/91 TC */ +void exitRobot(); +int phaser_plasmas(); +void go_home(struct Enemy *ebuf); +int do_repair(); +int isTractoringMe(struct Enemy *enemy_buf); +int projectDamage(int eNum, int *dirP); char roboname[15]; @@ -128,7 +137,7 @@ int avDir; extern struct Enemy *get_nearest(); struct Enemy *enemy_buf; - struct player *enemy; + struct player *enemy = NULL; static int roboclock = 0; static int avoid[2] = { -32, 32 }; int no_cloak; @@ -573,8 +582,7 @@ as close to them as it can, while staying in its own space. Otherwise, it will head to the center of its own space. */ -go_home(ebuf) -struct Enemy *ebuf; +void go_home(struct Enemy *ebuf) { int x, y; double dx, dy; @@ -638,7 +646,7 @@ if (! cloaker) cloak_off(); } -phaser_plasmas() +int phaser_plasmas() { struct torp *t; int myphrange; @@ -667,8 +675,7 @@ return 0; } -projectDamage(eNum, dirP) - int *dirP; +int projectDamage(int eNum, int *dirP) { register int i, j, numHits = 0, mx, my, tx, ty, dx, dy; double tdx, tdy, mdx, mdy; @@ -697,11 +704,10 @@ } if (numHits > 0) *dirP /= numHits; - return (numHits); + return numHits; } -isTractoringMe(enemy_buf) -struct Enemy *enemy_buf; +int isTractoringMe(struct Enemy *enemy_buf) { return ((enemy_buf->e_hisflags & PFTRACT) && /* bug fix: was using */ !(enemy_buf->e_hisflags & PFPRESS) && /* e_flags 6/24/92 TC */ @@ -819,9 +825,9 @@ } /* end for */ } /* end else */ if (pcount == 0) { - return (NOENEMY); /* no players in game */ + return NOENEMY; /* no players in game */ } else if (ebuf.e_info == me->p_no) { - return (0); /* no hostile players in the game */ + return 0; /* no hostile players in the game */ } else { j = &players[ebuf.e_info]; @@ -892,7 +898,6 @@ if ((polymorphic) && (j->p_ship.s_type != me->p_ship.s_type) && (j->p_ship.s_type != ATT)) { /* don't polymorph to ATT 4/8/92 TC */ extern int config(); - extern int getship(); int old_shield; int old_damage; old_shield = me->p_ship.s_maxshield; @@ -908,7 +913,7 @@ /(float)old_damage; } - return (&ebuf); + return &ebuf; } } @@ -931,11 +936,11 @@ return nearest; } -do_repair() +int do_repair() { /* Repair if necessary (we are safe) */ - register struct planet* l; + struct planet* l; int dx, dy; int dist; @@ -949,13 +954,13 @@ if ((dx < PFIREDIST) && (dy < PFIREDIST)) { if (debug) ERROR(1,( "%d) on top of hostile planet (%s)\n", me->p_no, l->pl_name)); - return(0); /* can't repair on top of hostile planets */ + return 0; /* can't repair on top of hostile planets */ } if ((int) (hypot((double) dx, (double) dy)) < PFIREDIST) { if (debug) ERROR(1,("%d) on top of hostile planet (%s)\n", me->p_no, l->pl_name)); - return(0); + return 0; } } me->p_desspeed = 0; @@ -984,7 +989,7 @@ me->p_flags &= ~PFPLLOCK; orbit(); } - return(1); + return 1; } else { /* not repair, so ignore it */ me->p_desspeed = 0; @@ -997,10 +1002,10 @@ ERROR(1,( "%d) repairing damage at %d\n", me->p_no, me->p_damage)); - return(1); + return 1; } else { - return (0); + return 0; } } @@ -1075,7 +1080,7 @@ } } *s='\0'; - return(rmessage); + return rmessage; } char* termie_message(enemy) @@ -1153,11 +1158,10 @@ } } *s='\0'; - return(tmessage); - + return tmessage; } -exitRobot() +void exitRobot() { SIGNAL(SIGALRM, SIG_IGN); if (me != NULL && me->p_team != ALLTEAM) { Index: robotII.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/robotII.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- robotII.c 22 Apr 2006 02:16:46 -0000 1.2 +++ robotII.c 12 May 2006 03:44:49 -0000 1.3 @@ -4,19 +4,21 @@ #include <stdio.h> #include <stdlib.h> -#include <sys/types.h> -#include <sys/time.h> +#include <unistd.h> +#include <time.h> #include <signal.h> -#include <setjmp.h> #include "defs.h" #include "struct.h" #include "data.h" +#include "proto.h" +#include "roboshar.h" extern int redrawall; /* maint: missing "extern" 6/22/92 TC */ extern int lastm; /* maint: missing "extern" 6/22/92 TC */ extern char roboname[15]; /* So it can be defined dynamically */ +void config(); /* lots of neat flags */ int hostile; @@ -54,7 +56,7 @@ register int i; void rmove(); int team = -1; - int bteam; + int bteam = FED; int pno; int class; /* ship class 8/9/91 TC */ @@ -301,7 +303,7 @@ } -config() +void config() { /* calc class-specific stuff */ Index: marsmove.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/marsmove.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- marsmove.c 22 Apr 2006 02:16:46 -0000 1.2 +++ marsmove.c 12 May 2006 03:44:49 -0000 1.3 @@ -25,6 +25,7 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include <signal.h> #include <math.h> #include <ctype.h> @@ -34,6 +35,8 @@ #include "defs.h" #include "struct.h" #include "data.h" +#include "proto.h" +#include "roboshar.h" #include "marsdefs.h" @@ -185,14 +188,14 @@ void reset_game(void); void reportFinal(void); void reportStanding(void); +int get_num_matches(int a, int b); void cleanup(void); +int nextFreeArena(void); void smileon(struct player* j); void do_msg_check(void); void do_stats(int who); -void do_war(void); void join(int who); void join_game(Track *track); -void mars_rules(void); int lookupshipname(char *shipname); void do_score(void); void player_maint(void); @@ -1418,7 +1421,7 @@ return; } - old_a = &arenas[track->t_arena]; + old_a = &arenas[(int) track->t_arena]; checkBadArenaNo(ano,"in teleport\n"); @@ -1704,7 +1707,7 @@ continue; /*Don't do this for dead and for puck*/ - a = &arenas[track->t_arena]; + a = &arenas[(int) track->t_arena]; /* kill torps that might distract guys in other arenas */ @@ -1938,7 +1941,6 @@ static DogStatEntry player; static int position= -1; int plfd; - int i; int entries; struct stat buf; Index: puck.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/puck.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- puck.c 22 Apr 2006 02:16:46 -0000 1.3 +++ puck.c 12 May 2006 03:44:49 -0000 1.4 @@ -10,16 +10,17 @@ #include "copyright.h" #include <stdio.h> +#include <unistd.h> #include <stdlib.h> -#include <sys/types.h> -#include <sys/time.h> +#include <time.h> #include <signal.h> -#include <setjmp.h> #include "defs.h" #include "struct.h" #include "data.h" -#include "puckdefs.h" #include "proto.h" +#include "puckdefs.h" +#include "roboshar.h" +#include "puckmove.h" #ifdef PUCK_FIRST #include <sys/sem.h> Index: pret.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/pret.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- pret.c 23 Apr 2006 10:39:10 -0000 1.3 +++ pret.c 12 May 2006 03:44:49 -0000 1.4 @@ -27,18 +27,14 @@ #include "defs.h" #include "struct.h" #include "data.h" +#include "proto.h" +#include "roboshar.h" #include "pretdefs.h" int debug=0; char *roboname = "Kathy"; -#define NUMADJ 12 -static char *adj_s[NUMADJ] = { - "VICIOUS", "RUTHLESS", "IRONFISTED", "RELENTLESS", - "MERCILESS", "UNFLINCHING", "FEARLESS", "BLOODTHIRSTY", - "FURIOUS", "DESPERATE", "FRENZIED", "RABID"}; - #define NUMNAMES 20 static char *names[NUMNAMES] = @@ -62,7 +58,7 @@ int trrange; /* tractor range 8/2/91 TC */ int ticks = 0; int oldmctl; -static realT = 0; +static int realT = 0; int pt_robots = 0; int team1=0; int team2=0; @@ -71,7 +67,6 @@ static void cleanup(int); void checkmess(int); -static void start_internal(char *type); static void obliterate(int wflag, char kreason, int killRobots); static void start_a_robot(char *team); static void stop_a_robot(void); @@ -109,7 +104,6 @@ int team = 4; int pno; int class; /* ship class 8/9/91 TC */ - int i; #ifndef TREKSERVER if (gethostname(hostname, 64) != 0) { @@ -201,7 +195,6 @@ void checkmess(int unused) { int shmemKey = PKEY; - int i; static int no_humans = 0; static int no_bots = 0; static int time_in_T = 0; @@ -257,8 +250,8 @@ /* Stop or start a robot. */ if ((ticks % ROBOCHECK) == 0) { int next_team; - int np = num_players(&next_team); - + num_players(&next_team); + if (!(ticks % ROBOEXITWAIT)) { if(debugTarget != -1) { @@ -442,7 +435,6 @@ static int rprog(char *login, char *robotHost) { - int v; char localHostName[80]; gethostname(localHostName, 80); @@ -533,8 +525,8 @@ static char * namearg(void) { - register i, k = 0; - register struct player *j; + int i, k = 0; + struct player *j; char *name; int namef = 1; @@ -579,7 +571,7 @@ return; if (pid == 0) { SIGNAL(SIGALRM, SIG_DFL); - execl("/bin/sh", "sh", "-c", command, 0); + execl("/bin/sh", "sh", "-c", command, (char *) NULL); perror("pret'execl"); _exit(1); } @@ -587,36 +579,6 @@ status->gameup |= GU_BOT_IN_GAME; } -static void start_internal(char *type) -{ - char *argv[6]; - u_int argc = 0; - - argv[argc++] = "robot"; - if ((strncmp(type, "iggy", 2) == 0) || - (strncmp(type, "hunterkiller", 2) == 0)) { - argv[argc++] = "-Ti"; - argv[argc++] = "-P"; - argv[argc++] = "-f"; /* Allow more than one */ - } else if (strncmp (type, "cloaker", 2) == 0) { - argv[argc++] = "-Ti"; - argv[argc++] = "-C"; /* Never uncloak */ - argv[argc++] = "-F"; /* Needs no fuel */ - argv[argc++] = "-f"; - } else if (strncmp (type, "hoser", 2) == 0) { - argv[argc++] = "-p"; - argv[argc++] = "-f"; - } else return; - - argv[argc] = NULL; - if (fork() == 0) { - SIGNAL(SIGALRM, SIG_DFL); - execv(Robot,argv); - perror(Robot); - _exit(1); - } -} - static void cleanup(int unused) { register struct player *j; @@ -730,7 +692,6 @@ { /* 0 = do nothing to war status, 1= make war with all, 2= make peace with all */ struct player *j; - int i, k; /* clear torps and plasmas out */ MZERO(torps, sizeof(struct torp) * MAXPLAYER * (MAXTORP + MAXPLASMA)); --- NEW FILE: roboshar.h --- /* from roboshar.c */ void robonameset(struct player *myself); void messAll(int mynum, char *name, const char *fmt, ...); u_char getcourse2(int x1, int y1, int x2, int y2); void messOne(int mynum, char *name, int who, const char *fmt, ...); /* from ntserv/commands.c */ int check_command(struct message *mess); Index: newbie.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/newbie.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- newbie.c 22 Apr 2006 02:16:46 -0000 1.3 +++ newbie.c 12 May 2006 03:44:49 -0000 1.4 @@ -27,6 +27,8 @@ #include "defs.h" #include "struct.h" #include "data.h" +#include "proto.h" +#include "roboshar.h" #include "newbiedefs.h" int debug=0; @@ -34,14 +36,6 @@ char *roboname = "Merlin"; -static char *team_s[4] = {"federation", "romulan", "klingon", "orion"}; - -#define NUMADJ 12 -static char *adj_s[NUMADJ] = { - "VICIOUS", "RUTHLESS", "IRONFISTED", "RELENTLESS", - "MERCILESS", "UNFLINCHING", "FEARLESS", "BLOODTHIRSTY", - "FURIOUS", "DESPERATE", "FRENZIED", "RABID"}; - #define NUMNAMES 20 static char *names[NUMNAMES] = @@ -70,7 +64,6 @@ static void cleanup(int); void checkmess(int); -static void start_internal(char *type); static void obliterate(int wflag, char kreason); static void start_a_robot(char *team); static void stop_a_robot(void); @@ -103,7 +96,6 @@ int team = 4; int pno; int class; /* ship class 8/9/91 TC */ - int i; #ifndef TREKSERVER if (gethostname(hostname, 64) != 0) { @@ -190,7 +182,6 @@ void checkmess(int unused) { int shmemKey = PKEY; - int i; static int no_humans = 0; HANDLE_SIG(SIGALRM,checkmess); @@ -308,8 +299,6 @@ static int rprog(char *login, char *monitor) { - int v; - if (strcmp(login, "robot!") == 0) /* if (strstr(monitor, "uci")) */ return 1; @@ -378,8 +367,8 @@ static char * namearg(void) { - register i, k = 0; - register struct player *j; + int i, k = 0; + struct player *j; char *name; int namef = 1; @@ -419,43 +408,13 @@ return; if (pid == 0) { SIGNAL(SIGALRM, SIG_DFL); - execl("/bin/sh", "sh", "-c", command, 0); + execl("/bin/sh", "sh", "-c", command, (char *) NULL); perror("newbie'execl"); _exit(1); } nb_robots++; } -static void start_internal(char *type) -{ - char *argv[6]; - u_int argc = 0; - - argv[argc++] = "robot"; - if ((strncmp(type, "iggy", 2) == 0) || - (strncmp(type, "hunterkiller", 2) == 0)) { - argv[argc++] = "-Ti"; - argv[argc++] = "-P"; - argv[argc++] = "-f"; /* Allow more than one */ - } else if (strncmp (type, "cloaker", 2) == 0) { - argv[argc++] = "-Ti"; - argv[argc++] = "-C"; /* Never uncloak */ - argv[argc++] = "-F"; /* Needs no fuel */ - argv[argc++] = "-f"; - } else if (strncmp (type, "hoser", 2) == 0) { - argv[argc++] = "-p"; - argv[argc++] = "-f"; - } else return; - - argv[argc] = NULL; - if (fork() == 0) { - SIGNAL(SIGALRM, SIG_DFL); - execv(Robot,argv); - perror(Robot); - _exit(1); - } -} - static void cleanup(int unused) { register struct player *j; @@ -514,7 +473,6 @@ { /* 0 = do nothing to war status, 1= make war with all, 2= make peace with all */ struct player *j; - int i, k; /* clear torps and plasmas out */ MZERO(torps, sizeof(struct torp) * MAXPLAYER * (MAXTORP + MAXPLASMA)); --- NEW FILE: puckmove.h --- void do_war(void); void puck_rules(void); void do_faceoff(void); Index: marsdefs.h =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/marsdefs.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- marsdefs.h 21 Mar 2005 05:23:46 -0000 1.1 +++ marsdefs.h 12 May 2006 03:44:49 -0000 1.2 @@ -8,6 +8,9 @@ #ifndef _h_marsdefs #define _h_marsdefs +void do_war(void); +void mars_rules(void); +void init_mars(void); #include "defs.h" Index: inldefs.h =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/inldefs.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- inldefs.h 21 Mar 2005 05:23:46 -0000 1.1 +++ inldefs.h 12 May 2006 03:44:49 -0000 1.2 @@ -128,5 +128,7 @@ char *message; /* Message to print */ } Inl_countdown; -#endif /* _h_inldefs */ +void start_countdown(); +void reset_inl(int); +#endif /* _h_inldefs */ Index: roboshar.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/roboshar.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- roboshar.c 22 Apr 2006 11:31:53 -0000 1.2 +++ roboshar.c 12 May 2006 03:44:49 -0000 1.3 @@ -4,11 +4,14 @@ #include "struct.h" #include "data.h" #include "proto.h" +#include "roboshar.h" #ifndef M_PI #include <math.h> #endif +extern void do_message(int recip, int group, char *address, u_char from, + const char *fmt, va_list args); /* Each robot must declare the following variables as globals */ extern int debug; @@ -102,13 +105,7 @@ va_start(args, fmt); -/* +++ 2.6pl0 cameron at sna.dec.com */ -#if defined(__alpha) - sprintf(addrbuf, "%s->ALL", &name ); -#else sprintf(addrbuf, "%s->ALL", name ); -#endif -/* --- */ do_message(0, MALL, addrbuf, mynum, fmt, args); va_end(args); } Index: inlcmds.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/inlcmds.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- inlcmds.c 21 Mar 2005 05:23:46 -0000 1.1 +++ inlcmds.c 12 May 2006 03:44:49 -0000 1.2 @@ -10,15 +10,9 @@ would be a horror to implement in the old scheme.. */ -#include <stdio.h> -#include <ctype.h> -#include <string.h> -#include <time.h> -#include <signal.h> #include "defs.h" #include "struct.h" #include "data.h" - #include "gencmds.h" #include "inldefs.h" @@ -49,6 +43,7 @@ int do_nothing() { + return 0; } /********* COMMANDS LIST ******** Index: inl.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/inl.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- inl.c 6 May 2006 12:28:20 -0000 1.4 +++ inl.c 12 May 2006 03:44:49 -0000 1.5 @@ -1,9 +1,5 @@ /* $Id$ */ -#ifndef lint -static char vcid[] = "$Id$"; -#endif /* lint */ - /* * inl.c * @@ -15,26 +11,20 @@ */ #include <stdio.h> -#include <sys/types.h> +#include <stdlib.h> +#include <unistd.h> #include <sys/time.h> -#include <sys/resource.h> -#include <signal.h> -#include <sys/file.h> #include <sys/wait.h> -#include <errno.h> -#include <pwd.h> -#include <ctype.h> +#include <sys/shm.h> #include <time.h> -#include <stdlib.h> -#include <unistd.h> #include <math.h> #include "defs.h" #include "struct.h" #include "data.h" #include "planets.h" #include "inldefs.h" -#include INC_STRINGS #include "proto.h" +#include "roboshar.h" #include "ltd_stats.h" /* @@ -160,13 +150,19 @@ }; void cleanup(); -void reset_inl(int); -int checkmess(); +void checkmess(); void inlmove(); int start_tourney(); void reset_stats(); void update_scores(); void announce_scores(int, int, FILE *); +void doResources(int startup); +void countdown(int counter, Inl_countdown *cnt); +void obliterate(int wflag, char kreason); +void player_maint(); +void init_server(); +int all_alert(int stat); +int check_winner(); extern char *addr_mess(int who, int type); @@ -176,12 +172,11 @@ int argc; char *argv[]; { - int i; - srandom(time(NULL)); getpath(); openmem(1); + do_message_post_set(check_command); readsysdefaults(); if ((inl_log = fopen(N_INLLOG,"w+"))==NULL) { @@ -386,7 +381,6 @@ { register int i; register struct planet *l; - struct planet *homep = NULL; struct player *j; int loser, winner; @@ -511,15 +505,14 @@ SIGNAL(SIGALRM, inlmove); } -player_maint() +void player_maint() { #ifdef INLDEBUG ERROR(2,("Enter player_maint\n")); #endif } -int -all_alert(int stat) +int all_alert(int stat) { struct player *j; @@ -530,43 +523,26 @@ return 1; } -logmessage(m) - struct message *m; +void logmessage(struct message *m) { - time_t curtime; - struct tm *tmstruct; - int hour; - int least = MBOMB; /* decide whether or not to log this message */ #ifdef nodef if (m->m_flags & MINDIV) return; /* individual message */ if (!(m->m_flags & MGOD)) return; if ((m->m_flags & MGOD) > least) return; #endif - /* - time(&curtime); - tmstruct = localtime(&curtime); - if (!(hour = tmstruct->tm_hour%12)) hour = 12; - fprintf(inl_log,"%02d:%02d %-73.73s\n", hour, tmstruct->tm_min, - m->m_data); - */ fprintf(inl_log,"%5d: %s\n",inl_stat.ticks,m->m_data); } -checkmess() +void checkmess() { - int shmemKey = PKEY; - int i; - #ifdef INLDEBUG ERROR(2,("Enter checkmess\n")); #endif /* make sure shared memory is still valid */ - if (shmget(shmemKey, SHMFLAG, 0) < 0) { + if (shmget(PKEY, SHMFLAG, 0) < 0) { exit(1); - ERROR(2,("ERROR: Invalid shared memory\n")); - } while (oldmctl!=mctl->mc_current) { @@ -863,11 +839,10 @@ return -1; } - + return 0; } -int -end_tourney() +int end_tourney() { int game_over = 0; int win_cond; @@ -1024,7 +999,7 @@ status->gameup &= ~(GU_PAUSED); gettimeofday(&tv, (struct timezone *) 0); - fprintf(inl_log, "TIME: Game ending at %d seconds\n", tv.tv_sec); + fprintf(inl_log, "TIME: Game ending at %d seconds\n", (int) tv.tv_sec); fclose(inl_log); sleep(2); /* a kluge to allow time for all the ntservs to run */ @@ -1041,7 +1016,7 @@ players[c].p_pos = -1; - sprintf(name, "%s.%d", N_INLLOG, tv.tv_sec); + sprintf(name, "%s.%d", N_INLLOG, (int) tv.tv_sec); rename(N_INLLOG, name); if ((inl_log = fopen(N_INLLOG,"w+"))==NULL) { @@ -1049,13 +1024,13 @@ exit(1); } - sprintf(name, "%s.%d", N_PLAYERFILE, tv.tv_sec); + sprintf(name, "%s.%d", N_PLAYERFILE, (int) tv.tv_sec); rename(N_PLAYERFILE, name); - sprintf(name, "%s.%d", N_PLFILE, tv.tv_sec); + sprintf(name, "%s.%d", N_PLFILE, (int) tv.tv_sec); rename(N_PLFILE, name); - sprintf(name, "%s.%d", N_GLOBAL, tv.tv_sec); + sprintf(name, "%s.%d", N_GLOBAL, (int) tv.tv_sec); rename(N_GLOBAL, name); /* Stop cambot. */ @@ -1063,7 +1038,7 @@ kill(cambot_pid, SIGTERM); waitpid(cambot_pid, NULL, 0); cambot_pid = 0; - sprintf(name, "%s.%d", Cambot_out, tv.tv_sec); + sprintf(name, "%s.%d", Cambot_out, (int) tv.tv_sec); rename(Cambot_out, name); } @@ -1077,9 +1052,9 @@ pmessage(who, MINDIV, addr_mess(who, MINDIV), "Official registration script starting."); } - sprintf(pipe, "./end_tourney.pl -register %d", tv.tv_sec); + sprintf(pipe, "./end_tourney.pl -register %d", (int) tv.tv_sec); } else { - sprintf(pipe, "./end_tourney.pl -practice %d", tv.tv_sec); + sprintf(pipe, "./end_tourney.pl -practice %d", (int) tv.tv_sec); } fp = popen(pipe, "r"); @@ -1108,11 +1083,10 @@ reset_inl(1); } /* if (game_over) */ - + return 0; } -void -reset_inl(int is_end_tourney) +void reset_inl(int is_end_tourney) /* is_end_tourney: boolean, used so that the galaxy isn't reset at the end of a tournament. */ { @@ -1203,10 +1177,9 @@ } -init_server() +void init_server() { - register i; - register struct planet *j; + int i; /* Tell other processes a game robot is running */ status->gameup |= GU_INROBOT; @@ -1371,10 +1344,8 @@ exit(0); } -start_countdown() +void start_countdown() { - int c; - inl_stat.change = 0; inl_teams[HOME].side = sides[inl_teams[HOME].side_index].flag; @@ -1415,14 +1386,11 @@ inl_countdown.end = inl_stat.ticks+INLSTARTFUSE; inl_countdown.action = start_tourney; inl_countdown.message = "Game start in %i %s"; - } -start_tourney() +int start_tourney() { - int c; - struct player* j; struct timeval tv; struct tm *tp; char *ap; @@ -1441,7 +1409,7 @@ gettimeofday (&tv, (struct timezone *) 0); - fprintf(inl_log, "TIME: Game started at %d seconds\n", tv.tv_sec); + fprintf(inl_log, "TIME: Game started at %d seconds\n", (int) tv.tv_sec); tp = localtime (&tv.tv_sec); ap = asctime (tp); @@ -1500,19 +1468,18 @@ if (pid < 0) perror("fork cambot"); else if (pid == 0) { - execl(Cambot, "cambot", 0); + execl(Cambot, "cambot", (char *) NULL); perror("execl cambot"); } else { cambot_pid = pid; } } + return 0; } -obliterate(wflag, kreason) - int wflag; - char kreason; +void obliterate(int wflag, char kreason) { /* 0 = do nothing to war status, 1= make war with all, 2= make peace with all */ struct player *j; @@ -1593,13 +1560,10 @@ } -countdown(counter,cnt) - int counter; - Inl_countdown *cnt; +void countdown(int counter, Inl_countdown *cnt) { int i = 0; int j = 0; - char *ms; if (cnt->end - cnt->counts[cnt->idx]*cnt->unit > counter) return; @@ -1625,8 +1589,7 @@ } -doResources(startup) - int startup; +void doResources(int startup) { int i, j, k, which; Index: inlcomm.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/inlcomm.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- inlcomm.c 12 Aug 2005 04:35:08 -0000 1.3 +++ inlcomm.c 12 May 2006 03:44:49 -0000 1.4 @@ -8,23 +8,12 @@ */ #include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/resource.h> #include <signal.h> -#include <setjmp.h> -#include <sys/file.h> -#include <sys/wait.h> -#include <sys/ipc.h> -#include <sys/shm.h> -#include <errno.h> -#include <pwd.h> -#include <ctype.h> -#include <time.h> #include "defs.h" #include "struct.h" #include "data.h" +#include "proto.h" +#include "roboshar.h" #include "inldefs.h" extern Inl_stats inl_stat; @@ -88,15 +77,10 @@ -do_switchside(comm,mess) +int do_switchside(comm,mess) char *comm; struct message *mess; { - int who; - int queue; - int side; - struct player *j; - #ifndef nodef return 0; /* disabled until fixed */ @@ -106,6 +90,10 @@ with a wait queue. cameron at stl.dec.com */ #else + int who; + int queue; + int side; + struct player *j; #ifdef INLDEBUG ERROR(2,(" Enter do_switchside\n")); @@ -180,7 +168,7 @@ /* Allows the captain to agree on starting the game */ -do_start(comm,mess) +int do_start(comm,mess) char *comm; struct message *mess; { @@ -276,9 +264,10 @@ inl_teams[c].flags &= ~T_START; start_countdown(); + return 0; } -do_register(comm,mess) +int do_register(comm,mess) char *comm; struct message *mess; { @@ -305,9 +294,10 @@ pmessage(0, MALL, inl_from, "Game is official.. will be automatically registered."); + return 0; } -do_gametime(comm,mess) +int do_gametime(comm,mess) char *comm; struct message *mess; { @@ -403,10 +393,11 @@ inl_stat.time = time * PERMIN; inl_stat.overtime = overtime * PERMIN; } + return 0; } -do_army(comm,mess) +int do_army(comm,mess) char *comm; struct message *mess; { @@ -467,12 +458,13 @@ army); inl_stat.start_armies = army; } + return 0; } /* Allows the captains of both teams to agree on resetting the galaxy */ -do_resetgalaxy(comm,mess) +int do_resetgalaxy(comm,mess) char *comm; struct message *mess; { @@ -517,18 +509,19 @@ pmessage (0, MALL, inl_from, "Game restarting with new galaxy. Teams should be reselected"); + return 0; } /* Makes the player who sent the message captain if it hasn't been taken yet. */ -do_captain(comm,mess) +int do_captain(comm,mess) char *comm; struct message *mess; { int who; - int c, num=-1; + int num = -1; #ifdef INLDEBUG ERROR(2,(" Enter do_captain\n")); @@ -568,12 +561,12 @@ /* Allows the captain to release captaining duties */ -do_uncaptain(comm,mess) +int do_uncaptain(comm,mess) char *comm; struct message *mess; { int who; - int c, num=-1; + int num = -1; #ifdef INLDEBUG ERROR(2,(" Enter do_uncaptain\n")); @@ -591,16 +584,25 @@ } +static int get_other_side(int num) +{ + int c; + for (c=0; c < INLTEAM; c++) { + if (inl_teams[num].team != inl_teams[c].team) + return inl_teams[c].team; + } + return 0; +} + /* This allows the captain to pick the different races */ -do_pickside(comm,mess) +int do_pickside(comm,mess) char *comm; struct message *mess; { int who; - int c, other_side, num=-1; - int race,diagonal; + int c, other_side, num = -1; #ifdef INLDEBUG ERROR(2,(" Enter pickside\n")); @@ -618,11 +620,7 @@ if ((num = check_player(who, 1)) == NONE) return 0; - for (c=0; c < INLTEAM; c++) - { - if (inl_teams[num].team != inl_teams[c].team) - other_side = inl_teams[c].team; - } + other_side = get_other_side(num); if (inl_teams[num].flags & T_SIDELOCKED) { @@ -688,13 +686,10 @@ return 1; } -do_tname(comm,mess) - char *comm; - struct message *mess; +int do_tname(char *comm, struct message *mess) { int who; - - int c, other_side, num=-1; + int num = -1; #ifdef INLDEBUG ERROR(2,(" Enter do_tname\n")); @@ -717,14 +712,14 @@ return 0; } - if (strlen(comm)+1 < 2) + comm++; + + if (strlen(comm) < 1) { pmessage(who, MINDIV, addr_mess(who, MINDIV), "No team name was given."); return 0; } - comm = ++comm; - /* free (inl_teams[num].t_name); */ inl_teams[num].t_name = strdup (comm); pmessage(who, MINDIV, addr_mess(who, MINDIV), @@ -739,16 +734,14 @@ inl_stat.flags &= ~(S_FREEZE | S_COUNTDOWN); status->gameup &= ~(GU_PRACTICE | GU_PAUSED); pmessage(0,MALL, inl_from, "---- Game continues ----"); + return 0; } -do_pause(comm,mess) +int do_pause(comm,mess) char *comm; struct message *mess; { int who; - int queue; - int side; - struct player *j; int c, begin=0, num=-1; #ifdef INLDEBUG @@ -818,17 +811,14 @@ inl_countdown.action=end_pause; inl_countdown.message="Game continues in %i seconds"; } - + return 0; } -do_restart(comm,mess) +int do_restart(comm,mess) char *comm; struct message *mess; { int who; - int queue; - int side; - struct player *j; int c, restart=0, num=-1; #ifdef INLDEBUG @@ -861,13 +851,14 @@ pmessage(0, MALL, inl_from, "INL SERVER RESTARTED"); reset_inl(0); } + return 0; } -do_timeout(char *comm, struct message *mess) +int do_timeout(char *comm, struct message *mess) { int who; int other_side; - int c, num=-1; + int num = -1; #ifdef INLDEBUG ERROR(2,(" Enter do_pause\n")); @@ -884,11 +875,7 @@ return 0; } - for (c=0; c < INLTEAM; c++) - { - if (inl_teams[num].team != inl_teams[c].team) - other_side = inl_teams[c].team; - } + other_side = get_other_side(num); if (inl_teams[num].flags & T_TIMEOUT) { @@ -925,12 +912,13 @@ pmessage(0, MALL, inl_from, "**********************************************************"); } + return 0; } -do_confine(char *comm, struct message *mess) +int do_confine(char *comm, struct message *mess) { int who; - int c, other_side, num=-1; + int other_side, num = -1; #ifdef INLDEBUG ERROR(2,(" Enter do_confine\n")); @@ -946,11 +934,7 @@ return 0; } - for (c=0; c < INLTEAM; c++) - { - if (inl_teams[num].team != inl_teams[c].team) - other_side = inl_teams[c].team; - } + other_side = get_other_side(num); if (inl_teams[num].flags & T_CONFINE) { @@ -974,9 +958,10 @@ inl_teams[num].t_name, players[who].p_mapchars); } + return 0; } -do_free(char *comm, struct message *mess) +int do_free(char *comm, struct message *mess) { int num=-1; int victim; @@ -986,6 +971,7 @@ if ((num = check_player(who, 1)) == NONE) return 0; /* Captain ? */ + extern int getplayer(int from, char *line); /* gencmds.c */ if ((victim = getplayer(who, comm)) == -1) return 0; @@ -1213,5 +1199,6 @@ pmessage(0, MALL, inl_from, "%s scoring mode approved. See MOTD.", mode); inl_stat.score_mode = inl_teams[HOME].score_mode; } + return 0; } Index: puckmove.c =================================================================== RCS file: /cvsroot/netrek/server/Vanilla/robots/puckmove.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- puckmove.c 26 Apr 2006 09:52:43 -0000 1.4 +++ puckmove.c 12 May 2006 03:44:49 -0000 1.5 @@ -22,7 +22,10 @@ #include "defs.h" #include "struct.h" #include "data.h" +#include "proto.h" #include "puckdefs.h" +#include "roboshar.h" +#include "puckmove.h" #ifdef PUCK_FIRST #include <sys/sem.h> @@ -143,13 +146,10 @@ void do_teleport_home(void); void do_peace(void); void do_msg_check(void); -void do_war(void); void place_anncer(void); void do_offsides(void); -void puck_rules(void); void do_goal(int); void do_score(void); -void do_faceoff(void); void woomp(void); void player_maint(void); void player_bounce(void); @@ -158,6 +158,8 @@ unsigned char getcourse(); char *robo_message(); char *puckie_message(); /* added 8/2/91 TC */ +int isInPossession(struct Enemy *enemy_buf); +int isPressoringMe(struct Enemy *enemy_buf); #ifdef HAVE_GOALIE struct player *ori_goalie = NULL; @@ -1051,7 +1053,7 @@ if ((j != me) && (j->p_status == PALIVE)) { if (((j->p_team == KLI) && (j->p_y > GWIDTH/2)) || ((j->p_team == ORI) && (j->p_y < GWIDTH/2))) { - int startplanet; + int startplanet = 10; messAll(me->p_no,roboname,"%s (%2s) is offsides.", j->p_name, j->p_mapchars); j->p_flags &= ~(PFORBIT|PFPLOCK|PFPLLOCK|PFTRACT|PFPRESS); /* ***BAV*** */