Update of /cvsroot/netrek/server/Vanilla/ntserv
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv28256/ntserv
Modified Files:
Makefile.in daemonII.c data.c detonate.c enter.c findslot.c
genspkt.c getship.c input.c interface.c main.c ntscmds.c
openmem.c orbit.c redraw.c socket.c transwarp.c
Log Message:
merge 2.11.1 from darcs
Index: redraw.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/redraw.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- redraw.c 12 May 2006 03:44:48 -0000 1.4
+++ redraw.c 1 Jun 2006 03:17:25 -0000 1.5
@@ -210,7 +210,7 @@
me->p_wtemp = pl->p_wtemp;
me->p_etemp = pl->p_etemp;
/* These flags shouldn't be propagated to observers */
-#define NOOBSMASK (PFWAR|PFREFITTING|PFSELFDEST|PFPLOCK|PFPLLOCK|PFOBSERV)
+#define NOOBSMASK (PFSELFDEST|PFPLOCK|PFPLLOCK|PFOBSERV)
me->p_flags = (pl->p_flags & ~NOOBSMASK) | (me->p_flags & NOOBSMASK);
me->p_dir = pl->p_dir;
Index: ntscmds.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/ntscmds.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- ntscmds.c 12 May 2006 03:44:48 -0000 1.12
+++ ntscmds.c 1 Jun 2006 03:17:25 -0000 1.13
@@ -56,6 +56,9 @@
void do_sbtime_msg(char *comm, struct message *mess);
void do_queue_msg(char *comm, struct message *mess);
void do_nowobble(char *comm, struct message *mess);
+#ifdef EXPERIMENTAL_BECOME
+void do_become(char *comm, struct message *mess);
+#endif
#ifdef GENO_COUNT
void do_genos_query(char *comm, struct message *mess, int who);
@@ -153,6 +156,12 @@
0,
"Test new wobble on planet lock fix.",
do_nowobble }, /* NOWOBBLE */
+#ifdef EXPERIMENTAL_BECOME
+ { "BECOME",
+ 0,
+ "Become a different slot number",
+ do_become }, /* BECOME */
+#endif
{ "TIME",
C_PR_INPICKUP,
"Show time left on surrender timer.",
@@ -745,6 +754,42 @@
nowobble ? "on (new test mode)" : "off (classic mode)", nowobble, comm );
}
+#ifdef EXPERIMENTAL_BECOME
+/* become another slot ... lacking client support, in progress */
+void do_become(char *comm, struct message *mess)
+{
+ int who, pno;
+ char *addr;
+
+ who = mess->m_from;
+ addr = addr_mess(who,MINDIV);
+
+ pno = atoi(comm+strlen("become "));
+
+ if (pno < 0) return;
+ if (pno > (MAXPLAYER-1)) return;
+
+ if (me->p_no == pno) {
+ pmessage(who, MINDIV, addr, "you are this slot already");
+ return;
+ }
+
+ struct player *be = &players[pno];
+ if (be->p_status != PFREE) {
+ pmessage(who, MINDIV, addr, "slot is not free");
+ return;
+ }
+
+ memcpy(be, me, sizeof(struct player));
+ me->p_status = PFREE;
+ me = be;
+ me->p_no = pno;
+ sprintf(me->p_mapchars,"%c%c",teamlet[me->p_team], shipnos[me->p_no]);
+ sprintf(me->p_longname, "%s (%s)", me->p_name, me->p_mapchars);
+ updateSelf(1);
+}
+#endif
+
void do_password(char *comm, struct message *mess)
{
int who = mess->m_from;
Index: orbit.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/orbit.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- orbit.c 10 Apr 2006 10:56:32 -0000 1.3
+++ orbit.c 1 Jun 2006 03:17:25 -0000 1.4
@@ -33,6 +33,9 @@
{
me->p_flags &= ~(PFPLOCK | PFPLLOCK | PFTRACT | PFPRESS);
#ifdef SB_TRANSWARP
+ /* upon arrival at a base, during a dock attempt, if the dock fails,
+ and we were transwarping in, force a refit delay for five
+ seconds. */
if (me->p_flags & PFTWARP){
me->p_flags &= ~PFTWARP;
me->p_flags |= PFREFITTING;
Index: Makefile.in
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/Makefile.in,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Makefile.in 6 May 2006 13:12:56 -0000 1.7
+++ Makefile.in 1 Jun 2006 03:17:25 -0000 1.8
@@ -2,6 +2,8 @@
srcdir = @srcdir@
CONFIG = system.mk
+RANLIB = @RANLIB@
+RANLIB_FLAGS = @RANLIB_FLAGS@
include ../$(CONFIG)
@@ -80,23 +82,23 @@
all: $(PMAKE) ntserv daemonII
ntserv: $(PMAKE) $(R_OBJS)
- $(CC) $(CFLAGS) ${LDFLAGS} -o ntserv $(R_OBJS) $(LIBS) $(LIBCRYPT) `glib-config --libs` -lgdbm
+ $(CC) $(CFLAGS) ${LDFLAGS} -o ntserv $(R_OBJS) $(LIBS) $(LIBCRYPT) -lgdbm
daemonII: $(PMAKE) $(D_OBJS)
$(CC) $(CFLAGS) ${LDFLAGS} -o daemonII $(D_OBJS) $(EXTRALIBS)
libnetrek.a: $(L_OBJS)
- ar cru $@ $(L_OBJS)
- ranlib $@
+ $(AR) cru $@ $(L_OBJS)
+ $(RANLIB) $(RANLIB_FLAGS) $@
libnetrek.so: $(L_OBJS)
- gcc -shared -Wl,-soname,$@ -o $@ $(L_OBJS) -lc
+ $(CC) -shared -Wl,-soname,$@ -o $@ $(L_OBJS) -lc
commands.o: $(PMAKE) ${srcdir}/commands.c
$(CC) $(CFLAGS) $(DEP) -c ${srcdir}/commands.c
db.o: $(PMAKE) db.c
- $(CC) $(CFLAGS) $(DEP) `glib-config --cflags` -c db.c
+ $(CC) $(CFLAGS) $(DEP) -c db.c
cflags:
echo "static char cflags[]=\"$(CFLAGS) $(LIBS)\";" >../cflags.h
@@ -131,6 +133,11 @@
touch $(DESTDIR)$(LOCALSTATEDIR)/planets
chmod 600 $(DESTDIR)$(LOCALSTATEDIR)/planets
+install-ntserv: ntserv
+ mkdir $(DESTDIR)$(LIBDIR)/ntserv-archive
+ mv $(DESTDIR)$(LIBDIR)/ntserv $(DESTDIR)$(LIBDIR)/ntserv-archive/ntserv.`date +%Y-%m-%d`.$$
+ $(INSTALLPROG) $(INSTALLOPTS) ntserv $(DESTDIR)$(LIBDIR)/ntserv
+
installbin: install
echo "target installbin deprecated, assumed install"
Index: input.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/input.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- input.c 21 Mar 2005 05:23:43 -0000 1.1
+++ input.c 1 Jun 2006 03:17:25 -0000 1.2
@@ -22,6 +22,7 @@
#include "struct.h"
#include "data.h"
#include "proto.h"
+#include "packets.h"
#define GHOSTTIME (30 * 1000000 / UPDATE) /* 30 secs */
@@ -56,10 +57,8 @@
ERROR(2,("%s: ghostbusted by ping loss\n",
me->p_mapchars));
fflush(stderr);
- } else
+ }
#endif /*PING*/
-
- me->p_ghostbuster = 0;
}
static int resurrect(void)
@@ -110,6 +109,15 @@
return 1;
}
+static void gamedown()
+{
+ struct badversion_spacket packet;
+ packet.type = SP_BADVERSION;
+ packet.why = 6;
+ sendClientPacket(&packet);
+ flushSockBuf();
+}
+
void input(void)
{
fd_set readfds;
@@ -127,6 +135,7 @@
resurrect();
}
if (! (status -> gameup & GU_GAMEOK)){
+ gamedown();
freeslot(me);
exit(0);
}
@@ -150,6 +159,7 @@
}
readFromClient();
+ me->p_ghostbuster = 0;
if (sendflag) {
intrupt();
sendflag=0;
@@ -159,5 +169,3 @@
}
}
-
-
Index: enter.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/enter.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- enter.c 26 Apr 2006 09:52:43 -0000 1.4
+++ enter.c 1 Jun 2006 03:17:25 -0000 1.5
@@ -210,7 +210,7 @@
#endif /*LTD_STATS*/
/* If switching, become hostile to former team 6/29/92 TC */
if (lastteam >= 0)
- declare_war(1<<lastteam);
+ declare_war(1<<lastteam, 0);
}
if (lastrank==-1) lastrank=mystats->st_rank; /* NBT patch */
lastteam=tno;
Index: getship.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/getship.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- getship.c 21 Mar 2005 05:23:43 -0000 1.1
+++ getship.c 1 Jun 2006 03:17:25 -0000 1.2
@@ -276,8 +276,8 @@
shipvals[ATT].s_mass = 32765; /* att: */
shipvals[ATT].s_tractstr = 32765; /* att: */
shipvals[ATT].s_tractrng = 25; /* att: */
- shipvals[ATT].s_width = 28; /* att: */
- shipvals[ATT].s_height = 28; /* att: */
+ shipvals[ATT].s_width = 20; /* att: */
+ shipvals[ATT].s_height = 20; /* att: */
shipvals[ATT].s_type = ATT; /* att: */
shipvals[CRUISER].s_turns = 170000; /* cruiser: */
shipvals[CRUISER].s_accint = 150; /* cruiser: */
Index: openmem.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/openmem.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- openmem.c 12 May 2006 03:44:48 -0000 1.5
+++ openmem.c 1 Jun 2006 03:17:25 -0000 1.6
@@ -1,6 +1,3 @@
-/*
- * $Id$
- */
#include "copyright.h"
#include <stdio.h>
@@ -10,9 +7,7 @@
#include <sys/ipc.h>
#include <sys/shm.h>
#include <errno.h>
-#include <pwd.h>
-#include <ctype.h>
-#include <time.h> /* 7/16/91 TC */
+#include <signal.h>
#include "defs.h"
#include "struct.h"
#include "data.h"
@@ -53,10 +48,59 @@
*
*/
+/* identifier of the shared memory segment */
+static int shmid;
+
+/* shared memory key */
+static int pkey = PKEY;
+
+/* shared memory pointer */
+static struct memory *sharedMemory = NULL;
+
+/* daemon initialisation is pending */
+static int daemon_initialisation_pending;
+
+/* set a different shared memory key for this process and children */
+void setpkey(int nkey)
+{
+ char ev[32];
+ pkey = nkey;
+ sprintf(ev, "NETREK_PKEY=%d", nkey);
+ if (putenv(ev) != 0) {
+ perror("setpkey: putenv");
+ }
+}
+
+/* get the current shared memory key for this process */
+int getpkey()
+{
+ return pkey;
+}
+
+/* initialise shared memory key from environment variables */
+static void initpkey()
+{
+ char *ev = getenv("NETREK_PKEY");
+ if (ev == NULL) return;
+ pkey = atoi(ev);
+ if (pkey < 1) pkey = PKEY;
+}
+
+/* called when daemon initialisation is complete */
+static void daemon_ready(int signum)
+{
+ daemon_initialisation_pending = 0;
+}
+
+/* start the daemon, wait for it to finish initialising */
static void startdaemon(void)
{
pid_t i;
+ /* ask to be told when daemon initialisation completes */
+ daemon_initialisation_pending = 1;
+ signal(SIGUSR1, daemon_ready);
+
i = fork();
if (i == (pid_t)0) {
execl(Daemon, "daemon", (char *) NULL);
@@ -64,8 +108,13 @@
ERROR(1,("Couldn't start daemon!!!\n"));
_exit(1);
}
+
+ /* wait until daemon has initialised */
+ while (daemon_initialisation_pending) pause();
+ signal(SIGUSR1, NULL);
}
+/* connect all the pointers to the various areas of the segment */
static void setup_memory(struct memory *sharedMemory)
{
players = sharedMemory->players;
@@ -86,14 +135,8 @@
/*ARGSUSED*/
int openmem(int trystart)
{
- extern int errno;
- int shmemKey = PKEY;
- struct memory *sharedMemory;
- int shmid;
-
- errno = 0;
-
- shmid = shmget(shmemKey, SHMFLAG, 0);
+ initpkey();
+ shmid = shmget(pkey, SHMFLAG, 0);
if (shmid < 0) { /* Could not find the shared memory */
if (errno != ENOENT) { /* Error other not created yet */
perror("shmget");
@@ -101,7 +144,6 @@
}
if (trystart==1){ /* Create the memory */
startdaemon();
- sleep(2);
}
else if (trystart < 0){ /* Just checking if it exists */
return 0;
@@ -110,7 +152,7 @@
fprintf(stderr,"Warning: Daemon not running!\n");
exit(1);
}
- shmid = shmget(shmemKey, SHMFLAG, 0);
+ shmid = shmget(pkey, SHMFLAG, 0);
if (shmid < 0) { /* This is a bummer of an error */
ERROR(1, ("Daemon not running (err:%d)\n",errno));
exit(1);
@@ -123,30 +165,22 @@
exit(1);
}
setup_memory(sharedMemory);
-
return 1;
}
-/* Static variable only used by these routines in the daemon*/
-static int shmid; /* The id of the shared memory segment */
-
int setupmem(void) {
- extern int errno;
- int shmemKey = PKEY;
- struct memory *sharedMemory;
struct shmid_ds smbuf;
- errno = 0;
-
+ initpkey();
/* Kill any existing segments */
- if ((shmid = shmget(shmemKey, SHMFLAG , 0)) >= 0) {
+ if ((shmid = shmget(pkey, SHMFLAG , 0)) >= 0) {
ERROR(2,("setupmem: Killing existing segment\n"));
shmctl(shmid, IPC_RMID, (struct shmid_ds *) 0);
}
/* Get them memory id */
- shmid = shmget(shmemKey, sizeof(struct memory), IPC_CREAT | 0777);
+ shmid = shmget(pkey, sizeof(struct memory), IPC_CREAT | 0777);
if (shmid < 0) {
ERROR(1,("setupmem: Can't open shared memory, error %i\n",errno));
return 0;
@@ -177,11 +211,12 @@
if (shmctl(shmid, IPC_RMID, (struct shmid_ds *) 0) < 0){
return 0;
}
+ perror("removemem");
return 1;
}
-#ifdef nodef
-static int detachmem(void) {
- return shmdt((void*)players); /* cheat! what is a better way?? jc */
+int detachmem(void) {
+ if (shmdt(sharedMemory) < 0) return 0;
+ perror("detachmem");
+ return 1;
}
-#endif
Index: transwarp.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/transwarp.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- transwarp.c 21 Mar 2005 05:23:44 -0000 1.1
+++ transwarp.c 1 Jun 2006 03:17:25 -0000 1.2
@@ -56,7 +56,7 @@
}
if (!((!(j->p_war & me->p_team)) &&
(!(me->p_war & j->p_team)))) {
- new_warning(UNDEF, "The starbase is not peaceful, captain!", -1);
+ new_warning(UNDEF, "Transwarp request rejected by battle computers, captain!", -1);
return (0);
}
if (!(j->p_flags & PFDOCKOK)) {
Index: findslot.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/findslot.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- findslot.c 6 May 2006 14:02:37 -0000 1.5
+++ findslot.c 1 Jun 2006 03:17:25 -0000 1.6
@@ -17,22 +17,20 @@
#include "packets.h"
#include "proto.h"
-#ifdef NO_DUPLICATE_HOSTS
-/* return true if the host is not already in the game */
-static int absent(int w_queue, char *host) {
- int i;
- for (i=0; i<MAXPLAYER; i++) {
+/* return number of other hosts in game with same ip */
+static int player_count_by_ip(int w_queue, char *ip) {
+ int i, j;
+ for (i=0, j=0; i<MAXPLAYER; i++) {
if (players[i].p_status == PFREE) continue;
if ((players[i].p_flags & PFROBOT)) continue;
#ifdef OBSERVERS
/* if we want a pickup slot, ignore any observer slot we have */
if (w_queue == QU_PICKUP && players[i].p_status == POBSERV) continue;
#endif
- if (strcmp(players[i].p_full_hostname, host) == 0) return 0;
+ if (strcmp(players[i].p_ip, ip) == 0) j++;
}
- return 1;
+ return j;
}
-#endif
/*
* The following code for findslot() is really nice.
@@ -48,7 +46,7 @@
* oldcount: (local) My position last time I looked.
*/
-int findslot(int w_queue, char *host)
+int findslot(int w_queue, char *ip)
{
u_int oldcount; /* My old number */
pid_t mypid = getpid();
@@ -59,24 +57,16 @@
/* Ensure that the queue is open */
if (!(queues[w_queue].q_flags & QU_OPEN)) return (-1);
-#ifdef NO_DUPLICATE_HOSTS
/* pre-queue if client from same ip address is already playing */
if ((w_queue == QU_PICKUP) || (w_queue == QU_PICKUP_OBS)) {
for (;;) {
-#ifdef CONTINUUM
- /* dogmeat's obstrek server */
- if (!strcmp(host, "c-24-4-208-59.client.comcast.net")) break;
- /* roland's workplace */
- if (!strcmp(host, "ip57.bb168.pacific.net.hk")) break;
-#endif
- if (absent(w_queue, host)) break;
+ if (player_count_by_ip(w_queue, ip) <= duplicates) break;
if (rep++ % 10 == 1) { sendQueuePacket((short) MAXPLAYER); }
if (isClientDead()) { fflush(stderr); exit(0); }
if (!(status->gameup & GU_GAMEOK)) { return (-1); }
sleep(1);
}
}
-#endif
/* If no one is waiting, I will try to enter now */
if (queues[w_queue].first == -1)
Index: data.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/data.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- data.c 12 May 2006 03:44:48 -0000 1.8
+++ data.c 1 Jun 2006 03:17:25 -0000 1.9
@@ -413,3 +413,4 @@
int eject_vote_enable=0;
int eject_vote_only_if_queue=0;
int eject_vote_vicious=0;
+int duplicates=3;
Index: genspkt.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/genspkt.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- genspkt.c 6 May 2006 14:02:37 -0000 1.6
+++ genspkt.c 1 Jun 2006 03:17:25 -0000 1.7
@@ -151,8 +151,8 @@
u_char clientVKills[MAXPLAYER*2+2 +4];
int clientVKillsCount;
struct stats_s_spacket singleStats;
-unsigned char n_flags[MAXPLAYER];
-int highest_active_player;
+static unsigned char n_flags[MAXPLAYER];
+static int highest_active_player;
#if MAXPLAYER > 32
static u_char clientVXPlayers[33*4];
@@ -300,13 +300,16 @@
}
+/* This function is for sending the flags of OTHER players, the player's
+ own flags are handled elsewhere. The cambot will set f_many_self,
+ and use this function to record the flags of all players. */
int sndFlags( struct flags_spacket *flags, struct player *pl, int howmuch)
{
/*#define FLAGMASK (PFSHIELD|PFBOMB|PFORBIT|PFCLOAK|PFROBOT|PFBEAMUP|PFBEAMDOWN|PFPRACTR|PFDOCK|PFTRACT|PFPRESS|PFDOCKOK) aieee, too much. 7/27/91 TC */
/*#define FLAGMASK (PFSHIELD|PFBOMB|PFORBIT|PFCLOAK|PFROBOT| PFPRACTR|PFDOCK|PFTRACT|PFPRESS|PFDOCKOK) still more than needed */
/* Flags we get to know about players not seen */
-#define INVISOMASK (PFCLOAK|PFROBOT|PFPRACTR|PFDOCKOK|PFOBSERV)
+#define INVISOMASK (PFCLOAK|PFROBOT|PFPRACTR|PFDOCKOK|PFOBSERV|PFBPROBOT)
/* Flags we get to know about players who are seen */
#define FLAGMASK (PFSHIELD | INVISOMASK)
@@ -314,16 +317,17 @@
int tractor = ((F_show_all_tractors || f_many_self) && pl->p_flags&PFTRACT)?
(pl->p_tractor|0x40):0;
+#ifdef OBSERVERS
+ if (!f_many_self && pl->p_status == POBSERV) {
+ mask = PFOBSERV; /* All we need to know about observers. */
+ tractor = 0;
+ } else
+#endif
if (howmuch == UPDT_ALL) {
mask = FLAGMASK;
if(F_show_all_tractors || f_many_self) mask |= PFTRACT|PFPRESS;
} else
mask = INVISOMASK;
-
- /* With short packets 2 flag sampling, these don't need to be sent */
- if (send_short>1 && pl->p_no<32)
- mask &= ~(PFSHIELD|PFCLOAK);
-
if ((ntohl(flags->flags)&mask) == (pl->p_flags&mask) &&
flags->tractor==tractor)
@@ -561,6 +565,7 @@
tp->type = SP_TORP;
tp->x = htonl(t->t_x);
tp->y = htonl(t->t_y);
+ tp->dir = t->t_dir; /* The robot needs this */
tp->tnum = htons(i);
sendClientPacket(tp);
if ( (t->t_status != tpi->status)
@@ -623,6 +628,11 @@
|| ((t->t_war & me->p_team) != tpi->war)) {
tpi->type = SP_PLASMA_INFO;
tpi->war = t->t_war & me->p_team;
+ /* In PP plasma mode, plasmas change teams, but client doesn't
+ know. If player is at war with plasma's new team, set the
+ plasma's war flag, so client knows it is hostile. */
+ if (pingpong_plasma && (t->t_team & me->p_war))
+ tpi->war |= me->p_team;
tpi->pnum = htons(i);
tpi->status = t->t_status;
sendClientPacket(tpi);
@@ -759,7 +769,8 @@
updtPlanet(struct planet_spacket *pl, struct planet *plan, int howmuch)
{
-#define PLFLAGMASK (PLREPAIR|PLFUEL|PLAGRI|PLHOME|PLCOUP)
+#define PLFLAGMASK (PLREPAIR|PLFUEL|PLAGRI|PLHOME|PLCOUP|PLCORE)
+
if (howmuch == UPDT_ALL) {
if ( pl->info != plan->pl_info
@@ -887,7 +898,7 @@
case DMKILLP:
#ifdef CHAIN_REACTION
if (why_dead) {
- swarning(KILLARGS2,(u_char)cur->args[5],0);
+ swarning(KILLARGS2,(u_char)cur->args[5],(u_char)cur->args[4]);
}
#endif
swarning(DMKILLP, (u_char)cur->args[1], (u_char)cur->args[2]);
@@ -1168,17 +1179,21 @@
sndPlayerInfo(cpli, pl);
sndKills(kills, pl);
+ /* S_P2 new flag sampling */
+ if (send_short > 1) {
+ u_int oldflags;
#ifdef OBSERVERS
- if(pl->p_status != POBSERV){
+ /* Skip observers' flags, unless I am the observer. */
+ if (pl->p_status != POBSERV || pl == me) {
#endif
- /* S_P2 new flag sampling */
- if(!(pl->p_flags & PFROBOT)) { /* No robos please */
switch(pl->p_status){
+#ifdef OBSERVERS
+ case POBSERV:
+#endif
case PALIVE: /* huh, we must work */
highest_active_player = i;
if(pl->p_flags & PFCLOAK){
n_flags[i] = 1;
- break;
}
else if(pl->p_flags & PFSHIELD){
n_flags[i] = 2;
@@ -1197,10 +1212,16 @@
/* Is it ok to send the old value ? */
break;
}
- } /* robos out */
+ /* Mark shield and cloak as updated, so they won't be resent
+ again with a flags packet. */
+ oldflags = ntohl(flags->flags);
+ oldflags &= ~(PFSHIELD|PFCLOAK);
+ oldflags |= pl->p_flags&(PFSHIELD|PFCLOAK);
+ flags->flags = htonl(oldflags);
#ifdef OBSERVERS
- }
+ }
#endif
+ }
if (sndPStatus(pstatus, pl)) {
update=1;
Index: detonate.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/detonate.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- detonate.c 24 Apr 2006 10:12:18 -0000 1.3
+++ detonate.c 1 Jun 2006 03:17:25 -0000 1.4
@@ -28,7 +28,8 @@
}
if (me->p_flags & PFWEP) {
new_warning(UNDEF, "Weapons overheated");
- return;
+ if (!chaosmode)
+ return;
}
me->p_fuel -= myship->s_detcost;
Index: main.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/main.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- main.c 12 May 2006 03:44:48 -0000 1.10
+++ main.c 1 Jun 2006 03:17:25 -0000 1.11
@@ -35,8 +35,7 @@
static void sendMotd(void);
static void sendConfigMsg(void);
static void printStats(void);
-static int check_temporary_bans(char *ip);
-static int check_permanent_bans(char *login, char *host);
+static void bans_check();
extern int ignored[MAXPLAYER];
int indie = 0; /* always be indie 8/28/91 TC */
@@ -171,7 +170,7 @@
sendMotd();
/* wait for a slot to become free */
- pno = findslot(w_queue, host);
+ pno = findslot(w_queue, inet_ntoa(*(struct in_addr *)&remoteaddr));
if (pno < 0) {
/* trigger client's "Sorry, but you cannot play xtrek now.
Try again later." */
@@ -400,37 +399,7 @@
#endif
me->p_status = PALIVE; /* Put player in game */
me->p_ghostbuster = 0;
-
- if (!bypassed) {
- char *reason = NULL;
- if (check_permanent_bans(login, host) == TRUE) {
- reason = "banned by the administrator";
- } else if (check_permanent_bans(login, me->p_ip) == TRUE) {
- reason = "banned by the administrator";
- } else if (check_temporary_bans(me->p_ip) == TRUE) {
- reason = "banned by the players";
- }
- if (reason != NULL) {
- FILE *logfile;
- time_t curtime;
-
- pmessage(0, MALL, "GOD->ALL","%s (%s@%s) is %s.",
- me->p_name, me->p_login, me->p_ip, reason);
- new_warning(UNDEF,"You are banned from the game.");
- me->p_explode=100;
- me->p_status=PEXPLODE;
- me->p_whydead=KQUIT; /* make him self destruct */
- me->p_whodead=0;
- logfile=fopen(LogFileName, "a");
- if (logfile) {
- curtime=time(NULL);
- fprintf(logfile, "Banned and exiting: %s (%s@%s), (%c), %s",
- me->p_name, me->p_login, host, shipnos[me->p_no], ctime(&curtime)
- );
- fclose(logfile);
- }
- }
- }
+ bans_check();
/* Get input until the player quits or dies */
living++;
@@ -818,7 +787,7 @@
}
/* check temporary bans voted */
-static int check_temporary_bans(char *ip)
+static int bans_check_temporary(char *ip)
{
int i;
for(i=0; i<MAXBANS; i++) {
@@ -839,7 +808,7 @@
}
/* check permanent bans in file */
-static int check_permanent_bans(char *login, char *host)
+static int bans_check_permanent(char *login, char *host)
{
FILE *bannedfile;
char log_buf[64], host_buf[64], line_buf[160];
@@ -907,6 +876,65 @@
return(FALSE);
}
+static void bans_log()
+{
+ FILE *logfile;
+ time_t curtime;
+
+ logfile = fopen(LogFileName, "a");
+ if (logfile) {
+ curtime = time(NULL);
+ fprintf(logfile, "Banned: %s (%s@%s), (%c), %s",
+ me->p_name, me->p_login, host, shipnos[me->p_no], ctime(&curtime)
+ );
+ fclose(logfile);
+ }
+}
+
+static void bans_enforce_alive()
+{
+ new_warning(UNDEF,"You are banned from the game, goodbye.");
+ me->p_explode=100;
+ me->p_status=PEXPLODE;
+ me->p_whydead=KQUIT; /* make him self destruct */
+ me->p_whodead=0;
+}
+
+static void bans_enforce_observ()
+{
+ mute = 1;
+ new_warning(UNDEF,"You are banned from the game, you may not speak.");
+}
+
+static void bans_enforce(char *reason)
+{
+ pmessage(0, MALL, "GOD->ALL","%s (%s@%s) is %s.",
+ me->p_name, me->p_login, me->p_ip, reason);
+ bans_log();
+ if (me->p_status == PALIVE) {
+ bans_enforce_alive();
+ } else if (me->p_status == POBSERV) {
+ bans_enforce_observ();
+ }
+}
+
+static void bans_check()
+{
+ if (!bypassed) {
+ char *reason = NULL;
+ if (bans_check_permanent(login, host) == TRUE) {
+ reason = "banned by the administrator";
+ } else if (bans_check_permanent(login, me->p_ip) == TRUE) {
+ reason = "banned by the administrator";
+ } else if (bans_check_temporary(me->p_ip) == TRUE) {
+ reason = "banned by the players";
+ }
+ if (reason != NULL) {
+ bans_enforce(reason);
+ }
+ }
+}
+
/* ARGSUSED */
void message_flag(struct message *cur, char *address)
{
Index: daemonII.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/daemonII.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- daemonII.c 12 May 2006 03:44:48 -0000 1.14
+++ daemonII.c 1 Jun 2006 03:17:25 -0000 1.15
@@ -276,10 +276,12 @@
exitDaemon(0);
}
- x = 0;
-
check_load();
+ /* signal parent ntserv that daemon is ready */
+ kill(getppid(), SIGUSR1);
+
+ x = 0;
for (;;) {
PAUSE(SIGALRM);
if (debug) {
@@ -336,7 +338,6 @@
#define TERMINATOR (-2) /* Terminator */
#define STERMINATOR (-3) /* sticky Terminator */
-int nplayers = 0; /* isae - was missing int */
int dietime = -1; /* isae - was missing int */
static int tournamentMode(void)
@@ -493,7 +494,8 @@
pmessage(0, MALL, "GOD->ALL","Diplomat insults foriegn emperor's mother and fighting breaks out!");
break;
case 6:
- pmessage(0, MALL, "GOD->ALL","Dan Quayle declares self as galactic emperor and chaos breaks out!");
+ pmessage(0, MALL, "GOD->ALL","%s declares self as galactic emperor and chaos breaks out!",
+ WARMONGER);
break;
default:
pmessage(0, MALL, "GOD->ALL","Peace parties have been demobilized, and fighting ensues.");
@@ -523,7 +525,8 @@
pmessage(0, MALL, "GOD->ALL","Diplomat apologizes to foreign emperor's mother and invasion is stopped!");
break;
case 6:
- pmessage(0, MALL, "GOD->ALL","Dan Quayle is locked up and order returns to the galaxy!");
+ pmessage(0, MALL, "GOD->ALL","%s is locked up and order returns to the galaxy!",
+ WARMONGER);
break;
default:
pmessage(0, MALL, "GOD->ALL","The peace party has reformed, and is rallying for peace");
@@ -864,7 +867,7 @@
float dist; /* used by tractor beams */
int maxspeed;
- nplayers = 0;
+ int nfree = 0;
tcount[FED] = tcount[ROM] = tcount[KLI] = tcount[ORI] = 0;
for (i = status->active = 0, j = &players[i]; i < MAXPLAYER; i++, j++) {
int outfitdelay;
@@ -907,7 +910,7 @@
}
continue;
case PFREE:
- nplayers++;
+ nfree++;
j->p_ghostbuster = 0; /* stop from hosing new players */
continue;
#ifdef OBSERVERS
@@ -1473,11 +1476,15 @@
break;
} /* end switch */
}
- if (nplayers == MAXPLAYER) {
- if (dietime == -1)
- dietime = ticks + 600 / PLAYERFUSE;
- }
- else {
+ if (nfree == MAXPLAYER) {
+ if (dietime == -1) {
+ if (status->gameup & GU_GAMEOK) {
+ dietime = ticks + 600 / PLAYERFUSE;
+ } else {
+ dietime = ticks + 10 / PLAYERFUSE;
+ }
+ }
+ } else {
dietime = -1;
}
}
@@ -2745,7 +2752,7 @@
arg[1] = j->p_no;
arg[2] = l->pl_no;
arg[3] = 0;
- arg[4] = 0;
+ arg[4] = j->p_armies;
#ifdef CHAIN_REACTION
strcat(buf," [planet]");
arg[5] = KPLANET;
Index: socket.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/socket.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- socket.c 6 May 2006 14:02:38 -0000 1.8
+++ socket.c 1 Jun 2006 03:17:25 -0000 1.9
@@ -1098,8 +1098,12 @@
packets_received ++;
#endif
if (handlers[(int)*bufptr].handler != NULL) {
- if (((FD_ISSET(*bufptr, &inputMask)) &&
- (me==NULL || !(me->p_flags & (PFWAR|PFREFITTING
+ if (((FD_ISSET(*bufptr, &inputMask)) &&
+ (me==NULL
+#ifdef OBSERVERS
+ || (me->p_status == POBSERV)
+#endif
+ || !(me->p_flags & (PFWAR|PFREFITTING
#ifdef SB_TRANSWARP
| PFTWARP
#endif
@@ -1325,7 +1329,7 @@
static void handleWarReq(struct war_cpacket *packet)
{
- declare_war(packet->newmask);
+ declare_war(packet->newmask, 1);
}
static void handlePlanlockReq(struct planlock_cpacket *packet)
Index: interface.c
===================================================================
RCS file: /cvsroot/netrek/server/Vanilla/ntserv/interface.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- interface.c 10 Apr 2006 10:56:32 -0000 1.4
+++ interface.c 1 Jun 2006 03:17:25 -0000 1.5
@@ -357,7 +357,7 @@
}
-void declare_war(int mask)
+void declare_war(int mask, int refitdelay)
{
int changes;
int i;
@@ -406,7 +406,7 @@
}
}
- if (mask & ~me->p_hostile) {
+ if (refitdelay && (mask & ~me->p_hostile)) {
me->p_flags |= PFWAR;
delay = me->p_updates + 100;
new_warning(49,"Pausing ten seconds to re-program battle computers.");
@@ -447,7 +447,7 @@
int i=0;
struct ship_cap_spacket ShipFoo;
- if (type<0 || type>=ATT) return;
+ if (type<0 || type>ATT) return;
if (me->p_flags & PFORBIT) {
if (!(planets[me->p_planet].pl_flags & PLHOME)) {
new_warning(50,"You must orbit your HOME planet to apply for command reassignment!");