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)
|
||||
, mNewGame (false)
|
||||
, mUseSound (true)
|
||||
, mCompileAll (false)
|
||||
, mScriptManager (0)
|
||||
, mScriptContext (0)
|
||||
, mGuiManager (0)
|
||||
|
@ -301,6 +302,29 @@ void OMW::Engine::go()
|
|||
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
|
||||
mOgre.start();
|
||||
|
||||
|
@ -341,3 +365,8 @@ void OMW::Engine::activate()
|
|||
interpreterContext.executeActivation();
|
||||
}
|
||||
}
|
||||
|
||||
void OMW::Engine::setCompileAll (bool all)
|
||||
{
|
||||
mCompileAll = all;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace OMW
|
|||
bool mVerboseScripts;
|
||||
bool mNewGame;
|
||||
bool mUseSound;
|
||||
bool mCompileAll;
|
||||
|
||||
MWWorld::Environment mEnvironment;
|
||||
MWScript::ScriptManager *mScriptManager;
|
||||
|
@ -127,6 +128,9 @@ namespace OMW
|
|||
|
||||
/// Activate the focussed object.
|
||||
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" )
|
||||
( "script-verbose", "verbose script output" )
|
||||
( "new-game", "activate char gen/new game mechanics" )
|
||||
( "script-all", "compile all scripts (excluding dialogue scripts) at startup")
|
||||
;
|
||||
|
||||
bpo::variables_map variables;
|
||||
|
@ -75,6 +76,9 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
|||
if (variables.count ("new-game"))
|
||||
engine.setNewGame();
|
||||
|
||||
if (variables.count ("script-all"))
|
||||
engine.setCompileAll (true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Interpreter
|
|||
}
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
{
|
||||
class ScriptManager
|
||||
{
|
||||
Compiler::StreamErrorHandler mErrorHandler;
|
||||
|
@ -35,19 +35,21 @@ namespace MWScript
|
|||
bool mVerbose;
|
||||
Compiler::Context& mCompilerContext;
|
||||
Compiler::FileParser mParser;
|
||||
|
||||
|
||||
std::map<std::string, std::vector<Interpreter::Type_Code> > mScripts;
|
||||
|
||||
bool compile (const std::string& name);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
ScriptManager (const ESMS::ESMStore& store, bool verbose,
|
||||
Compiler::Context& compilerContext);
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue