[Scummvm-cvs-logs] CVS: residual driver_tinygl.cpp,1.21,1.22 engine.cpp,1.81,1.82 engine.h,1.31,1.32 lua.cpp,1.148,1.149 registry.cpp,1.12,1.13 textobject.cpp,1.28,1.29

Erich Edgar Hoover compholio at users.sourceforge.net
Tue Aug 9 22:32:36 CEST 2005


Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12472

Modified Files:
	driver_tinygl.cpp engine.cpp engine.h lua.cpp registry.cpp 
	textobject.cpp 
Log Message:
fix for text object memory problems and some small improvements to the menu handling system

Index: driver_tinygl.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_tinygl.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- driver_tinygl.cpp	5 May 2005 21:23:17 -0000	1.21
+++ driver_tinygl.cpp	10 Aug 2005 05:30:58 -0000	1.22
@@ -469,7 +469,7 @@
 }
 
 void DriverTinyGL::destroyTextBitmap(TextObjectHandle *handle) {
-	delete handle->bitmapData;
+	delete[] handle->bitmapData;
 	SDL_FreeSurface((SDL_Surface *)handle->surface);
 }
 

Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.cpp,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- engine.cpp	1 Aug 2005 03:49:02 -0000	1.81
+++ engine.cpp	10 Aug 2005 05:30:58 -0000	1.82
@@ -44,6 +44,7 @@
 
 #else
 
+char g_find_file_data[100];
 DIR *g_searchFile;
 
 #endif

Index: engine.h
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- engine.h	1 Aug 2005 03:49:02 -0000	1.31
+++ engine.h	10 Aug 2005 05:30:58 -0000	1.32
@@ -234,6 +234,7 @@
 
 #else
 
+extern char g_find_file_data[100];
 extern DIR *g_searchFile;
 
 #endif

Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- lua.cpp	8 Aug 2005 07:05:46 -0000	1.148
+++ lua.cpp	10 Aug 2005 05:30:58 -0000	1.149
@@ -2042,15 +2042,28 @@
 #else
 		do {
 			de = readdir(g_searchFile);
-			if (de)
-				found = true;
-		} while (de && (de->d_type == 6/* DT_DIR ? */));
+			if (de) {
+				// If the 'extension' is a wildcard pattern then check only the extensions,
+				// otherwise check the entire filename
+				if (g_find_file_data[0] == '*' && g_find_file_data[1] == '.') {
+					char *c = strrchr(de->d_name, '.');
+					
+					if (c != NULL && !strcasecmp(c, &g_find_file_data[1])) {
+						found = true;
+						break;
+					}
+				} else if (!strcasecmp(de->d_name, g_find_file_data)) {
+					found = true;
+					break;
+				}
+			}
+		} while (de);
 #endif
 
 #ifdef _WIN32
 		if (g_find_file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
 #else
-		if (de->d_type == 6/* DT_DIR ? */)
+		if (!de)
 #endif
 			found = false;
 	}
@@ -2067,7 +2080,7 @@
 }
 
 static void luaFileFindFirst() {
-	char path[255], *extension;
+	char *path, *extension;
 	lua_Object pathObj;
 
 	DEBUG_FUNCTION();
@@ -2075,20 +2088,22 @@
 	pathObj = lua_getparam(2);
 	FileFindDispose();
 
-	if (!lua_isnil(pathObj)) {
-		sprintf(path, "%s/%s", lua_getstring(pathObj), extension);
-	} else {
-		sprintf(path, "%s", extension);
-	}
-
+	if (lua_isnil(pathObj))
+		path = ".";
+	else
+		path = lua_getstring(pathObj);
+	
 #ifdef _WIN32
 	std::string dir_strWin32 = path;
+	dir_strWin32 += "/";
+	dir_strWin32 += extension;
 	g_searchFile = FindFirstFile(dir_strWin32.c_str(), &g_find_file_data);
 	g_firstFind = true;
 	if (g_searchFile == INVALID_HANDLE_VALUE)
 		g_searchFile = NULL;
 #else
 	g_searchFile = opendir(path);
+	strcpy(g_find_file_data, extension);
 #endif
 
 	if (g_searchFile) {
@@ -2183,6 +2198,11 @@
 	int x, y;
 	
 	DEBUG_FUNCTION();
+	// Allow displaying a null image to fail gracefully.
+	// Once main_menu:cancel is handled better this should
+	// be unnecessary.
+	if (lua_isnil(lua_getparam(1)))
+		return;
 	bitmap = check_bitmapobject(1);
 	x = check_int(2);
 	y = check_int(3);
@@ -2294,6 +2314,21 @@
 		error("Unable to push exit event!");
 }
 
+/* This function acts as a wrapper around the actual
+ * cancel operation, which fails if the second parameter
+ * passed to it is not 'nil'
+ */
+static void cancelHandler() {
+	lua_Object menuTable, cancelFunction;
+	
+	stubWarning("cancelHandler");
+	menuTable = lua_getparam(1);
+	cancelFunction = getTableValue(menuTable, "cancel_orig");
+	lua_pushobject(menuTable);
+	lua_pushnil();
+	lua_callfunction(cancelFunction);
+}
+
 /* This function provides all of the menu
  * handling that has been observed
  */
@@ -2343,8 +2378,13 @@
 		itemTable = getTableValue(menuTable, "active_menu");
 	} else if (!lua_isnil(getTableValue(menuTable, "num_choices"))) {
 		// Exit Menu
-		int current_choice = atoi(lua_getstring(getTableValue(menuTable, "current_choice")));
+		lua_Object currentChoice = getTableValue(menuTable, "current_choice");
 		int num_choices = atoi(lua_getstring(getTableValue(menuTable, "num_choices")));
+		int current_choice;
+		
+		if (lua_isnil(currentChoice))
+			return; // if the current choice is 'nil' then there are no choices
+		current_choice = atoi(lua_getstring(currentChoice));
 		
 		if (key == SDLK_RIGHT)
 			current_choice++;
@@ -2382,6 +2422,20 @@
 		warning("Unhandled type of menu!");
 		return;
 	}
