[Scummvm-cvs-logs] scummvm master -> 1f7780bef53b11ebd1d59e8a5e4ea53d59cad948

bluegr bluegr at gmail.com
Sat Sep 14 11:41:15 CEST 2013


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

Summary:
7625ae6718 NEVERHOOD: Move StaticScene into scene.h/.cpp
cdeb55777d NEVERHOOD: Add console commands to handle resources
1f7780bef5 NEVERHOOD: Rename the "room" command to "scene" and enhance it


Commit: 7625ae671859ae53c90a343a21e20307d0c87c89
    https://github.com/scummvm/scummvm/commit/7625ae671859ae53c90a343a21e20307d0c87c89
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-09-14T02:39:57-07:00

Commit Message:
NEVERHOOD: Move StaticScene into scene.h/.cpp

Changed paths:
    engines/neverhood/modules/module1000.cpp
    engines/neverhood/modules/module1000.h
    engines/neverhood/scene.cpp
    engines/neverhood/scene.h



diff --git a/engines/neverhood/modules/module1000.cpp b/engines/neverhood/modules/module1000.cpp
index f65b898..08fb88a 100644
--- a/engines/neverhood/modules/module1000.cpp
+++ b/engines/neverhood/modules/module1000.cpp
@@ -1383,29 +1383,6 @@ uint32 Scene1002::handleMessage(int messageNum, const MessageParam &param, Entit
 	return messageResult;
 }
 
-// StaticScene
-
-StaticScene::StaticScene(NeverhoodEngine *vm, Module *parentModule, uint32 backgroundFileHash, uint32 cursorFileHash)
-	: Scene(vm, parentModule) {
-
-	SetMessageHandler(&StaticScene::handleMessage);
-
-	setBackground(backgroundFileHash);
-	setPalette(backgroundFileHash);
-	insertPuzzleMouse(cursorFileHash, 20, 620);
-}
-
-uint32 StaticScene::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
-	Scene::handleMessage(messageNum, param, sender);
-	switch (messageNum) {
-	case 0x0001:
-		if (param.asPoint().x <= 20 || param.asPoint().x >= 620)
-			leaveScene(0);
-		break;
-	}
-	return 0;
-}
-
 // Scene1004
 
 AsScene1004TrashCan::AsScene1004TrashCan(NeverhoodEngine *vm)
diff --git a/engines/neverhood/modules/module1000.h b/engines/neverhood/modules/module1000.h
index 8461ecf..9e97e82 100644
--- a/engines/neverhood/modules/module1000.h
+++ b/engines/neverhood/modules/module1000.h
@@ -102,15 +102,6 @@ protected:
 	uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
 };
 
-// TODO: Move this to some common file since it's used several times
-
-class StaticScene : public Scene {
-public:
-	StaticScene(NeverhoodEngine *vm, Module *parentModule, uint32 backgroundFileHash, uint32 cursorFileHash);
-protected:
-	uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
-};
-
 // Scene1002
 
 class AsScene1002Ring : public AnimatedSprite {
diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp
index c8d7490..8a0e3d5 100644
--- a/engines/neverhood/scene.cpp
+++ b/engines/neverhood/scene.cpp
@@ -593,4 +593,27 @@ void Scene::insertMouse(Mouse *mouseCursor) {
 	addEntity(_mouseCursor);
 }
 
+// StaticScene
+
+StaticScene::StaticScene(NeverhoodEngine *vm, Module *parentModule, uint32 backgroundFileHash, uint32 cursorFileHash)
+	: Scene(vm, parentModule) {
+
+	SetMessageHandler(&StaticScene::handleMessage);
+
+	setBackground(backgroundFileHash);
+	setPalette(backgroundFileHash);
+	insertPuzzleMouse(cursorFileHash, 20, 620);
+}
+
+uint32 StaticScene::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
+	Scene::handleMessage(messageNum, param, sender);
+	switch (messageNum) {
+	case 0x0001:
+		if (param.asPoint().x <= 20 || param.asPoint().x >= 620)
+			leaveScene(0);
+		break;
+	}
+	return 0;
+}
+
 } // End of namespace Neverhood
