Vanilla Netrek Server Development Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[VANILLA-L:629] Minor INL robot upgrade



The following patch introduces a new bit entry (GU_INROBOT) to status->gameup
in the shared memory segment.  It allows the INL robot to inform other processes
that a "Game robot" is running.  This is necessary to prevent
a robot from being invoked while another robot is already running.

Also, in this patch, all outdated references to status->gameup as a boolean
have been changed to reference status->gameup as a bitfield.  (This has
no real effect - it is just code cleanup.)

Note - Only the INL robot takes advantage of this.  The other "Game robots"
(IE basep/puck/dog) should be upgraded in a similar way.


*** ntserv/daemonII.c.orig	Tue Apr 29 04:01:46 1997
--- ntserv/daemonII.c	Sun May  4 04:39:56 1997
***************
*** 171,177 ****
      queues_init();  /* Initialize the queues for pickup */
  
      status->active = 0;
!     status->gameup = (1 | (chaosmode ? GU_CHAOS : 0));
  
      (void) SIGNAL(SIGCHLD, reaper);
  
--- 171,177 ----
      queues_init();  /* Initialize the queues for pickup */
  
      status->active = 0;
!     status->gameup = (GU_GAMEOK | (chaosmode ? GU_CHAOS : 0));
  
      (void) SIGNAL(SIGCHLD, reaper);
  
***************
*** 2700,2706 ****
              (void) kill (j->p_process, SIGTERM);
      }
  
!     status->gameup = 0; /* say goodbye to xsg et. al. 4/10/92 TC */
      /* Kill waiting players */
      for (i=0; i<MAXQUEUE; i++) queues[i].q_flags=0;
      save_planets();
--- 2700,2706 ----
              (void) kill (j->p_process, SIGTERM);
      }
  
!     status->gameup &= ~(GU_GAMEOK); /* say goodbye to xsg et. al. 4/10/92 TC */
      /* Kill waiting players */
      for (i=0; i<MAXQUEUE; i++) queues[i].q_flags=0;
      save_planets();
***************
*** 2766,2777 ****
          exit(0);
      }
      if (sscanf(s+1, " %f", &load) == 1) {
!         if (load>=maxload && (status->gameup)) {
!             status->gameup=0;
              pmessage(0, MALL, "GOD->ALL",
                  "The load is %f, this game is going down", load);
!         } else if (load<maxload && status->gameup==0) {
!             status->gameup= (1 | (chaosmode ? GU_CHAOS : 0));
              pmessage(0, MALL, "GOD->ALL",
                  "The load is %f, this game is coming up", load);
          }
--- 2766,2777 ----
          exit(0);
      }
      if (sscanf(s+1, " %f", &load) == 1) {
!         if (load>=maxload && (status->gameup & GU_GAMEOK)) {
!             status->gameup&=~(GU_GAMEOK);
              pmessage(0, MALL, "GOD->ALL",
                  "The load is %f, this game is going down", load);
!         } else if (load<maxload && !(status->gameup & GU_GAMEOK)) {
! 	    status->gameup|=GU_GAMEOK;
              pmessage(0, MALL, "GOD->ALL",
                  "The load is %f, this game is coming up", load);
          }
*** ntserv/findslot.c.orig	Sun May  4 04:23:00 1997
--- ntserv/findslot.c	Sun May  4 05:05:07 1997
***************
*** 86,92 ****
  	}
  
  	/* Message from daemon that it died (is going down) */
! 	if (status->gameup == 0) {
  	    queue_exit(mywait);
  	    return (-1);
  	}
--- 86,92 ----
  	}
  
  	/* Message from daemon that it died (is going down) */
! 	if (!(status->gameup & GU_GAMEOK)) {
  	    queue_exit(mywait);
  	    return (-1);
  	}
*** ntserv/gencmds.h.orig	Tue Apr 29 03:33:07 1997
--- ntserv/gencmds.h	Tue Apr 22 04:44:19 1997
***************
*** 18,23 ****
--- 18,26 ----
  #define C_PR_1          0x0400   /* Future use */
  #define C_PR_2          0x0800
  #define C_PR_3          0x1000
