[Scummvm-cvs-logs] scummvm master -> f2d0f76939f713bfe4317798665e1ba004f122f3

bluegr bluegr at gmail.com
Sun Jun 9 15:09:52 CEST 2013


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
a14cb193a9 NEVERHOOD: Add a debug console, together with a command to change rooms
f2d0f76939 NEVERHOOD: Fix a memory leak when changing modules


Commit: a14cb193a9d0cde8b6eb84c5193ba6944de1e6c4
    https://github.com/scummvm/scummvm/commit/a14cb193a9d0cde8b6eb84c5193ba6944de1e6c4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-06-09T06:07:45-07:00

Commit Message:
NEVERHOOD: Add a debug console, together with a command to change rooms

Changed paths:
  A engines/neverhood/console.cpp
  A engines/neverhood/console.h
    engines/neverhood/gamemodule.h
    engines/neverhood/module.mk
    engines/neverhood/neverhood.cpp
    engines/neverhood/neverhood.h



diff --git a/engines/neverhood/console.cpp b/engines/neverhood/console.cpp
new file mode 100644
index 0000000..c82f3a5
--- /dev/null
+++ b/engines/neverhood/console.cpp
@@ -0,0 +1,58 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "neverhood/console.h"
+#include "gui/debugger.h"
+#include "neverhood/neverhood.h"
+#include "neverhood/gamemodule.h"
+
+namespace Neverhood {
+
+Console::Console(NeverhoodEngine *vm) : GUI::Debugger(), _vm(vm) {
+	DCmd_Register("room",			WRAP_METHOD(Console, Cmd_Room));
+}
+
+Console::~Console() {
+}
+
+bool Console::Cmd_Room(int argc, const char **argv) {
+	int currentModule = _vm->_gameModule->getCurrentModuleNum();
+	int previousModule = _vm->_gameModule->getPreviousModuleNum();
+	int scene = _vm->gameState().sceneNum;
+
+	DebugPrintf("Current module: %d, previous module: %d, scene %d\n", currentModule, previousModule, scene);
+
+	if (argc != 3) {
+		DebugPrintf("Use room <module> <scene> to change rooms\n");
+		DebugPrintf("Modules are incremental by 100, from 1000 to 3000\n");
+	} else {
+		int module = atoi(argv[1]);
+		int scene  = atoi(argv[2]);
+
+		_vm->gameState().sceneNum = scene;
+		_vm->_gameModule->createModule(module, -1);
+	}
+
+	return true;
+}
+
+} // End of namespace Neverhood
diff --git a/engines/neverhood/console.h b/engines/neverhood/console.h
new file mode 100644
index 0000000..78a7338
--- /dev/null
+++ b/engines/neverhood/console.h
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef NEVERHOOD_CONSOLE_H
+#define NEVERHOOD_CONSOLE_H
+
+#include "gui/debugger.h"
+
+namespace Neverhood {
+
+class NeverhoodEngine;
+
+class Console : public GUI::Debugger {
+public:
+	Console(NeverhoodEngine *vm);
+	virtual ~Console(void);
+
+private:
+	NeverhoodEngine *_vm;
+
+	bool Cmd_Room(int argc, const char **argv);
+};
+
+} // End of namespace Neverhood
+#endif
diff --git a/engines/neverhood/gamemodule.h b/engines/neverhood/gamemodule.h
index 8101d38..1fb3557 100644
--- a/engines/neverhood/gamemodule.h
+++ b/engines/neverhood/gamemodule.h
@@ -55,6 +55,10 @@ public:
 	void initCubeSymbolsPuzzle();
 	void initCrystalColorsPuzzle();
 	uint32 getCurrRadioMusicFileHash();
+	int getCurrentModuleNum() { return _moduleNum; }
+	int getPreviousModuleNum() { return _moduleNum; }
+
+	void createModule(int moduleNum, int which);
 protected:
 	int _moduleNum;
 	Entity *_prevChildObject;
@@ -64,7 +68,6 @@ protected:
 	bool _canRequestMainMenu;
 	bool _mainMenuRequested;
 	uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
-	void createModule(int moduleNum, int which);
 	void createModuleByHash(uint32 nameHash);
 	void updateModule();
 	void openMainMenu();