diff --git a/engines/neverhood/scene.h b/engines/neverhood/scene.h
index 5e42e34..cd44ba7 100644
--- a/engines/neverhood/scene.h
+++ b/engines/neverhood/scene.h
@@ -224,6 +224,14 @@ protected:
 	void insertMouse(Mouse *mouseCursor);
 };
 
+
+class StaticScene : public Scene {
+public:
+	StaticScene(NeverhoodEngine *vm, Module *parentModule, uint32 backgroundFileHash, uint32 cursorFileHash);
+protected:
+	uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
+};
+
 } // End of namespace Neverhood
 
 #endif /* NEVERHOOD_SCENE_H */


Commit: cdeb55777d4279cfb332a3a68ac91cafdff7f48b
    https://github.com/scummvm/scummvm/commit/cdeb55777d4279cfb332a3a68ac91cafdff7f48b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-09-14T02:39:58-07:00

Commit Message:
NEVERHOOD: Add console commands to handle resources

Changed paths:
    engines/neverhood/console.cpp
    engines/neverhood/console.h



diff --git a/engines/neverhood/console.cpp b/engines/neverhood/console.cpp
index 733d7dd..fc85f88 100644
--- a/engines/neverhood/console.cpp
+++ b/engines/neverhood/console.cpp
@@ -32,6 +32,8 @@ namespace Neverhood {
 
 Console::Console(NeverhoodEngine *vm) : GUI::Debugger(), _vm(vm) {
 	DCmd_Register("cheat",			WRAP_METHOD(Console, Cmd_Cheat));
+	DCmd_Register("checkresource",	WRAP_METHOD(Console, Cmd_CheckResource));
+	DCmd_Register("dumpresource",	WRAP_METHOD(Console, Cmd_DumpResource));
 	DCmd_Register("dumpvars",		WRAP_METHOD(Console, Cmd_Dumpvars));
 	DCmd_Register("room",			WRAP_METHOD(Console, Cmd_Room));
 	DCmd_Register("surfaces",		WRAP_METHOD(Console, Cmd_Surfaces));
@@ -188,4 +190,51 @@ bool Console::Cmd_PlaySound(int argc, const char **argv) {
 	return true;
 }
 
+bool Console::Cmd_CheckResource(int argc, const char **argv) {
+	const char *resourceNames[] = { "unknown", "unknown", "bitmap", "palette", "animation", "data", "text", "sound", "music", "unknown", "video" };
+
+	if (argc < 2) {
+		DebugPrintf("Gets information about a resource\n");
+		DebugPrintf("Usage: %s <resource hash>\n", argv[0]);
+	} else {
+		uint32 resourceHash = strtol(argv[1], NULL, 0);
+		ResourceHandle handle;
+
+		_vm->_res->queryResource(resourceHash, handle);
+		if (!handle.isValid()) {
+			DebugPrintf("Invalid resource hash\n");
+		} else {
+			DebugPrintf("Resource type: %d (%s). Size: %d bytes\n", handle.type(), resourceNames[handle.type()], handle.size());
+		}
+	}
+
+	return true;
+}
+
+bool Console::Cmd_DumpResource(int argc, const char **argv) {
+	if (argc < 3) {
+		DebugPrintf("Dumps a resource to disk\n");
+		DebugPrintf("Usage: %s <resource hash> <output file>\n", argv[0]);
+	} else {
+		uint32 resourceHash = strtol(argv[1], NULL, 0);
+		const char *outFileName = argv[2];
+		ResourceHandle handle;
+
+		_vm->_res->queryResource(resourceHash, handle);
+		if (!handle.isValid()) {
+			DebugPrintf("Invalid resource hash\n");
+		} else {
+			_vm->_res->loadResource(handle);
+			Common::DumpFile outFile;
+			outFile.open(outFileName);
+			outFile.write(handle.data(), handle.size());
+			outFile.finalize();
+			outFile.close();
+			_vm->_res->unloadResource(handle);
+		}
+	}
+
+	return true;
+}
+
 } // End of namespace Neverhood
diff --git a/engines/neverhood/console.h b/engines/neverhood/console.h
index 62d65bd..77dde23 100644
--- a/engines/neverhood/console.h
+++ b/engines/neverhood/console.h
@@ -42,6 +42,9 @@ private:
 	bool Cmd_Cheat(int argc, const char **argv);
 	bool Cmd_Dumpvars(int argc, const char **argv);
 	bool Cmd_PlaySound(int argc, const char **argv);
+	bool Cmd_CheckResource(int argc, const char **argv);
+	bool Cmd_DumpResource(int argc, const char **argv);
+
 };
 
 } // End of namespace Neverhood


