diff options
| author | D G Turner | 2019-09-14 03:03:17 +0100 | 
|---|---|---|
| committer | D G Turner | 2019-09-14 03:03:17 +0100 | 
| commit | 85556572078c7a725dd376217f4572c13188d6c1 (patch) | |
| tree | 06c06183fa7c9918774a6a304ca92021d0770213 | |
| parent | 076514da3f027cf59d3eab6e170e451a2e64bcb9 (diff) | |
| download | scummvm-rg350-85556572078c7a725dd376217f4572c13188d6c1.tar.gz scummvm-rg350-85556572078c7a725dd376217f4572c13188d6c1.tar.bz2 scummvm-rg350-85556572078c7a725dd376217f4572c13188d6c1.zip  | |
HDB: Improve String Code Usage in HDB Engine Code
| -rw-r--r-- | engines/hdb/hdb.cpp | 29 | 
1 files changed, 15 insertions, 14 deletions
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp index 8788c2037f..0de3f32eda 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 {  | 
