#include "StdInc.h" #include "VCMI_Lib.h" #include "CArtHandler.h" #include "CCreatureHandler.h" #include "CDefObjInfoHandler.h" #include "CHeroHandler.h" #include "CObjectHandler.h" #include "CTownHandler.h" #include "CBuildingHandler.h" #include "CSpellHandler.h" #include "CGeneralTextHandler.h" #include "CModHandler.h" #include "IGameEventsReceiver.h" #include "CStopWatch.h" #include "VCMIDirs.h" #include "Filesystem/CResourceLoader.h" /* * VCMI_Lib.cpp, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * * License: GNU General Public License v2.0 or later * Full text of license available in license.txt file, in main folder * */ LibClasses * VLC = NULL; DLL_LINKAGE VCMIDirs GVCMIDirs; DLL_LINKAGE void initDLL(CConsoleHandler *Console, std::ostream *Logfile) { console = Console; logfile = Logfile; VLC = new LibClasses; try { VLC->init(); } HANDLE_EXCEPTION; } void LibClasses::loadFilesystem() { CStopWatch totalTime; CStopWatch loadTime; CResourceHandler::initialize(); tlog0<<"\t Initialization: "<load(); tlog0<<"\tGeneral text handler: "<loadHeroes(); heroh->loadObstacles(); heroh->loadPuzzleInfo(); tlog0 <<"\tHero handler: "<loadArtifacts(false); tlog0<<"\tArtifact handler: "<loadCreatures(); tlog0<<"\tCreature handler: "<load(); tlog0<<"\tTown handler: "<loadObjects(); tlog0<<"\tObject handler: "<load(); tlog0<<"\tDef information handler: "<loadSpells(); tlog0<<"\tSpell handler: "<recreateHandlers(); //load all new creatures parsed in the meantime. //TODO: This should be done every time mod config changes IS_AI_ENABLED = false; } void LibClasses::clear() { delete generaltexth; delete heroh; delete arth; delete creh; delete townh; delete objh; delete dobjinfo; delete spellh; delete modh; makeNull(); } void LibClasses::makeNull() { generaltexth = NULL; heroh = NULL; arth = NULL; creh = NULL; townh = NULL; objh = NULL; dobjinfo = NULL; spellh = NULL; modh = NULL; } LibClasses::LibClasses() { //init pointers to handlers makeNull(); } void LibClasses::callWhenDeserializing() { generaltexth = new CGeneralTextHandler; generaltexth->load(); arth->loadArtifacts(true); //modh->loadConfigFromFile ("defaultMods"); //TODO: remember last saved config } LibClasses::~LibClasses() { clear(); }