Add pause function to mamer
[capablanca.git] / lasker-2.2.3 / bots / mamer / Mamer.cc
index 38bfd59..e09cddf 100644 (file)
@@ -3,11 +3,16 @@
 //
 // Matthew E. Moses & Michael A. Long
 //
-// $Revision: 1.19 $
-// $Date: 2002/07/02 00:05:19 $
+// $Revision: 1.17 $
+// $Date: 1998/09/10 19:57:17 $
+//
+// $Author: mlong $
+// $Locker:  $
 //
 //--------------------------------------------------------------------------
 
+// static char RCSid[] = "$Id: Mamer.cc,v 1.17 1998/09/10 19:57:17 mlong Exp $";
+
 #include "Mamer.hh"
 
 extern void HandleSignals(int);
@@ -134,6 +139,7 @@ int Mamer::Initialize(int argc, char **argv) {
        switch(errno) {
         case ENOENT:
            if(-1 == mkdir(userFilePath, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IXOTH)) {
+               printf("name = '%s'\n", userFilePath);
                perror("create user file path");
                return(0);
            }
@@ -1156,6 +1162,8 @@ int Mamer::HandleGame(char *message) {
   Game *g = NULL;
   TourneyPlayers *tp = NULL;
 
+  printf("MESSAGE: %s\n", message);
+
   // {Game 8 (Blammor vs. Havard) Blammor resigns} 0-1
 
   sscanf(message, "{Game %d (%s vs. %s", &gameNumber, user1, user2);
@@ -1199,7 +1207,7 @@ int Mamer::HandleGame(char *message) {
            continue;
          }
          moreGames = t->SetGameResult(user1, user2, result_code);  //- SetGameResult deletes the game for us
-         if(moreGames == 2) {
+         if(moreGames == 2 && !t->IsPaused()) {
            moreRounds = (t->GetRoundsRemaining());
            LinkListIter<TourneyPlayers> playerIter(t->playerList);
            playerIter.Reset();
@@ -1286,7 +1294,7 @@ int Mamer::HandlePlayerInfo(char *message) {
           player, ratings[2], ratings[3], ratings[1], ratings[0], ratings[4], ratings[5]);
 
   p = FindPending(player);
-
+printf("player p=%d\n", p);
   if(p != NULL) {
     tourneyNumber = p->value;       // find out which tourney we want
     t = FindTourney(tourneyNumber); // Get the tourney.  If its in the list it should be valid
@@ -1295,6 +1303,7 @@ int Mamer::HandlePlayerInfo(char *message) {
   } //Check for valid tourney is done in CommandEntry::JoinTourney
 
   return_from_AddPlayer = t->AddPlayer(player, ratings[t->GetVariant()], 0.0);
+printf("ret = %d\n", return_from_AddPlayer);
   TellUser(JoinedTourney, player, return_from_AddPlayer);
   if(return_from_AddPlayer == 1)
     XServerCom("%s %s %d%s", "tournset", player, 1, "\n");
@@ -1460,6 +1469,12 @@ void Mamer::BuildCommandList(void) {
     commandList.Append(new Command("open", "ot", DIRECTOR, "Opens the tournament to players.",
                                   "d", (USERFP)&Mamer::OpenTourney));
 
+    commandList.Append(new Command("pause", "pa", DIRECTOR, "Supresses start of new round.",
+                                  "d", (USERFP)&Mamer::PauseTourney));
+
+    commandList.Append(new Command("resume", "re", DIRECTOR, "Resumes a paused tournament.",
+                                  "d", (USERFP)&Mamer::ResumeTourney));
+
     commandList.Append(new Command("setcommandlevel", "setcl", VICE, "Set the level required to execute a command.",
                                   "wd", (USERFP)&Mamer::SetCommandLevel));
 
@@ -1507,7 +1522,7 @@ void Mamer::NextRound() {
   LinkListIter<Tourney> tourneyIter(tourneyList);
   tourneyIter.Reset();
   while((t = tourneyIter.Next())) {
-    if(t->GetStatus() != CLOSED) continue;
+    if(t->GetStatus() != CLOSED || t->IsPaused()) continue;
     moreRounds = (t->GetRoundsRemaining());
     moreGames = 0;
     LinkListIter<Game> gameIter(t->gameList);
@@ -1523,7 +1538,7 @@ void Mamer::NextRound() {
        if(madeMoreGames) 
          t->TellThemWhoTheyPlay();
        else {    // tourney over!
-         cerr << "Coulnd't make any more games.  End of Tourney.  From Next Round" << endl;
+         cerr << "Couldn't make any more games.  End of Tourney.  From Next Round" << endl;
          AnnounceTourneyEnd(t);
          savePlayerData(t);
        }
@@ -1969,13 +1984,6 @@ int Mamer::GenerateTourneyNumber(void) {
 
 
 // $Log: Mamer.cc,v $
-// Revision 1.19  2002/07/02 00:05:19  tridge
-// got rid of a bunch of RCS tags now that its in CVS
-//
-// Revision 1.18  2002/07/02 00:02:40  tridge
-// - fixed compile on g++ 2.96
-// - updated for lasker 'rmatch'
-//
 // Revision 1.17  1998/09/10 19:57:17  mlong
 // lots of little bug fixes and a few new features
 //