FULLPIPE: Fix memory leaks of arcade keys

Fixes Trac#9657.
This commit is contained in:
Colin Snover 2017-11-18 10:58:46 -06:00 committed by Eugene Sandulenko
parent a5060cf378
commit e40b4a348a
2 changed files with 9 additions and 13 deletions

View file

@ -223,7 +223,7 @@ public:
Common::ScopedPtr<Floaters> _floaters; Common::ScopedPtr<Floaters> _floaters;
Common::ScopedPtr<AniHandler> _aniHandler; Common::ScopedPtr<AniHandler> _aniHandler;
Common::Array<Common::Point *> _arcadeKeys; Common::Array<Common::Point> _arcadeKeys;
void initMap(); void initMap();
void updateMap(PreloadItem *pre); void updateMap(PreloadItem *pre);

View file

@ -262,16 +262,12 @@ void FullpipeEngine::initArcadeKeys(const char *varname) {
return; return;
int cnt = var->getSubVarsCount(); int cnt = var->getSubVarsCount();
_arcadeKeys.resize(cnt);
for (int i = 0; i < cnt; i++) { for (int i = 0; i < cnt; i++) {
Common::Point *point = new Common::Point; Common::Point &point = _arcadeKeys[i];
GameVar *sub = var->getSubVarByIndex(i); GameVar *sub = var->getSubVarByIndex(i);
point.x = sub->getSubVarAsInt("X");
point->x = sub->getSubVarAsInt("X"); point.y = sub->getSubVarAsInt("Y");
point->y = sub->getSubVarAsInt("Y");
_arcadeKeys.push_back(point);
} }
} }
@ -283,7 +279,7 @@ void FullpipeEngine::processArcade(ExCommand *cmd) {
if (cmd->_sceneClickX <= g_fp->_aniMan2->_ox) { if (cmd->_sceneClickX <= g_fp->_aniMan2->_ox) {
for (idx = (int)_arcadeKeys.size() - 1; idx >= 0; idx--) { for (idx = (int)_arcadeKeys.size() - 1; idx >= 0; idx--) {
if (_arcadeKeys[idx]->x < g_fp->_aniMan2->_ox) if (_arcadeKeys[idx].x < g_fp->_aniMan2->_ox)
break; break;
} }
@ -291,7 +287,7 @@ void FullpipeEngine::processArcade(ExCommand *cmd) {
return; return;
} else { } else {
for (idx = 0; idx < (int)_arcadeKeys.size(); idx++) { for (idx = 0; idx < (int)_arcadeKeys.size(); idx++) {
if (_arcadeKeys[idx]->x > g_fp->_aniMan2->_ox) if (_arcadeKeys[idx].x > g_fp->_aniMan2->_ox)
break; break;
} }
@ -299,8 +295,8 @@ void FullpipeEngine::processArcade(ExCommand *cmd) {
return; return;
} }
cmd->_sceneClickX = _arcadeKeys[idx]->x; cmd->_sceneClickX = _arcadeKeys[idx].x;
cmd->_sceneClickY = _arcadeKeys[idx]->y; cmd->_sceneClickY = _arcadeKeys[idx].y;
cmd->_x = cmd->_sceneClickX - g_fp->_sceneRect.left; cmd->_x = cmd->_sceneClickX - g_fp->_sceneRect.left;
cmd->_y = cmd->_sceneClickY - g_fp->_sceneRect.top; cmd->_y = cmd->_sceneClickY - g_fp->_sceneRect.top;