+ #define C_PR_4          0x2000
+ #define C_PR_5          0x4000
+ #define C_PR_6          0x8000
  
  #ifdef VOTING
  #define C_VC_ALL        0x0020   /* Command only passes with Majority concensus */
*** ntserv/getentry.c.orig	Sun May  4 04:24:13 1997
--- ntserv/getentry.c	Sun May  4 04:59:25 1997
***************
*** 284,290 ****
  
      /* First, handle any special cases */
      /* Is the server closed, or did the daemond die. */
!     if ((!time_access()) || (status->gameup==0)) return 0;
      /* You must leave */
      if (mustexit) return (0);
      /* Special modes */
--- 284,290 ----
  
      /* First, handle any special cases */
      /* Is the server closed, or did the daemond die. */
!     if ((!time_access()) || !(status->gameup & GU_GAMEOK)) return 0;
      /* You must leave */
      if (mustexit) return (0);
      /* Special modes */
*** ntserv/input.c.orig	Sun May  4 04:24:58 1997
--- ntserv/input.c	Sun May  4 04:24:50 1997
***************
*** 144,150 ****
  	    }
  	    resurrect();
  	}
! 	if (! status -> gameup){
  	    freeslot(me);
  	    exit(0);
  	}
--- 144,150 ----
  	    }
  	    resurrect();
  	}
! 	if (! (status -> gameup & GU_GAMEOK)){
  	    freeslot(me);
  	    exit(0);
  	}
*** ntserv/ntscmds.c.orig	Tue Apr 29 03:33:32 1997
--- ntserv/ntscmds.c	Tue Apr 29 04:12:03 1997
***************
*** 21,26 ****
--- 21,28 ----
  #include "data.h"
  #include "gencmds.h"
  
+ #define C_PR_INPICKUP    C_PR_1
+ 
  #if defined (ALLOW_EJECT)
  int do_player_eject();
  #endif
***************
*** 110,176 ****
                  "Show player's starbase stats. Ex: 'SBSTATS 0'",
                  do_sbstats_query },             /* SBSTATS */
  						/***** Vanilla commands */
-     { "TIME",
- 		0,
- 		"Show time left on Genocide timer.",
- 		do_time_msg },			/* TIME */
      { "QUEUE",
  		0,
  		"Show how many people are on the queue.",
  		do_queue_msg },			/* QUEUE */
  #ifdef GENO_COUNT
      { "GENOS",
! 		C_PLAYER,
  		"Show player's winning genocides.  Ex: 'GENOS 0'",
  		do_genos_query },                       /* GENOS */
  #endif
  #ifdef VOTING
  
!     { "The following votes can be used:  (M=Majority, T=Team vote)", C_DESC },
!     { "Ejection Votes are recorded for the god to review.", C_DESC },
  #if defined(ALLOW_EJECT)
      { "EJECT",
! 	C_VC_TEAM | C_GLOG | C_PLAYER,
  	"To eject a player. Ex: 'EJECT 0'", 
  	do_player_eject,				/* EJECT */
  	2, 0, 120, 600},
  #endif
  #if defined(TRIPLE_PLANET_MAYHEM)
      { "TRIPLE",
!         C_VC_ALL | C_GLOG,
          "Start triple planet mayhem by vote",
          do_triple_planet_mayhem,
  	2, 22, 0},
      { "BALANCE",
!         C_VC_ALL | C_GLOG,
          "Request team randomise & balance",
          do_balance,
          4, 23, 0 },
  #endif
  #if defined(AUTO_INL)
    { "INL",
! 	C_VC_ALL | C_GLOG,
  	"Start game under INL rules.",
  	do_start_inl,
  	1, 20, 0 },
  #endif
  #if defined(AUTO_PRACTICE)
    { "PRACTICE",
! 	C_VC_ALL,
  	"Start basepractice by majority vote.",
  	do_start_basep,
  	1, 20, 0 },
  #endif
  #if defined(AUTO_HOCKEY)
    { "HOCKEY",
! 	C_VC_ALL | C_GLOG,
  	"Start hockey by majority vote.",
  	do_start_puck,
  	1, 20, 0 },
  #endif
  #if defined(AUTO_DOGFIGHT)
    { "DOGFIGHT",
! 	C_VC_ALL | C_GLOG,
  	"Start dogfight tournament by majority vote.",
  	do_start_mars,
  	1, 20, 0 },
