Allow mamer addtotourney to do late-joins
[capablanca.git] / lasker-2.2.3 / bots / mamer / CommandEntry.cc
index c9b25f0..0b7708e 100644 (file)
@@ -3,14 +3,13 @@
 //
 // Matthew E. Moses & Michael A. Long
 //
-// $Log: CommandEntry.cc,v $
-// Revision 1.15  2002/07/02 00:05:19  tridge
-// got rid of a bunch of RCS tags now that its in CVS
+// $Revision: 1.13 $
+// $Date: 1998/09/10 19:57:17 $
 //
-// Revision 1.14  2002/07/02 00:02:40  tridge
-// - fixed compile on g++ 2.96
-// - updated for lasker 'rmatch'
+// $Author: mlong $
+// $Locker:  $
 //
+// $Log: CommandEntry.cc,v $
 // Revision 1.13  1998/09/10 19:57:17  mlong
 // lots of little bug fixes and a few new features
 //
@@ -49,6 +48,8 @@
 //
 //--------------------------------------------------------------------------
 
+// static char RCSid[] = "$Id: CommandEntry.cc,v 1.13 1998/09/10 19:57:17 mlong Exp $";
+
 #include "CommandEntry.hh"
 #include "Mamer.hh"
 
@@ -229,7 +230,7 @@ int CommandEntry::ListManagers(User *user, param_list params) {
                        "-----------------", "---", "----", "--------", "",
                        "-----------------", "---", "----", "--------", "", "\\n");
       i=1;
-      memset(date, '\0', 64);
+      memset(date, '\0', 16);
       gMamer.XServerCom("\n%s %s ", "qtell", user->name);
       while(fscanf(theFile, "%s", manager) > 0) {
        needToDelete = 0;
@@ -575,6 +576,37 @@ int CommandEntry::OpenTourney(User *user, param_list params) {
   return(0);
 }//- End OpenTourney
 
+//- PauseTourney ------------------------------------------------------------
+int CommandEntry::PauseTourney(User *user, param_list params) {
+  Tourney *tourn = NULL;
+
+  tourn = gMamer.FindTourney(params[0].val.integer);
+  if(NULL != tourn) {
+    if(tourn->GetStatus() == CLOSED) {
+      tourn->SetPause(TRUE);
+    }
+    return(1);
+  }
+  gMamer.TellUser(NotFound, user->name, "tourney");  
+  return(0);
+}//- End PauseTourney
+
+//- ResumeTourney ------------------------------------------------------------
+int CommandEntry::ResumeTourney(User *user, param_list params) {
+  Tourney *tourn = NULL;
+
+  tourn = gMamer.FindTourney(params[0].val.integer);
+  if(NULL != tourn) {
+    if(tourn->GetStatus() == CLOSED && tourn->IsPaused()) {
+      tourn->SetPause(FALSE); // unpause
+      gMamer.NextRound(); // and start next round
+    }
+    return(1);
+  }
+  gMamer.TellUser(NotFound, user->name, "tourney");  
+  return(0);
+}//- End ResumeTourney
+
 //- AnnounceTourney ----------------------------------------------------------
 int CommandEntry::AnnounceTourney(User *user, param_list params) {
   Tourney *tourn = NULL;
@@ -721,7 +753,7 @@ int CommandEntry::ListTourneys(User *user, param_list params) {
       else if(Tstatus == OPEN) 
        sprintf(outStatus, "%s", "open");
       else if(Tstatus == CLOSED)
-       sprintf(outStatus, "%s", "closed");
+       sprintf(outStatus, "%s", t->IsPaused() ? "paused" : "closed");
       else if(Tstatus == DONE)
        sprintf(outStatus, "%s", "done");
       else
@@ -749,16 +781,17 @@ int CommandEntry::ListTourneys(User *user, param_list params) {
 int CommandEntry::JoinTourney(User *user, param_list params) {
   Tourney *tourn = NULL;
   Player *newEntry = NULL;
-
+printf("join\n");
   tourn = gMamer.FindTourney(params[0].val.integer);
   
   if(NULL != tourn) {    
-    newEntry = new Player(user->name, params[0].val.integer);
+    newEntry = new Player(user->name, 0., params[0].val.integer); // [HGM] signal this was from join
+printf("entry=%d\n",newEntry);
     gMamer.pendingList.Append(newEntry);
     gMamer.XServerCom("getpi %s%s", user->name, "\n");
     return(1);
   }
-
+printf("error\n");
   gMamer.TellUser(TourneyNotFound, user->name, params[0].val.integer);
   return(0);
 }
@@ -771,7 +804,7 @@ int CommandEntry::AddToTourney(User *user, param_list params) {
   tourn = gMamer.FindTourney(params[1].val.integer);
   
   if(NULL != tourn) {
-    newEntry = new Player(params[0].val.word, params[1].val.integer);
+    newEntry = new Player(params[0].val.word, 1., params[1].val.integer); // [HGM] signal this was from att
     gMamer.pendingList.Append(newEntry);
     gMamer.XServerCom("getpi %s%s", params[0].val.word, "\n");
     return(1);
@@ -940,7 +973,7 @@ int CommandEntry::ListTourneyPlayers(User *user, param_list params) {
        }
        gMamer.XServerCom("%c%-0.2d%c ", result, p->value, color);
       }
-      if(((i % 9) == 0) && (i > 0)) {
+      if(((i % 8) == 0) && (i > 0)) {
        gMamer.XServerCom("%s %s %s %s", "\n", "qtell", user->name, "\\n");
       } else {
        gMamer.XServerCom("%s", "\\n");