Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 18, 2009, 12:06:41 PM (15 years ago)
Author:
rgrieder
Message:

Added bLuaSupport_ to XMLFile so we can load the resource locations without lua. And therefore LuaState can access its init script via resources.
Also fixed a problem in the LevelManager with level loading.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource2/src/core/Loader.cc

    r5654 r5660  
    122122        Loader::currentMask_s = file->getMask() * mask;
    123123
    124         // Use the LuaState to replace the XML tags (calls our function)
    125         scoped_ptr<LuaState> luaState(new LuaState());
    126         luaState->setIncludeParser(&Loader::replaceLuaTags);
    127         luaState->includeFile(file->getFilename(), file->getResourceGroup(), false);
    128         //luaState->doString(luaInput);
     124        std::string xmlInput;
     125        if (file->getLuaSupport())
     126        {
     127            // Use the LuaState to replace the XML tags (calls our function)
     128            scoped_ptr<LuaState> luaState(new LuaState());
     129            luaState->setIncludeParser(&Loader::replaceLuaTags);
     130            luaState->includeFile(file->getFilename(), file->getResourceGroup(), false);
     131            xmlInput = luaState->getOutput().str();
     132        }
     133        else
     134        {
     135            shared_ptr<ResourceInfo> info = Resource::getInfo(file->getFilename(), file->getResourceGroup());
     136            if (info == NULL)
     137            {
     138                COUT(1) << "Error: Could not find XML file '" << file->getFilename() << "'." << std::endl;
     139                return false;
     140            }
     141            xmlInput = Resource::open(file->getFilename(), file->getResourceGroup())->getAsString();
     142        }
    129143
    130144        try
     
    134148
    135149            ticpp::Document xmlfile(file->getFilename());
    136             xmlfile.Parse(luaState->getOutput().str(), true);
     150            xmlfile.Parse(xmlInput, true);
    137151
    138152            ticpp::Element rootElement;
Note: See TracChangeset for help on using the changeset viewer.