[Scummvm-git-logs] scummvm master -> 3fe4d8fc0fff7d685d903d912443c651a2f16eec

lolbot-iichan lolbot_iichan at mail.ru
Fri May 28 18:07:15 UTC 2021


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

Summary:
6ed025dd89 ACHIEVEMENTS: Add API methods that are easy to use
a4aa95b2b3 ACHIEVEMENTS: Minor refactoring
4d582218a9 GUI: Use simple achievements API
4bcf76dd9e WINTERMUTE: Use simple achievements API
65788d14ad TWINE: Use simple achievements API
5fb2919986 TWINE: Init achievements manager on game start
dda0cbec5f TESTBED: Use simple achievements API
36d304ec7c AGS: Simplify achievements plugin code
3fe4d8fc0f ACHIEVEMENTS: Remove old API methods


Commit: 6ed025dd894e0f635f7227e20dfcca993e2160b2
    https://github.com/scummvm/scummvm/commit/6ed025dd894e0f635f7227e20dfcca993e2160b2
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-05-28T21:07:08+03:00

Commit Message:
ACHIEVEMENTS: Add API methods that are easy to use

Changed paths:
    common/achievements.cpp
    common/achievements.h


diff --git a/common/achievements.cpp b/common/achievements.cpp
index e4b3bda5de..3be95c9726 100644
--- a/common/achievements.cpp
+++ b/common/achievements.cpp
@@ -40,6 +40,17 @@ AchievementsManager::AchievementsManager() {
 AchievementsManager::~AchievementsManager() {
 }
 
+bool AchievementsManager::setActiveDomain(const AchievementsInfo &info) {
+	if (info.appId.empty()) {
+		unsetActiveDomain();
+		return false;
+	}
+
+	_descriptions = info.descriptions;
+
+	return setActiveDomain(info.platform, info.appId);
+}
+
 bool AchievementsManager::setActiveDomain(AchievementsPlatform platform, const String &appId) {
 	String prefix = platform == STEAM_ACHIEVEMENTS ? "steam-" + appId :
 					platform == GALAXY_ACHIEVEMENTS ? "galaxy-" + appId :
@@ -70,10 +81,31 @@ bool AchievementsManager::unsetActiveDomain() {
 	delete _iniFile;
 	_iniFile = nullptr;
 
+	_descriptions.clear();
+
 	return true;
 }
 
 
+bool AchievementsManager::setAchievement(const String &id) {
+	if (!isReady()) {
+		return false;
+	}
+	if (isAchieved(id)) {
+		return true;
+	}
+
+	String displayedMessage = id;
+	for (uint32 i = 0; i < _descriptions.size(); i++) {
+		if (strcmp(_descriptions[i].id, id.c_str()) == 0) {
+			displayedMessage = _descriptions[i].title;
+			break;
+		}
+	}
+
+	return setAchievement(id, displayedMessage);
+}
+
 bool AchievementsManager::setAchievement(const String &id, const String &displayedMessage) {
 	if (!isReady()) {
 		return false;
diff --git a/common/achievements.h b/common/achievements.h
index 1a0f689c16..a94e6cbc9d 100644
--- a/common/achievements.h
+++ b/common/achievements.h
@@ -81,12 +81,19 @@ public:
 	~AchievementsManager();
 
 	/**
-	 * Set a platform and application ID as active domain.
+	 * (DEPRECATED) Set a platform and application ID as active domain.
 	 *
 	 * @param[in] platform Achievements platform.
 	 * @param[in] appId	Achievements application ID of the given platform.
 	 */
 	bool setActiveDomain(AchievementsPlatform platform, const String &appId);
+
+	/**
+	 * Set a platform and application ID as active domain, store messages texts.
+	 *
+	 * @param[in] info Achievements platform, application ID and messages information.
+	 */
+	bool setActiveDomain(const AchievementsInfo &info);
 	bool unsetActiveDomain();                            //!< Unset the current active domain.
 	bool isReady() const { return _iniFile != nullptr; } //!< Check whether the domain is ready.
 
@@ -95,13 +102,19 @@ public:
 	 * @{
 	 */
 
-	/** Set an achievement.
+	/** (DEPRECATED) Set an achievement.
 	 *
 	 * @param[in] id			   Internal ID of the achievement.
 	 * @param[in] displayedMessage Message displayed when the achievement is achieved.
 	 */
 	bool setAchievement(const String &id, const String &displayedMessage);
 
+	/** Set an achievement. Message is automatically displayed with text from active domain.
+	 *
+	 * @param[in] id			   Internal ID of the achievement.
+	 */
+	bool setAchievement(const String &id);
+
 	/**
 	 * Set an achievement as achieved.
 	 *
@@ -167,6 +180,7 @@ public:
 private:
 	INIFile *_iniFile;
 	String _iniFileName;
+	Common::Array<AchievementDescription> _descriptions;
 };
 
 /** Shortcut for accessing the Achievements Manager. */


Commit: a4aa95b2b370867a26a22649bc7e7a937c472f49
    https://github.com/scummvm/scummvm/commit/a4aa95b2b370867a26a22649bc7e7a937c472f49
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-05-28T21:07:08+03:00

Commit Message:
ACHIEVEMENTS: Minor refactoring

Changed paths:
    common/achievements.cpp
    common/achievements.h


diff --git a/common/achievements.cpp b/common/achievements.cpp
index 3be95c9726..c2c04a013f 100644
--- a/common/achievements.cpp
+++ b/common/achievements.cpp
@@ -52,11 +52,11 @@ bool AchievementsManager::setActiveDomain(const AchievementsInfo &info) {
 }
 
 bool AchievementsManager::setActiveDomain(AchievementsPlatform platform, const String &appId) {
-	String prefix = platform == STEAM_ACHIEVEMENTS ? "steam-" + appId :
-					platform == GALAXY_ACHIEVEMENTS ? "galaxy-" + appId :
-					appId;
+	const char* prefix = platform == STEAM_ACHIEVEMENTS ? "steam" :
+					platform == GALAXY_ACHIEVEMENTS ? "galaxy" :
+					"achman";
 
-	String iniFileName = prefix + ".dat";
+	String iniFileName = String::format("%s-%s.dat", prefix, appId.c_str());
 
 	if (_iniFileName == iniFileName) {
 		return true;
@@ -114,7 +114,7 @@ bool AchievementsManager::setAchievement(const String &id, const String &display
 		return true;
 	}
 
-	debug("AchievementsManager::setAchievement('%s'): Achievement unlocked!", id.c_str());
+	debug("AchievementsManager::setAchievement('%s'): %s", id.c_str(), displayedMessage.c_str());
 
 	_iniFile->setKey(id, "achievements", "true");
 	_iniFile->saveToSaveFile(_iniFileName);
diff --git a/common/achievements.h b/common/achievements.h
index a94e6cbc9d..6c473fd5df 100644
--- a/common/achievements.h
+++ b/common/achievements.h
@@ -116,7 +116,7 @@ public:
 	bool setAchievement(const String &id);
 
 	/**
-	 * Set an achievement as achieved.
+	 * Check if an achievement as achieved.
 	 *
 	 * @param[in] id Internal ID of the achievement.
 	 */


Commit: 4d582218a98783deac1a04c1ee8fdc9a77fbea05
    https://github.com/scummvm/scummvm/commit/4d582218a98783deac1a04c1ee8fdc9a77fbea05
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-05-28T21:07:08+03:00

Commit Message:
GUI: Use simple achievements API

Changed paths:
    gui/options.cpp


diff --git a/gui/options.cpp b/gui/options.cpp
index a22d412483..41f91a71ff 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -1191,7 +1191,7 @@ void OptionsDialog::addKeyMapperControls(GuiObject *boss, const Common::String &
 
 void OptionsDialog::addAchievementsControls(GuiObject *boss, const Common::String &prefix, const Common::AchievementsInfo &info) {
 	Common::String achDomainId = ConfMan.get("achievements", _domain);
-	AchMan.setActiveDomain(info.platform, info.appId);
+	AchMan.setActiveDomain(info);
 
 	GUI::ScrollContainerWidget *scrollContainer;
 	scrollContainer = new GUI::ScrollContainerWidget(boss, prefix + "Container", "");


Commit: 4bcf76dd9e13565a6a1fa2ec54b3700c718e859c
    https://github.com/scummvm/scummvm/commit/4bcf76dd9e13565a6a1fa2ec54b3700c718e859c
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-05-28T21:07:08+03:00

Commit Message:
WINTERMUTE: Use simple achievements API

Changed paths:
    engines/wintermute/ext/scene_achievements.cpp
    engines/wintermute/ext/wme_galaxy.cpp
    engines/wintermute/ext/wme_galaxy.h
    engines/wintermute/ext/wme_steam.cpp


diff --git a/engines/wintermute/ext/scene_achievements.cpp b/engines/wintermute/ext/scene_achievements.cpp
index 1c605481b1..d7002cc6aa 100644
--- a/engines/wintermute/ext/scene_achievements.cpp
+++ b/engines/wintermute/ext/scene_achievements.cpp
@@ -32,18 +32,13 @@
 
 namespace Wintermute {
 
-void SetAchievement(const char *id) {
-	Common::AchievementsInfo info = getAchievementsInfo();
-	AchMan.setActiveDomain(Common::STEAM_ACHIEVEMENTS, info.appId);
-	AchMan.setAchievement(id, getAchievementMessage(info, id));
-}
-
 void SceneAchievements(const char *sceneFilename) {
 	for (const AchievementsList *i = achievementsList; i->gameId; i++) {
 		if (BaseEngine::instance().getGameId() == i->gameId) {
 			for (const Achievement *it = i->mapping; it->sceneFilename; it++) {
 				if (strcmp(sceneFilename, it->sceneFilename) == 0) {
-					SetAchievement(it->id);
+					AchMan.setActiveDomain(getAchievementsInfo());
+					AchMan.setAchievement(it->id);
 					return;
 				}
 			}
diff --git a/engines/wintermute/ext/wme_galaxy.cpp b/engines/wintermute/ext/wme_galaxy.cpp
index a6ce4f7e9a..14fdae4207 100644
--- a/engines/wintermute/ext/wme_galaxy.cpp
+++ b/engines/wintermute/ext/wme_galaxy.cpp
@@ -52,14 +52,7 @@ SXWMEGalaxyAPI::SXWMEGalaxyAPI(BaseGame *inGame, ScStack *stack) : BaseScriptabl
 void SXWMEGalaxyAPI::init() {
 	const MetaEngine *meta = g_engine->getMetaEngine();
 	const Common::String target = BaseEngine::instance().getGameTargetName();
-	_achievementsInfo = meta->getAchievementsInfo(target);
-
-	if (!_achievementsInfo.appId.empty()) {
-		AchMan.setActiveDomain(Common::GALAXY_ACHIEVEMENTS, _achievementsInfo.appId);
-	} else {
-		warning("Unknown game accessing WMEGalaxyAPI. All achievements will be ignored.");
-		AchMan.unsetActiveDomain();
-	}
+	AchMan.setActiveDomain(meta->getAchievementsInfo(target));
 }
 
 
@@ -96,15 +89,7 @@ bool SXWMEGalaxyAPI::scCallMethod(ScScript *script, ScStack *stack, ScStack *thi
 		stack->correctParams(1);
 		const char *id = stack->pop()->getString();
 
-		Common::String msg = id;
-		for (uint32 i = 0; i < _achievementsInfo.descriptions.size(); i++) {
-			if (strcmp(_achievementsInfo.descriptions[i].id, id) == 0) {
-				msg = _achievementsInfo.descriptions[i].title;
-				break;
-			}
-		}
-
-		stack->pushBool(AchMan.setAchievement(id, msg));
+		stack->pushBool(AchMan.setAchievement(id));
 		return STATUS_OK;
 	}
 
diff --git a/engines/wintermute/ext/wme_galaxy.h b/engines/wintermute/ext/wme_galaxy.h
index 4d898ed225..22be4e2cc2 100644
--- a/engines/wintermute/ext/wme_galaxy.h
+++ b/engines/wintermute/ext/wme_galaxy.h
@@ -46,8 +46,6 @@ public:
 
 private:
 	void init();
-
-	Common::AchievementsInfo _achievementsInfo;
 };
 
 } // End of namespace Wintermute
diff --git a/engines/wintermute/ext/wme_steam.cpp b/engines/wintermute/ext/wme_steam.cpp
index ee334295d6..88b6b4c84a 100644
--- a/engines/wintermute/ext/wme_steam.cpp
+++ b/engines/wintermute/ext/wme_steam.cpp
@@ -49,17 +49,6 @@ Common::AchievementsInfo getAchievementsInfo() {
 	return meta->getAchievementsInfo(target);
 }
 
-//////////////////////////////////////////////////////////////////////////
-Common::String getAchievementMessage(const Common::AchievementsInfo &info, const char *id) {
-	for (uint32 i = 0; i < info.descriptions.size(); i++) {
-		if (strcmp(info.descriptions[i].id, id) == 0) {
-			return info.descriptions[i].title;
-		}
-	}
-	return id;
-}
-
-
 //////////////////////////////////////////////////////////////////////////
 SXSteamAPI::SXSteamAPI(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) {
 	stack->correctParams(0);
@@ -69,13 +58,7 @@ SXSteamAPI::SXSteamAPI(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame
 //////////////////////////////////////////////////////////////////////////
 void SXSteamAPI::init() {
 	_achievementsInfo = getAchievementsInfo();
-
-	if (!_achievementsInfo.appId.empty()) {
-		AchMan.setActiveDomain(Common::STEAM_ACHIEVEMENTS, _achievementsInfo.appId);
-	} else {
-		warning("Unknown game accessing SteamAPI. All achievements will be ignored.");
-		AchMan.unsetActiveDomain();
-	}
+	AchMan.setActiveDomain(_achievementsInfo);
 }
 
 
@@ -108,8 +91,7 @@ bool SXSteamAPI::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
 	else if (strcmp(name, "SetAchievement") == 0) {
 		stack->correctParams(1);
 		const char *id = stack->pop()->getString();
-		Common::String msg = getAchievementMessage(_achievementsInfo, id);
-		stack->pushBool(AchMan.setAchievement(id, msg));
+		stack->pushBool(AchMan.setAchievement(id));
 		return STATUS_OK;
 	}
 	//////////////////////////////////////////////////////////////////////////


Commit: 65788d14ad9414898e179177b8a69607009d5f70
    https://github.com/scummvm/scummvm/commit/65788d14ad9414898e179177b8a69607009d5f70
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-05-28T21:07:08+03:00

Commit Message:
TWINE: Use simple achievements API

Changed paths:
    engines/twine/twine.cpp


diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index f7223868f4..9e2b73f42d 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -1148,18 +1148,7 @@ const char *TwinEEngine::getGameId() const {
 }
 
 bool TwinEEngine::unlockAchievement(const Common::String &id) {
-	const MetaEngine *meta = getMetaEngine();
-	const Common::AchievementsInfo &achievementsInfo = meta->getAchievementsInfo(ConfMan.getActiveDomainName());
-
-	Common::String msg = id;
-	for (uint32 i = 0; i < achievementsInfo.descriptions.size(); i++) {
-		if (id == achievementsInfo.descriptions[i].id) {
-			msg = achievementsInfo.descriptions[i].title;
-			break;
-		}
-	}
-
-	return AchMan.setAchievement(id, msg);
+	return AchMan.setAchievement(id);
 }
 
 Common::Rect TwinEEngine::centerOnScreen(int32 w, int32 h) const {


Commit: 5fb2919986df433dc449852b49aa56599a0eb323
    https://github.com/scummvm/scummvm/commit/5fb2919986df433dc449852b49aa56599a0eb323
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-05-28T21:07:08+03:00

Commit Message:
TWINE: Init achievements manager on game start

Changed paths:
    engines/twine/twine.cpp


diff --git a/engines/twine/twine.cpp b/engines/twine/twine.cpp
index 9e2b73f42d..56e10a040f 100644
--- a/engines/twine/twine.cpp
+++ b/engines/twine/twine.cpp
@@ -227,6 +227,9 @@ Common::Error TwinEEngine::run() {
 	ConfMan.registerDefault("usehighres", false);
 	ConfMan.registerDefault("wallcollision", false);
 
+	Common::String gameTarget = ConfMan.getActiveDomainName();
+	AchMan.setActiveDomain(getMetaEngine()->getAchievementsInfo(gameTarget));
+
 	syncSoundSettings();
 	int32 w = ORIGINAL_WIDTH;
 	int32 h = ORIGINAL_HEIGHT;


Commit: dda0cbec5f6eb5a2038d5a9132084fee774e76b7
    https://github.com/scummvm/scummvm/commit/dda0cbec5f6eb5a2038d5a9132084fee774e76b7
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-05-28T21:07:08+03:00

Commit Message:
TESTBED: Use simple achievements API

Changed paths:
  A engines/testbed/achievements.cpp
  A engines/testbed/achievements.h
    engines/testbed/metaengine.cpp
    engines/testbed/module.mk
    engines/testbed/testbed.cpp


diff --git a/engines/testbed/achievements.cpp b/engines/testbed/achievements.cpp
new file mode 100644
index 0000000000..b6514ebdc2
--- /dev/null
+++ b/engines/testbed/achievements.cpp
@@ -0,0 +1,48 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "testbed/achievements.h"
+#include "testbed/testbed.h"
+#include "testbed/testsuite.h"
+
+namespace Testbed {
+
+const Common::AchievementsInfo getAchievementsInfo(const Common::String &target) {
+	Common::AchievementsInfo result;
+	result.platform = Common::UNK_ACHIEVEMENTS;
+	result.appId = "testbed";
+
+	Common::AchievementDescription testSuiteFinalAchievement = {"EVERYTHINGWORKS", true, "Everything works!", "Completed all available testsuites"};
+	result.descriptions.push_back(testSuiteFinalAchievement);
+
+	Common::Array<Testbed::Testsuite *> testsuiteList;
+	Testbed::TestbedEngine::pushTestsuites(testsuiteList);
+	for (Common::Array<Testbed::Testsuite *>::const_iterator i = testsuiteList.begin(); i != testsuiteList.end(); ++i) {
+		Common::AchievementDescription it = {(*i)->getName(), false, (*i)->getDescription(), 0};
+		result.descriptions.push_back(it);
+		delete (*i);
+	}
+
+	return result;
+}
+
+} // End of namespace Testbed
diff --git a/engines/testbed/achievements.h b/engines/testbed/achievements.h
new file mode 100644
index 0000000000..5fe6b4ac73
--- /dev/null
+++ b/engines/testbed/achievements.h
@@ -0,0 +1,35 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TESTBED_ACHIEVEMENTS_H
+#define TESTBED_ACHIEVEMENTS_H
+ 
+#include "common/achievements.h"
+
+namespace Testbed {
+
+const Common::AchievementsInfo getAchievementsInfo(const Common::String &target);
+
+} // End of namespace Testbed
+
+#endif // TESTBED_ACHIEVEMENTS_H 
+
diff --git a/engines/testbed/metaengine.cpp b/engines/testbed/metaengine.cpp
index c5747a3568..8c20741753 100644
--- a/engines/testbed/metaengine.cpp
+++ b/engines/testbed/metaengine.cpp
@@ -26,8 +26,8 @@
 
 #include "engines/advancedDetector.h"
 
+#include "testbed/achievements.h"
 #include "testbed/testbed.h"
-#include "testbed/testsuite.h"
 
 class TestbedMetaEngine : public AdvancedMetaEngine {
 public:
@@ -41,21 +41,7 @@ public:
 	}
 
 	const Common::AchievementsInfo getAchievementsInfo(const Common::String &target) const override {
-		Common::AchievementsInfo result;
-		result.platform = Common::UNK_ACHIEVEMENTS;
-		result.appId = "testbed";
-		Common::AchievementDescription testSuiteFinalAchievement = {"EVERYTHINGWORKS", true, "Everything works!", "Completed all available testsuites"};
-		result.descriptions.push_back(testSuiteFinalAchievement);
-
-		Common::Array<Testbed::Testsuite *> testsuiteList;
-		Testbed::TestbedEngine::pushTestsuites(testsuiteList);
-		for (Common::Array<Testbed::Testsuite *>::const_iterator i = testsuiteList.begin(); i != testsuiteList.end(); ++i) {
-			Common::AchievementDescription it = {(*i)->getName(), false, (*i)->getDescription(), 0};
-			result.descriptions.push_back(it);
-			delete (*i);
-		}
-
-		return result;
+		return Testbed::getAchievementsInfo(target);
 	}
 
 	bool hasFeature(MetaEngineFeature f) const override {
diff --git a/engines/testbed/module.mk b/engines/testbed/module.mk
index a341928477..1bcae5ac95 100644
--- a/engines/testbed/module.mk
+++ b/engines/testbed/module.mk
@@ -1,6 +1,7 @@
 MODULE := engines/testbed
 
 MODULE_OBJS := \
+	achievements.o \
 	config.o \
 	config-params.o \
 	events.o \
diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp
index 2a600f6631..a984b9a895 100644
--- a/engines/testbed/testbed.cpp
+++ b/engines/testbed/testbed.cpp
@@ -32,6 +32,7 @@
 
 #include "engines/util.h"
 
+#include "testbed/achievements.h"
 #include "testbed/events.h"
 #include "testbed/fs.h"
 #include "testbed/graphics.h"
@@ -197,7 +198,7 @@ void TestbedEngine::invokeTestsuites(TestbedConfigManager &cfMan) {
 			(*iter)->execute();
 		}
 		if ((*iter)->getNumTests() == (*iter)->getNumTestsPassed()) {
-			AchMan.setAchievement((*iter)->getName(), (*iter)->getDescription());
+			AchMan.setAchievement((*iter)->getName());
 			checkForAllAchievements();
 		}
 	}
@@ -210,7 +211,7 @@ void TestbedEngine::checkForAllAchievements() {
 			return;
 		}
 	}
-	AchMan.setAchievement("EVERYTHINGWORKS", "Everything works!");
+	AchMan.setAchievement("EVERYTHINGWORKS");
 }
 
 Common::Error TestbedEngine::run() {
@@ -223,7 +224,7 @@ Common::Error TestbedEngine::run() {
 	initGraphics(320, 200);
 
 	// Initialize achievements manager
-	AchMan.setActiveDomain(Common::UNK_ACHIEVEMENTS, "testbed");
+	AchMan.setActiveDomain(getAchievementsInfo(ConfMan.getActiveDomainName()));
 
 	// As of now we are using GUI::MessageDialog for interaction, Test if it works.
 	// interactive mode could also be modified by a config parameter "non-interactive=1"


Commit: 36d304ec7c75cb1d1cad2c8c691e485b2d6ba9d7
    https://github.com/scummvm/scummvm/commit/36d304ec7c75cb1d1cad2c8c691e485b2d6ba9d7
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-05-28T21:07:08+03:00

Commit Message:
AGS: Simplify achievements plugin code

Changed paths:
    engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.cpp
    engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h


diff --git a/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.cpp b/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.cpp
index 815f38ad91..1ff1f2e6c4 100644
--- a/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.cpp
+++ b/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.cpp
@@ -55,18 +55,25 @@ void AGS2Client::AGS_EngineStartup(IAGSEngine *engine) {
 	SCRIPT_METHOD_EXT(AGS2Client::GetCurrentGameLanguage^0, GetCurrentGameLanguage);
 	SCRIPT_METHOD_EXT(AGS2Client::FindLeaderboard^1, FindLeaderboard);
 	SCRIPT_METHOD_EXT(AGS2Client::Initialize^2, Initialize);
+
+	Common::String gameTarget = ConfMan.getActiveDomainName();
+	const MetaEngine *meta = ::AGS::g_vm->getMetaEngine();
+	AchMan.setActiveDomain(meta->getAchievementsInfo(gameTarget));
 }
 
 void AGS2Client::IsAchievementAchieved(ScriptMethodParams &params) {
-	params._result = false;
+	PARAMS1(char *, id);
+	params._result = AchMan.isAchieved(id);
 }
 
 void AGS2Client::SetAchievementAchieved(ScriptMethodParams &params) {
-	params._result = false;
+	PARAMS1(char *, id);
+	params._result = AchMan.setAchievement(id);
 }
 
 void AGS2Client::ResetAchievement(ScriptMethodParams &params) {
-	params._result = false;
+	PARAMS1(char *, id);
+	params._result = AchMan.clearAchievement(id);
 }
 
 void AGS2Client::GetIntStat(ScriptMethodParams &params) {
@@ -94,6 +101,8 @@ void AGS2Client::UpdateAverageRateStat(ScriptMethodParams &params) {
 }
 
 void AGS2Client::ResetStatsAndAchievements(ScriptMethodParams &params) {
+	AchMan.resetAllAchievements();
+	AchMan.resetAllStats();
 }
 
 void AGS2Client::get_Initialized(ScriptMethodParams &params) {
@@ -168,108 +177,6 @@ void AGSGalaxy::AGS_EngineStartup(IAGSEngine *engine) {
 	SCRIPT_METHOD_EXT(AGSGalaxy::GetUserName^0, GetUserName);
 	SCRIPT_METHOD_EXT(AGSGalaxy::GetCurrentGameLanguage^0, GetCurrentGameLanguage);
 	SCRIPT_METHOD_EXT(AGSGalaxy::Initialize^2, Initialize);
-
-	Common::String gameTarget = ConfMan.getActiveDomainName();
-	const MetaEngine *meta = ::AGS::g_vm->getMetaEngine();
-	Common::AchievementsInfo achievementsInfo = meta->getAchievementsInfo(gameTarget);
-	const Common::String target = achievementsInfo.appId;
-	if (!target.empty()) {
-		AchMan.setActiveDomain(Common::GALAXY_ACHIEVEMENTS, target);
-	} else {
-		warning("Unknown game accessing SteamAPI. All achievements will be ignored.");
-		AchMan.unsetActiveDomain();
-	}
-}
-
-void AGSGalaxy::IsAchievementAchieved(ScriptMethodParams &params) {
-	PARAMS1(char *, id);
-	params._result = AchMan.isAchieved(id);
-}
-
-void AGSGalaxy::SetAchievementAchieved(ScriptMethodParams &params) {
-	PARAMS1(char *, id);
-
-	Common::String gameTarget = ConfMan.getActiveDomainName();
-	const MetaEngine *meta = ::AGS::g_vm->getMetaEngine();
-	Common::AchievementsInfo achievementsInfo = meta->getAchievementsInfo(gameTarget);
-
-	Common::String msg = id;
-	for (uint32 i = 0; i < achievementsInfo.descriptions.size(); i++) {
-		if (strcmp(achievementsInfo.descriptions[i].id, id) == 0) {
-			msg = achievementsInfo.descriptions[i].title;
-		}
-	}
-
-	params._result = AchMan.setAchievement(id, msg);
-}
-
-void AGSGalaxy::ResetAchievement(ScriptMethodParams &params) {
-	PARAMS1(char *, id);
-	params._result = AchMan.clearAchievement(id);
-}
-
-void AGSGalaxy::GetIntStat(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSGalaxy::GetFloatStat(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSGalaxy::GetAverageRateStat(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSGalaxy::SetIntStat(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSGalaxy::SetFloatStat(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSGalaxy::UpdateAverageRateStat(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSGalaxy::ResetStatsAndAchievements(ScriptMethodParams &params) {
-	AchMan.resetAllAchievements();
-	AchMan.resetAllStats();
-}
-
-void AGSGalaxy::get_Initialized(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSGalaxy::get_CurrentLeaderboardName(ScriptMethodParams &params) {
-}
-
-void AGSGalaxy::RequestLeaderboard(ScriptMethodParams &params) {
-}
-
-void AGSGalaxy::UploadScore(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSGalaxy::geti_LeaderboardNames(ScriptMethodParams &params) {
-}
-
-void AGSGalaxy::geti_LeaderboardScores(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSGalaxy::get_LeaderboardCount(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSGalaxy::GetUserName(ScriptMethodParams &params) {
-}
-
-void AGSGalaxy::GetCurrentGameLanguage(ScriptMethodParams &params) {
-}
-
-void AGSGalaxy::Initialize(ScriptMethodParams &params) {
-	params._result = 0;
 }
 
 /*------------------------------------------------------------------*/
@@ -306,108 +213,6 @@ void AGSSteam::AGS_EngineStartup(IAGSEngine *engine) {
 	SCRIPT_METHOD_EXT(AGSteam::GetUserName^0, GetUserName);
 	SCRIPT_METHOD_EXT(AGSteam::GetCurrentGameLanguage^0, GetCurrentGameLanguage);
 	SCRIPT_METHOD_EXT(AGSteam::FindLeaderboard^1, FindLeaderboard);
-
-	Common::String gameTarget = ConfMan.getActiveDomainName();
-	const MetaEngine *meta = ::AGS::g_vm->getMetaEngine();
-	Common::AchievementsInfo achievementsInfo = meta->getAchievementsInfo(gameTarget);
-	const Common::String target = achievementsInfo.appId;
-	if (!target.empty()) {
-		AchMan.setActiveDomain(Common::STEAM_ACHIEVEMENTS, target);
-	} else {
-		warning("Unknown game accessing SteamAPI. All achievements will be ignored.");
-		AchMan.unsetActiveDomain();
-	}
-}
-
-void AGSSteam::IsAchievementAchieved(ScriptMethodParams &params) {
-	PARAMS1(char *, id);
-	params._result = AchMan.isAchieved(id);
-}
-
-void AGSSteam::SetAchievementAchieved(ScriptMethodParams &params) {
-	PARAMS1(char *, id);
-
-	Common::String gameTarget = ConfMan.getActiveDomainName();
-	const MetaEngine *meta = ::AGS::g_vm->getMetaEngine();
-	Common::AchievementsInfo achievementsInfo = meta->getAchievementsInfo(gameTarget);
-
-	Common::String msg = id;
-	for (uint32 i = 0; i < achievementsInfo.descriptions.size(); i++) {
-		if (strcmp(achievementsInfo.descriptions[i].id, id) == 0) {
-			msg = achievementsInfo.descriptions[i].title;
-		}
-	}
-
-	params._result = AchMan.setAchievement(id, msg);
-}
-
-void AGSSteam::ResetAchievement(ScriptMethodParams &params) {
-	PARAMS1(char *, id);
-	params._result = AchMan.clearAchievement(id);
-}
-
-void AGSSteam::GetIntStat(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSSteam::GetFloatStat(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSSteam::GetAverageRateStat(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSSteam::SetIntStat(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSSteam::SetFloatStat(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSSteam::UpdateAverageRateStat(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSSteam::ResetStatsAndAchievements(ScriptMethodParams &params) {
-	AchMan.resetAllAchievements();
-	AchMan.resetAllStats();
-}
-
-void AGSSteam::get_Initialized(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSSteam::get_CurrentLeaderboardName(ScriptMethodParams &params) {
-}
-
-void AGSSteam::RequestLeaderboard(ScriptMethodParams &params) {
-}
-
-void AGSSteam::UploadScore(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSSteam::geti_LeaderboardNames(ScriptMethodParams &params) {
-}
-
-void AGSSteam::geti_LeaderboardScores(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSSteam::get_LeaderboardCount(ScriptMethodParams &params) {
-	params._result = 0;
-}
-
-void AGSSteam::GetUserName(ScriptMethodParams &params) {
-}
-
-void AGSSteam::GetCurrentGameLanguage(ScriptMethodParams &params) {
-}
-
-void AGSSteam::FindLeaderboard(ScriptMethodParams &params) {
-	params._result = 0;
 }
 
 } // namespace AGSGalaxySteam
diff --git a/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h b/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h
index 542f1fc032..b0deb7308d 100644
--- a/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h
+++ b/engines/ags/plugins/ags_galaxy_steam/ags_galaxy_steam.h
@@ -69,27 +69,6 @@ private:
 	static const char *AGS_GetPluginName();
 	static void AGS_EngineStartup(IAGSEngine *engine);
 
-	static void IsAchievementAchieved(ScriptMethodParams &params);
-	static void SetAchievementAchieved(ScriptMethodParams &params);
-	static void ResetAchievement(ScriptMethodParams &params);
-	static void GetIntStat(ScriptMethodParams &params);
-	static void GetFloatStat(ScriptMethodParams &params);
-	static void GetAverageRateStat(ScriptMethodParams &params);
-	static void SetIntStat(ScriptMethodParams &params);
-	static void SetFloatStat(ScriptMethodParams &params);
-	static void UpdateAverageRateStat(ScriptMethodParams &params);
-	static void ResetStatsAndAchievements(ScriptMethodParams &params);
-	static void get_Initialized(ScriptMethodParams &params);
-	static void get_CurrentLeaderboardName(ScriptMethodParams &params);
-	static void RequestLeaderboard(ScriptMethodParams &params);
-	static void UploadScore(ScriptMethodParams &params);
-	static void geti_LeaderboardNames(ScriptMethodParams &params);
-	static void geti_LeaderboardScores(ScriptMethodParams &params);
-	static void get_LeaderboardCount(ScriptMethodParams &params);
-	static void GetUserName(ScriptMethodParams &params);
-	static void GetCurrentGameLanguage(ScriptMethodParams &params);
-	static void Initialize(ScriptMethodParams &params);
-
 public:
 	AGSGalaxy();
 };
@@ -101,27 +80,6 @@ private:
 protected:
 	static void AGS_EngineStartup(IAGSEngine *engine);
 
-	static void IsAchievementAchieved(ScriptMethodParams &params);
-	static void SetAchievementAchieved(ScriptMethodParams &params);
-	static void ResetAchievement(ScriptMethodParams &params);
-	static void GetIntStat(ScriptMethodParams &params);
-	static void GetFloatStat(ScriptMethodParams &params);
-	static void GetAverageRateStat(ScriptMethodParams &params);
-	static void SetIntStat(ScriptMethodParams &params);
-	static void SetFloatStat(ScriptMethodParams &params);
-	static void UpdateAverageRateStat(ScriptMethodParams &params);
-	static void ResetStatsAndAchievements(ScriptMethodParams &params);
-	static void get_Initialized(ScriptMethodParams &params);
-	static void get_CurrentLeaderboardName(ScriptMethodParams &params);
-	static void RequestLeaderboard(ScriptMethodParams &params);
-	static void UploadScore(ScriptMethodParams &params);
-	static void geti_LeaderboardNames(ScriptMethodParams &params);
-	static void geti_LeaderboardScores(ScriptMethodParams &params);
-	static void get_LeaderboardCount(ScriptMethodParams &params);
-	static void GetUserName(ScriptMethodParams &params);
-	static void GetCurrentGameLanguage(ScriptMethodParams &params);
-	static void FindLeaderboard(ScriptMethodParams &params);
-
 public:
 	AGSSteam();
 };


Commit: 3fe4d8fc0fff7d685d903d912443c651a2f16eec
    https://github.com/scummvm/scummvm/commit/3fe4d8fc0fff7d685d903d912443c651a2f16eec
Author: lb_ii (lolbot_iichan at mail.ru)
Date: 2021-05-28T21:07:08+03:00

Commit Message:
ACHIEVEMENTS: Remove old API methods

Changed paths:
    common/achievements.cpp
    common/achievements.h


diff --git a/common/achievements.cpp b/common/achievements.cpp
index c2c04a013f..b44dfaa06b 100644
--- a/common/achievements.cpp
+++ b/common/achievements.cpp
@@ -46,17 +46,11 @@ bool AchievementsManager::setActiveDomain(const AchievementsInfo &info) {
 		return false;
 	}
 
-	_descriptions = info.descriptions;
-
-	return setActiveDomain(info.platform, info.appId);
-}
-
-bool AchievementsManager::setActiveDomain(AchievementsPlatform platform, const String &appId) {
-	const char* prefix = platform == STEAM_ACHIEVEMENTS ? "steam" :
-					platform == GALAXY_ACHIEVEMENTS ? "galaxy" :
+	const char* prefix = info.platform == STEAM_ACHIEVEMENTS ? "steam" :
+					info.platform == GALAXY_ACHIEVEMENTS ? "galaxy" :
 					"achman";
 
-	String iniFileName = String::format("%s-%s.dat", prefix, appId.c_str());
+	String iniFileName = String::format("%s-%s.dat", prefix, info.appId.c_str());
 
 	if (_iniFileName == iniFileName) {
 		return true;
@@ -71,6 +65,8 @@ bool AchievementsManager::setActiveDomain(AchievementsPlatform platform, const S
 	_iniFile = new Common::INIFile();
 	_iniFile->loadFromSaveFile(_iniFileName); // missing file is OK
 
+	_descriptions = info.descriptions;
+
 	return true;
 }
 
@@ -103,17 +99,6 @@ bool AchievementsManager::setAchievement(const String &id) {
 		}
 	}
 
-	return setAchievement(id, displayedMessage);
-}
-
-bool AchievementsManager::setAchievement(const String &id, const String &displayedMessage) {
-	if (!isReady()) {
-		return false;
-	}
-	if (isAchieved(id)) {
-		return true;
-	}
-
 	debug("AchievementsManager::setAchievement('%s'): %s", id.c_str(), displayedMessage.c_str());
 
 	_iniFile->setKey(id, "achievements", "true");
diff --git a/common/achievements.h b/common/achievements.h
index 6c473fd5df..a8e4364ae9 100644
--- a/common/achievements.h
+++ b/common/achievements.h
@@ -80,14 +80,6 @@ public:
 	AchievementsManager();
 	~AchievementsManager();
 
-	/**
-	 * (DEPRECATED) Set a platform and application ID as active domain.
-	 *
-	 * @param[in] platform Achievements platform.
-	 * @param[in] appId	Achievements application ID of the given platform.
-	 */
-	bool setActiveDomain(AchievementsPlatform platform, const String &appId);
-
 	/**
 	 * Set a platform and application ID as active domain, store messages texts.
 	 *
@@ -102,13 +94,6 @@ public:
 	 * @{
 	 */
 
-	/** (DEPRECATED) Set an achievement.
-	 *
-	 * @param[in] id			   Internal ID of the achievement.
-	 * @param[in] displayedMessage Message displayed when the achievement is achieved.
-	 */
-	bool setAchievement(const String &id, const String &displayedMessage);
-
 	/** Set an achievement. Message is automatically displayed with text from active domain.
 	 *
 	 * @param[in] id			   Internal ID of the achievement.




More information about the Scummvm-git-logs mailing list