mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-07-21 05:14:10 +00:00
[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)
|
if (mUseSound)
|
||||||
mEnvironment.getSoundManager()->update(frametime);
|
mEnvironment.getSoundManager()->update(frametime);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Update multiplayer processing for the current frame
|
||||||
|
*/
|
||||||
mwmp::Main::frame(frametime);
|
mwmp::Main::frame(frametime);
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
// Main menu opened? Then scripts are also paused.
|
// Main menu opened? Then scripts are also paused.
|
||||||
bool paused = /*mEnvironment.getWindowManager()->containsMode(MWGui::GM_MainMenu);*/ false;
|
bool paused = mEnvironment.getWindowManager()->containsMode(MWGui::GM_MainMenu);
|
||||||
// The above is overridden by tes3mp, where the game should never be pausable
|
|
||||||
|
/*
|
||||||
|
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
|
// update game state
|
||||||
mEnvironment.getStateManager()->update (frametime);
|
mEnvironment.getStateManager()->update (frametime);
|
||||||
|
|
||||||
bool guiActive = /*mEnvironment.getWindowManager()->isGuiMode()*/ false;
|
bool guiActive = mEnvironment.getWindowManager()->isGuiMode();
|
||||||
// The above is overridden by tes3mp, where the Gui being active doesn't matter
|
|
||||||
|
/*
|
||||||
|
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();
|
osg::Timer_t beforeScriptTick = osg::Timer::instance()->tick();
|
||||||
if (mEnvironment.getStateManager()->getState()==
|
if (mEnvironment.getStateManager()->getState()==
|
||||||
|
@ -179,9 +207,18 @@ void OMW::Engine::frame(float frametime)
|
||||||
if (mEnvironment.getStateManager()->getState()==
|
if (mEnvironment.getStateManager()->getState()==
|
||||||
MWBase::StateManager::State_Running)
|
MWBase::StateManager::State_Running)
|
||||||
{
|
{
|
||||||
/*MWWorld::Ptr player = mEnvironment.getWorld()->getPlayerPtr();
|
/*
|
||||||
if(!guiActive && player.getClass().getCreatureStats(player).isDead())
|
Start of tes3mp change (major)
|
||||||
mEnvironment.getStateManager()->endGame();*/
|
|
||||||
|
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
|
// update world
|
||||||
|
@ -267,10 +304,27 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
||||||
|
|
||||||
OMW::Engine::~Engine()
|
OMW::Engine::~Engine()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Free up memory allocated by multiplayer's GUIController
|
||||||
|
*/
|
||||||
mwmp::Main::get().getGUIController()->cleanUp();
|
mwmp::Main::get().getGUIController()->cleanUp();
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
mEnvironment.cleanup();
|
mEnvironment.cleanup();
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Free up memory allocated by multiplayer's Main class
|
||||||
|
*/
|
||||||
mwmp::Main::destroy();
|
mwmp::Main::destroy();
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
delete mScriptContext;
|
delete mScriptContext;
|
||||||
mScriptContext = NULL;
|
mScriptContext = NULL;
|
||||||
|
@ -289,8 +343,15 @@ OMW::Engine::~Engine()
|
||||||
|
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Free up memory allocated by multiplayer's logger
|
||||||
|
*/
|
||||||
LOG_QUIT();
|
LOG_QUIT();
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void OMW::Engine::enableFSStrict(bool fsStrict)
|
void OMW::Engine::enableFSStrict(bool fsStrict)
|
||||||
|
@ -662,8 +723,17 @@ private:
|
||||||
void OMW::Engine::go()
|
void OMW::Engine::go()
|
||||||
{
|
{
|
||||||
assert (!mContentFiles.empty());
|
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;
|
return;
|
||||||
|
/*
|
||||||
|
End of tes3mp change (major)
|
||||||
|
*/
|
||||||
|
|
||||||
std::cout << "OSG version: " << osgGetVersion() << std::endl;
|
std::cout << "OSG version: " << osgGetVersion() << std::endl;
|
||||||
|
|
||||||
|
@ -698,8 +768,26 @@ void OMW::Engine::go()
|
||||||
mEncoder = &encoder;
|
mEncoder = &encoder;
|
||||||
|
|
||||||
prepareEngine (settings);
|
prepareEngine (settings);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Handle post-initialization for multiplayer classes
|
||||||
|
*/
|
||||||
mwmp::Main::postInit();
|
mwmp::Main::postInit();
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp change (major)
|
||||||
|
|
||||||
|
Always skip the main menu in multiplayer
|
||||||
|
*/
|
||||||
mSkipMenu = true;
|
mSkipMenu = true;
|
||||||
|
/*
|
||||||
|
End of tes3mp change (major)
|
||||||
|
*/
|
||||||
|
|
||||||
if (!mSaveGameFile.empty())
|
if (!mSaveGameFile.empty())
|
||||||
{
|
{
|
||||||
|
@ -735,8 +823,18 @@ void OMW::Engine::go()
|
||||||
frameTimer.setStartTick();
|
frameTimer.setStartTick();
|
||||||
dt = std::min(dt, 0.2);
|
dt = std::min(dt, 0.2);
|
||||||
|
|
||||||
bool guiActive = /*mEnvironment.getWindowManager()->isGuiMode()*/ false;
|
bool guiActive = mEnvironment.getWindowManager()->isGuiMode();
|
||||||
// The above is overridden by tes3mp, where the Gui being active doesn't matter
|
|
||||||
|
/*
|
||||||
|
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)
|
if (!guiActive)
|
||||||
simulationTime += dt;
|
simulationTime += dt;
|
||||||
|
|
|
@ -9,7 +9,16 @@
|
||||||
#include "engine.hpp"
|
#include "engine.hpp"
|
||||||
|
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Include the header of the multiplayer's Main class
|
||||||
|
*/
|
||||||
#include "mwmp/Main.hpp"
|
#include "mwmp/Main.hpp"
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
// For OutputDebugString
|
// 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);
|
extern int is_debugger_attached(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Include the header of the logger added for multiplayer
|
||||||
|
*/
|
||||||
#include <components/openmw-mp/Log.hpp>
|
#include <components/openmw-mp/Log.hpp>
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Workaround for problems with whitespaces in paths in older versions of Boost library
|
* 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");
|
("activate-dist", bpo::value <int> ()->default_value (-1), "activation distance override");
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Parse options added by multiplayer
|
||||||
|
*/
|
||||||
mwmp::Main::optionsDesc(&desc);
|
mwmp::Main::optionsDesc(&desc);
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
|
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
|
||||||
.options(desc).allow_unregistered().run();
|
.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.setActivationDistanceOverride (variables["activate-dist"].as<int>());
|
||||||
engine.enableFontExport(variables["export-fonts"].as<bool>());
|
engine.enableFontExport(variables["export-fonts"].as<bool>());
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Configure multiplayer using parsed variables
|
||||||
|
*/
|
||||||
mwmp::Main::configure(&variables);
|
mwmp::Main::configure(&variables);
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -326,8 +359,17 @@ int main(int argc, char**argv)
|
||||||
std::cout.rdbuf (&sb);
|
std::cout.rdbuf (&sb);
|
||||||
std::cerr.rdbuf (&sb);
|
std::cerr.rdbuf (&sb);
|
||||||
#else
|
#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
|
// Redirect cout and cerr to tes3mp client log
|
||||||
logfile.open (boost::filesystem::path(cfgMgr.getLogPath() / "/tes3mp-client-" += Log::getFilenameTimestamp() += ".log"));
|
logfile.open (boost::filesystem::path(cfgMgr.getLogPath() / "/tes3mp-client-" += Log::getFilenameTimestamp() += ".log"));
|
||||||
|
/*
|
||||||
|
End of tes3mp change (major)
|
||||||
|
*/
|
||||||
|
|
||||||
coutsb.open (Tee(logfile, oldcout));
|
coutsb.open (Tee(logfile, oldcout));
|
||||||
cerrsb.open (Tee(logfile, oldcerr));
|
cerrsb.open (Tee(logfile, oldcerr));
|
||||||
|
@ -335,7 +377,16 @@ int main(int argc, char**argv)
|
||||||
std::cout.rdbuf (&coutsb);
|
std::cout.rdbuf (&coutsb);
|
||||||
std::cerr.rdbuf (&cerrsb);
|
std::cerr.rdbuf (&cerrsb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
Start of tes3mp addition
|
||||||
|
|
||||||
|
Initialize the logger added for multiplayer
|
||||||
|
*/
|
||||||
LOG_INIT(Log::LOG_INFO);
|
LOG_INIT(Log::LOG_INFO);
|
||||||
|
/*
|
||||||
|
End of tes3mp addition
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#if USE_CRASH_CATCHER
|
#if USE_CRASH_CATCHER
|
||||||
|
@ -378,7 +429,6 @@ int main(int argc, char**argv)
|
||||||
std::cout.rdbuf(cout_rdbuf);
|
std::cout.rdbuf(cout_rdbuf);
|
||||||
std::cerr.rdbuf(cerr_rdbuf);
|
std::cerr.rdbuf(cerr_rdbuf);
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue