Skip to content

Commit

Permalink
WITCHER: Use ScopedPtr in Campaign
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Oct 26, 2016
1 parent 2926a1f commit 3942435
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
12 changes: 4 additions & 8 deletions src/engines/witcher/campaign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,16 @@ namespace Engines {
namespace Witcher {

Campaign::Campaign(::Engines::Console &console) : _console(&console),
_hasCampaign(false), _running(false), _exit(true), _module(0), _pc(0),
_newCampaignStandalone(false) {
_hasCampaign(false), _running(false), _exit(true), _newCampaignStandalone(false) {

_module = new Module(*_console);
_module.reset(new Module(*_console));
}

Campaign::~Campaign() {
try {
clear();
} catch (...) {
}

delete _module;
}

void Campaign::clear() {
Expand Down Expand Up @@ -112,8 +109,7 @@ void Campaign::unload(bool completeUnload) {
}

void Campaign::unloadPC() {
delete _pc;
_pc = 0;
_pc.reset();
}

void Campaign::load(const Common::UString &campaign) {
Expand Down Expand Up @@ -226,7 +222,7 @@ void Campaign::usePC(const Common::UString &utc) {
throw Common::Exception("Tried to load an empty PC");

try {
_pc = new Creature(utc);
_pc.reset(new Creature(utc));
} catch (Common::Exception &e) {
e.add("Can't load PC \"%s\"", utc.c_str());
throw e;
Expand Down
5 changes: 3 additions & 2 deletions src/engines/witcher/campaign.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <list>

#include "src/common/scopedptr.h"
#include "src/common/ustring.h"

#include "src/aurora/locstring.h"
Expand Down Expand Up @@ -125,10 +126,10 @@ class Campaign {
Common::UString _startModule;

/** The current module of the current campaign. */
Module *_module;
Common::ScopedPtr<Module> _module;

/** The player character we use. */
Creature *_pc;
Common::ScopedPtr<Creature> _pc;

/** The campaign we should change to. */
Common::UString _newCampaign;
Expand Down

0 comments on commit 3942435

Please sign in to comment.