mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-11-17 07:48:27 +01:00
- add "load" in game_factory
This commit is contained in:
parent
8d79f6ba78
commit
69dada550b
2 changed files with 22 additions and 1 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue