forked from teamnwah/openmw-tes3coop
added --script-all switch
This commit is contained in:
parent
8659ce3a82
commit
1c4db82a0e
4 changed files with 47 additions and 8 deletions
|
@ -107,6 +107,7 @@ OMW::Engine::Engine()
|
||||||
, mVerboseScripts (false)
|
, mVerboseScripts (false)
|
||||||
, mNewGame (false)
|
, mNewGame (false)
|
||||||
, mUseSound (true)
|
, mUseSound (true)
|
||||||
|
, mCompileAll (false)
|
||||||
, mScriptManager (0)
|
, mScriptManager (0)
|
||||||
, mScriptContext (0)
|
, mScriptContext (0)
|
||||||
, mGuiManager (0)
|
, mGuiManager (0)
|
||||||
|
@ -301,6 +302,29 @@ void OMW::Engine::go()
|
||||||
std::cout << " Music Error: " << e.what() << "\n";
|
std::cout << " Music Error: " << e.what() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// scripts
|
||||||
|
if (mCompileAll)
|
||||||
|
{
|
||||||
|
typedef ESMS::ScriptListT<ESM::Script>::MapType Container;
|
||||||
|
|
||||||
|
Container scripts = mEnvironment.mWorld->getStore().scripts.list;
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
int success = 0;
|
||||||
|
|
||||||
|
for (Container::const_iterator iter (scripts.begin()); iter!=scripts.end(); ++iter, ++count)
|
||||||
|
if (mScriptManager->compile (iter->first))
|
||||||
|
++success;
|
||||||
|
|
||||||
|
if (count)
|
||||||
|
std::cout
|
||||||
|
<< "compiled " << success << " of " << count << " scripts ("
|
||||||
|
<< 100*static_cast<double> (success)/count
|
||||||
|
<< "%)"
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Start the main rendering loop
|
// Start the main rendering loop
|
||||||
mOgre.start();
|
mOgre.start();
|
||||||
|
|
||||||
|
@ -341,3 +365,8 @@ void OMW::Engine::activate()
|
||||||
interpreterContext.executeActivation();
|
interpreterContext.executeActivation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OMW::Engine::setCompileAll (bool all)
|
||||||
|
{
|
||||||
|
mCompileAll = all;
|
||||||
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ namespace OMW
|
||||||
bool mVerboseScripts;
|
bool mVerboseScripts;
|
||||||
bool mNewGame;
|
bool mNewGame;
|
||||||
bool mUseSound;
|
bool mUseSound;
|
||||||
|
bool mCompileAll;
|
||||||
|
|
||||||
MWWorld::Environment mEnvironment;
|
MWWorld::Environment mEnvironment;
|
||||||
MWScript::ScriptManager *mScriptManager;
|
MWScript::ScriptManager *mScriptManager;
|
||||||
|
@ -127,6 +128,9 @@ namespace OMW
|
||||||
|
|
||||||
/// Activate the focussed object.
|
/// Activate the focussed object.
|
||||||
void activate();
|
void activate();
|
||||||
|
|
||||||
|
/// Compile all scripts (excludign dialogue scripts) at startup?
|
||||||
|
void setCompileAll (bool all);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
||||||
( "nosound", "disable all sound" )
|
( "nosound", "disable all sound" )
|
||||||
( "script-verbose", "verbose script output" )
|
( "script-verbose", "verbose script output" )
|
||||||
( "new-game", "activate char gen/new game mechanics" )
|
( "new-game", "activate char gen/new game mechanics" )
|
||||||
|
( "script-all", "compile all scripts (excluding dialogue scripts) at startup")
|
||||||
;
|
;
|
||||||
|
|
||||||
bpo::variables_map variables;
|
bpo::variables_map variables;
|
||||||
|
@ -75,6 +76,9 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
||||||
if (variables.count ("new-game"))
|
if (variables.count ("new-game"))
|
||||||
engine.setNewGame();
|
engine.setNewGame();
|
||||||
|
|
||||||
|
if (variables.count ("script-all"))
|
||||||
|
engine.setCompileAll (true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,16 +38,18 @@ namespace MWScript
|
||||||
|
|
||||||
std::map<std::string, std::vector<Interpreter::Type_Code> > mScripts;
|
std::map<std::string, std::vector<Interpreter::Type_Code> > mScripts;
|
||||||
|
|
||||||
bool compile (const std::string& name);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ScriptManager (const ESMS::ESMStore& store, bool verbose,
|
ScriptManager (const ESMS::ESMStore& store, bool verbose,
|
||||||
Compiler::Context& compilerContext);
|
Compiler::Context& compilerContext);
|
||||||
|
|
||||||
void run (const std::string& name, Interpreter::Context& interpreterContext);
|
void run (const std::string& name, Interpreter::Context& interpreterContext);
|
||||||
|
///< Run the script with the given name (compile first, if not compiled yet)
|
||||||
|
|
||||||
|
bool compile (const std::string& name);
|
||||||
|
///< Compile script with the given namen
|
||||||
|
/// \return Success?
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue