forked from teamnwah/openmw-tes3coop
[Client] Delimit and clarify changes made by tes3mp to engine and main
This commit is contained in:
parent
f65f996418
commit
aeb1ec3394
2 changed files with 159 additions and 11 deletions
|
@ -128,17 +128,45 @@ void OMW::Engine::frame(float frametime)
|
|||
if (mUseSound)
|
||||
mEnvironment.getSoundManager()->update(frametime);
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Update multiplayer processing for the current frame
|
||||
*/
|
||||
mwmp::Main::frame(frametime);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
// Main menu opened? Then scripts are also paused.
|
||||
bool paused = /*mEnvironment.getWindowManager()->containsMode(MWGui::GM_MainMenu);*/ false;
|
||||
// The above is overridden by tes3mp, where the game should never be pausable
|
||||
bool paused = mEnvironment.getWindowManager()->containsMode(MWGui::GM_MainMenu);
|
||||
|
||||
/*
|
||||
Start of tes3mp change (major)
|
||||
|
||||
Time should not be frozen in multiplayer, so the paused boolean is always set to
|
||||
false instead
|
||||
*/
|
||||
paused = false;
|
||||
/*
|
||||
End of tes3mp change (major)
|
||||
*/
|
||||
|
||||
// update game state
|
||||
mEnvironment.getStateManager()->update (frametime);
|
||||
|
||||
bool guiActive = /*mEnvironment.getWindowManager()->isGuiMode()*/ false;
|
||||
// The above is overridden by tes3mp, where the Gui being active doesn't matter
|
||||
bool guiActive = mEnvironment.getWindowManager()->isGuiMode();
|
||||
|
||||
/*
|
||||
Start of tes3mp change (major)
|
||||
|
||||
Whether the GUI is active should have no relevance in multiplayer, so the guiActive
|
||||
boolean is always set to false instead
|
||||
*/
|
||||
guiActive = false;
|
||||
/*
|
||||
End of tes3mp change (major)
|
||||
*/
|
||||
|
||||
osg::Timer_t beforeScriptTick = osg::Timer::instance()->tick();
|
||||
if (mEnvironment.getStateManager()->getState()==
|
||||
|
@ -179,9 +207,18 @@ void OMW::Engine::frame(float frametime)
|
|||
if (mEnvironment.getStateManager()->getState()==
|
||||
MWBase::StateManager::State_Running)
|
||||
{
|
||||
/*MWWorld::Ptr player = mEnvironment.getWorld()->getPlayerPtr();
|
||||
if(!guiActive && player.getClass().getCreatureStats(player).isDead())
|
||||
mEnvironment.getStateManager()->endGame();*/
|
||||
/*
|
||||
Start of tes3mp change (major)
|
||||
|
||||
In multiplayer, the game should not end when the player dies,
|
||||
so the code here has been commented out
|
||||
*/
|
||||
//MWWorld::Ptr player = mEnvironment.getWorld()->getPlayerPtr();
|
||||
//if(!guiActive && player.getClass().getCreatureStats(player).isDead())
|
||||
// mEnvironment.getStateManager()->endGame();
|
||||
/*
|
||||
End of tes3mp change (major)
|
||||
*/
|
||||
}
|
||||
|
||||
// update world
|
||||
|
@ -267,10 +304,27 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
|||
|
||||
OMW::Engine::~Engine()
|
||||
{
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Free up memory allocated by multiplayer's GUIController
|
||||
*/
|
||||
mwmp::Main::get().getGUIController()->cleanUp();
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
mEnvironment.cleanup();
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Free up memory allocated by multiplayer's Main class
|
||||
*/
|
||||
mwmp::Main::destroy();
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
delete mScriptContext;
|
||||
mScriptContext = NULL;
|
||||
|
@ -289,8 +343,15 @@ OMW::Engine::~Engine()
|
|||
|
||||
SDL_Quit();
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Free up memory allocated by multiplayer's logger
|
||||
*/
|
||||
LOG_QUIT();
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
|
||||
void OMW::Engine::enableFSStrict(bool fsStrict)
|
||||
|
@ -662,8 +723,17 @@ private:
|
|||
void OMW::Engine::go()
|
||||
{
|
||||
assert (!mContentFiles.empty());
|
||||
if(!mwmp::Main::init(mContentFiles, mFileCollections))
|
||||
|
||||
/*
|
||||
Start of tes3mp change (major)
|
||||
|
||||
Attempt multiplayer initialization and proceed no further if it fails
|
||||
*/
|
||||
if (!mwmp::Main::init(mContentFiles, mFileCollections))
|
||||
return;
|
||||
/*
|
||||
End of tes3mp change (major)
|
||||
*/
|
||||
|
||||
std::cout << "OSG version: " << osgGetVersion() << std::endl;
|
||||
|
||||
|
@ -698,8 +768,26 @@ void OMW::Engine::go()
|
|||
mEncoder = &encoder;
|
||||
|
||||
prepareEngine (settings);
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Handle post-initialization for multiplayer classes
|
||||
*/
|
||||
mwmp::Main::postInit();
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
/*
|
||||
Start of tes3mp change (major)
|
||||
|
||||
Always skip the main menu in multiplayer
|
||||
*/
|
||||
mSkipMenu = true;
|
||||
/*
|
||||
End of tes3mp change (major)
|
||||
*/
|
||||
|
||||
if (!mSaveGameFile.empty())
|
||||
{
|
||||
|
@ -735,8 +823,18 @@ void OMW::Engine::go()
|
|||
frameTimer.setStartTick();
|
||||
dt = std::min(dt, 0.2);
|
||||
|
||||
bool guiActive = /*mEnvironment.getWindowManager()->isGuiMode()*/ false;
|
||||
// The above is overridden by tes3mp, where the Gui being active doesn't matter
|
||||
bool guiActive = mEnvironment.getWindowManager()->isGuiMode();
|
||||
|
||||
/*
|
||||
Start of tes3mp change (major)
|
||||
|
||||
Whether the GUI is active should have no relevance in multiplayer, so the guiActive
|
||||
boolean is always set to false instead
|
||||
*/
|
||||
guiActive = false;
|
||||
/*
|
||||
End of tes3mp change (major)
|
||||
*/
|
||||
|
||||
if (!guiActive)
|
||||
simulationTime += dt;
|
||||
|
|
|
@ -9,7 +9,16 @@
|
|||
#include "engine.hpp"
|
||||
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Include the header of the multiplayer's Main class
|
||||
*/
|
||||
#include "mwmp/Main.hpp"
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
#if defined(_WIN32)
|
||||
// For OutputDebugString
|
||||
|
@ -34,7 +43,15 @@ extern int cc_install_handlers(int argc, char **argv, int num_signals, int *sigs
|
|||
extern int is_debugger_attached(void);
|
||||
#endif
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Include the header of the logger added for multiplayer
|
||||
*/
|
||||
#include <components/openmw-mp/Log.hpp>
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
/**
|
||||
* Workaround for problems with whitespaces in paths in older versions of Boost library
|
||||
|
@ -150,7 +167,15 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
|
||||
("activate-dist", bpo::value <int> ()->default_value (-1), "activation distance override");
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Parse options added by multiplayer
|
||||
*/
|
||||
mwmp::Main::optionsDesc(&desc);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
|
||||
.options(desc).allow_unregistered().run();
|
||||
|
@ -248,7 +273,15 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
|||
engine.setActivationDistanceOverride (variables["activate-dist"].as<int>());
|
||||
engine.enableFontExport(variables["export-fonts"].as<bool>());
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Configure multiplayer using parsed variables
|
||||
*/
|
||||
mwmp::Main::configure(&variables);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -326,8 +359,17 @@ int main(int argc, char**argv)
|
|||
std::cout.rdbuf (&sb);
|
||||
std::cerr.rdbuf (&sb);
|
||||
#else
|
||||
/*
|
||||
Start of tes3mp change (major)
|
||||
|
||||
Instead of logging information in openmw.log, use a more descriptive filename
|
||||
that includes a timestamp
|
||||
*/
|
||||
// Redirect cout and cerr to tes3mp client log
|
||||
logfile.open (boost::filesystem::path(cfgMgr.getLogPath() / "/tes3mp-client-" += Log::getFilenameTimestamp() += ".log"));
|
||||
/*
|
||||
End of tes3mp change (major)
|
||||
*/
|
||||
|
||||
coutsb.open (Tee(logfile, oldcout));
|
||||
cerrsb.open (Tee(logfile, oldcerr));
|
||||
|
@ -335,7 +377,16 @@ int main(int argc, char**argv)
|
|||
std::cout.rdbuf (&coutsb);
|
||||
std::cerr.rdbuf (&cerrsb);
|
||||
#endif
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Initialize the logger added for multiplayer
|
||||
*/
|
||||
LOG_INIT(Log::LOG_INFO);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
|
||||
#if USE_CRASH_CATCHER
|
||||
|
@ -378,7 +429,6 @@ int main(int argc, char**argv)
|
|||
std::cout.rdbuf(cout_rdbuf);
|
||||
std::cerr.rdbuf(cerr_rdbuf);
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue