aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorEugene Sandulenko2016-04-01 21:29:29 +0200
committerEugene Sandulenko2016-04-01 21:29:29 +0200
commita743ec2e07ccada0286085ecec54f4d87ed49d44 (patch)
treedd5ae6b63db99de9b95992a8afabda34cd4ba804 /common
parent14478a65f179318f0e269f10d8bfd77174d73cb1 (diff)
downloadscummvm-rg350-a743ec2e07ccada0286085ecec54f4d87ed49d44.tar.gz
scummvm-rg350-a743ec2e07ccada0286085ecec54f4d87ed49d44.tar.bz2
scummvm-rg350-a743ec2e07ccada0286085ecec54f4d87ed49d44.zip
UPDATES: Implement and use method for normalizing interval value to accepted values
Diffstat (limited to 'common')
-rw-r--r--common/updates.cpp10
-rw-r--r--common/updates.h9
2 files changed, 19 insertions, 0 deletions
diff --git a/common/updates.cpp b/common/updates.cpp
index 0318864881..552324ef5a 100644
--- a/common/updates.cpp
+++ b/common/updates.cpp
@@ -38,6 +38,16 @@ const int *UpdateManager::getUpdateIntervals() {
return updateIntervals;
}
+int UpdateManager::normalizeInterval(int interval) {
+ const int *val = updateIntervals;
+
+ while (*val != -1)
+ if (*val > interval)
+ return *val;
+
+ return val[-1]; // Return maximal acceptable value
+}
+
const char *UpdateManager::updateIntervalToString(int interval) {
switch (interval) {
case kUpdateIntervalNotSupported:
diff --git a/common/updates.h b/common/updates.h
index fa6f79fb91..65eb5ac095 100644
--- a/common/updates.h
+++ b/common/updates.h
@@ -105,9 +105,18 @@ public:
/**
* Returns string representation of a given interval.
*
+ * @param interval The interval.
* @return pointer to localized string of given interval.
*/
static const char *updateIntervalToString(int interval);
+
+ /**
+ * Rounds up the given interval to acceptable value.
+ *
+ * @param interval The interval.
+ * @return rounded up interval
+ */
+ static int normalizeInterval(int interval);
};
} // End of namespace Common