Commit: 1f7780bef53b11ebd1d59e8a5e4ea53d59cad948
    https://github.com/scummvm/scummvm/commit/1f7780bef53b11ebd1d59e8a5e4ea53d59cad948
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-09-14T02:39:58-07:00

Commit Message:
NEVERHOOD: Rename the "room" command to "scene" and enhance it

The naming has been changed from "room" to "scene", in order to keep it
consistent with the rest of the engine. The scene command now also
displays resource information about the current scene when invoked
without parameters

Changed paths:
    engines/neverhood/console.cpp
    engines/neverhood/console.h
    engines/neverhood/module.h
    engines/neverhood/navigationscene.cpp
    engines/neverhood/navigationscene.h
    engines/neverhood/scene.cpp
    engines/neverhood/scene.h
    engines/neverhood/smackerscene.h



diff --git a/engines/neverhood/console.cpp b/engines/neverhood/console.cpp
index fc85f88..a2ceed8 100644
--- a/engines/neverhood/console.cpp
+++ b/engines/neverhood/console.cpp
@@ -24,7 +24,9 @@
 #include "gui/debugger.h"
 #include "neverhood/neverhood.h"
 #include "neverhood/gamemodule.h"
+#include "neverhood/navigationscene.h"
 #include "neverhood/scene.h"
+#include "neverhood/smackerscene.h"
 #include "neverhood/sound.h"
 #include "neverhood/modules/module1600.h"
 
@@ -35,23 +37,49 @@ Console::Console(NeverhoodEngine *vm) : GUI::Debugger(), _vm(vm) {
 	DCmd_Register("checkresource",	WRAP_METHOD(Console, Cmd_CheckResource));
 	DCmd_Register("dumpresource",	WRAP_METHOD(Console, Cmd_DumpResource));
 	DCmd_Register("dumpvars",		WRAP_METHOD(Console, Cmd_Dumpvars));
-	DCmd_Register("room",			WRAP_METHOD(Console, Cmd_Room));
-	DCmd_Register("surfaces",		WRAP_METHOD(Console, Cmd_Surfaces));
 	DCmd_Register("playsound",		WRAP_METHOD(Console, Cmd_PlaySound));
+	DCmd_Register("scene",			WRAP_METHOD(Console, Cmd_Scene));
+	DCmd_Register("surfaces",		WRAP_METHOD(Console, Cmd_Surfaces));
 }
 
 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);