--- 112,180 ----
                  "Show player's starbase stats. Ex: 'SBSTATS 0'",
                  do_sbstats_query },             /* SBSTATS */
  						/***** Vanilla commands */
      { "QUEUE",
  		0,
  		"Show how many people are on the queue.",
  		do_queue_msg },			/* QUEUE */
+     { "TIME",
+ 		C_PR_INPICKUP,
+ 		"Show time left on Genocide timer.",
+ 		do_time_msg },			/* TIME */
  #ifdef GENO_COUNT
      { "GENOS",
! 		C_PLAYER | C_PR_INPICKUP,
  		"Show player's winning genocides.  Ex: 'GENOS 0'",
  		do_genos_query },                       /* GENOS */
  #endif
  #ifdef VOTING
  
!     { "The following votes can be used:  (M=Majority, T=Team vote)",
!       C_DESC  | C_PR_INPICKUP},
!     { "Ejection Votes are recorded for the god to review.",
!       C_DESC  | C_PR_INPICKUP},
  #if defined(ALLOW_EJECT)
      { "EJECT",
! 	C_VC_TEAM | C_GLOG | C_PLAYER | C_PR_INPICKUP,
  	"To eject a player. Ex: 'EJECT 0'", 
  	do_player_eject,				/* EJECT */
  	2, 0, 120, 600},
  #endif
  #if defined(TRIPLE_PLANET_MAYHEM)
      { "TRIPLE",
!         C_VC_ALL | C_GLOG | C_PR_INPICKUP,
          "Start triple planet mayhem by vote",
          do_triple_planet_mayhem,
  	2, 22, 0},
      { "BALANCE",
!         C_VC_ALL | C_GLOG | C_PR_INPICKUP,
          "Request team randomise & balance",
          do_balance,
          4, 23, 0 },
  #endif
  #if defined(AUTO_INL)
    { "INL",
! 	C_VC_ALL | C_GLOG | C_PR_INPICKUP,
  	"Start game under INL rules.",
  	do_start_inl,
  	1, 20, 0 },
  #endif
  #if defined(AUTO_PRACTICE)
    { "PRACTICE",
! 	C_VC_ALL | C_PR_INPICKUP,
  	"Start basepractice by majority vote.",
  	do_start_basep,
  	1, 20, 0 },
  #endif
  #if defined(AUTO_HOCKEY)
    { "HOCKEY",
! 	C_VC_ALL | C_GLOG | C_PR_INPICKUP,
  	"Start hockey by majority vote.",
  	do_start_puck,
  	1, 20, 0 },
  #endif
  #if defined(AUTO_DOGFIGHT)
    { "DOGFIGHT",
! 	C_VC_ALL | C_GLOG | C_PR_INPICKUP,
  	"Start dogfight tournament by majority vote.",
  	do_start_mars,
  	1, 20, 0 },
***************
*** 184,190 ****
  check_command(mess)
       struct message *mess;
  {
!   return check_2_command(mess, nts_commands, 0);
  }
  
  #if defined (ALLOW_EJECT)
--- 188,195 ----
  check_command(mess)
       struct message *mess;
  {
!   return check_2_command(mess, nts_commands,
! 			 (status->gameup & GU_INROBOT) ? 0 : C_PR_INPICKUP);
  }
  
  #if defined (ALLOW_EJECT)
*** ntserv/struct.h.orig	Tue Apr 22 04:20:38 1997
--- ntserv/struct.h	Sun May  4 04:18:19 1997
***************
*** 64,75 ****
--- 64,78 ----
  };
  
  /* The following defines are for gameup field */
