[Scummvm-git-logs] scummvm master -> 85556572078c7a725dd376217f4572c13188d6c1

digitall dgturner at iee.org
Sat Sep 14 04:06:34 CEST 2019


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

Summary:
8555657207 HDB: Improve String Code Usage in HDB Engine Code


Commit: 85556572078c7a725dd376217f4572c13188d6c1
    https://github.com/scummvm/scummvm/commit/85556572078c7a725dd376217f4572c13188d6c1
Author: D G Turner (digitall at scummvm.org)
Date: 2019-09-14T03:03:17+01:00

Commit Message:
HDB: Improve String Code Usage in HDB Engine Code

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 8788c20..0de3f32 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -323,15 +323,15 @@ bool HDBGame::restartMap() {
 
 bool HDBGame::startMap(const char *name) {
 	// save last mapname
-	strcpy(_lastMapname, _currentMapname);
+	Common::strlcpy(_lastMapname, _currentMapname, sizeof(_lastMapname));
 
 	// set current mapname
-	strcpy(_currentMapname, name);
-	strcat(_currentMapname, ".MSM");
+	Common::strlcpy(_currentMapname, name, sizeof(_currentMapname));
+	Common::strlcat(_currentMapname, ".MSM", sizeof(_currentMapname));
 
 	// set current luaname
-	strcpy(_currentLuaName, name );
-	strcat(_currentLuaName, ".LUA");
+	Common::strlcpy(_currentLuaName, name, sizeof(_currentLuaName));
+	Common::strlcat(_currentLuaName, ".LUA", sizeof(_currentLuaName));
 
 	restartMap();
 
@@ -932,25 +932,26 @@ Common::Error HDBGame::run() {
 #endif
 
 	if (ConfMan.hasKey("boot_param")) {
-		char mapname[20];
 		int arg = ConfMan.getInt("boot_param");
 		int actionMode = MIN(arg / 100, 1);
 		int level = MIN(arg % 100, 31);
 
 		setActionMode(actionMode);
 
-		if (level <= 30)
-			snprintf(mapname, 10, "MAP%02d", level);
-		else
-			strcpy(mapname, "CINE_OUTRO");
+		Common::String mapNameString = Common::String::format("MAP%02d", level);
+
+		if (level > 30) {
+			mapNameString = "CINE_OUTRO";
+		}
 
-		if (isDemo())
-			strcat(mapname, "_DEMO");
+		if (isDemo()) {
+			mapNameString += "_DEMO";
+		}
 
-		debug("Starting level %s in %s", mapname, getActionMode() ? "Action Mode" : "Puzzle Mode");
+		debug("Starting level %s in %s Mode", mapNameString.c_str(), getActionMode() ? "Action" : "Puzzle");
 
 		_ai->clearPersistent();
-		startMap(mapname);
+		startMap(mapNameString.c_str());
 
 		_gameState = GAME_PLAY;
 	} else {





More information about the Scummvm-git-logs mailing list