- add "load" in game_factory

This commit is contained in:
Antoine Fraboulet 2006-08-11 22:14:21 +00:00
parent 8d79f6ba78
commit 69dada550b
2 changed files with 22 additions and 1 deletions

View file

@ -18,6 +18,7 @@
*****************************************************************************/
#include <getopt.h>
#include <string>
#include "config.h"
#include "dic.h"
@ -184,6 +185,20 @@ Game *GameFactory::createFromCmdLine(int argc, char **argv)
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)
{

View file

@ -46,7 +46,13 @@ public:
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);