diff --git a/engines/neverhood/module.mk b/engines/neverhood/module.mk
index 714fc30..030c78a 100644
--- a/engines/neverhood/module.mk
+++ b/engines/neverhood/module.mk
@@ -3,6 +3,7 @@ MODULE := engines/neverhood
 MODULE_OBJS = \
 	background.o \
 	blbarchive.o \
+	console.o \
 	detection.o \
 	diskplayerscene.o \
 	entity.o \
diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp
index 6b27343..57fce58 100644
--- a/engines/neverhood/neverhood.cpp
+++ b/engines/neverhood/neverhood.cpp
@@ -22,12 +22,18 @@
 
 #include "common/file.h"
 #include "common/config-manager.h"
+#include "common/textconsole.h"
+
 #include "base/plugins.h"
 #include "base/version.h"
+
 #include "graphics/cursorman.h"
+
 #include "engines/util.h"
+
 #include "neverhood/neverhood.h"
 #include "neverhood/blbarchive.h"
+#include "neverhood/console.h"
 #include "neverhood/gamemodule.h"
 #include "neverhood/gamevars.h"
 #include "neverhood/graphics.h"
@@ -76,7 +82,8 @@ Common::Error NeverhoodEngine::run() {
 	_gameVars = new GameVars();
 	_screen = new Screen(this);
 	_res = new ResourceMan();
-	
+	_console = new Console(this);
+
 	if (isDemo()) {
 		_res->addArchive("a.blb");
 		_res->addArchive("nevdemo.blb");
@@ -123,6 +130,7 @@ Common::Error NeverhoodEngine::run() {
 	delete _soundMan;
 	delete _audioResourceMan;
 
+	delete _console;
 	delete _res;
 	delete _screen;
 
@@ -140,6 +148,11 @@ void NeverhoodEngine::mainLoop() {
 		while (eventMan->pollEvent(event)) {
 			switch (event.type) {
 			case Common::EVENT_KEYDOWN:
+				if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_d) {
+					// Open debugger console
+					_console->attach();
+					continue;
+				}
 				_gameModule->handleKeyDown(event.kbd.keycode);
 				_gameModule->handleAsciiKey(event.kbd.ascii);
 				break;
@@ -169,6 +182,7 @@ void NeverhoodEngine::mainLoop() {
 			_gameModule->checkRequests();
 			_gameModule->handleUpdate();
 			_gameModule->draw();
+			_console->onFrame();
 			_screen->update();
 			nextFrameTime = _screen->getNextFrameTime();
 		};
diff --git a/engines/neverhood/neverhood.h b/engines/neverhood/neverhood.h
index 577fbd7..18f2cc9 100644
--- a/engines/neverhood/neverhood.h
+++ b/engines/neverhood/neverhood.h
@@ -48,6 +48,7 @@ class Screen;
 class SoundMan;
 class AudioResourceMan;
 class StaticData;
+class Console;
 struct NPoint;
 
 struct GameState {
@@ -86,7 +87,8 @@ public:
 	ResourceMan *_res;
 	GameModule *_gameModule;
 	StaticData *_staticData;
-	
+	Console *_console;
+
 	SoundMan *_soundMan;
 	AudioResourceMan *_audioResourceMan;
 


Commit: f2d0f76939f713bfe4317798665e1ba004f122f3
    https://github.com/scummvm/scummvm/commit/f2d0f76939f713bfe4317798665e1ba004f122f3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-06-09T06:08:40-07:00

Commit Message:
NEVERHOOD: Fix a memory leak when changing modules

Changed paths:
    engines/neverhood/gamemodule.cpp



diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp
index 49682b0..db4d0ef 100644
--- a/engines/neverhood/gamemodule.cpp
+++ b/engines/neverhood/gamemodule.cpp
@@ -440,6 +440,10 @@ void GameModule::checkRequests() {
 void GameModule::createModule(int moduleNum, int which) {
 	debug("GameModule::createModule(%d, %d)", moduleNum, which);
 	_moduleNum = moduleNum;
+
+	if (_childObject)
+		delete _childObject;
+
 	switch (_moduleNum) {
 	case 1000:
 		setGlobalVar(V_MODULE_NAME, 0x03294419);






More information about the Scummvm-git-logs mailing list