Use unique_ptr over new/delete (Fixes #4305)

0.6.3
scrawl 7 years ago
parent 25a6a67508
commit b1b8e31562
No known key found for this signature in database
GPG Key ID: 2E6CC3676024C402

@ -148,16 +148,16 @@ namespace MWWorld
ToUTF8::Utf8Encoder* encoder, const std::map<std::string,std::string>& fallbackMap,
int activationDistanceOverride, const std::string& startCell, const std::string& startupScript,
const std::string& resourcePath, const std::string& userDataPath)
: mResourceSystem(resourceSystem), mFallback(fallbackMap), mPlayer (0), mLocalScripts (mStore),
: mResourceSystem(resourceSystem), mFallback(fallbackMap), mLocalScripts (mStore),
mSky (true), mCells (mStore, mEsm),
mGodMode(false), mScriptsEnabled(true), mContentFiles (contentFiles), mUserDataPath(userDataPath),
mActivationDistanceOverride (activationDistanceOverride), mStartupScript(startupScript),
mStartCell (startCell), mDistanceToFacedObject(-1), mTeleportEnabled(true),
mLevitationEnabled(true), mGoToJail(false), mDaysInPrison(0), mSpellPreloadTimer(0.f)
{
mPhysics = new MWPhysics::PhysicsSystem(resourceSystem, rootNode);
mRendering = new MWRender::RenderingManager(viewer, rootNode, resourceSystem, workQueue, &mFallback, resourcePath);
mProjectileManager.reset(new ProjectileManager(mRendering->getLightRoot(), resourceSystem, mRendering, mPhysics));
mPhysics.reset(new MWPhysics::PhysicsSystem(resourceSystem, rootNode));
mRendering.reset(new MWRender::RenderingManager(viewer, rootNode, resourceSystem, workQueue, &mFallback, resourcePath));
mProjectileManager.reset(new ProjectileManager(mRendering->getLightRoot(), resourceSystem, mRendering.get(), mPhysics.get()));
mRendering->preloadCommonAssets();
@ -189,9 +189,9 @@ namespace MWWorld
mSwimHeightScale = mStore.get<ESM::GameSetting>().find("fSwimHeightScale")->getFloat();
mWeatherManager = new MWWorld::WeatherManager(*mRendering, mFallback, mStore);
mWeatherManager.reset(new MWWorld::WeatherManager(*mRendering, mFallback, mStore));
mWorldScene = new Scene(*mRendering, mPhysics);
mWorldScene.reset(new Scene(*mRendering.get(), mPhysics.get()));
}
void World::fillGlobalVariables()
@ -224,8 +224,8 @@ namespace MWWorld
// we don't want old weather to persist on a new game
// Note that if reset later, the initial ChangeWeather that the chargen script calls will be lost.
delete mWeatherManager;
mWeatherManager = new MWWorld::WeatherManager(*mRendering, mFallback, mStore);
mWeatherManager.reset();
mWeatherManager.reset(new MWWorld::WeatherManager(*mRendering.get(), mFallback, mStore));
if (!bypass)
{
@ -492,12 +492,6 @@ namespace MWWorld
{
// Must be cleared before mRendering is destroyed
mProjectileManager->clear();
delete mWeatherManager;
delete mWorldScene;
delete mRendering;
delete mPhysics;
delete mPlayer;
}
const ESM::Cell *World::getExterior (const std::string& cellName) const
@ -2214,7 +2208,7 @@ namespace MWWorld
{
const ESM::NPC *player = mStore.get<ESM::NPC>().find("player");
if (!mPlayer)
mPlayer = new MWWorld::Player(player);
mPlayer.reset(new MWWorld::Player(player));
else
{
// Remove the old CharacterController
@ -3478,17 +3472,17 @@ namespace MWWorld
if (MWMechanics::isSummoningEffect(it->mEffectID))
{
preload(mWorldScene, mStore, "VFX_Summon_Start");
preload(mWorldScene, mStore, MWMechanics::getSummonedCreature(it->mEffectID));
preload(mWorldScene.get(), mStore, "VFX_Summon_Start");
preload(mWorldScene.get(), mStore, MWMechanics::getSummonedCreature(it->mEffectID));
}
preload(mWorldScene, mStore, effect->mCasting);
preload(mWorldScene, mStore, effect->mHit);
preload(mWorldScene.get(), mStore, effect->mCasting);
preload(mWorldScene.get(), mStore, effect->mHit);
if (it->mArea > 0)
preload(mWorldScene, mStore, effect->mArea);
preload(mWorldScene.get(), mStore, effect->mArea);
if (it->mRange == ESM::RT_Target)
preload(mWorldScene, mStore, effect->mBolt);
preload(mWorldScene.get(), mStore, effect->mBolt);
}
}

@ -74,17 +74,11 @@ namespace MWWorld
Resource::ResourceSystem* mResourceSystem;
Fallback::Map mFallback;
MWRender::RenderingManager* mRendering;
MWWorld::WeatherManager* mWeatherManager;
MWWorld::Scene *mWorldScene;
MWWorld::Player *mPlayer;
std::vector<ESM::ESMReader> mEsm;
MWWorld::ESMStore mStore;
LocalScripts mLocalScripts;
MWWorld::Globals mGlobalVariables;
MWPhysics::PhysicsSystem *mPhysics;
bool mSky;
ESM::Variant* mGameHour;
@ -98,6 +92,11 @@ namespace MWWorld
std::string mCurrentWorldSpace;
std::unique_ptr<MWWorld::Player> mPlayer;
std::unique_ptr<MWPhysics::PhysicsSystem> mPhysics;
std::unique_ptr<MWRender::RenderingManager> mRendering;
std::unique_ptr<MWWorld::Scene> mWorldScene;
std::unique_ptr<MWWorld::WeatherManager> mWeatherManager;
std::shared_ptr<ProjectileManager> mProjectileManager;
bool mGodMode;

Loading…
Cancel
Save