[Scummvm-cvs-logs] SF.net SVN: scummvm:[38775] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sun Feb 22 02:33:16 CET 2009


Revision: 38775
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38775&view=rev
Author:   thebluegr
Date:     2009-02-22 01:33:16 +0000 (Sun, 22 Feb 2009)

Log Message:
-----------
- Made ResourceManager accessible from _vm
- Replaced c_version by its corresponding ScummVM equivalent command

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/console.h
    scummvm/trunk/engines/sci/engine/scriptconsole.cpp
    scummvm/trunk/engines/sci/sci.cpp
    scummvm/trunk/engines/sci/sci.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-02-22 01:11:06 UTC (rev 38774)
+++ scummvm/trunk/engines/sci/console.cpp	2009-02-22 01:33:16 UTC (rev 38775)
@@ -27,6 +27,7 @@
 
 #include "sci/sci.h"
 #include "sci/console.h"
+#include "sci/include/sciresource.h"
 #include "sci/include/versions.h"
 
 namespace Sci {
@@ -35,6 +36,7 @@
 	_vm = vm;
 
 	DCmd_Register("version",			WRAP_METHOD(Console, cmdGetVersion));
+	DCmd_Register("man",				WRAP_METHOD(Console, cmdMan));
 }
 
 Console::~Console() {
@@ -42,9 +44,52 @@
 
 bool Console::cmdGetVersion(int argc, const char **argv) {
 	int ver = _vm->getVersion();
-	DebugPrintf("SCI version: %d.%03d.%03d\n", SCI_VERSION_MAJOR(ver), SCI_VERSION_MINOR(ver), SCI_VERSION_PATCHLEVEL(ver));
 
+	DebugPrintf("Resource file version:        %s\n", sci_version_types[_vm->getResMgr()->sci_version]);
+
+	DebugPrintf("Emulated interpreter version: %d.%03d.%03d\n", 
+		SCI_VERSION_MAJOR(ver), SCI_VERSION_MINOR(ver), SCI_VERSION_PATCHLEVEL(ver));
+
 	return true;
 }
 
+bool Console::cmdMan(int argc, const char **argv) {
+#if 0
+	int section = 0;
+	unsigned int i;
+	char *name = cmd_params[0].str;
+	char *c = strchr(name, '.');
+	cmd_mm_entry_t *entry = 0;
+
+	if (c) {
+		*c = 0;
+		section = atoi(c + 1);
+	}
+
+	if (section < 0 || section >= CMD_MM_ENTRIES) {
+		DebugPrintf("Invalid section %d\n", section);
+		return true;
+	}
+
+	DebugPrintf("section:%d\n", section);
+	if (section)
+		entry = cmd_mm_find(name, section - 1);
+	else
+		for (i = 0; i < CMD_MM_ENTRIES && !section; i++) {
+			if ((entry = cmd_mm_find(name, i)))
+				section = i + 1;
+		}
+
+	if (!entry) {
+		DebugPrintf("No manual entry\n");
+		return true;
+	}
+
+	DebugPrintf("-- %s: %s.%d\n", cmd_mm[section - 1].name, name, section);
+	cmd_mm[section - 1].print(entry, 1);
+
+#endif
+	return true;
+}
+
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h	2009-02-22 01:11:06 UTC (rev 38774)
+++ scummvm/trunk/engines/sci/console.h	2009-02-22 01:33:16 UTC (rev 38775)
@@ -41,6 +41,7 @@
 
 private:
 	bool cmdGetVersion(int argc, const char **argv);
+	bool cmdMan(int argc, const char **argv);
 
 private:
 	SciEngine *_vm;

Modified: scummvm/trunk/engines/sci/engine/scriptconsole.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptconsole.cpp	2009-02-22 01:11:06 UTC (rev 38774)
+++ scummvm/trunk/engines/sci/engine/scriptconsole.cpp	2009-02-22 01:33:16 UTC (rev 38775)
@@ -37,7 +37,6 @@
 
 // console commands
 
-static int c_version(EngineState *s); // displays the package and version number
 static int c_list(EngineState *s); // lists various types of things
 static int c_man(EngineState *s); // 'manual page'
 static int c_set(EngineState *s); // sets an int variable
@@ -171,7 +170,6 @@
 		atexit(_cmd_exit);
 
 		// Hook up some commands
-		con_hook_command(&c_version, "version", "", "Displays the version number");
 		con_hook_command(&c_list, "list", "s*", "Lists various things (try 'list')");
 		con_hook_command(&c_man, "man", "s", "Gives a short description of something");
 		con_hook_command(&c_print, "print", "s", "Prints an int variable");
@@ -690,19 +688,6 @@
 	return res;
 }
 
