Skip to content

Commit

Permalink
WITCHER: Use ScopedPtr in Area
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Oct 26, 2016
1 parent ee1c0c7 commit b44a030
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/engines/witcher/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace Witcher {

Area::Area(Module &module, const Common::UString &resRef) : Object(kObjectTypeArea),
_module(&module), _resRef(resRef), _visible(false),
_model(0), _activeObject(0), _highlightAll(false) {
_activeObject(0), _highlightAll(false) {

try {
// Load ARE and GIT
Expand Down Expand Up @@ -93,8 +93,7 @@ void Area::clear() {
_objects.clear();

// Delete area geometry model
delete _model;
_model = 0;
_model.reset();
}

Aurora::LocString Area::getName(const Common::UString &resRef) {
Expand Down Expand Up @@ -290,16 +289,15 @@ void Area::loadAreaModel() {
if (_modelName.empty())
return;

_model = loadModelObject(_modelName);
_model.reset(loadModelObject(_modelName));
if (!_model)
throw Common::Exception("Can't load area geometry model \"%s\"", _modelName.c_str());

_model->setPosition(1500.0f, 1500.0f, 0.0f);
}

void Area::unloadAreaModel() {
delete _model;
_model = 0;
_model.reset();
}

void Area::loadObject(Engines::Witcher::Object &object) {
Expand Down
5 changes: 3 additions & 2 deletions src/engines/witcher/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <map>

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

Expand Down Expand Up @@ -134,8 +135,8 @@ class Area : public Witcher::Object, public Events::Notifyable {

Sound::ChannelHandle _ambientMusic; ///< Sound handle of the currently playing music.

Common::UString _modelName; ///< Name of area geometry ("tile") model.
Graphics::Aurora::Model *_model; ///< The actual area geometry model.
Common::UString _modelName; ///< Name of area geometry ("tile") model.
Common::ScopedPtr<Graphics::Aurora::Model> _model; ///< The actual area geometry model.

ObjectList _objects; ///< List of all objects in the area.
ObjectMap _objectMap; ///< Map of all non-static objects in the area.
Expand Down

0 comments on commit b44a030

Please sign in to comment.