eliot-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Eliot-dev] eliot/game game_io.cpp


From: eliot-dev
Subject: [Eliot-dev] eliot/game game_io.cpp
Date: Fri, 11 Aug 2006 22:14:49 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Changes by:     Antoine Fraboulet <afrab>       06/08/11 22:14:49

Modified files:
        game           : game_io.cpp 

Log message:
        - add debug strings

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game_io.cpp?cvsroot=eliot&r1=1.3&r2=1.4

Patches:
Index: game_io.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game_io.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- game_io.cpp 22 Jan 2006 12:23:53 -0000      1.3
+++ game_io.cpp 11 Aug 2006 22:14:49 -0000      1.4
@@ -97,6 +97,8 @@
 
 Game* Game::gameLoadFormat_14(FILE *fin, const Dictionary& iDic)
 {
+    int ret = 0;
+    int line = 0;
      Tile tile;
      char buff[4096];
      char rack[20];
@@ -107,7 +109,6 @@
      Game *pGame = NULL;
 
      debug("Game::gameLoadFormat_14\n");
-
      pGame = GameFactory::Instance()->createTraining(iDic);
      pGame->start();
 
@@ -117,9 +118,11 @@
      /* read all turns until total */
      while (fgets(buff, sizeof(buff), fin))
      {
+        line++;
          token = strtok(buff, delim);
          if (token != NULL)
          {
+            debug("======== \n");
              if (strcmp(token, "total") == 0)
              {
                  break;
@@ -129,7 +132,7 @@
              strncpy(rack, token, sizeof(rack));
              static_cast<Training*>(pGame)->setRack(RACK_MANUAL, false,
                                                     convertToWc(rack));
-             debug("%s ", rack);
+            debug("load: %8s ", rack);
 
              /* word */
              token = strtok(NULL, delim);
@@ -139,7 +142,7 @@
              }
 
              strncpy(word, token, sizeof(word));
-             debug("\t%s ", word);
+            debug(" %12s ", word);
 
              /* bonus */
              if ((token = strtok(NULL, delim)) == NULL)
@@ -152,24 +155,32 @@
                  if ((token = strtok(NULL, delim)) == NULL)
                      break;
              }
+            else
+            {
+                debug(" \t");
+            }
 
              /* pos 1 */
              if ((token = strtok(NULL, delim)) == NULL)
                  break;
 
-             debug("(%s ", token);
+            //debug("(%s ", token);
              strncpy(pos, token, sizeof(pos));
 
              /* pos 2 */
              if ((token = strtok(NULL, delim)) == NULL)
                  break;
 
-             debug("%s)", token);
+            //debug("%s)", token);
              strncat(pos, token, sizeof(pos));
              debug("%s\n", pos);
 
-             debug("   play %s %s\n", pos, word);
-             pGame->play(convertToWc(pos), convertToWc(word));
+            if ((ret = pGame->play(convertToWc(pos), convertToWc(word))))
+            {
+                debug("loading error %d on line %d\n",ret,line);
+                GameFactory::Instance()->releaseGame(*pGame);
+                return NULL;
+            }
          }
      }
      return pGame;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]