-static int c_version(EngineState * s) {
-	if (NULL == s) {
-		sciprintf("console.c: c_version: NULL passed for parameter s\n");
-		return -1;
-	}
-
-	sciprintf("Resource file version:        %s\n", sci_version_types[s->resmgr->sci_version]);
-	sciprintf("Emulated interpreter version: %d.%03d.%03d\n", SCI_VERSION_MAJOR(s->version),
-	          SCI_VERSION_MINOR(s->version), SCI_VERSION_PATCHLEVEL(s->version));
-
-	return 0;
-}
-
 static int c_list_words(EngineState *s) {
 	word_t **words;
 	int words_nr;

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-02-22 01:11:06 UTC (rev 38774)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-02-22 01:33:16 UTC (rev 38775)
@@ -200,7 +200,6 @@
 	} */
 
 	// FIXME/TODO: Move some of the stuff below to init()
-	ResourceManager *resmgr;
 
 	init_console(); /* So we can get any output */
 
@@ -217,25 +216,25 @@
 	char resource_dir[MAXPATHLEN+1] = "";
 	getcwd(resource_dir, MAXPATHLEN); // Store resource directory
 
-	resmgr = new ResourceManager(res_version, 256 * 1024);
+	_resmgr = new ResourceManager(res_version, 256 * 1024);
 
-	if (!resmgr) {
+	if (!_resmgr) {
 		printf("No resources found in '%s'.\nAborting...\n",
 		       resource_dir);
 		return Common::kNoGameDataFoundError;
 	}
 
-	script_adjust_opcode_formats(resmgr->sci_version);
+	script_adjust_opcode_formats(_resmgr->sci_version);
 
 #if 0
 	printf("Mapping instruments to General Midi\n");
 
-	map_MIDI_instruments(resmgr);
+	map_MIDI_instruments(_resmgr);
 #endif
 
 	EngineState* gamestate = (EngineState *) sci_malloc(sizeof(EngineState));
 	memset(gamestate, 0, sizeof(EngineState));
-	gamestate->resmgr = resmgr;
+	gamestate->resmgr = _resmgr;
 	gamestate->gfx_state = NULL;
 
 	if (init_gamestate(gamestate, version))
@@ -262,7 +261,7 @@
 
 	gfx_state_t gfx_state;
 	gfx_state.driver = &gfx_driver_scummvm;
-	gfx_state.version = resmgr->sci_version;
+	gfx_state.version = _resmgr->sci_version;
 	gamestate->gfx_state = &gfx_state;
 
 	// Default config:
@@ -288,7 +287,7 @@
 	}
 	// Default config ends
 
-	if (gfxop_init_default(&gfx_state, &gfx_options, resmgr)) {
+	if (gfxop_init_default(&gfx_state, &gfx_options, _resmgr)) {
 		fprintf(stderr, "Graphics initialization failed. Aborting...\n");
 		return Common::kUnknownError;
 	}
@@ -316,7 +315,7 @@
 	free(gamestate->work_dir);
 	free(gamestate);
 
-	delete resmgr;
+	delete _resmgr;
 
 	close_console_file();
 

Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h	2009-02-22 01:11:06 UTC (rev 38774)
+++ scummvm/trunk/engines/sci/sci.h	2009-02-22 01:33:16 UTC (rev 38775)
@@ -30,6 +30,7 @@
 #include "engines/advancedDetector.h"
 
 #include "sci/console.h"
+#include "sci/include/sciresource.h"
 
 namespace Sci {
 
@@ -84,12 +85,13 @@
 	Common::Language getLanguage() const;
 	Common::Platform getPlatform() const;
 	uint32 getFlags() const;
-
+	ResourceManager *getResMgr() { return _resmgr; }
 	Common::String getSavegameName(int nr) const;
 
 private:
 	const SciGameDescription *_gameDescription;
 	Console *_console;
+	ResourceManager *_resmgr;
 };
 
 } // End of namespace Sci


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list