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

AndywinXp noreply at scummvm.org
Thu Sep 19 19:33:20 UTC 2024


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:
3f4bc1241f SCUMM: HE: Move "enable_competitive_mods" check at startup


Commit: 3f4bc1241f9451b1caf358b8fbae85cfe7abc578
    https://github.com/scummvm/scummvm/commit/3f4bc1241f9451b1caf358b8fbae85cfe7abc578
Author: AndywinXp (andywinxp at gmail.com)
Date: 2024-09-19T21:33:13+02:00

Commit Message:
SCUMM: HE: Move "enable_competitive_mods" check at startup

This greatly reduces lag in Backyard Basketball, as
those calls to ConfMan.getBool were done in very
frequently called arithmetics opcodes.

Changed paths:
    engines/scumm/he/script_v72he.cpp
    engines/scumm/script.cpp
    engines/scumm/script_v6.cpp
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h


diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index c3d1293368b..1dcf9ca30a3 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -166,7 +166,7 @@ int ScummEngine_v72he::readArray(int array, int idx2, int idx1) {
 	}
 
 #if defined(USE_ENET) && defined(USE_LIBCURL)
-	if (ConfMan.getBool("enable_competitive_mods")) {
+	if (_enableHECompetitiveOnlineMods) {
 		// Mod for Backyard Baseball 2001 online competitive play: allow baserunners to be
 		// turned around while they're jogging to the next base on a pop-up.
 		// The game checks if the runner is forced to the next base (i.e. there's a runner on the base behind them),
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index 6582ea3ffd8..66ef0c3c3d8 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -590,7 +590,7 @@ int ScummEngine::readVar(uint var) {
 		}
 
 #if defined(USE_ENET) && defined(USE_LIBCURL)
-		if (ConfMan.getBool("enable_competitive_mods")) {
+		if (_enableHECompetitiveOnlineMods) {
 			// HACK: If we're reading var586, competitive mods enabled, playing online,
 			// successfully fetched custom teams, and we're not in one of the three scripts
 			// that cause bugs if 263 is returned here, return 263.
@@ -616,7 +616,7 @@ int ScummEngine::readVar(uint var) {
 			assertRange(0, var, _numRoomVariables - 1, "room variable (reading)");
 
 #if defined(USE_ENET) && defined(USE_LIBCURL)
-			if (ConfMan.getBool("enable_competitive_mods")) {
+			if (_enableHECompetitiveOnlineMods) {
 				// Mod for Backyard Baseball 2001 online competitive play: don't give powerups for double plays
 				// Return true for this variable, which dictates whether powerups are disabled, but only in this script
 				// that detects double plays (among other things)
@@ -669,7 +669,7 @@ int ScummEngine::readVar(uint var) {
 #if defined(USE_ENET) && defined(USE_LIBCURL)
 		// Mod for Backyard Baseball 2001 online competitive play: change impact of
 		// batter's power stat on hit power
-		if (ConfMan.getBool("enable_competitive_mods")) {
+		if (_enableHECompetitiveOnlineMods) {
 			if (_game.id == GID_BASEBALL2001 &&
 				_currentRoom == 4 && vm.slot[_currentScript].number == 2090  // The script that calculates hit power
 				&& readVar(399) == 1  // Check that we're playing online
diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp
index 6c44e754284..71f3c3f77ba 100644
--- a/engines/scumm/script_v6.cpp
+++ b/engines/scumm/script_v6.cpp
@@ -501,7 +501,7 @@ void ScummEngine_v6::o6_pushByteVar() {
 void ScummEngine_v6::o6_pushWordVar() {
 // BACKYARD BASEBALL 2001 ONLINE CHANGES
 #if defined(USE_ENET) && defined(USE_LIBCURL)
-	if (ConfMan.getBool("enable_competitive_mods")) {
+	if (_enableHECompetitiveOnlineMods) {
 		// Sprinting in competitive Backyard Baseball is considered too weak in its current state. This will increase how effective
 		// it is, limiting the highest speed characters enough to where they cannot go TOO fast.
 		if (_game.id == GID_BASEBALL2001 && _currentRoom == 3 && vm.slot[_currentScript].number == 2095 && readVar(399) == 1) {
@@ -586,7 +586,7 @@ void ScummEngine_v6::o6_wordArrayRead() {
 	int base = pop();
 	int array = fetchScriptWord();
 #if defined(USE_ENET) && defined(USE_LIBCURL)
-	if (ConfMan.getBool("enable_competitive_mods")) {
+	if (_enableHECompetitiveOnlineMods) {
 		// If we're pulling from the randomly selected teams for online play
 		// at Prince Rupert, read from variables 748 and 749 instead
 		if (_game.id == GID_BASEBALL2001 && _currentRoom == 6 && vm.slot[_currentScript].number == 2071 &&
@@ -648,7 +648,7 @@ void ScummEngine_v6::o6_eq() {
 		}
 	}
 
-	if (ConfMan.getBool("enable_competitive_mods")) {
+	if (_enableHECompetitiveOnlineMods) {
 		int pitchXValue = readVar(0x8000 + 11);
 		int pitchYValue = readVar(0x8000 + 12);
 		int strikeZoneTop = readVar(0x8000 + 29);
@@ -777,7 +777,7 @@ void ScummEngine_v6::o6_eq() {
 	// HACK: This script doesn't allow Super Colossal Dome to be chosen for online play, by checking if the selected
 	// field's value is 5 (SCD's number) and incrementing/decrementing if it is. To allow SCD to be used, we return 0
 	// for those checks.
-	} else if (ConfMan.getBool("enable_competitive_mods") && _game.id == GID_BASEBALL2001 && _currentRoom == 40 &&
+	} else if (_enableHECompetitiveOnlineMods && _game.id == GID_BASEBALL2001 && _currentRoom == 40 &&
 		vm.slot[_currentScript].number == 2106 && a == 5 && (offset == 16754 || offset == 16791)) {
 		push(0);
 
@@ -858,7 +858,7 @@ void ScummEngine_v6::o6_ge() {
 #if defined(USE_ENET) && defined(USE_LIBCURL)
 	// Mod for Backyard Baseball 2001 online competitive play: Reduce sprints
 	// required to reach top speed
-	if (ConfMan.getBool("enable_competitive_mods") && _game.id == GID_BASEBALL2001 &&
+	if (_enableHECompetitiveOnlineMods && _game.id == GID_BASEBALL2001 &&
 		_currentRoom == 3 && vm.slot[_currentScript].number == 2095 && readVar(399) == 1) {
 		a -= 1;  // If sprint counter (b) is higher than a, runner gets 1 extra speed
 	}
@@ -889,7 +889,7 @@ void ScummEngine_v6::o6_div() {
 #if defined(USE_ENET) && defined(USE_LIBCURL)
 	// Mod for Backyard Baseball 2001 online competitive play: Allow full sprinting while
 	// running half-speed on a popup
-	if (ConfMan.getBool("enable_competitive_mods") && _game.id == GID_BASEBALL2001 && _currentRoom == 3 &&
+	if (_enableHECompetitiveOnlineMods && _game.id == GID_BASEBALL2001 && _currentRoom == 3 &&
 		vm.slot[_currentScript].number == 2095 && readVar(399) == 1 && a == 2) {
 		// Normally divides speed by two here
 		int runnerIdx = readVar(0x4000);
@@ -1146,7 +1146,7 @@ void ScummEngine_v6::o6_startScriptQuick2() {
 #if defined(USE_ENET) && defined(USE_LIBCURL)
 	// Mod for Backyard Baseball 2001 online competitive play: change effect of
 	// pitch location on hit quality
-	if (ConfMan.getBool("enable_competitive_mods") && _game.id == GID_BASEBALL2001 && _currentRoom == 4 && script == 2085 && readVar(399) == 1) {
+	if (_enableHECompetitiveOnlineMods && _game.id == GID_BASEBALL2001 && _currentRoom == 4 && script == 2085 && readVar(399) == 1) {
 		int zone = _roomVars[2];
 		int stance = readVar(447);
 		int handedness = _roomVars[0];
@@ -1736,7 +1736,7 @@ void ScummEngine_v6::o6_getRandomNumberRange() {
 	int rnd = _rnd.getRandomNumber(0x7fff);
 	rnd = min + (rnd % (max - min + 1));
 #if defined(USE_ENET) && defined(USE_LIBCURL)
-	if (ConfMan.getBool("enable_competitive_mods")) {
+	if (_enableHECompetitiveOnlineMods) {
 		// For using predefined teams in Prince Rupert, instead of choosing player IDs randomly
 		// let's pull from the variables that contain the teams
 		if (_game.id == GID_BASEBALL2001 && vm.slot[_currentScript].number == 298 &&
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 11b473871f7..786025dab57 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -430,6 +430,8 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
 	_isIndy4Jap = _game.id == GID_INDY4 &&
 				  (_game.platform == Common::kPlatformMacintosh || _game.platform == Common::kPlatformDOS) &&
 				  _language == Common::JA_JPN;
+
+	_enableHECompetitiveOnlineMods = ConfMan.getBool("enable_competitive_mods");
 }
 
 
diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
index 07102738913..7610b569cee 100644
--- a/engines/scumm/scumm.h
+++ b/engines/scumm/scumm.h
@@ -560,6 +560,7 @@ public:
 	bool _isAmigaPALSystem = false;
 	bool _quitFromScriptCmd = false;
 	bool _isHE995 = false;
+	bool _enableHECompetitiveOnlineMods = false;
 
 	Common::Keymap *_insaneKeymap;
 




More information about the Scummvm-git-logs mailing list