ULTIMA4: Better settings data equality comparitor

This commit is contained in:
Paul Gilbert authored and Paul Gilbert committed 2020-04-09 18:00:54 -07:00
1 parent b41ed3d836
commit 76dc074454
5 files changed
+57 -39

No files matched your search

+46 -26
View File
@@ -31,41 +31,61 @@
namespace Ultima {
namespace Ultima4 {
using namespace std;
/*
* Initialize static members
*/
Settings *Settings::_instance = NULL;
bool SettingsEnhancementOptions::operator==(const SettingsEnhancementOptions &s) const {
return _activePlayer == s._activePlayer
&& _u5spellMixing == s._u5spellMixing
&& _u5shrines == s._u5shrines
&& _u5combat == s._u5combat
&& _slimeDivides == s._slimeDivides
&& _gazerSpawnsInsects == s._gazerSpawnsInsects
&& _textColorization == s._textColorization
&& _c64chestTraps == s._c64chestTraps
&& _smartEnterKey == s._smartEnterKey
&& _peerShowsObjects == s._peerShowsObjects
&& _u4TileTransparencyHack == s._u4TileTransparencyHack
&& _u4TileTransparencyHackPixelShadowOpacity == s._u4TileTransparencyHackPixelShadowOpacity
&& _u4TrileTransparencyHackShadowBreadth == s._u4TrileTransparencyHackShadowBreadth;
}
/*-------------------------------------------------------------------*/
bool SettingsData::operator==(const SettingsData &s) const {
// TODO: Refactor this to a clean comparison of individual settings
int fieldsSize = (const int *)&_end_of_bitwise_comparators - (const int *)this;
if (memcmp(this, &s, fieldsSize) != 0)
return false;
if (_filter != s._filter)
return false;
if (_gemLayout != s._gemLayout)
return false;
if (_lineOfSight != s._lineOfSight)
return false;
if (_videoType != s._videoType)
return false;
if (_battleDiff != s._battleDiff)
return false;
if (_logging != s._logging)
return false;
if (_game != s._game)
return false;
return true;
return _battleSpeed == s._battleSpeed
&& _campingAlwaysCombat == s._campingAlwaysCombat
&& _campTime == s._campTime
&& _debug == s._debug
&& _enhancements == s._enhancements
&& _enhancementsOptions == s._enhancementsOptions
&& _filterMoveMessages == s._filterMoveMessages
&& _gameCyclesPerSecond == s._gameCyclesPerSecond
&& _screenAnimationFramesPerSecond == s._screenAnimationFramesPerSecond
&& _innAlwaysCombat == s._innAlwaysCombat
&& _innTime == s._innTime
&& _keydelay == s._keydelay
&& _keyinterval == s._keyinterval
&& _mouseOptions == s._mouseOptions
&& _screenShakes == s._screenShakes
&& _gamma == s._gamma
&& _shakeInterval == s._shakeInterval
&& _shortcutCommands == s._shortcutCommands
&& _shrineTime == s._shrineTime
&& _spellEffectSpeed == s._spellEffectSpeed
&& _validateXml == s._validateXml
&& _volumeFades == s._volumeFades
&& _titleSpeedRandom == s._titleSpeedRandom
&& _titleSpeedOther == s._titleSpeedOther;
}
bool SettingsData::operator!=(const SettingsData &s) const {
return !operator==(s);
}
/*-------------------------------------------------------------------*/
Settings::Settings() {
init();
@@ -144,7 +164,7 @@ bool Settings::read() {
_campingAlwaysCombat = 0;
// mouse defaults to on
_mouseOptions.enabled = 1;
_mouseOptions._enabled = 1;
_logging = DEFAULT_LOGGING;
_game = "Ultima IV";
@@ -222,7 +242,7 @@ bool Settings::read() {
// mouse options
if (ConfMan.hasKey("mouseEnabled"))
_mouseOptions.enabled = ConfMan.getBool("mouseEnabled");
_mouseOptions._enabled = ConfMan.getBool("mouseEnabled");
if (ConfMan.hasKey("logging"))
_logging = ConfMan.get("logging");
@@ -279,7 +299,7 @@ bool Settings::write() {
ConfMan.setBool("innAlwaysCombat", _innAlwaysCombat);
ConfMan.setBool("campingAlwaysCombat", _campingAlwaysCombat);
ConfMan.setBool("mouseEnabled", _mouseOptions.enabled);
ConfMan.setBool("mouseEnabled", _mouseOptions._enabled);
ConfMan.set("logging", _logging);
ConfMan.setBool("renderTileTransparency",
+7 -9
View File
@@ -96,10 +96,15 @@ struct SettingsEnhancementOptions {
int _u4TileTransparencyHackPixelShadowOpacity;
int _u4TrileTransparencyHackShadowBreadth;
bool operator==(const SettingsEnhancementOptions &s) const;
};
struct MouseOptions {
bool enabled;
bool _enabled;
bool operator==(const MouseOptions &s) const {
return _enabled == s._enabled;
}
};
/**
@@ -119,7 +124,6 @@ public:
bool _filterMoveMessages;
bool _fullscreen;
int _gameCyclesPerSecond;
int _eventTimerGranularity;
int _screenAnimationFramesPerSecond;
bool _innAlwaysCombat;
int _innTime;
@@ -144,14 +148,8 @@ public:
int _pauseForEachTurn;
int _pauseForEachMovement;
/**
* Strings, classes, and other objects that cannot
* be bitwise-compared must be placed here at the
* end of the list so that our == and != operators
* function correctly
*/
long _end_of_bitwise_comparators;
int _eventTimerGranularity;
Common::String _filter;
Common::String _gemLayout;
Common::String _lineOfSight;
+2 -2
View File
@@ -202,7 +202,7 @@ EventHandler::EventHandler() : _timer(settings._eventTimerGranularity), _updateS
}
static void handleMouseMotionEvent(const Common::Event &event) {
if (!settings._mouseOptions.enabled)
if (!settings._mouseOptions._enabled)
return;
const MouseArea *area;
@@ -233,7 +233,7 @@ static void handleMouseButtonDownEvent(const Common::Event &event, Controller *c
else if (event.type == Common::EVENT_MBUTTONDOWN)
button = 2;
if (!settings._mouseOptions.enabled)
if (!settings._mouseOptions._enabled)
return;
if (button > 2)
+1 -1
View File
@@ -243,7 +243,7 @@ IntroController::IntroController() :
_inputMenu.add(MI_INPUT_01, new IntMenuItem("Repeat Delay %4d msec", 2, 2,/*'d'*/ 7, &settingsChanged._keydelay, 100, MAX_KEY_DELAY, 100));
_inputMenu.add(MI_INPUT_02, new IntMenuItem("Repeat Interval %4d msec", 2, 3,/*'i'*/ 7, &settingsChanged._keyinterval, 10, MAX_KEY_INTERVAL, 10));
/* "Mouse Options:" is drawn in the updateInputMenu() function */
_inputMenu.add(MI_INPUT_03, new BoolMenuItem("Mouse %s", 2, 7,/*'m'*/ 0, &settingsChanged._mouseOptions.enabled));
_inputMenu.add(MI_INPUT_03, new BoolMenuItem("Mouse %s", 2, 7,/*'m'*/ 0, &settingsChanged._mouseOptions._enabled));
_inputMenu.add(USE_SETTINGS, "\010 Use These Settings", 2, 11,/*'u'*/ 2);
_inputMenu.add(CANCEL, "\010 Cancel", 2, 12,/*'c'*/ 2);
_inputMenu.addShortcutKey(CANCEL, ' ');
+1 -1
View File
@@ -85,7 +85,7 @@ void screenInit_sys() {
initGraphics(320 * settings._scale, 200 * settings._scale);
#endif
/* enable or disable the mouse cursor */
if (settings._mouseOptions.enabled) {
if (settings._mouseOptions._enabled) {
g_system->showMouse(true);
#ifdef TODO
cursors[0] = SDL_GetCursor();