[Scummvm-git-logs] scummvm master -> 47f6c2e9b9687150da6d5d1498fce90523706c28

dreammaster dreammaster at scummvm.org
Sun Sep 24 18:18:21 CEST 2017


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

Summary:
67090d3cda GUI: Add support for double quoted parameters in debugger
f9bec828de TITANIC: Support full view specification in debugger room command
54ec788541 GUI: Update comment for strdup call
0b9b3e336a GUI: Remove code that closes debugger if # or ~ keys are pressed
1ecb27e6cc TITANIC: Simplify sound command now that # character is allowed
47f6c2e9b9 Merge pull request #1010 from dreammaster/debugger_params


Commit: 67090d3cda86020d701106a8a53100f4c4178edf
    https://github.com/scummvm/scummvm/commit/67090d3cda86020d701106a8a53100f4c4178edf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-09-04T10:04:26-04:00

Commit Message:
GUI: Add support for double quoted parameters in debugger

Changed paths:
    gui/debugger.cpp
    gui/debugger.h


diff --git a/gui/debugger.cpp b/gui/debugger.cpp
index 7595efc..ce994a4 100644
--- a/gui/debugger.cpp
+++ b/gui/debugger.cpp
@@ -288,17 +288,10 @@ bool Debugger::handleCommand(int argc, const char **argv, bool &result) {
 bool Debugger::parseCommand(const char *inputOrig) {
 	int num_params = 0;
 	const char *param[256];
-	char *input = strdup(inputOrig);	// One of the rare occasions using strdup is OK (although avoiding strtok might be more elegant here).
 
 	// Parse out any params
-	char *tok = strtok(input, " ");
-	if (tok) {
-		do {
-			param[num_params++] = tok;
-		} while ((tok = strtok(NULL, " ")) != NULL);
-	} else {
-		param[num_params++] = input;
-	}
+	char *input = strdup(inputOrig);	// One of the rare occasions using strdup is OK (although avoiding strtok might be more elegant here).
+	splitCommand(input, num_params, &param[0]);
 
 	// Handle commands first
 	bool result;
@@ -398,6 +391,57 @@ bool Debugger::parseCommand(const char *inputOrig) {
 	return true;
 }
 
+void Debugger::splitCommand(char *input, int &argc, const char **argv) {
+	byte c;
+	enum states { DULL, IN_WORD, IN_STRING } state = DULL;
+	const char *paramStart = nullptr;
+	
+	argc = 0;
+	for (char *p = input; *p; ++p) {
+		c = (byte)*p;
+
+		switch (state) {
+		case DULL: 
+			// not in a word, not in a double quoted string
+			if (isspace(c))
+				break;
+			
+			// not a space -- if it's a double quote we go to IN_STRING, else to IN_WORD
+			if (c == '"') {
+				state = IN_STRING;
+				paramStart = p + 1; // word starts at *next* char, not this one
+			} else {
+				state = IN_WORD;
+				paramStart = p;		// word starts here
+			}
+			break;
+
+		case IN_STRING:
+			// we're in a double quoted string, so keep going until we hit a close "
+			if (c == '"') {
+				// Add entire quoted string to parameter list
+				*p = '\0';
+				argv[argc++] = paramStart;
+				state = DULL;	// back to "not in word, not in string" state
+			}
+			break;
+
+		case IN_WORD:
+			// we're in a word, so keep going until we get to a space
+			if (isspace(c)) {
+				*p = '\0';
+				argv[argc++] = paramStart;
+				state = DULL;	// back to "not in word, not in string" state
+			}
+			break;
+		}
+	}
+
+	if (state != DULL)
+		// Add in final parameter
+		argv[argc++] = paramStart;
+}
+
 // returns true if something has been completed
 // completion has to be delete[]-ed then
 bool Debugger::tabComplete(const char *input, Common::String &completion) const {
diff --git a/gui/debugger.h b/gui/debugger.h
index bc9306c..b12bd27 100644
--- a/gui/debugger.h
+++ b/gui/debugger.h
@@ -204,6 +204,12 @@ protected:
 private:
 	void enter();
 
+	/**
+	 * Splits up the input into individual parameters
+	 * @remarks		Adapted from code provided by torek on StackOverflow
+	 */
+	void splitCommand(char *input, int &argc, const char **argv);
+
 	bool parseCommand(const char *input);
 	bool tabComplete(const char *input, Common::String &completion) const;
 


Commit: f9bec828de2d858f10ec6980ce1bc984f0eb43ce
    https://github.com/scummvm/scummvm/commit/f9bec828de2d858f10ec6980ce1bc984f0eb43ce
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-09-04T10:15:53-04:00

Commit Message:
TITANIC: Support full view specification in debugger room command

Changed paths:
    engines/titanic/core/game_object.cpp
    engines/titanic/core/project_item.cpp
    engines/titanic/core/project_item.h
    engines/titanic/debugger.cpp


diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index ae517a2..55dbbad 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -1205,28 +1205,11 @@ void CGameObject::loadSurface() {
 }
 
 bool CGameObject::changeView(const CString &viewName) {
-	return changeView(viewName, "");
+	return getRoot()->changeView(viewName, "");
 }
 
 bool CGameObject::changeView(const CString &viewName, const CString &clipName) {
-	CViewItem *newView = parseView(viewName);
-	CGameManager *gameManager = getGameManager();
-	CViewItem *oldView = gameManager->getView();
-
-	if (!oldView || !newView)
-		return false;
-
-	CMovieClip *clip = nullptr;
-	if (!clipName.empty()) {
-		clip = oldView->findNode()->findRoom()->findClip(clipName);
-	} else {
-		CLinkItem *link = oldView->findLink(newView);
-		if (link)
-			clip = link->getClip();
-	}
-
-	gameManager->_gameState.changeView(newView, clip);
-	return true;
+	return getRoot()->changeView(viewName, clipName);
 }
 
 void CGameObject::dragMove(const Point &pt) {
diff --git a/engines/titanic/core/project_item.cpp b/engines/titanic/core/project_item.cpp
index 0fa5d44..92faebc 100644
--- a/engines/titanic/core/project_item.cpp
+++ b/engines/titanic/core/project_item.cpp
@@ -626,4 +626,30 @@ CViewItem *CProjectItem::parseView(const CString &viewString) {
 	return view;
 }
 
+bool CProjectItem::changeView(const CString &viewName) {
+	return changeView(viewName, "");
+}
+
+bool CProjectItem::changeView(const CString &viewName, const CString &clipName) {
+	CViewItem *newView = parseView(viewName);
+	CGameManager *gameManager = getGameManager();
+	CViewItem *oldView = gameManager->getView();
+
+	if (!oldView || !newView)
+		return false;
+
+	CMovieClip *clip = nullptr;
+	if (!clipName.empty()) {
+		clip = oldView->findNode()->findRoom()->findClip(clipName);
+	} else {
+		CLinkItem *link = oldView->findLink(newView);
+		if (link)
+			clip = link->getClip();
+	}
+
+	gameManager->_gameState.changeView(newView, clip);
+	return true;
+}
+
+
 } // End of namespace Titanic
diff --git a/engines/titanic/core/project_item.h b/engines/titanic/core/project_item.h
index 4a87e64..c9fd6f9 100644
--- a/engines/titanic/core/project_item.h
+++ b/engines/titanic/core/project_item.h
@@ -242,6 +242,15 @@ public:
 	 */
 	CViewItem *parseView(const CString &viewString);
 
+	/**
+	 * Change the view
+	 */
+	bool changeView(const CString &viewName, const CString &clipName);
+
+	/**
+	 * Change the view
+	 */
+	bool changeView(const CString &viewName);
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/debugger.cpp b/engines/titanic/debugger.cpp
index a8b580b..dd363f8 100644
--- a/engines/titanic/debugger.cpp
+++ b/engines/titanic/debugger.cpp
@@ -168,9 +168,18 @@ bool Debugger::cmdRoom(int argc, const char **argv) {
 	} else if (argc >= 2) {
 		CRoomItem *roomItem = findRoom(argv[1]);
 
-		if (!roomItem)
-			debugPrintf("Could not find room - %s\n", argv[1]);
-		else if (argc == 2)
+		if (!roomItem && argc == 2) {
+			// Presume it's a full view specified
+			CProjectItem *project = g_vm->_window->_project;
+			CViewItem *view = project->parseView(argv[1]);
+
+			if (view) {
+				project->changeView(argv[1]);
+				return false;
+			} else {
+				debugPrintf("Could not find view - %s\n", argv[1]);
+			}
+		} else if (argc == 2)
 			listRoom(roomItem);
 		else {
 			CNodeItem *nodeItem = findNode(roomItem, argv[2]);


Commit: 54ec7885411bd5720d5d6a37bf96cf73dd924d1d
    https://github.com/scummvm/scummvm/commit/54ec7885411bd5720d5d6a37bf96cf73dd924d1d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-09-05T19:35:08-04:00

Commit Message:
GUI: Update comment for strdup call

Changed paths:
    gui/debugger.cpp


diff --git a/gui/debugger.cpp b/gui/debugger.cpp
index ce994a4..33afc9c 100644
--- a/gui/debugger.cpp
+++ b/gui/debugger.cpp
@@ -290,7 +290,8 @@ bool Debugger::parseCommand(const char *inputOrig) {
 	const char *param[256];
 
 	// Parse out any params
-	char *input = strdup(inputOrig);	// One of the rare occasions using strdup is OK (although avoiding strtok might be more elegant here).
+	// One of the rare occasions using strdup is OK, since splitCommands needs to modify it
+	char *input = strdup(inputOrig);
 	splitCommand(input, num_params, &param[0]);
 
 	// Handle commands first


Commit: 0b9b3e336aa17e8fcd5780c9cf493deb796b2a3a
    https://github.com/scummvm/scummvm/commit/0b9b3e336aa17e8fcd5780c9cf493deb796b2a3a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-09-05T19:36:47-04:00

Commit Message:
GUI: Remove code that closes debugger if # or ~ keys are pressed

Changed paths:
    gui/console.cpp


diff --git a/gui/console.cpp b/gui/console.cpp
index 27b38ac..f99197c 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -480,9 +480,7 @@ void ConsoleDialog::handleKeyDown(Common::KeyState state) {
 }
 
 void ConsoleDialog::defaultKeyDownHandler(Common::KeyState &state) {
-	if (state.ascii == '~' || state.ascii == '#') {
-		slideUpAndClose();
-	} else if (state.hasFlags(Common::KBD_CTRL)) {
+	if (state.hasFlags(Common::KBD_CTRL)) {
 		specialKeys(state.keycode);
 	} else if ((state.ascii >= 32 && state.ascii <= 127) || (state.ascii >= 160 && state.ascii <= 255)) {
 		for (int i = _promptEndPos - 1; i >= _currentPos; i--)


Commit: 1ecb27e6cc32eba24079e9b28aea414319c6cbcf
    https://github.com/scummvm/scummvm/commit/1ecb27e6cc32eba24079e9b28aea414319c6cbcf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-09-05T19:38:56-04:00

Commit Message:
TITANIC: Simplify sound command now that # character is allowed

Changed paths:
    engines/titanic/debugger.cpp


diff --git a/engines/titanic/debugger.cpp b/engines/titanic/debugger.cpp
index dd363f8..a42c51c 100644
--- a/engines/titanic/debugger.cpp
+++ b/engines/titanic/debugger.cpp
@@ -331,9 +331,6 @@ bool Debugger::cmdMovie(int argc, const char **argv) {
 bool Debugger::cmdSound(int argc, const char **argv) {
 	if (argc == 2) {
 		Common::String name = argv[1];
-		const char *ch = strchr(argv[1], '!');
-		if (ch)
-			name.setChar('#', ch - argv[1]);
 		if (!name.contains("#"))
 			name = "z#" + name;
 


Commit: 47f6c2e9b9687150da6d5d1498fce90523706c28
    https://github.com/scummvm/scummvm/commit/47f6c2e9b9687150da6d5d1498fce90523706c28
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-09-24T12:18:15-04:00

Commit Message:
Merge pull request #1010 from dreammaster/debugger_params

GUI: Support double quoted debugger parameters

Changed paths:
    engines/titanic/core/game_object.cpp
    engines/titanic/core/project_item.cpp
    engines/titanic/core/project_item.h
    engines/titanic/debugger.cpp
    gui/console.cpp
    gui/debugger.cpp
    gui/debugger.h







More information about the Scummvm-git-logs mailing list