+	
+	if (lua_isnil(getTableValue(menuTable, "cancel_orig"))) {
+		lua_Object cancelFunction = getTableValue(menuTable, "cancel");
+		// Install Alternative Cancel Handler
+		lua_pushobject(menuTable);
+		lua_pushstring(const_cast<char *>("cancel"));
+		lua_pushcfunction(cancelHandler);
+		lua_settable();
+		// Store the old Cancel Handler
+		lua_pushobject(menuTable);
+		lua_pushstring(const_cast<char *>("cancel_orig"));
+		lua_pushobject(cancelFunction);
+		lua_settable();
+	}
 
 	// get the current item
 	menuItem = atoi(lua_getstring(getTableValue(itemTable, "cur_item")));
@@ -2391,13 +2445,6 @@
 	if (key == SDLK_RETURN && strmatch(itemText(itemTable, menuItem), "/sytx247/"))
 		key = SDLK_ESCAPE;
 
-	// hack the "&Quit" command so it actually works
-	// (at this time it cannot open the exit menu on top of the normal one)
-	if (key == SDLK_RETURN && strmatch(itemText(itemTable, menuItem), "/sytx248/")) {
-		Exit();
-		return;
-	}
-	
 	/* if we're running the menu then we need to manually handle
 	 * a lot of the operations necessary to use the menu
 	 */
@@ -2421,16 +2468,20 @@
 		case SDLK_DOWN:
 			do {
 				menuItem++;
-				if (menuItem > menuItems)
-					return;
+				if (menuItem > menuItems) {
+					menuItem = 1;
+					break;
+				}
 			} while (itemDisabled(itemTable, menuItem));
 			menuChanged = true;
 			break;
 		case SDLK_UP:
 			do {
 				menuItem--;
-				if (menuItem < 1)
-					return;
+				if (menuItem < 1) {
+					menuItem = menuItems;
+					break;
+				}
 			} while (itemDisabled(itemTable, menuItem));
 			menuChanged = true;
 			break;
@@ -2440,6 +2491,12 @@
 		case SDLK_RIGHT:
 			sliderValue = 1;
 			break;
+		case SDLK_RETURN:
+			// Allow the return key to act as a "slide right" operation,
+			// this actually isn't supposed to do anything for normal
+			// sliders but handling more is better than less.
+			sliderValue = 1;
+			break;
 	}
 	if (menuChanged)
 		setTableValue(itemTable, "cur_item", menuItem);
@@ -2969,6 +3026,12 @@
 	int strSize;
 	int count = 0;
 
+	// Get the name of the saved game
+	lua_pushobject(result);
+	lua_pushnumber(count++);
+	lua_pushstring(filename); // TODO: Use an actual stored name
+	lua_settable();
+	
 	for (;;) {
 		if (dataSize <= 0)
 			break;

Index: registry.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/registry.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- registry.cpp	10 Jul 2005 18:57:27 -0000	1.12
+++ registry.cpp	10 Aug 2005 05:30:58 -0000	1.13
@@ -49,6 +49,10 @@
 }
 
 const char *Registry::get(const char *key, const char *defval) const {
+	// GrimDataDir is an alias for DataDir for our purposes
+	if (!strcmp(key, "GrimDataDir"))
+		key = "DataDir";
+	
 	Group::const_iterator i = _settings.find(key);
 	if (i == _settings.end())
 		return defval;

Index: textobject.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/textobject.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- textobject.cpp	10 Jul 2005 18:57:27 -0000	1.28
+++ textobject.cpp	10 Aug 2005 05:30:58 -0000	1.29
@@ -151,8 +151,9 @@
 		}
 		//printf("creating textobject: %s\nheight: %d\nwidth: %d\n", currentLine.c_str(), _bitmapHeight[j], _bitmapWidth[j]);
 
-		_textBitmap = new uint8[_bitmapHeightPtr[j] * _bitmapWidthPtr[j]];
-		memset(_textBitmap, 0, _bitmapHeightPtr[j] * _bitmapWidthPtr[j]);
+		// Due to the size of charWidth we need to allocate one more byte than we plan on using
+		_textBitmap = new uint8[_bitmapHeightPtr[j] * _bitmapWidthPtr[j] + 1];
+		memset(_textBitmap, 0, _bitmapHeightPtr[j] * _bitmapWidthPtr[j] + 1);
 
 		// Fill bitmap
 		int offset = 0;





More information about the Scummvm-git-logs mailing list