[Scummvm-cvs-logs] scummvm master -> 305c6b4d8372178fc2dcd6e55a49ef3774766cf6

digitall digitall at scummvm.org
Thu Jun 2 20:48:54 CEST 2011


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:
305c6b4d83 AGI: Replace snprintf() usage with Common::String::format()


Commit: 305c6b4d8372178fc2dcd6e55a49ef3774766cf6
    https://github.com/scummvm/scummvm/commit/305c6b4d8372178fc2dcd6e55a49ef3774766cf6
Author: D G Turner (digitall at scummvm.org)
Date: 2011-06-02T11:46:55-07:00

Commit Message:
AGI: Replace snprintf() usage with Common::String::format()

Safer and less portability issues.

Changed paths:
    engines/agi/saveload.cpp



diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index 7eaf13d..dae3dd4 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -551,11 +551,8 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
 #define NUM_VISIBLE_SLOTS 12
 
 const char *AgiEngine::getSavegameFilename(int num) {
-	static Common::String saveLoadSlot;
-	char extension[5];
-	snprintf(extension, sizeof(extension), ".%.3d", num);
-
-	saveLoadSlot = _targetName + extension;
+	Common::String saveLoadSlot = _targetName;
+	saveLoadSlot += Common::String::format(".%.3d", num);
 	return saveLoadSlot.c_str();
 }
 
@@ -987,14 +984,12 @@ void AgiEngine::releaseImageStack() {
 
 void AgiEngine::checkQuickLoad() {
 	if (ConfMan.hasKey("save_slot")) {
-		char saveNameBuffer[256];
-
-		snprintf(saveNameBuffer, 256, "%s.%03d", _targetName.c_str(), ConfMan.getInt("save_slot"));
+		Common::String saveNameBuffer = Common::String::format("%s.%03d", _targetName.c_str(), ConfMan.getInt("save_slot"));
 
 		_sprites->eraseBoth();
 		_sound->stopSound();
 
-		if (loadGame(saveNameBuffer, false) == errOK) {	 // Do not check game id
+		if (loadGame(saveNameBuffer.c_str(), false) == errOK) {	 // Do not check game id
 			_game.exitAllLogics = 1;
 			_menu->enableAll();
 		}






More information about the Scummvm-git-logs mailing list