Vanilla Development Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVS update: Vanilla/ntserv



Date:	Friday June 23, 2000 @ 6:18
Author:	cameron

Update of /home/netrek/cvsroot/Vanilla/ntserv
In directory swashbuckler.fortress.real-time.com:/var/tmp/cvs-serv2054/ntserv

Modified Files:
	ntscmds.c 
Log Message:
Addition of administration commands as messages.


****************************************

Index: Vanilla/ntserv/ntscmds.c
diff -u Vanilla/ntserv/ntscmds.c:1.10 Vanilla/ntserv/ntscmds.c:1.11
--- Vanilla/ntserv/ntscmds.c:1.10	Fri Jun 23 04:12:58 2000
+++ Vanilla/ntserv/ntscmds.c	Fri Jun 23 06:18:24 2000
@@ -1,4 +1,4 @@
-/* $Id: ntscmds.c,v 1.10 2000/06/23 09:12:58 cameron Exp $
+/* $Id: ntscmds.c,v 1.11 2000/06/23 11:18:24 cameron Exp $
  */
 
 /*
@@ -53,6 +53,7 @@
 void do_triple_planet_mayhem(void);
 #endif
 void do_password(char *comm, struct message *mess);
+void do_admin(char *comm, struct message *mess);
 
 const char myname[] = {"GOD"};
 
@@ -108,6 +109,10 @@
 		C_PR_INPICKUP,
 		"Change your password         e.g. 'password neato neato'",
 		do_password },			/* PASSWORD */
+    { "ADMIN",
+		C_PR_INPICKUP,
+		"Administration commands for privileged users",
+		do_admin },			/* ADMIN */
 #ifdef ALLOW_PAUSE
     { "PAUSE",
                 0,
@@ -1075,4 +1080,78 @@
 
   pmessage(who, MINDIV, addr, 
 	   "You want your password to be %s", one);
+}
+
+
+void do_admin(char *comm, struct message *mess)
+{
+  int who = mess->m_from;
+  struct player *p = &players[who];
+  char *addr = addr_mess(who,MINDIV);
+  char *one, *two;
+  char command[256];
+  int slot;
+  struct player *them = NULL;
+
+  /* if player not on god queue, say no luck and exit */
+  if (p->w_queue != QU_GOD_OBS && p->w_queue != QU_GOD) {
+    pmessage(who, MINDIV, addr, "Sorry, no.", p->w_queue);
+  }
+
+  /* admin quit n - simulate quit */
+  /* admin kill n - blow them up */
+  /* admin ban n - ban the host */
+  /* admin reset - reset galactic */
+  
+  /* admin */
+  one = strtok(comm, " ");
+  if (one == NULL) return;
+
+  /* command */
+  one = strtok(NULL, " ");
+  if (one == NULL) {
+    pmessage(who, MINDIV, addr, "admin: expected command, kill/quit/ban/reset");
+    return;
+  }
+
+  /* argument */
+  two = strtok(NULL, " ");
+  if (two != NULL) {
+    *two = toupper(*two);
+    if ((*two >= '0') && (*two <='9'))
+      slot = *two - '0';
+    else if ((*two >= 'A') && (*two <= ('A' + MAXPLAYER - 10)))
+      slot = *two - 'A' + 10;
+    else {
+      pmessage(who, MINDIV, addr, "admin: ignored, slot not recognised");
+      return;
+    }
+    them = &players[slot];
+    if (them->p_status == PFREE) {
+      pmessage(who, MINDIV, addr, "admin: ignored, slot is free");
+      return;
+    }
+  }
+
+  if (!strcmp(one, "quit")) {
+    if (them == NULL) return;
+    sprintf(command, "tools/xtkill %c e", them->p_mapchars[1]);
+    system(command);
+    pmessage(who, MINDIV, addr, "admin: player %s forced to quit.", two);
+  } else if (!strcmp(one, "kill")) {
+    if (them == NULL) return;
+    sprintf(command, "tools/xtkill %c", them->p_mapchars[1]);
+    system(command);
+    pmessage(who, MINDIV, addr, "admin: player %s killed.", two);
+  } else if (!strcmp(one, "ban")) {
+    if (them == NULL) return;
+    sprintf(command, "mail -s 'ban: %s' `whoami` < /dev/null", them->p_full_hostname);
+    system(command);
+    pmessage(who, MINDIV, addr, "admin: ban for player %s requested.", two);
+  } else if (!strcmp(one, "reset")) {
+    system("tools/setgalaxy t");
+    pmessage(who, MINDIV, addr, "admin: galactic has been reset.");
+  } else {
+    pmessage(who, MINDIV, addr, "admin: what? kill/quit/ban/reset, lowercase");
+  }
 }