Fri Sep  7 17:21:24 EST 2007  quozl@us.netrek.org
  * inl draft, restrict navigation and add hooks
Fri Sep  7 17:20:37 EST 2007  quozl@us.netrek.org
  * fix formatting and return syntax
Fri Sep  7 17:20:04 EST 2007  quozl@us.netrek.org
  * inl draft, add task specific sources
Fri Sep  7 17:19:42 EST 2007  quozl@us.netrek.org
  * inl draft, add structures and constants
Fri Sep  7 17:19:10 EST 2007  quozl@us.netrek.org
  * use hex values for gameup flags
diff -rN -u old-netrek-server/Vanilla/include/struct.h new-netrek-server/Vanilla/include/struct.h
--- old-netrek-server/Vanilla/include/struct.h	2007-09-07 17:24:12.000000000 +1000
+++ new-netrek-server/Vanilla/include/struct.h	2007-09-07 17:24:13.000000000 +1000
@@ -106,25 +106,26 @@
 
 
 /* The following defines are for gameup field */
-#define GU_GAMEOK 1
-#define GU_PRACTICE 2			/* Basepractice robot is present */
+#define GU_GAMEOK 0x1
+#define GU_PRACTICE 0x2			/* Basepractice robot is present */
 #define practice_mode ((status->gameup) & GU_PRACTICE)
-#define GU_CHAOS 4
+#define GU_CHAOS 0x4
 #define chaos ((status->gameup) & GU_CHAOS)
-#define GU_PAUSED 8
-#define GU_INROBOT 16			/* INL robot is present	*/
+#define GU_PAUSED 0x8
+#define GU_INROBOT 0x10			/* INL robot is present	*/
 #define inl_mode ((status->gameup) & GU_INROBOT)
-#define GU_NEWBIE 32			/* Newbie robot is present */
+#define GU_NEWBIE 0x20			/* Newbie robot is present */
 #define newbie_mode ((status->gameup) & GU_NEWBIE)
-#define GU_PRET 64			/* Pre-t robot is present */
+#define GU_PRET 0x40			/* Pre-t robot is present */
 #define pre_t_mode ((status->gameup) & GU_PRET)
-#define GU_BOT_IN_GAME 128		/* Pre-t robot + bots are present */
+#define GU_BOT_IN_GAME 0x80		/* Pre-t robot + bots are present */
 #define bot_in_game ((status->gameup) & GU_BOT_IN_GAME)
-#define GU_CONQUER 256			/* conquest parade in progress	*/
-#define GU_PUCK 512			/* Hockey robot is present */
+#define GU_CONQUER 0x100		/* conquest parade in progress	*/
+#define GU_PUCK 0x200			/* Hockey robot is present */
 #define hockey_mode ((status->gameup) & GU_PUCK)
-#define GU_DOG 1024			/* Dogfight robot is present */
+#define GU_DOG 0x400			/* Dogfight robot is present */
 #define dogfight_mode ((status->gameup) & GU_DOG)
+#define GU_INL_DRAFT 0x800
 
 /* values of p_status */
 #define PFREE 		   0x0000
@@ -501,10 +502,20 @@
     struct specialweapon p_weapons[NUMSPECIAL];
 #endif
     int p_inlcaptain;           /* Player is an INL captain */
+    int p_inl_draft;            /* Player navigation restricted by INL draft */
     int p_ip_duplicates;        /* ignore this slot for duplicate ip check */
     /* add initialisation of new variables in enter(), or ntserv main() */
 };
 
