[Scummvm-git-logs] scummvm master -> e94ab92898afca61d547e027852f05968fc10139
dreammaster
paulfgilbert at gmail.com
Sat May 9 01:59:04 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
e94ab92898 ULTIMA4: Fix context memory leak
Commit: e94ab92898afca61d547e027852f05968fc10139
https://github.com/scummvm/scummvm/commit/e94ab92898afca61d547e027852f05968fc10139
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-05-08T18:58:46-07:00
Commit Message:
ULTIMA4: Fix context memory leak
Changed paths:
engines/ultima/ultima4/game/context.cpp
engines/ultima/ultima4/game/context.h
diff --git a/engines/ultima/ultima4/game/context.cpp b/engines/ultima/ultima4/game/context.cpp
index 91ef21e8f1..b90f99486b 100644
--- a/engines/ultima/ultima4/game/context.cpp
+++ b/engines/ultima/ultima4/game/context.cpp
@@ -21,23 +21,42 @@
*/
#include "ultima/ultima4/game/context.h"
+#include "ultima/ultima4/views/stats.h"
namespace Ultima {
namespace Ultima4 {
Context *g_context;
-Context::Context() : _party(nullptr), _location(nullptr),
- _line(999), _col(0), _stats(nullptr), _moonPhase(0),
- _windDirection(0), _windCounter(0), _windLock(false),
- _aura(nullptr), _horseSpeed(0), _opacity(0),
- _transportContext(TRANSPORT_ANY), _lastCommandTime(0),
- _lastShip(nullptr) {
+Context::Context() : _stats(nullptr), _aura(nullptr) {
g_context = this;
+ reset();
}
Context::~Context() {
g_context = nullptr;
+ delete _stats;
+ delete _aura;
+}
+
+void Context::reset() {
+ delete _stats;
+ delete _aura;
+ _stats = nullptr;
+ _aura = nullptr;
+
+ _party = nullptr;
+ _location = nullptr;
+ _lastShip = nullptr;
+ _line = _col = 0;
+ _moonPhase = 0;
+ _windDirection = 0;
+ _windCounter = 0;
+ _windLock = false;
+ _horseSpeed = 0;
+ _opacity = 0;
+ _lastCommandTime = 0;
+ _transportContext = TRANSPORT_ANY;
}
} // End of namespace Ultima4
diff --git a/engines/ultima/ultima4/game/context.h b/engines/ultima/ultima4/game/context.h
index 2f9bf379b1..af6804b843 100644
--- a/engines/ultima/ultima4/game/context.h
+++ b/engines/ultima/ultima4/game/context.h
@@ -58,15 +58,20 @@ public:
Context();
~Context();
+ /**
+ * Reset the context
+ */
+ void reset();
+
+ StatsArea *_stats;
+ Aura *_aura;
Party *_party;
Location *_location;
int _line, _col;
- StatsArea *_stats;
int _moonPhase;
int _windDirection;
int _windCounter;
bool _windLock;
- Aura *_aura;
int _horseSpeed;
int _opacity;
TransportContext _transportContext;
More information about the Scummvm-git-logs
mailing list