Vanilla Development Maling List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS update: Vanilla/robots
Date: Sunday June 6, 1999 @ 17:38
Author: jeffno
Update of /home/netrek/cvsroot/Vanilla/robots
In directory cvs.castle.real-time.com:/var/tmp/cvs-serv5325/Vanilla/robots
Modified Files:
inl.c
Log Message:
Add a sysdef option to record an INL game server side with
CamBot.
****************************************
Index: Vanilla/robots/inl.c
diff -u Vanilla/robots/inl.c:1.17 Vanilla/robots/inl.c:1.18
--- Vanilla/robots/inl.c:1.17 Wed Jun 2 23:57:05 1999
+++ Vanilla/robots/inl.c Sun Jun 6 17:38:27 1999
@@ -1,7 +1,7 @@
-/* $Id: inl.c,v 1.17 1999/06/03 04:57:05 jeffno Exp $ */
+/* $Id: inl.c,v 1.18 1999/06/06 22:38:27 jeffno Exp $ */
#ifndef lint
-static char vcid[] = "$Id: inl.c,v 1.17 1999/06/03 04:57:05 jeffno Exp $";
+static char vcid[] = "$Id: inl.c,v 1.18 1999/06/06 22:38:27 jeffno Exp $";
#endif /* lint */
/*
@@ -36,6 +36,8 @@
int debug=0;
+static int cambot_pid = 0;
+
struct planet *oldplanets; /* for restoring galaxy */
#ifdef nodef
struct planet *inl_planets;
@@ -473,6 +475,8 @@
int
end_tourney()
{
+ int game_over = 0;
+
countplanets();
if ((inl_teams[HOME].planets > inl_teams[AWAY].planets+2)
|| (inl_teams[AWAY].planets > inl_teams[HOME].planets+2))
@@ -481,11 +485,10 @@
pmessage(0, MALL, inl_from, "Result: %i - %i - %i",
inl_teams[HOME].planets, inl_teams[AWAY].planets,
(20 - inl_teams[HOME].planets - inl_teams[AWAY].planets));
- status->tourn = 0;
- reset_inl(1);
+ game_over = 1;
}
- if (inl_stat.flags & S_TOURNEY)
+ else if (inl_stat.flags & S_TOURNEY)
{
inl_stat.flags &= ~(S_TOURNEY | S_COUNTDOWN);
inl_stat.flags |= S_OVERTIME;
@@ -502,37 +505,20 @@
{
pmessage(0, MALL, inl_from,
"------ Game ran out of time without a winner ------");
- status->tourn = 0;
- reset_inl(1);
+ game_over = 1;
}
-}
-
-void
-reset_inl(int is_end_tourney)
- /* is_end_tourney: boolean, used so that the galaxy isn't reset
- at the end of a tournament. */
-{
- int c;
- /* Flushing messages */
- checkmess();
-
- /* Tourn off t-mode */
- status->gameup |= (GU_CHAOS | GU_PRACTICE);
- status->gameup &= ~(GU_PAUSED);
-
- /* for end regulation or overtime, "the tournament game has ended" */
- /* for INL robot entry, "nuked by God" */
- obliterate(1, is_end_tourney ? TOURNEND : KPROVIDENCE);
-
/* run the stats script for an ending game */
- if (is_end_tourney) {
+ if (game_over) {
FILE *fp;
char pipe[256];
char name[64];
struct timeval tv;
int c, official = 0;
-
+
+ status->tourn = 0;
+ obliterate(1, TOURNEND);
+
gettimeofday(&tv, (struct timezone *) 0);
fprintf(inl_log, "TIME: Game ending at %d seconds\n", tv.tv_sec);
fclose(inl_log);
@@ -591,8 +577,40 @@
}
}
}
- }
+ /* Stop cambot. */
+ if (cambot_pid > 0) {
+ kill(cambot_pid, SIGTERM);
+ waitpid(cambot_pid, NULL, 0);
+ cambot_pid = 0;
+ sprintf(name, "%s.%d", Cambot_out, tv.tv_sec);
+ rename(Cambot_out, name);
+ }
+
+ reset_inl(1);
+
+ } /* if (game_over) */
+
+}
+
+void
+reset_inl(int is_end_tourney)
+ /* is_end_tourney: boolean, used so that the galaxy isn't reset
+ at the end of a tournament. */
+{
+ int c;
+
+ /* Flushing messages */
+ checkmess();
+
+ /* Tourn off t-mode */
+ status->gameup |= (GU_CHAOS | GU_PRACTICE);
+ status->gameup &= ~(GU_PAUSED);
+
+ /* obliterate is taken care of by the calling function for end_tourney */
+ if (!is_end_tourney)
+ obliterate(1, KPROVIDENCE);
+
inl_stat.ticks = 0;
for (c=0; c < INLTEAM; c++) {
@@ -925,6 +943,21 @@
inl_game.end= inl_stat.time;
/* inl_game.counts[0] = inl_stat.time / ( PERMIN * 2); */
inl_game.message = "%i %s left in regulation time";
+
+ /* Start cambot. */
+ if (inl_record) {
+ int pid;
+ pid = fork();
+ if (pid < 0)
+ perror("fork cambot");
+ else if (pid == 0) {
+ execl(Cambot, "cambot", 0);
+ perror("execl cambot");
+ }
+ else {
+ cambot_pid = pid;
+ }
+ }
}