+ #define GU_GAMEOK 1
+ #define game_ok ((status->gameup) & GU_GAMEOK)
  #define GU_PRACTICE 2
  #define practice_mode ((status->gameup) & GU_PRACTICE)
  #define GU_CHAOS 4
  #define chaos ((status->gameup) & GU_CHAOS)
  #define GU_PAUSED 8
  #define ispaused ((status->gameup) & GU_PAUSED)
+ #define GU_INROBOT 16
  
  /* changed these so we can use and and or functions on them in future */
  #define PFREE 		   0x0000
*** robots/inl.c.orig	Tue Apr 22 04:24:54 1997
--- robots/inl.c	Tue Apr 22 04:24:41 1997
***************
*** 513,518 ****
--- 513,521 ----
     register        i;
     register struct planet *j;
  
+    /* Tell other processes a game robot is running */
+    status->gameup |= GU_INROBOT;
+ 
     /* Fix planets */
     oldplanets = (struct planet *) malloc(sizeof(struct planet) * MAXPLANETS);
     MCOPY(planets, oldplanets, sizeof(struct planet) * MAXPLANETS);
***************
*** 652,657 ****
--- 655,663 ----
      queues[QU_PICKUP].high_slot = MAXPLAYER-TESTERS;
      queues[QU_PICKUP].max_slots = MAXPLAYER-TESTERS;
  #endif
+ 
+     /* Inform other processes that a game robot is no longer running */
+     status->gameup &= ~(GU_INROBOT);
  
      pmessage(0, MALL, inl_from, "##########################");
      pmessage(0, MALL, inl_from, "#  The inl robot has left");
*** robots/inlcmds.c.orig	Tue Apr 29 04:33:35 1997
--- robots/inlcmds.c	Tue Apr 29 05:28:40 1997
***************
*** 58,65 ****
  		"Show this help information",
  		do_help },     			/* HELP */
      { "GAMETIME",
! 		0,
! 		"Shows the game time or sets it. Ex: 'GAMETIME 30 10'",
  		do_gametime },			/* GAMETIME */
      { "CAPTAIN",
  		0,
--- 58,65 ----
  		"Show this help information",
  		do_help },     			/* HELP */
      { "GAMETIME",
! 		C_PR_INGAME,
! 		"Shows the current game time.",
  		do_gametime },			/* GAMETIME */
      { "CAPTAIN",
  		0,
***************
*** 74,79 ****
--- 74,83 ----
  		C_PR_PREGAME,
  		"Switch to away team.",
  		do_switchside },		/* AWAY */
+     { "GAMETIME",       /* Same as above but with different availability */
+ 		C_PR_CAPTAIN | C_PR_PREGAME,
+ 		"Sets regulation/overtime length. Ex: 'GAMETIME 30 10'",
+ 		do_gametime },			/* GAMETIME */
      { "TNAME",
  		C_PR_CAPTAIN | C_PR_PREGAME,
  		"Change the name of your team.",
*** robots/robotII.c.orig	Sun May  4 04:30:22 1997
--- robots/robotII.c	Sun May  4 04:30:04 1997
***************
*** 293,299 ****
  
      me->p_status = PALIVE;		/* Put robot in game */
      if (cloaker) cloak_on();
!     while (status -> gameup && (me -> p_status != PFREE)) {
  	PAUSE(SIGALRM);
      }
      exit(1);
--- 293,299 ----
  
      me->p_status = PALIVE;		/* Put robot in game */
      if (cloaker) cloak_on();
!     while ((status -> gameup & GU_GAMEOK) && (me -> p_status != PFREE)) {
  	PAUSE(SIGALRM);
      }
      exit(1);


-- 
 ------------------------------------------------------------------------
 | Kevin O'Connor               "BTW, IMHO we need a FAQ for 'RTFM',    | **
 | koconnor@acsu.buffalo.edu    'IMHO', 'IMO', 'FAQ', 'BTW', etc. !"    | **
 ------------------------------------------------------------------------ **
   *************************************************************************