Update of /cvsroot/netrek/server/Vanilla/ntserv
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13843/ntserv

Modified Files:
	Makefile.in daemonII.c detonate.c phaser.c torp.c 
Added Files:
	conquer.c 
Log Message:
conquest gloat

Index: phaser.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/phaser.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- phaser.c	23 Apr 2006 13:30:41 -0000	1.2
+++ phaser.c	24 Apr 2006 10:12:18 -0000	1.3
@@ -29,7 +29,7 @@
   U_LONG range_sq, this_range_sq;
   struct phaser *mine = &phasers[me->p_no];
 
-  if (status->gameup & GU_GLOAT_CONQUER) return;
+  if (status->gameup & GU_CONQUER) return;
 
   if (mine->ph_status != PHFREE) {
     new_warning(32, "Phasers have not recharged.");

--- NEW FILE: conquer.c ---
#include "copyright.h"
#include "config.h"
#include "defs.h"
#include "struct.h"
#include "data.h"

/* conquest gloating parade */

static int conquer_player;	/* player number that won	*/
static int conquer_planet;	/* planet they won at		*/
static int conquer_timer;	/* countdown timer		*/

#define CONQUER_TIMER_BEGIN	100	/* total parade length in ticks	*/
#define CONQUER_TIMER_DECLOAK	 90	/* threshold to decloak all	*/
#define CONQUER_TIMER_PARADE	 40	/* threshold to complete parade	*/
#define CONQUER_TIMER_GOODBYE	 10	/* threshold to say goodbye	*/

#define CONQUER_RING_RADIUS	  5	/* orbital radius of ring	*/

/* total bandwidth cost is 2000 bytes per second per slot over ten seconds */

/* borrowed from daemonII.c until we find a better place */
#define TORPFUSE 1
#define PLASMAFUSE 1
#define PLAYERFUSE 1

/* force decloak and visibility of all ships */
static void conquer_decloak()
{
	int h;
	struct player *j;

	for (h = 0, j = &players[0]; h < MAXPLAYER; h++, j++) {
                if (j->p_status == PFREE) continue;
		j->p_flags &= ~PFCLOAK;
		j->p_flags |= PFSEEN;
	}
}

/* cancel any inflight plasma, we want the plasma slots */
static void conquer_deplasma()
{
	struct torp *t;
	for (t = firstPlasma; t <= lastPlasma; t++) {
		t->t_status = TFREE;
	}
}

/* count the number of players to be paraded */
static int conquer_count_players()
{
	int n, h;
	struct player *j;
	for (n = 0, h = 0, j = &players[0]; h < MAXPLAYER; h++, j++) {
                if (j->p_status == PFREE) continue;
		if (j->p_no == conquer_player) continue;
		n++;
	}
	return n;
}

/* calculate parade ring coordinates */
static void conquer_ring_coordinates(struct player *j, int h, int n, int *x, int *y)
{
	j->p_dir = h*256/(n+1);
	j->p_desdir = j->p_dir;
	*x = planets[conquer_planet].pl_x + (ORBDIST * CONQUER_RING_RADIUS)
		* Cos[(u_char) (j->p_dir - (u_char) 64)];
	*y = planets[conquer_planet].pl_y + (ORBDIST * CONQUER_RING_RADIUS)
		* Sin[(u_char) (j->p_dir - (u_char) 64)];
}

/* animate a ring of plasma, in expanding spiral */
static void conquer_plasma_ring()
{
	struct torp *k;
	int np = 0, pn = 0;
	int radius = (CONQUER_TIMER_BEGIN - conquer_timer) 
		* CONQUER_RING_RADIUS * ORBDIST / CONQUER_TIMER_BEGIN;

	for (k = firstPlasma; k <= lastPlasma; k++, k++) {
		np++;
	}

	for (k = firstPlasma; k <= lastPlasma; k++, k++, pn++) {
		k->t_status = TMOVE;
		k->t_type = TPLASMA;
		k->t_attribute = 0;
		k->t_owner = conquer_player;
		k->t_dir = (pn*256/np)+conquer_timer;
		k->t_x = planets[conquer_planet].pl_x + radius
			* Cos[(u_char) (k->t_dir - (u_char) 64)];
		k->t_y = planets[conquer_planet].pl_y + radius
			* Sin[(u_char) (k->t_dir - (u_char) 64)];
		k->t_turns = k->t_damage = k->t_gspeed = k->t_fuse = 1;
		k->t_war = players[conquer_player].p_war;
		k->t_team = players[conquer_player].p_team;
		k->t_whodet = NODET;
	}
}

/* explode the ring of plasma */
static void conquer_plasma_explode()
{
	struct torp *k;
	int np = 0, pn = 0;
	for (k = firstPlasma; k <= lastPlasma; k++, k++) {
		np++;
	}
	for (k = firstPlasma; k <= lastPlasma; k++, k++, pn++) {
		k->t_status = TEXPLODE;
		k->t_fuse = 10/TORPFUSE; 
	}
}

/* animate a ring of ships, move them slowly into position */
static void conquer_ships_ring()
{
	int n, h;
	struct player *j;

	conquer_decloak();
	n = conquer_count_players();
	for (h = 0, j = &players[0]; h < MAXPLAYER; h++, j++) {
		int x, y, dx, dy;
                if (j->p_status == PFREE) continue;
		if (j->p_no == conquer_player) continue;
		conquer_ring_coordinates(j, h, n, &x, &y);
		dx = j->p_x - x;
		dy = j->p_y - y;
		if (abs(dx) < 50) {
			j->p_x = x;
			j->p_y = y;
		} else {
			j->p_x = j->p_x - (dx / 10);
			j->p_y = j->p_y - (dy / 10);
		}
	}


}

/* force the ring of ships into final position */
static void conquer_parade()
{
	int n, h;
	struct player *j;

	n = conquer_count_players();
	for (h = 0, j = &players[0]; h < MAXPLAYER; h++, j++) {
                if (j->p_status == PFREE) continue;
		if (j->p_no == conquer_player) continue;
		conquer_ring_coordinates(j, h, n, &j->p_x, &j->p_y);
		j->p_speed = 0;
	}
}

/* explode the ring of ships */
static void conquer_ships_explode()
{
	int h;
	struct player *j;


	for (h = 0, j = &players[0]; h < MAXPLAYER; h++, j++) {
                if (j->p_status == PFREE) continue;
#ifdef NEWBIESERVER
                /* Don't kill newbie robot. */
                if (status->gameup & GU_NEWBIE && j->p_flags & PFROBOT) continue;
#endif
#ifdef PRETSERVER
                /* Don't kill pre-T robot. */
                if (status->gameup & GU_PRET && j->p_flags & PFROBOT) continue;
#endif
                j->p_status = PEXPLODE;
                j->p_whydead = KWINNER;
                j->p_whodead = conquer_player;
                if (j->p_ship.s_type == STARBASE)
			j->p_explode = 2*SBEXPVIEWS/PLAYERFUSE;
                else
			j->p_explode = 10/PLAYERFUSE;
                j->p_ntorp = 0;
                j->p_nplasmatorp = 0;
	}
}

/* reset the galaxy after conquer */
static void conquer_galaxy_reset()
{
	int i;

	doResources();
	for (i = 0; i <= MAXTEAM; i++) {
                teams[i].s_turns = 0;
                teams[i].s_surrender = 0;
	}
}

static void conquer_end()
{
	conquer_ships_explode();
	conquer_galaxy_reset();
}

/* manage the animation sequence */
/* called by daemon once per tick while in a GU_CONQUER pause */
void conquer_update()
{
	conquer_timer--;
	if (conquer_timer == CONQUER_TIMER_DECLOAK) {
		conquer_decloak();
		conquer_deplasma();
	}
	if (conquer_timer < CONQUER_TIMER_DECLOAK) {
		conquer_plasma_ring();
		conquer_ships_ring();
	}
	if (conquer_timer == CONQUER_TIMER_PARADE)
		conquer_parade();
	if (conquer_timer == CONQUER_TIMER_GOODBYE)
		pmessage(0, MALL, "GOD->ALL", "Goodbye.");
	if (conquer_timer > 0) return;
	status->gameup &= ~(GU_PAUSED|GU_CONQUER);
	conquer_plasma_explode();
	conquer_end();
}

/* begin a conquer parade sequence */
void conquer_begin(struct player *winner)
{
#ifdef NOCONQUERPARADE
	conquer_end();
#else
	status->gameup |= GU_CONQUER|GU_PAUSED;
	conquer_player = winner->p_no;
	conquer_planet = winner->p_planet;
	conquer_timer = CONQUER_TIMER_BEGIN;
#endif
}

/*  Hey Emacs!
 * Local Variables:
 * c-file-style:"bsd"
 * End:
 */

Index: Makefile.in
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/Makefile.in,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Makefile.in	22 Apr 2006 11:31:53 -0000	1.5
+++ Makefile.in	24 Apr 2006 10:12:17 -0000	1.6
@@ -43,7 +43,8 @@
 
 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 libnetrek.a
+	    wander2.o openmem.o solicit.o ltd_stats.o conquer.o \
+	    libnetrek.a
 
 #	Src files
 

Index: torp.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/torp.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- torp.c	23 Apr 2006 13:30:41 -0000	1.2
+++ torp.c	24 Apr 2006 10:12:18 -0000	1.3
@@ -53,7 +53,7 @@
   static LONG last_torp_fired_update = 0;
   struct torp *k;
 
-  if (status->gameup & GU_GLOAT_CONQUER) return;
+  if (status->gameup & GU_CONQUER) return;
 
   /*
    * Prevent player from firing more than one torp per update.  */

Index: detonate.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/detonate.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- detonate.c	23 Apr 2006 13:30:41 -0000	1.2
+++ detonate.c	24 Apr 2006 10:12:18 -0000	1.3
@@ -20,7 +20,7 @@
   struct player *j;
   struct torp *t;
 
-  if (status->gameup & GU_GLOAT_CONQUER) return;
+  if (status->gameup & GU_CONQUER) return;
 
   if (me->p_fuel < myship->s_detcost) {
     new_warning(UNDEF, "Not enough fuel to detonate");

Index: daemonII.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/daemonII.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- daemonII.c	23 Apr 2006 13:30:41 -0000	1.10
+++ daemonII.c	24 Apr 2006 10:12:17 -0000	1.11
@@ -101,7 +101,6 @@
 static void exitDaemon(int sig);
 static void save_planets(void);
 static void checkgen(int loser, struct player *winner);
-static void gloat_conquer_timer();
 static int checkwin(struct player *winner);
 static void ghostmess(struct player *victim);
 static void saveplayer(struct player *victim);
@@ -119,7 +118,7 @@
 static void conquerMessage(int winner);
 static void displayBest(FILE *conqfile, int team, int type);
 static void fork_robot(int robot);
-static void doResources(void);
+void doResources(void);
 /* static void doRotateGalaxy(void); */
 static void signal_servers(void);
 
@@ -569,7 +568,7 @@
     if (status->gameup & GU_PAUSED){ /* Game is paused */
       if (fuse(PLAYERFUSE))
         udplayerpause();
-      if (status->gameup & GU_GLOAT_CONQUER) gloat_conquer_timer();
+      if (status->gameup & GU_CONQUER) conquer_update();
       signal_servers();
       (void) SIGNAL(SIGALRM, move);
       return;
@@ -3710,106 +3709,6 @@
     /* constants (now in defs.h).  30-60 min for a coup.  4/15/92 TC */
 }
 
-#define GLOAT_TIMER_BEGIN 100
-#define GLOAT_TIMER_DECLOAK 90
-#define GLOAT_TIMER_PARADE 40
-#define GLOAT_TIMER_GOODBYE 10
-
-int gloat_player;
-int gloat_planet;
-int gloat_timer;
-
-static void gloat_conquer_decloak()
-{
-	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 & PFCLOAK) {
-			j->p_flags &= ~PFCLOAK;
-			// players[i].p_cloakphase--;
-		}
-	}
-}
-
-static void gloat_conquer_parade()
-{
-	int i, h;
-	struct player *j;
-
-	for (i = 0, h = 0, j = &players[0]; h < MAXPLAYER; h++, j++) {
-                if (j->p_status == PFREE) continue;
-		if (j->p_no == gloat_player) continue;
-		i++;
-	}
-	for (h = 0, j = &players[0]; h < MAXPLAYER; h++, j++) {
-                if (j->p_status == PFREE) continue;
-		if (j->p_no == gloat_player) continue;
-		j->p_dir = h*256/i;
-		j->p_desdir = j->p_dir;
-		j->p_x = planets[gloat_planet].pl_x + (ORBDIST * 5)
-                        * Cos[(u_char) (j->p_dir - (u_char) 64)];
-		j->p_y = planets[gloat_planet].pl_y + (ORBDIST * 5)
-                        * Sin[(u_char) (j->p_dir - (u_char) 64)];
-	}
-}
-
-static void gloat_conquer_kill()
-{
-	int h;
-	struct player *j;
-
-	for (h = 0, j = &players[0]; h < MAXPLAYER; h++, j++) {
-                if (j->p_status == PFREE) continue;
-#ifdef NEWBIESERVER
-                /* Don't kill newbie robot. */
-                if (status->gameup & GU_NEWBIE && j->p_flags & PFROBOT) continue;
-#endif
-#ifdef PRETSERVER
-                /* Don't kill pre-T robot. */
-                if (status->gameup & GU_PRET && j->p_flags & PFROBOT) continue;
-#endif
-                j->p_status = PEXPLODE;
-                j->p_whydead = KWINNER;
-                j->p_whodead = gloat_player;
-                if (j->p_ship.s_type == STARBASE)
-			j->p_explode = 2*SBEXPVIEWS/PLAYERFUSE;
-                else
-			j->p_explode = 10/PLAYERFUSE;
-                j->p_ntorp = 0;
-                j->p_nplasmatorp = 0;
-	}
-}
-
-static void gloat_conquer_reset()
-{
-	int i;
-
-	doResources();
-	ERROR(2,("Resetting galaxy after Conquer.\n"));
-	for (i = 0; i <= MAXTEAM; i++) {
-                teams[i].s_turns = 0;
-                teams[i].s_surrender = 0;
-	}
-}
-
-static void gloat_conquer_timer()
-{
-	gloat_timer--;
-	if (gloat_timer == GLOAT_TIMER_DECLOAK)
-		gloat_conquer_decloak();
-	if (gloat_timer == GLOAT_TIMER_PARADE)
-		gloat_conquer_parade();
-	if (gloat_timer == GLOAT_TIMER_GOODBYE)
-		pmessage(0, MALL, "GOD->ALL", "Goodbye.");
-	if (gloat_timer > 0) return;
-	
-	status->gameup &= ~(GU_PAUSED|GU_GLOAT_CONQUER);
-	gloat_conquer_kill();
-	gloat_conquer_reset();
-}
-
 /* This function is called when a planet has been taken over.
    It checks all the planets to see if the victory conditions
    are right.  If so, it blows everyone out of the game and
@@ -3869,10 +3768,7 @@
     for (i = 0; i < 4; i++) {
         if (team[1<<i] >= VICTORY) {
             conquerMessage(winner->p_team);
-	    status->gameup |= GU_GLOAT_CONQUER|GU_PAUSED;
-	    gloat_player = winner->p_no;
-	    gloat_planet = winner->p_planet;
-	    gloat_timer = GLOAT_TIMER_BEGIN;
+	    conquer_begin(winner);
 	    return 1;
         }
     }
@@ -4393,7 +4289,7 @@
  { 31, 32, 33, 35, 36,},
 };
 
-static void doResources(void)
+void doResources(void)
 {
   int i, j, k, which;
   MCOPY(pdata, planets, sizeof(pdata));
@@ -4447,7 +4343,7 @@
   }
 }
 #else
-static void doResources(void)
+void doResources(void)
 {
     int i;
     int agricount[4];