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

[VANILLA-L:1405] INL robot fixes



This patch completes resetting of player stats for tourn start.  It
also moves the .global, .players, and .planets file to <file>.<tvsec>
like is done for INL_log.  I ran a couple of 5 min. regulation games
in sequence, and it seemed to handle it ok.

For some reason, user: netrek, pwd: netrek was no longer working for
CVS, so I couldn't make sure this patch is relevant to the latest CVS
files.

As threatened, this will hose your database if voted in, so any INL
server should be a dedicated INL server.  config.h.in needs to be
changed to disallow voting in the INL robot.  EXIT should also be
disabled in inlcmds.c.  James can you take care of that?

And James, don't remove that patch I had submitted earlier.  This
patch fixes that patch, but in a completely different file.

Details:
--
* genspkt.c does a check that startT* variables are <= their player
stat counterparts.  The comment in the file explains a bit more.

* daemonII.c no longer holds open the .global and .planets files, but
instead reopens them when it writes, as was being done with the
.players file.  It also creates the files if they don't exist.  This
makes it safe to rename the files in inl.c.  Well almost safe.  There
is a window for synchronization problems, but a most of the netrek
code is like that.

* inl.c includes code to rename the dotfiles.

Patch follows.

-Jeff

*** ../vanilla_ori/Vanilla/robots/inl.c	Wed Feb 10 10:53:20 1999
--- robots/inl.c	Wed Feb 10 10:41:08 1999
***************
*** 538,543 ****
--- 538,552 ----
        exit(1);
      }
  
+     sprintf(name, "%s.%d", N_PLAYERFILE, tv.tv_sec);
+     rename(N_PLAYERFILE, name);
+ 
+     sprintf(name, "%s.%d", N_PLFILE, tv.tv_sec);
+     rename(N_PLFILE, name);
+ 
+     sprintf(name, "%s.%d", N_GLOBAL, tv.tv_sec);
+     rename(N_GLOBAL, name);
+ 
      for (c=0; c < INLTEAM; c++) {
        if (inl_teams[c].flags & T_REGISTER) official++;
      }
*** ../vanilla_ori/Vanilla/ntserv/daemonII.c	Wed Feb 10 00:53:57 1999
--- ntserv/daemonII.c	Wed Feb 10 10:19:31 1999
***************
*** 48,55 ****
  static int debug = 0;
  static int ticks = 0;
  static int tourntimestamp = 0; /* ticks since last Tmode 8/2/91 TC */
- static int plfd;
- static int glfd;
  
  jmp_buf env;
  
--- 48,53 ----
***************
*** 77,82 ****
--- 75,81 ----
      int x = 0;
      void move();
      static struct itimerval udt;
+     int glfd, plfd;
  
  #ifdef AUTOMOTD
    time_t        mnow;
***************
*** 2767,2772 ****
--- 2766,2781 ----
  
  save_planets()
  {
+     int plfd, glfd;
+ 
+ #ifdef NEUTRAL
+     plfd = open(NeutFile, O_RDWR|O_CREAT, 0744);
+ #else
+     plfd = open(PlFile, O_RDWR|O_CREAT, 0744);
+ #endif
+ 
+     glfd = open(Global, O_RDWR|O_CREAT, 0744);
+ 
      if (plfd >= 0) {
          (void) lseek(plfd, (off_t) 0, 0);
          (void) write(plfd, (char *) planets, sizeof(pdata));
*** ../vanilla_ori/Vanilla/ntserv/genspkt.c	Wed Feb 10 00:54:13 1999
--- ntserv/genspkt.c	Tue Feb  9 23:36:36 1999
***************
*** 2023,2028 ****
--- 2023,2046 ----
  
      stats = &clientStats[i];
  
+     /* Taken from inl source, socket.c.  Hack for INL robot (when stats are
+        reset).  Stick it in here for lack of a better place.  Needed because
+        these are ntserv process variables, so robot can't touch them. */
+ 
+     if (startTkills > me->p_stats.st_tkills ||
+         startTlosses > me->p_stats.st_tlosses ||
+         startTarms > me->p_stats.st_tarmsbomb ||
+         startTplanets > me->p_stats.st_tplanets ||
+         startTticks > me->p_stats.st_tticks)
+     {
+         startTkills = me->p_stats.st_tkills;
+         startTlosses = me->p_stats.st_tlosses;
+         startTarms = me->p_stats.st_tarmsbomb;
+         startTplanets = me->p_stats.st_tplanets;
+         startTticks = me->p_stats.st_tticks;
+     }
+ 
+ 
      /*
       * Send stat packets once per five updates. But, only send one.  We
       * will cycle through them all eventually.
+
++ Vanilla-l Mailing List ++
To unsubscribe: send "unsubscribe vanilla-l" to majordomo@real-time.com
For more information: http://archives.real-time.com