-
+bool Console::Cmd_Scene(int argc, const char **argv) {
 	if (argc != 3) {
-		DebugPrintf("Use room <module> <scene> to change rooms\n");
+		int currentModule = _vm->_gameModule->getCurrentModuleNum();
+		int previousModule = _vm->_gameModule->getPreviousModuleNum();
+		int scenenNum = _vm->gameState().sceneNum;
+		SceneType sceneType = ((GameModule *)_vm->_gameModule->_childObject)->getSceneType();
+
+		const char *sceneTypes[] = { "normal", "smacker", "navigation" };
+
+		DebugPrintf("Current module: %d, previous module: %d, scene %d (%s scene)\n", currentModule, previousModule, scenenNum, sceneTypes[sceneType]);	
+
+		if (sceneType == kSceneTypeNormal) {
+			Scene *scene = (Scene *)((GameModule *)_vm->_gameModule->_childObject)->_childObject;
+			// Normal scenes have a background and a cursor file hash
+			DebugPrintf("Background hash: 0x%x, cursor hash: 0x%x\n", scene->getBackgroundFileHash(), scene->getCursorFileHash());
+		} else if (sceneType == kSceneTypeSmacker) {
+			SmackerScene *scene = (SmackerScene *)((GameModule *)_vm->_gameModule->_childObject)->_childObject;
+			// Smacker scenes have a file hash, or a list of hashes
+			// TODO: Only the first file hash is shown - any additional hashes, found in
+			// scenes with a list of hashes (two scenes in module 1100 and the making of
+			// video) aren't shown yet
+			DebugPrintf("File hash: 0x%x\n", scene->getSmackerFileHash());
+		} else if (sceneType == kSceneTypeNavigation) {
+			NavigationScene *scene = (NavigationScene *)((GameModule *)_vm->_gameModule->_childObject)->_childObject;
+			// Navigation scenes have a navigation list and its index
+			NavigationList *navigationList = _vm->_staticData->getNavigationList(scene->getNavigationListId());
+			int navigationIndex = scene->getGlobalVar(V_NAVIGATION_INDEX);
+			NavigationItem curNavigation = (*navigationList)[navigationIndex];
+			DebugPrintf("Navigation list ID: 0x%x, index: %d\n", scene->getNavigationListId(), navigationIndex);
+			DebugPrintf("File hash: 0x%x, cursor hash: 0x%x, Smacker hashes: [left: 0x%x, middle: 0x%x, right: 0x%x\n",
+				curNavigation.fileHash, curNavigation.mouseCursorFileHash,
+				curNavigation.leftSmackerFileHash, curNavigation.middleSmackerFileHash, curNavigation.rightSmackerFileHash);
+		}
+
+		DebugPrintf("Use %s <module> <scene> to change scenes\n", argv[0]);
 		DebugPrintf("Modules are incremental by 100, from 1000 to 3000\n");
 	} else {
 		int newModule = atoi(argv[1]);
diff --git a/engines/neverhood/console.h b/engines/neverhood/console.h
index 77dde23..70260a9 100644
--- a/engines/neverhood/console.h
+++ b/engines/neverhood/console.h
@@ -37,7 +37,7 @@ public:
 private:
 	NeverhoodEngine *_vm;
 
-	bool Cmd_Room(int argc, const char **argv);
+	bool Cmd_Scene(int argc, const char **argv);
 	bool Cmd_Surfaces(int argc, const char **argv);
 	bool Cmd_Cheat(int argc, const char **argv);
 	bool Cmd_Dumpvars(int argc, const char **argv);
diff --git a/engines/neverhood/module.h b/engines/neverhood/module.h
index ba1e1fa..8ab2159 100644
--- a/engines/neverhood/module.h
+++ b/engines/neverhood/module.h
@@ -48,6 +48,7 @@ public:
 	Module(NeverhoodEngine *vm, Module *parentModule);
 	virtual ~Module();
 	virtual void draw();
+	SceneType getSceneType() { return _sceneType; }
 
 	Entity *_childObject;
 protected:
diff --git a/engines/neverhood/navigationscene.cpp b/engines/neverhood/navigationscene.cpp
index 51ab96e..a15c00d 100644
--- a/engines/neverhood/navigationscene.cpp
+++ b/engines/neverhood/navigationscene.cpp
@@ -35,6 +35,7 @@ NavigationScene::NavigationScene(NeverhoodEngine *vm, Module *parentModule, uint
 	_isWalkingForward(false), _isTurning(false), _smackerFileHash(0), _interactive(true), _leaveSceneAfter(false) {
 
 	_navigationList = _vm->_staticData->getNavigationList(navigationListId);
+	_navigationListId = navigationListId;
 
 	if (_navigationIndex < 0) {
 		_navigationIndex = (int)getGlobalVar(V_NAVIGATION_INDEX);
diff --git a/engines/neverhood/navigationscene.h b/engines/neverhood/navigationscene.h
index ebe9a35..c174468 100644
--- a/engines/neverhood/navigationscene.h
+++ b/engines/neverhood/navigationscene.h
@@ -38,10 +38,12 @@ public:
 	bool isWalkingForward() const { return _isWalkingForward; }
 	bool isTurning() const { return _isTurning; }
 	int getFrameNumber() const { return _smackerPlayer->getFrameNumber(); }
+	uint32 getNavigationListId() const { return _navigationListId; }
 protected:
 	SmackerPlayer *_smackerPlayer;
 	bool _smackerDone;
 	NavigationList *_navigationList;
+	uint32 _navigationListId;	// used for debugging
 	int _navigationIndex;
 	uint32 _smackerFileHash;
 	bool _interactive;
diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp
index 8a0e3d5..0b2e9c6 100644
--- a/engines/neverhood/scene.cpp
+++ b/engines/neverhood/scene.cpp
@@ -51,6 +51,8 @@ Scene::Scene(NeverhoodEngine *vm, Module *parentModule)
 	_isMessageListBusy = false;
 	_messageValue = -1;
 
+	_backgroundFileHash = _cursorFileHash = 0;
+
 	SetUpdateHandler(&Scene::update);
 	SetMessageHandler(&Scene::handleMessage);
 
@@ -188,6 +190,7 @@ Background *Scene::addBackground(Background *background) {
 
 void Scene::setBackground(uint32 fileHash) {
 	_background = addBackground(new Background(_vm, fileHash, 0, 0));
+	_backgroundFileHash = fileHash;
 }
 
 void Scene::changeBackground(uint32 fileHash) {
@@ -216,14 +219,17 @@ void Scene::insertScreenMouse(uint32 fileHash, const NRect *mouseRect) {
 	if (mouseRect)
 		rect = *mouseRect;
 	insertMouse(new Mouse(_vm, fileHash, rect));
+	_cursorFileHash = fileHash;
 }
 
 void Scene::insertPuzzleMouse(uint32 fileHash, int16 x1, int16 x2) {
 	insertMouse(new Mouse(_vm, fileHash, x1, x2));
+	_cursorFileHash = fileHash;
 }
 
 void Scene::insertNavigationMouse(uint32 fileHash, int type) {
 	insertMouse(new Mouse(_vm, fileHash, type));
+	_cursorFileHash = fileHash;
 }
 
 void Scene::showMouse(bool visible) {
diff --git a/engines/neverhood/scene.h b/engines/neverhood/scene.h
index cd44ba7..f60e291 100644
--- a/engines/neverhood/scene.h
+++ b/engines/neverhood/scene.h
@@ -162,6 +162,10 @@ public:
 	T* createSprite(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5, Arg6 arg6) {
 		return new T(_vm, arg1, arg2, arg3, arg4, arg5, arg6);
 	}
+
+	uint32 getBackgroundFileHash() const { return _backgroundFileHash; }
+	uint32 getCursorFileHash() const { return _cursorFileHash; }
+
 protected:
 	Module *_parentModule;
 	Common::Array<Entity*> _entities;
@@ -197,6 +201,9 @@ protected:
 	HitRectList *_hitRects;
 	Common::Array<Sprite*> _collisionSprites;
 
+	// Used for debugging
+	uint32 _backgroundFileHash, _cursorFileHash;    // for StaticScene and all Scene* classes
+
 	void (Entity::*_savedUpdateHandlerCb)();
 	uint32 (Entity::*_savedMessageHandlerCb)(int messageNum, const MessageParam &param, Entity *sender);
 	int _messageValue;
diff --git a/engines/neverhood/smackerscene.h b/engines/neverhood/smackerscene.h
index 7ed2e02..8e50845 100644
--- a/engines/neverhood/smackerscene.h
+++ b/engines/neverhood/smackerscene.h
@@ -36,6 +36,7 @@ public:
 	void setFileHash(uint32 fileHash);
 	void setFileHashList(const uint32 *fileHashList);
 	void nextVideo();
+	uint32 getSmackerFileHash() const { return _fileHash[0]; }
 protected:
 	bool _doubleSurface;
 	bool _canSkip;






More information about the Scummvm-git-logs mailing list