[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot/game game_factory.h game_factory.cpp
From: |
eliot-dev |
Subject: |
[Eliot-dev] eliot/game game_factory.h game_factory.cpp |
Date: |
Fri, 11 Aug 2006 22:14:21 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Antoine Fraboulet <afrab> 06/08/11 22:14:21
Modified files:
game : game_factory.h game_factory.cpp
Log message:
- add "load" in game_factory
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game_factory.h?cvsroot=eliot&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game_factory.cpp?cvsroot=eliot&r1=1.7&r2=1.8
Patches:
Index: game_factory.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game_factory.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- game_factory.h 1 Jan 2006 19:49:35 -0000 1.7
+++ game_factory.h 11 Aug 2006 22:14:21 -0000 1.8
@@ -46,7 +46,13 @@
Training *createTraining(const Dictionary &iDic);
FreeGame *createFreeGame(const Dictionary &iDic);
Duplicate *createDuplicate(const Dictionary &iDic);
- //Game *loadGame(FILE *fin, const Dictionary &iDic);
+
+ /**
+ * load() returns the loaded game, or NULL if there was a problem
+ * load() might need some more work to be robust enough to
+ * handle "hand written" files
+ */
+ Game *load(string filename, const Dictionary &iDic);
Game *createFromCmdLine(int argc, char **argv);
Index: game_factory.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game_factory.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- game_factory.cpp 1 Jan 2006 19:49:35 -0000 1.7
+++ game_factory.cpp 11 Aug 2006 22:14:21 -0000 1.8
@@ -18,6 +18,7 @@
*****************************************************************************/
#include <getopt.h>
+#include <string>
#include "config.h"
#include "dic.h"
@@ -184,6 +185,20 @@
return game;
}
+Game* GameFactory::load(string filename, const Dictionary &iDic)
+{
+ Game* game;
+ FILE* fin;
+ if ((fin = fopen(filename.c_str(), "r")) == NULL)
+ {
+ printf("impossible d'ouvrir %s\n",
+ filename.c_str());
+ return NULL;
+ }
+ game = Game::load(fin,iDic);
+ fclose(fin);
+ return game;
+}
void GameFactory::releaseGame(Game &iGame)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot/game game_factory.h game_factory.cpp,
eliot-dev <=