+/* INL draft states for p_inl_draft */
+#define INL_DRAFT_OFF            0 /* not involved */
+#define INL_DRAFT_MOVING_TO_POOL 1 /* in transit to pool */
+#define INL_DRAFT_CAPTAIN_UP     2 /* captain with right to select */
+#define INL_DRAFT_CAPTAIN_DOWN   3 /* captain without right to select */
+#define INL_DRAFT_POOLED         4 /* in pool of players to be chosen */
+#define INL_DRAFT_MOVING_TO_PICK 5 /* has been chosen, in transit to team */
+#define INL_DRAFT_PICKED         6 /* has been chosen by a captain */
+
 struct statentry {
     char name[NAME_LEN], password[NAME_LEN];
     struct stats stats;
diff -rN -u old-netrek-server/Vanilla/ntserv/Makefile.in new-netrek-server/Vanilla/ntserv/Makefile.in
--- old-netrek-server/Vanilla/ntserv/Makefile.in	2007-09-07 17:24:12.000000000 +1000
+++ new-netrek-server/Vanilla/ntserv/Makefile.in	2007-09-07 17:24:14.000000000 +1000
@@ -15,7 +15,7 @@
 
 L_OBJS = advertise.o alarm.o balance.o bans.o bay.o blog.o \
 	coup.o \
-	data.o db.o detonate.o distress.o \
+	data.o db.o detonate.o distress.o draft.o \
 	enter.o \
 	feature.o features.o \
 	gencmds.o genspkt.o getpath.o getship.o glog.o \
@@ -32,21 +32,21 @@
 
 #	ntserv object files
 
-R_OBJS =    cluecheck.o coup.o db.o death.o detonate.o enter.o \
-	    findslot.o  getentry.o  getname.o  getship.o  input.o \
-	    interface.o  main.o  orbit.o  phaser.o  plasma.o  redraw.o \
-	    reserved.o  sintab.o  socket.o  genspkt.o  smessage.o  \
-	    startrobot.o  sysdefaults.o  timecheck.o  torp.o  util.o  \
-	    warning.o ping.o $(RANDOMO) $(STRDUPO) features.o \
-	    distress.o transwarp.o gencmds.o ntscmds.o openmem.o feature.o \
-	    queue.o slotmaint.o rsa_key.o ltd_stats.o libnetrek.a
+R_OBJS =    cluecheck.o death.o \
+	    findslot.o getentry.o getname.o input.o \
+	    main.o redraw.o \
+	    reserved.o  \
+	    timecheck.o  \
+	    $(RANDOMO) $(STRDUPO) \
+	    ntscmds.o \
+	    queue.o libnetrek.a
 
 
 #	daemonII object files
 
-D_OBJS =    daemonII.o  sintab.o  sysdefaults.o  slotmaint.o \
-	    util.o  $(RANDOMO) getship.o smessage.o  queue.o \
-	    wander2.o openmem.o solicit.o ltd_stats.o conquer.o \
+D_OBJS =    daemonII.o \
+	    $(RANDOMO) queue.o \
+	    wander2.o solicit.o conquer.o \
 	    libnetrek.a
 
 #	Src files
diff -rN -u old-netrek-server/Vanilla/ntserv/draft.c new-netrek-server/Vanilla/ntserv/draft.c
--- old-netrek-server/Vanilla/ntserv/draft.c	1970-01-01 10:00:00.000000000 +1000
+++ new-netrek-server/Vanilla/ntserv/draft.c	2007-09-07 17:24:15.000000000 +1000
@@ -0,0 +1,159 @@
+#include <stdlib.h>
+#include "copyright.h"
+#include "config.h"
+#include "defs.h"
+#include "struct.h"
+#include "data.h"
+#include "proto.h"
+#include "daemon.h"
+#include "conquer.h"
+#include "util.h"
+
+/* draft */
+
+/* http://en.wikipedia.org/wiki/Draft_%28sports%29 "A sports draft is
+the process by which professional sports teams select players not
+contracted to any team, often from colleges or amateur ranks." */
+
+/* TODO: initial draft mode declaration by captains, mutual agreement,
+   sets all players to appropriate p_inl_draft modes, and moves
+   players into position. */
+
+/* TODO: potential positioning on tactical
+
++--------------------------------------------------+
+|                                                  |
+|                           P P P P                |
+|                         C                        |
+| O O O O O O O O O O                              |
+|                         C                        |
+|                           P P P P P              |
+|                                                  |
++--------------------------------------------------+
+
+Key: O = pool players, C = captains, P = picked team
+
+*/
+
+/* TODO: during a draft if a slot joins, with INL_DRAFT_OFF, head them
+   into the pool */
+
+void inl_draft_begin()
+{
+  int h;
+  struct player *j;
+
+  for (h = 0, j = &players[0]; h < MAXPLAYER; h++, j++) {
+    if (j->p_status == PFREE) continue;
+    if (j->p_flags & PFROBOT) continue;
+    j->p_inl_draft = INL_DRAFT_MOVING_TO_POOL;
+  }
+  /* TODO: set course and speed, speed proportional to distance to target */
+  status->gameup |= GU_INL_DRAFT;
+}
+
+void inl_draft_end()
+{
+  int h;
+  struct player *j;
+
+  for (h = 0, j = &players[0]; h < MAXPLAYER; h++, j++) {
+    if (j->p_status == PFREE) continue;
+    if (j->p_flags & PFROBOT) continue;
+    j->p_inl_draft = INL_DRAFT_OFF;
+  }
+  status->gameup &= ~(GU_INL_DRAFT);
+}
+
+/* TODO: call inl_draft_update from daemon during GU_INL_DRAFT mode */
+
+void inl_draft_update()
+{
+  /* TODO: for INL_DRAFT_MOVING_TO_POOL animate position, and on
+     arrival choose whether they are INL_DRAFT_POOLED or
+     INL_DRAFT_CAPTAIN_UP or INL_DRAFT_CAPTAIN_DOWN */
+
+  /* TODO: for INL_DRAFT_MOVING_TO_PICK animate position, and on
+     arrival change to INL_DRAFT_PICKED */
+}
+
+void inl_draft_select(int n)
+{
+  struct player *player;
+  if ((n < 0) || (n > MAXPLAYER)) return;
+  player = &players[n];
+  switch (player->p_inl_draft) {
+  case INL_DRAFT_OFF            : /* not involved */
+    break;
+  case INL_DRAFT_CAPTAIN_UP     : /* captain with right to select */
+    break;
+  case INL_DRAFT_CAPTAIN_DOWN   : /* captain without right to select */
+    if (me->p_inl_draft == INL_DRAFT_CAPTAIN_UP) {
+      /* captain fingers fellow captain */
+      /* meaning: pass */
+      /* TODO: identify fellow captain, set him to INL_DRAFT_CAPTAIN_UP */
+      me->p_inl_draft = INL_DRAFT_CAPTAIN_DOWN;
+    }
+    break;
+  case INL_DRAFT_MOVING_TO_POOL : /* in transit to pool */
+  case INL_DRAFT_POOLED         : /* in pool of players to be chosen */
+    if (me->p_inl_draft == INL_DRAFT_CAPTAIN_UP) {
+      /* captain fingers a pool player */
+      /* meaning: pool player is picked, next captain to pick */
+      player->p_inl_draft = INL_DRAFT_MOVING_TO_PICK;
+      /* TODO: draw phaser from captain to pick */
+      /* TODO: change pick to captain's team and fix war settings */
+      /* TODO: set course, speed and move pick to team */
+      /* TODO: upon arrival set INL_DRAFT_PICKED */
+
+      /* TODO: count slots in INL_DRAFT_MOVING_TO_POOL or INL_DRAFT_POOLED */
+      /* TODO: terminate draft if no slots remain in pool */
+      /* TODO: identify fellow captain, set him to INL_DRAFT_CAPTAIN_UP */
+      me->p_inl_draft = INL_DRAFT_CAPTAIN_DOWN;
+    } else if (me->p_inl_draft == INL_DRAFT_PICKED) {
+      /* non-captain fingers a pool player */
+      /* TODO: distort position according to how many fingerings by team */
+    }
+    break;
+  case INL_DRAFT_MOVING_TO_PICK : /* has been chosen, in transit to team */
+  case INL_DRAFT_PICKED         : /* has been chosen by a captain */
+    if (me->p_inl_draft == INL_DRAFT_CAPTAIN_UP) {
+      /* captain fingers a picked player */
+      /* meaning: undefined */
+      /* TODO: verify pick is on same team as captain */
+      /* TODO: throw the pick back to the pool */
+    }
+    break;
+  }
+}
+
+void inl_draft_reject(int n)
+{
+  struct player *player;
+  if ((n < 0) || (n > MAXPLAYER)) return;
+  player = &players[n];
+  switch (player->p_inl_draft) {
+  case INL_DRAFT_OFF            : /* not involved */
+  case INL_DRAFT_MOVING_TO_POOL : /* in transit to pool */
+  case INL_DRAFT_POOLED         : /* in pool of players to be chosen */
+  case INL_DRAFT_CAPTAIN_UP     : /* captain with right to select */
+  case INL_DRAFT_CAPTAIN_DOWN   : /* captain without right to select */
+    break;
+  case INL_DRAFT_MOVING_TO_PICK : /* has been chosen, in transit to team */
+  case INL_DRAFT_PICKED         : /* has been chosen by a captain */
+    if (me->p_inl_draft == INL_DRAFT_CAPTAIN_UP) {
+      /* captain flicks a picked player */
+      /* meaning: undo pick */
+      /* TODO: sysdef policy default DRAFT_UNPICK=0 */
+      /* TODO: verify pick is on same team as captain */
+      /* TODO: throw the pick back to the pool */
+    }
+    break;
+  }
+}
+
+/*  Hey Emacs!
+ * Local Variables:
+ * c-file-style:"bsd"
+ * End:
+ */
diff -rN -u old-netrek-server/Vanilla/ntserv/enter.c new-netrek-server/Vanilla/ntserv/enter.c
--- old-netrek-server/Vanilla/ntserv/enter.c	2007-09-07 17:24:12.000000000 +1000
+++ new-netrek-server/Vanilla/ntserv/enter.c	2007-09-07 17:24:14.000000000 +1000
@@ -185,6 +185,7 @@
       j->voting[me->p_no] = -1;
 
     me->p_inlcaptain = 0;
+    me->p_inl_draft = INL_DRAFT_OFF;
 
     /* join message stuff */
     sprintf(me->p_mapchars,"%c%c",teamlet[me->p_team], shipnos[me->p_no]);
diff -rN -u old-netrek-server/Vanilla/ntserv/interface.c new-netrek-server/Vanilla/ntserv/interface.c
--- old-netrek-server/Vanilla/ntserv/interface.c	2007-09-07 17:24:12.000000000 +1000
+++ new-netrek-server/Vanilla/ntserv/interface.c	2007-09-07 17:24:14.000000000 +1000
@@ -28,6 +28,7 @@
 #ifdef STURGEON
     if (sturgeon && !sturgeon_hook_set_speed(speed)) return;
 #endif
+    if (me->p_inl_draft != INL_DRAFT_OFF) return;
     if (speed > me->p_ship.s_maxspeed) {
 	me->p_desspeed = me->p_ship.s_maxspeed;
     } else if (speed < 0) {
@@ -43,6 +44,8 @@
 
 void set_course(u_char dir)
 {
+    if (me->p_inl_draft == INL_DRAFT_MOVING_TO_POOL) return;
+    if (me->p_inl_draft == INL_DRAFT_MOVING_TO_PICK) return;
     me->p_desdir = dir;
     bay_release(me);
     me->p_flags &= ~(PFBOMB | PFORBIT | PFBEAMUP | PFBEAMDOWN);
@@ -238,6 +241,7 @@
 
 void cloak_on(void)
 {
+    if (me->p_inl_draft != INL_DRAFT_OFF) return;
     me->p_flags |= PFCLOAK;
     me->p_flags &= ~(PFTRACT | PFPRESS);
 }
@@ -249,21 +253,26 @@
 
 void lock_planet(int planet)
 {
+    if (me->p_inl_draft != INL_DRAFT_OFF) return;
     if (planet<0 || planet>=MAXPLANETS) return;
 
     me->p_flags |= PFPLLOCK;
     me->p_flags &= ~(PFPLOCK|PFORBIT|PFBEAMUP|PFBEAMDOWN|PFBOMB);
     me->p_planet = planet;
-    if(send_short) {
-                swarning(LOCKPLANET_TEXT, (u_char) planet, 0);
+    if (send_short) {
+        swarning(LOCKPLANET_TEXT, (u_char) planet, 0);
+    } else {
+        new_warning(UNDEF,"Locking onto %s", planets[planet].pl_name);
     }
-    else {
-    new_warning(UNDEF,"Locking onto %s", planets[planet].pl_name);
-     }
 }
 
 void lock_player(int player)
 {
+    if (me->p_inl_draft == INL_DRAFT_CAPTAIN_UP) {
+        inl_draft_select(player);
+        return;
+    }
+    if (me->p_inl_draft != INL_DRAFT_OFF) return;
     if (player<0 || player>=MAXPLAYER) return;
     if (players[player].p_status != PALIVE) return;
     if (players[player].p_flags & PFCLOAK && !Observer) return;
@@ -307,6 +316,11 @@
 {
     struct player *victim;
 
+    if (me->p_inl_draft == INL_DRAFT_CAPTAIN_UP) {
+        inl_draft_select(player);
+        return;
+    }
+    if (me->p_inl_draft != INL_DRAFT_OFF) return;
     if (weaponsallowed[WP_TRACTOR]==0) {
 	return;
     }
@@ -338,6 +352,11 @@
     int target;
     struct player *victim;
 
+    if (me->p_inl_draft == INL_DRAFT_CAPTAIN_UP) {
+        inl_draft_reject(player);
+        return;
+    }
+    if (me->p_inl_draft != INL_DRAFT_OFF) return;
     if (weaponsallowed[WP_TRACTOR]==0) {
         new_warning(0,"Tractor beams haven't been invented yet.");
 	return;
diff -rN -u old-netrek-server/Vanilla/ntserv/orbit.c new-netrek-server/Vanilla/ntserv/orbit.c
--- old-netrek-server/Vanilla/ntserv/orbit.c	2007-09-07 17:24:12.000000000 +1000
+++ new-netrek-server/Vanilla/ntserv/orbit.c	2007-09-07 17:24:14.000000000 +1000
@@ -162,6 +162,8 @@
   u_char dir;
   LONG dx, dy;
 
+  if (me->p_inl_draft != INL_DRAFT_OFF) return;
+
   /*
    * Make sure ship is going slowly enough to orbit: */
   if (me->p_speed > ORBSPEED) {
diff -rN -u old-netrek-server/Vanilla/ntserv/transwarp.c new-netrek-server/Vanilla/ntserv/transwarp.c
--- old-netrek-server/Vanilla/ntserv/transwarp.c	2007-09-07 17:24:12.000000000 +1000
+++ new-netrek-server/Vanilla/ntserv/transwarp.c	2007-09-07 17:24:15.000000000 +1000
@@ -20,54 +20,55 @@
    struct player  *j;
    int		  maxspeed;
 
+   if (me->p_inl_draft != INL_DRAFT_OFF) return 0;
    if (!twarpMode) {
       new_warning(UNDEF, "Sorry, transwarp mode is not active.", -1);
-      return (0);
+      return 0;
    }
    if (me->p_status != PALIVE)
-      return (0);
+      return 0;
    if (!me->p_cantranswarp) {
       new_warning(UNDEF, "Starbase refuses transwarping from us in particular, captain!", -1);
-      return (0);
+      return 0;
    }
    if (!me->p_candock) {
       new_warning(UNDEF, "Starbase refuses docking from us in particular, captain!", -1);
-      return (0);
+      return 0;
    }
    if (me->p_flags & PFENG) {
       new_warning(UNDEF, "Engine temperature is too high to initiate transwarp!", -1);
-      return (0);
+      return 0;
    }
    if (me->p_ship.s_type == STARBASE && !chaosmode) {
       new_warning(UNDEF, "Starbases are not allowed to transwarp, captain!", -1);
-      return (0);
+      return 0;
    }
    j = &players[me->p_playerl];
    if (!(me->p_flags & PFPLOCK) ||
        ((me->p_flags & PFPLOCK) && (j->p_ship.s_type != STARBASE))) {
       new_warning(UNDEF, "You're not locked on to a starbase!", -1);
-      return (0);
+      return 0;
    }
    if (!(me->p_flags & PFGREEN)) {
 	new_warning(UNDEF, "OSHA safety regulations prohibit transwarp near enemy ships.", -1);
-	return (0);
+	return 0;
    }
    if (j->p_status != PALIVE) {
       new_warning(UNDEF, "The starbase has been destroyed!", -1);
-      return (0);
+      return 0;
    }
    if (j->p_flags & PFTWARP) {
       new_warning(UNDEF, "Cannot transwarp to a ship already in transwarp, captain!", -1);
-      return (0);
+      return 0;
    }
    if (!((!(j->p_war & me->p_team)) &&
 	 (!(me->p_war & j->p_team)))) {
       new_warning(UNDEF, "Transwarp request rejected by battle computers, captain!", -1);
-      return (0);
+      return 0;
    }
    if (!(j->p_flags & PFDOCKOK)) {
       new_warning(UNDEF, "Starbase refusing all docking permission captain!", -1);
-      return (0);
+      return 0;
    }
    if (!(j->p_transwarp & (j->p_flags ^ PFSHIELD))) {
       char *reason = "";
@@ -82,31 +83,31 @@
          reason = "Starbase refusing transwarp, captain!"; break;
       }
       new_warning(UNDEF, reason, -1);
-      return (0);
+      return 0;
    }
    if (me->p_speed > MIN_INITIAL_SPEED) {
       new_warning(UNDEF, "We cannot exceed warp 2 to initiate transwarp, captain!", -1);
-      return (0);
+      return 0;
    }
    if (me->p_flags & PFREPAIR) {
       new_warning(UNDEF, "Vessel under repair, cannot initiate transwarp!", -1);
-      return (0);
+      return 0;
    }
    if (me->p_flags & PFCLOAK) {
       new_warning(UNDEF, "We're not allowed to transwarp while cloaked, captain!", -1);
-      return (0);
+      return 0;
    }
    if (me->p_flags & PFORBIT) {
       new_warning(UNDEF, "We can't transwarp while orbiting, captain!", -1);
-      return (0);
+      return 0;
    }
    if (me->p_damage > (int) (me->p_ship.s_maxdamage / 3)) {
       new_warning(UNDEF, "Our ship's condition makes it impossible to tranwswarp, captain!", -1);
-      return (0);
+      return 0;
    }
    if (me->p_fuel < (int) (me->p_ship.s_maxfuel / 2)) {
       new_warning(UNDEF, "Too low on fuel, cannot initiate transwarp!", -1);
-      return (0);
+      return 0;
    }
    new_warning(UNDEF, "Transwarp initiated, all systems are DOWN meanwhile!", -1);
 
diff -rN -u old-netrek-server/Vanilla/ntserv/util.c new-netrek-server/Vanilla/ntserv/util.c
--- old-netrek-server/Vanilla/ntserv/util.c	2007-09-07 17:24:12.000000000 +1000
+++ new-netrek-server/Vanilla/ntserv/util.c	2007-09-07 17:24:15.000000000 +1000
@@ -500,6 +500,7 @@
 */
 int is_idle(struct player *victim)
 {
+    if (victim->p_inl_draft != INL_DRAFT_OFF) return 1;
     if (safe_idle
         && (!status->tourn)
         && ((victim->p_flags & PFCLOAK) && (victim->p_flags & PFORBIT)

