CGE2: Fix memory leak concerning the quit menu.
This commit is contained in:
parent
239fa2a5cf
commit
8eae09afca
3 changed files with 19 additions and 11 deletions
|
@ -129,18 +129,15 @@ void CGE2Engine::checkMusicSwitch() {
|
|||
}
|
||||
|
||||
void CGE2Engine::quit() {
|
||||
Common::Array<Choice *> quitMenu; // Deleted in VMenu's destructor.
|
||||
quitMenu.push_back(new ExitGameChoice(this));
|
||||
quitMenu.push_back(new ReturnToGameChoice(this));
|
||||
|
||||
if (_commandHandler->idle()) {
|
||||
if (VMenu::_addr) {
|
||||
_commandHandlerTurbo->addCommand(kCmdKill, -1, 0, VMenu::_addr);
|
||||
ReturnToGameChoice rqsChoice(this);
|
||||
rqsChoice.proc();
|
||||
} else {
|
||||
quitMenu[0]->_text = _text->getText(kQuitText);
|
||||
quitMenu[1]->_text = _text->getText(kNoQuitText);
|
||||
Common::Array<Choice *> quitMenu; // Deleted in VMenu's destructor.
|
||||
quitMenu.push_back(new ExitGameChoice(this));
|
||||
quitMenu.push_back(new ReturnToGameChoice(this));
|
||||
(new VMenu(this, quitMenu, V2D(this, -1, -1), kCBMnu))->setName(_text->getText(kQuitTitle));
|
||||
_commandHandlerTurbo->addCommand(kCmdSeq, kPowerRef, 0, nullptr);
|
||||
keyClick();
|
||||
|
|
|
@ -25,16 +25,26 @@
|
|||
* Copyright (c) 1994-1997 Janus B. Wisniewski and L.K. Avalon
|
||||
*/
|
||||
|
||||
#include "cge2/cge2.h"
|
||||
#include "cge2/text.h"
|
||||
#include "cge2/vmenu.h"
|
||||
#include "cge2/events.h"
|
||||
|
||||
namespace CGE2 {
|
||||
|
||||
Choice::Choice(CGE2Engine *vm) : _vm(vm), _text(nullptr) {}
|
||||
|
||||
ExitGameChoice::ExitGameChoice(CGE2Engine *vm) : Choice(vm) {
|
||||
_text = _vm->_text->getText(kQuitText);
|
||||
}
|
||||
|
||||
void ExitGameChoice::proc() {
|
||||
_vm->switchScene(-1);
|
||||
}
|
||||
|
||||
ReturnToGameChoice::ReturnToGameChoice(CGE2Engine *vm) : Choice(vm) {
|
||||
_text = _vm->_text->getText(kNoQuitText);
|
||||
}
|
||||
|
||||
void ReturnToGameChoice::proc() {
|
||||
_vm->_commandHandlerTurbo->addCommand(kCmdSeq, kPowerRef, 1, nullptr);
|
||||
_vm->keyClick();
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#define kLt 3
|
||||
#define kRb 1
|
||||
|
||||
#include "cge2/cge2.h"
|
||||
#include "cge2/talk.h"
|
||||
|
||||
namespace CGE2 {
|
||||
|
@ -42,21 +43,21 @@ protected:
|
|||
CGE2Engine *_vm;
|
||||
public:
|
||||
char *_text;
|
||||
|
||||
virtual void proc() = 0;
|
||||
|
||||
Choice(CGE2Engine *vm) : _vm(vm), _text(nullptr) {}
|
||||
virtual ~Choice() {}
|
||||
Choice(CGE2Engine *vm);
|
||||
};
|
||||
|
||||
class ExitGameChoice : public Choice {
|
||||
public:
|
||||
ExitGameChoice(CGE2Engine *vm) : Choice(vm) {}
|
||||
ExitGameChoice(CGE2Engine *vm);
|
||||
void proc();
|
||||
};
|
||||
|
||||
class ReturnToGameChoice : public Choice {
|
||||
public:
|
||||
ReturnToGameChoice(CGE2Engine *vm) : Choice(vm) {}
|
||||
ReturnToGameChoice(CGE2Engine *vm);
|
||||
void proc();
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue