1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 22:45:34 +00:00

Merged pull request #1912

This commit is contained in:
Marc Zinnschlag 2018-09-12 12:04:49 +02:00
commit 6100e34051
17 changed files with 119 additions and 65 deletions

View file

@ -526,7 +526,10 @@ public:
class ConvertGAME : public Converter class ConvertGAME : public Converter
{ {
public: public:
ConvertGAME() : mHasGame(false) {} ConvertGAME()
: mHasGame(false)
{
}
virtual void read(ESM::ESMReader &esm) virtual void read(ESM::ESMReader &esm)
{ {

View file

@ -14,13 +14,13 @@ namespace ESSImport
{ {
struct GMDT struct GMDT
{ {
char mCellName[64]; char mCellName[64] {};
int mFogColour; int mFogColour {0};
float mFogDensity; float mFogDensity {0.f};
int mCurrentWeather, mNextWeather; int mCurrentWeather {0}, mNextWeather {0};
int mWeatherTransition; // 0-100 transition between weathers, top 3 bytes may be garbage int mWeatherTransition {0}; // 0-100 transition between weathers, top 3 bytes may be garbage
float mTimeOfNextTransition; // weather changes when gamehour == timeOfNextTransition float mTimeOfNextTransition {0.f}; // weather changes when gamehour == timeOfNextTransition
int mMasserPhase, mSecundaPhase; // top 3 bytes may be garbage int mMasserPhase {0}, mSecundaPhase {0}; // top 3 bytes may be garbage
}; };
GMDT mGMDT; GMDT mGMDT;

View file

@ -6,6 +6,8 @@
#include <MyGUI_Gui.h> #include <MyGUI_Gui.h>
#include <MyGUI_Window.h> #include <MyGUI_Window.h>
#include <components/debug/debuglog.hpp>
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -49,7 +51,14 @@ KeyboardNavigation::KeyboardNavigation()
KeyboardNavigation::~KeyboardNavigation() KeyboardNavigation::~KeyboardNavigation()
{ {
MyGUI::WidgetManager::getInstance().unregisterUnlinker(this); try
{
MyGUI::WidgetManager::getInstance().unregisterUnlinker(this);
}
catch(const MyGUI::Exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
} }
void KeyboardNavigation::saveFocus(int mode) void KeyboardNavigation::saveFocus(int mode)

View file

@ -5,6 +5,8 @@
#include <MyGUI_WidgetDefines.h> #include <MyGUI_WidgetDefines.h>
#include <MyGUI_Widget.h> #include <MyGUI_Widget.h>
#include <components/debug/debuglog.hpp>
namespace MWGui namespace MWGui
{ {
/** The Layout class is an utility class used to load MyGUI layouts /** The Layout class is an utility class used to load MyGUI layouts
@ -16,7 +18,17 @@ namespace MWGui
Layout(const std::string & _layout, MyGUI::Widget* _parent = nullptr) Layout(const std::string & _layout, MyGUI::Widget* _parent = nullptr)
: mMainWidget(nullptr) : mMainWidget(nullptr)
{ initialise(_layout, _parent); } { initialise(_layout, _parent); }
virtual ~Layout() { shutdown(); } virtual ~Layout()
{
try
{
shutdown();
}
catch(const MyGUI::Exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
}
MyGUI::Widget* getWidget(const std::string& _name); MyGUI::Widget* getWidget(const std::string& _name);

View file

@ -99,7 +99,14 @@ namespace MWGui
ScreenFader::~ScreenFader() ScreenFader::~ScreenFader()
{ {
MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &ScreenFader::onFrameStart); try
{
MyGUI::Gui::getInstance().eventFrameStart -= MyGUI::newDelegate(this, &ScreenFader::onFrameStart);
}
catch(const MyGUI::Exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
} }
void ScreenFader::onFrameStart(float dt) void ScreenFader::onFrameStart(float dt)

View file

@ -518,35 +518,42 @@ namespace MWGui
WindowManager::~WindowManager() WindowManager::~WindowManager()
{ {
mKeyboardNavigation.reset(); try
{
mKeyboardNavigation.reset();
MyGUI::LanguageManager::getInstance().eventRequestTag.clear(); MyGUI::LanguageManager::getInstance().eventRequestTag.clear();
MyGUI::PointerManager::getInstance().eventChangeMousePointer.clear(); MyGUI::PointerManager::getInstance().eventChangeMousePointer.clear();
MyGUI::InputManager::getInstance().eventChangeKeyFocus.clear(); MyGUI::InputManager::getInstance().eventChangeKeyFocus.clear();
MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear(); MyGUI::ClipboardManager::getInstance().eventClipboardChanged.clear();
MyGUI::ClipboardManager::getInstance().eventClipboardRequested.clear(); MyGUI::ClipboardManager::getInstance().eventClipboardRequested.clear();
for (WindowBase* window : mWindows) for (WindowBase* window : mWindows)
delete window; delete window;
mWindows.clear(); mWindows.clear();
delete mMessageBoxManager; delete mMessageBoxManager;
delete mLocalMapRender; delete mLocalMapRender;
delete mCharGen; delete mCharGen;
delete mDragAndDrop; delete mDragAndDrop;
delete mSoulgemDialog; delete mSoulgemDialog;
delete mCursorManager; delete mCursorManager;
delete mToolTips; delete mToolTips;
cleanupGarbage(); cleanupGarbage();
mFontLoader.reset(); mFontLoader.reset();
mGui->shutdown(); mGui->shutdown();
delete mGui; delete mGui;
mGuiPlatform->shutdown(); mGuiPlatform->shutdown();
delete mGuiPlatform; delete mGuiPlatform;
}
catch(const MyGUI::Exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
} }
void WindowManager::setStore(const MWWorld::ESMStore &store) void WindowManager::setStore(const MWWorld::ESMStore &store)

View file

@ -2145,9 +2145,11 @@ void CharacterController::update(float duration)
if (isTurning()) if (isTurning())
{ {
// Adjust animation speed from 1.0 to 1.5 multiplier // Adjust animation speed from 1.0 to 1.5 multiplier
float turnSpeed = std::min(1.5f, std::abs(rot.z()) / duration / static_cast<float>(osg::PI));
if (duration > 0) if (duration > 0)
{
float turnSpeed = std::min(1.5f, std::abs(rot.z()) / duration / static_cast<float>(osg::PI));
mAnimation->adjustSpeedMult(mCurrentMovement, std::max(turnSpeed, 1.0f)); mAnimation->adjustSpeedMult(mCurrentMovement, std::max(turnSpeed, 1.0f));
}
} }
else if (mMovementState != CharState_None && mAdjustMovementAnimSpeed) else if (mMovementState != CharState_None && mAdjustMovementAnimSpeed)
{ {

View file

@ -219,6 +219,7 @@ namespace
RemoveFinishedCallbackVisitor(int effectId) RemoveFinishedCallbackVisitor(int effectId)
: RemoveVisitor() : RemoveVisitor()
, mHasMagicEffects(false)
, mEffectId(effectId) , mEffectId(effectId)
{ {
} }

View file

@ -1483,7 +1483,8 @@ void OpenAL_Output::resumeSounds(int types)
OpenAL_Output::OpenAL_Output(SoundManager &mgr) OpenAL_Output::OpenAL_Output(SoundManager &mgr)
: Sound_Output(mgr), mDevice(0), mContext(0) : Sound_Output(mgr)
, mDevice(0), mContext(0)
, mListenerPos(0.0f, 0.0f, 0.0f), mListenerEnv(Env_Normal) , mListenerPos(0.0f, 0.0f, 0.0f), mListenerEnv(Env_Normal)
, mWaterFilter(0), mWaterEffect(0), mDefaultEffect(0), mEffectSlot(0) , mWaterFilter(0), mWaterEffect(0), mDefaultEffect(0), mEffectSlot(0)
, mStreamThread(new StreamThread) , mStreamThread(new StreamThread)

View file

@ -26,10 +26,10 @@ namespace MWSound
struct { struct {
bool EXT_EFX : 1; bool EXT_EFX : 1;
bool SOFT_HRTF : 1; bool SOFT_HRTF : 1;
} ALC; } ALC = {false, false};
struct { struct {
bool SOFT_source_spatialize : 1; bool SOFT_source_spatialize : 1;
} AL; } AL = {false};
typedef std::deque<ALuint> IDDq; typedef std::deque<ALuint> IDDq;
IDDq mFreeSources; IDDq mFreeSources;

View file

@ -1159,11 +1159,17 @@ namespace MWWorld
osg::Vec3f vec(x, y, z); osg::Vec3f vec(x, y, z);
CellStore *currCell = ptr.isInCell() ? ptr.getCell() : NULL; // currCell == NULL should only happen for player, during initial startup CellStore *currCell = ptr.isInCell() ? ptr.getCell() : nullptr; // currCell == nullptr should only happen for player, during initial startup
bool isPlayer = ptr == mPlayer->getPlayer(); bool isPlayer = ptr == mPlayer->getPlayer();
bool haveToMove = isPlayer || (currCell && mWorldScene->isCellActive(*currCell)); bool haveToMove = isPlayer || (currCell && mWorldScene->isCellActive(*currCell));
MWWorld::Ptr newPtr = ptr; MWWorld::Ptr newPtr = ptr;
if (!isPlayer && !currCell)
throw std::runtime_error("Can not move actor \"" + ptr.getCellRef().getRefId() + "\" to another cell: current cell is nullptr");
if (!newCell)
throw std::runtime_error("Can not move actor \"" + ptr.getCellRef().getRefId() + "\" to another cell: new cell is nullptr");
if (currCell != newCell) if (currCell != newCell)
{ {
removeContainerScripts(ptr); removeContainerScripts(ptr);
@ -1185,10 +1191,10 @@ namespace MWWorld
addContainerScripts (getPlayerPtr(), newCell); addContainerScripts (getPlayerPtr(), newCell);
newPtr = getPlayerPtr(); newPtr = getPlayerPtr();
} }
else if (currCell) else
{ {
bool currCellActive = mWorldScene->isCellActive(*currCell); bool currCellActive = mWorldScene->isCellActive(*currCell);
bool newCellActive = newCell && mWorldScene->isCellActive(*newCell); bool newCellActive = mWorldScene->isCellActive(*newCell);
if (!currCellActive && newCellActive) if (!currCellActive && newCellActive)
{ {
newPtr = currCell->moveTo(ptr, newCell); newPtr = currCell->moveTo(ptr, newCell);

View file

@ -175,17 +175,18 @@ static void gdb_info(pid_t pid)
fflush(stdout); fflush(stdout);
/* Clean up */ /* Clean up */
remove(respfile); if (remove(respfile) != 0)
Log(Debug::Warning) << "Warning: can not remove file '" << respfile << "': " << std::strerror(errno);
} }
else else
{ {
/* Error creating temp file */ /* Error creating temp file */
if(fd >= 0) if(fd >= 0)
{ {
if (close(fd) == 0) if (close(fd) != 0)
remove(respfile); Log(Debug::Warning) << "Warning: can not close file '" << respfile << "': " << std::strerror(errno);
else else if (remove(respfile) != 0)
Log(Debug::Warning) << "Warning: can not close and remove file '" << respfile << "': " << std::strerror(errno); Log(Debug::Warning) << "Warning: can not remove file '" << respfile << "': " << std::strerror(errno);
} }
printf("!!! Could not create gdb command file\n"); printf("!!! Could not create gdb command file\n");
} }

View file

@ -41,8 +41,6 @@ namespace Debug
{ {
return size; return size;
} }
char mDebugLevel;
}; };
#if defined(_WIN32) && defined(_DEBUG) #if defined(_WIN32) && defined(_DEBUG)

View file

@ -78,14 +78,14 @@ struct Cell
struct DATAstruct struct DATAstruct
{ {
int mFlags; int mFlags {0};
int mX, mY; int mX {0}, mY {0};
}; };
struct AMBIstruct struct AMBIstruct
{ {
Color mAmbient, mSunlight, mFog; Color mAmbient {0}, mSunlight {0}, mFog {0};
float mFogDensity; float mFogDensity {0.f};
}; };
Cell() : mName(""), Cell() : mName(""),

View file

@ -103,21 +103,16 @@ namespace Files
}; };
ConstrainedFileStream::ConstrainedFileStream(const char *filename, size_t start, size_t length) ConstrainedFileStream::ConstrainedFileStream(std::unique_ptr<std::streambuf> buf)
: std::istream(new ConstrainedFileStreamBuf(filename, start, length)) : std::istream(buf.get())
, mBuf(std::move(buf))
{ {
} }
ConstrainedFileStream::~ConstrainedFileStream()
{
delete rdbuf();
}
IStreamPtr openConstrainedFileStream(const char *filename, IStreamPtr openConstrainedFileStream(const char *filename,
size_t start, size_t length) size_t start, size_t length)
{ {
return IStreamPtr(new ConstrainedFileStream(filename, start, length)); auto buf = std::unique_ptr<std::streambuf>(new ConstrainedFileStreamBuf(filename, start, length));
return IStreamPtr(new ConstrainedFileStream(std::move(buf)));
} }
} }

View file

@ -11,9 +11,11 @@ namespace Files
class ConstrainedFileStream : public std::istream class ConstrainedFileStream : public std::istream
{ {
public: public:
ConstrainedFileStream(const char *filename, ConstrainedFileStream(std::unique_ptr<std::streambuf> buf);
size_t start=0, size_t length=0xFFFFFFFF); virtual ~ConstrainedFileStream() {};
virtual ~ConstrainedFileStream();
private:
std::unique_ptr<std::streambuf> mBuf;
}; };
typedef std::shared_ptr<std::istream> IStreamPtr; typedef std::shared_ptr<std::istream> IStreamPtr;

View file

@ -161,7 +161,17 @@ namespace Gui
mTextures.clear(); mTextures.clear();
for (std::vector<MyGUI::ResourceManualFont*>::iterator it = mFonts.begin(); it != mFonts.end(); ++it) for (std::vector<MyGUI::ResourceManualFont*>::iterator it = mFonts.begin(); it != mFonts.end(); ++it)
MyGUI::ResourceManager::getInstance().removeByName((*it)->getResourceName()); {
try
{
MyGUI::ResourceManager::getInstance().removeByName((*it)->getResourceName());
}
catch(const MyGUI::Exception& e)
{
Log(Debug::Error) << "Error in the destructor: " << e.what();
}
}
mFonts.clear(); mFonts.clear();
} }