aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/PalmOS/Src/be_base.cpp10
-rw-r--r--backends/platform/PalmOS/Src/be_base.h2
-rw-r--r--backends/platform/dc/dc.h2
-rw-r--r--backends/platform/dc/dcmain.cpp10
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.cpp10
-rw-r--r--backends/platform/ds/arm9/source/osystem_ds.h2
-rw-r--r--backends/platform/gp2x/gp2x-common.h2
-rw-r--r--backends/platform/gp2x/gp2x.cpp10
-rw-r--r--backends/platform/iphone/osys_main.cpp10
-rw-r--r--backends/platform/iphone/osys_main.h2
-rw-r--r--backends/platform/null/null.cpp4
-rw-r--r--backends/platform/ps2/ps2time.cpp4
-rw-r--r--backends/platform/ps2/systemps2.h2
-rw-r--r--backends/platform/psp/osys_psp.cpp10
-rw-r--r--backends/platform/psp/osys_psp.h2
-rw-r--r--backends/platform/sdl/sdl.cpp10
-rw-r--r--backends/platform/sdl/sdl.h2
-rw-r--r--backends/platform/wii/osystem.cpp10
-rw-r--r--backends/platform/wii/osystem.h2
-rw-r--r--backends/platform/wince/wince-sdl.cpp3
-rw-r--r--backends/platform/wince/wince-sdl.h2
-rw-r--r--common/system.h20
-rw-r--r--engines/agi/saveload.cpp4
-rw-r--r--engines/draci/saveload.cpp4
-rw-r--r--engines/gob/inter.cpp4
-rw-r--r--engines/saga/saveload.cpp4
-rw-r--r--engines/sci/engine/kmisc.cpp4
-rw-r--r--engines/sci/engine/savegame.cpp5
-rw-r--r--engines/scumm/saveload.cpp6
-rw-r--r--engines/scumm/script_v6.cpp4
-rw-r--r--engines/sword1/control.cpp6
-rw-r--r--engines/tinsel/saveload.cpp33
-rw-r--r--engines/tinsel/savescn.h4
33 files changed, 134 insertions, 75 deletions
diff --git a/backends/platform/PalmOS/Src/be_base.cpp b/backends/platform/PalmOS/Src/be_base.cpp
index 0355f28501..66dd823df0 100644
--- a/backends/platform/PalmOS/Src/be_base.cpp
+++ b/backends/platform/PalmOS/Src/be_base.cpp
@@ -125,9 +125,15 @@ void OSystem_PalmBase::initBackend() {
OSystem::initBackend();
}
-void OSystem_PalmBase::getTimeAndDate(struct tm &t) const {
+void OSystem_PalmBase::getTimeAndDate(TimeDate &td) const {
time_t curTime = time(0);
- t = *localtime(&curTime);
+ struct tm t = *localtime(&curTime);
+ td.tm_sec = t.tm_sec;
+ td.tm_min = t.tm_min;
+ td.tm_hour = t.tm_hour;
+ td.tm_mday = t.tm_mday;
+ td.tm_mon = t.tm_mon;
+ td.tm_year = t.tm_year;
}
uint32 OSystem_PalmBase::getMillis() {
diff --git a/backends/platform/PalmOS/Src/be_base.h b/backends/platform/PalmOS/Src/be_base.h
index 83b2ec2cbd..3f6da2e058 100644
--- a/backends/platform/PalmOS/Src/be_base.h
+++ b/backends/platform/PalmOS/Src/be_base.h
@@ -239,7 +239,7 @@ public:
bool pollEvent(Common::Event &event);
- void getTimeAndDate(struct tm &t) const;
+ void getTimeAndDate(TimeDate &t) const;
virtual uint32 getMillis();
virtual void delayMillis(uint msecs);
diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h
index f5d200968e..45d9aa99c2 100644
--- a/backends/platform/dc/dc.h
+++ b/backends/platform/dc/dc.h
@@ -123,7 +123,7 @@ class OSystem_Dreamcast : private DCHardware, public BaseBackend, public Filesys
void delayMillis(uint msecs);
// Get the current time and date. Correspond to time()+localtime().
- void getTimeAndDate(struct tm &t) const;
+ void getTimeAndDate(TimeDate &t) const;
// Get the next event.
// Returns true if an event was retrieved.
diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp
index 795504d243..078c6266a4 100644
--- a/backends/platform/dc/dcmain.cpp
+++ b/backends/platform/dc/dcmain.cpp
@@ -193,10 +193,16 @@ bool OSystem_Dreamcast::getFeatureState(Feature f)
}
}
-void OSystem_Dreamcast::getTimeAndDate(struct tm &t) const {
+void OSystem_Dreamcast::getTimeAndDate(TimeDate &td) const {
time_t curTime;
time(&curTime);
- t = *localtime(&curTime);
+ struct tm t = *localtime(&curTime);
+ td.tm_sec = t.tm_sec;
+ td.tm_min = t.tm_min;
+ td.tm_hour = t.tm_hour;
+ td.tm_mday = t.tm_mday;
+ td.tm_mon = t.tm_mon;
+ td.tm_year = t.tm_year;
}
void DCHardware::dc_init_hardware()
diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp
index 1654bb31e7..8ea9b06b23 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.cpp
+++ b/backends/platform/ds/arm9/source/osystem_ds.cpp
@@ -655,14 +655,20 @@ void OSystem_DS::delayMillis(uint msecs) {
}
-void OSystem_DS::getTimeAndDate(struct tm &t) const {
+void OSystem_DS::getTimeAndDate(TimeDate &td) const {
time_t curTime;
#if 0
curTime = time(0);
#else
curTime = 0xABCD1234 + DS::getMillis() / 1000;
#endif
- t = *localtime(&curTime);
+ struct tm t = *localtime(&curTime);
+ td.tm_sec = t.tm_sec;
+ td.tm_min = t.tm_min;
+ td.tm_hour = t.tm_hour;
+ td.tm_mday = t.tm_mday;
+ td.tm_mon = t.tm_mon;
+ td.tm_year = t.tm_year;
}
FilesystemFactory *OSystem_DS::getFilesystemFactory() {
diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h
index ce55ec2740..27c4052d9d 100644
--- a/backends/platform/ds/arm9/source/osystem_ds.h
+++ b/backends/platform/ds/arm9/source/osystem_ds.h
@@ -118,7 +118,7 @@ public:
virtual bool pollEvent(Common::Event &event);
virtual uint32 getMillis();
virtual void delayMillis(uint msecs);
- virtual void getTimeAndDate(struct tm &t) const;
+ virtual void getTimeAndDate(TimeDate &t) const;
virtual MutexRef createMutex(void);
virtual void lockMutex(MutexRef mutex);
diff --git a/backends/platform/gp2x/gp2x-common.h b/backends/platform/gp2x/gp2x-common.h
index c8bbd93de0..6878673024 100644
--- a/backends/platform/gp2x/gp2x-common.h
+++ b/backends/platform/gp2x/gp2x-common.h
@@ -138,7 +138,7 @@ public:
// Quit
void quit();
- void getTimeAndDate(struct tm &t) const;
+ void getTimeAndDate(TimeDate &t) const;
virtual Common::TimerManager *getTimerManager();
// Mutex handling
diff --git a/backends/platform/gp2x/gp2x.cpp b/backends/platform/gp2x/gp2x.cpp
index 21a047b345..e15281dbf4 100644
--- a/backends/platform/gp2x/gp2x.cpp
+++ b/backends/platform/gp2x/gp2x.cpp
@@ -301,9 +301,15 @@ void OSystem_GP2X::delayMillis(uint msecs) {
SDL_Delay(msecs);
}
-void OSystem_GP2X::getTimeAndDate(struct tm &t) const {
+void OSystem_GP2X::getTimeAndDate(TimeDate &td) const {
time_t curTime = time(0);
- t = *localtime(&curTime);
+ struct tm t = *localtime(&curTime);
+ td.tm_sec = t.tm_sec;
+ td.tm_min = t.tm_min;
+ td.tm_hour = t.tm_hour;
+ td.tm_mday = t.tm_mday;
+ td.tm_mon = t.tm_mon;
+ td.tm_year = t.tm_year;
}
Common::TimerManager *OSystem_GP2X::getTimerManager() {
diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp
index eb2ecf8769..b151688e4e 100644
--- a/backends/platform/iphone/osys_main.cpp
+++ b/backends/platform/iphone/osys_main.cpp
@@ -198,9 +198,15 @@ void OSystem_IPHONE::setTimerCallback(TimerProc callback, int interval) {
void OSystem_IPHONE::quit() {
}
-void OSystem_IPHONE::getTimeAndDate(struct tm &t) const {
+void OSystem_IPHONE::getTimeAndDate(TimeDate &td) const {
time_t curTime = time(0);
- t = *localtime(&curTime);
+ struct tm t = *localtime(&curTime);
+ td.tm_sec = t.tm_sec;
+ td.tm_min = t.tm_min;
+ td.tm_hour = t.tm_hour;
+ td.tm_mday = t.tm_mday;
+ td.tm_mon = t.tm_mon;
+ td.tm_year = t.tm_year;
}
Common::SaveFileManager *OSystem_IPHONE::getSavefileManager() {
diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h
index c4c1a8b080..c923d0f4e8 100644
--- a/backends/platform/iphone/osys_main.h
+++ b/backends/platform/iphone/osys_main.h
@@ -169,7 +169,7 @@ public:
FilesystemFactory *getFilesystemFactory() { return _fsFactory; }
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
- virtual void getTimeAndDate(struct tm &t) const;
+ virtual void getTimeAndDate(TimeDate &t) const;
virtual Common::SaveFileManager *getSavefileManager();
virtual Audio::Mixer *getMixer();
diff --git a/backends/platform/null/null.cpp b/backends/platform/null/null.cpp
index ca4eda9158..26e4654dde 100644
--- a/backends/platform/null/null.cpp
+++ b/backends/platform/null/null.cpp
@@ -115,7 +115,7 @@ public:
virtual Common::SaveFileManager *getSavefileManager();
virtual Audio::Mixer *getMixer();
- virtual void getTimeAndDate(struct tm &t) const;
+ virtual void getTimeAndDate(TimeDate &t) const;
virtual Common::TimerManager *getTimerManager();
FilesystemFactory *getFilesystemFactory();
@@ -321,7 +321,7 @@ Common::TimerManager *OSystem_NULL::getTimerManager() {
return _timer;
}
-void OSystem_NULL::getTimeAndDate(struct tm &t) const {
+void OSystem_NULL::getTimeAndDate(TimeDate &t) const {
}
FilesystemFactory *OSystem_NULL::getFilesystemFactory() {
diff --git a/backends/platform/ps2/ps2time.cpp b/backends/platform/ps2/ps2time.cpp
index 65b4cb90d7..4da8420478 100644
--- a/backends/platform/ps2/ps2time.cpp
+++ b/backends/platform/ps2/ps2time.cpp
@@ -106,7 +106,7 @@ void OSystem_PS2::readRtcTime(void) {
g_day, g_month, g_year + 2000);
}
-void OSystem_PS2::getTimeAndDate(struct tm &t) const {
+void OSystem_PS2::getTimeAndDate(TimeDate &t) const {
uint32 currentSecs = g_timeSecs + (msecCount - g_lastTimeCheck) / 1000;
if (currentSecs >= SECONDS_PER_DAY) {
@@ -121,6 +121,4 @@ void OSystem_PS2::getTimeAndDate(struct tm &t) const {
t.tm_year = g_year + 100;
t.tm_mday = g_day;
t.tm_mon = g_month - 1;
- // tm_wday, tm_yday and tm_isdst are zero for now
- t.tm_wday = t.tm_yday = t.tm_isdst = 0;
}
diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h
index 3fa7ce733b..31aa29e83f 100644
--- a/backends/platform/ps2/systemps2.h
+++ b/backends/platform/ps2/systemps2.h
@@ -124,7 +124,7 @@ public:
virtual Common::SaveFileManager *getSavefileManager();
virtual FilesystemFactory *getFilesystemFactory();
- virtual void getTimeAndDate(struct tm &t) const;
+ virtual void getTimeAndDate(TimeDate &t) const;
void timerThread(void);
void soundThread(void);
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index 53512beb24..24ea27698c 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -1155,9 +1155,15 @@ void OSystem_PSP::quit() {
sceKernelExitGame();
}
-void OSystem_PSP::getTimeAndDate(struct tm &t) const {
+void OSystem_PSP::getTimeAndDate(TimeDate &td) const {
time_t curTime = time(0);
- t = *localtime(&curTime);
+ struct tm t = *localtime(&curTime);
+ td.tm_sec = t.tm_sec;
+ td.tm_min = t.tm_min;
+ td.tm_hour = t.tm_hour;
+ td.tm_mday = t.tm_mday;
+ td.tm_mon = t.tm_mon;
+ td.tm_year = t.tm_year;
}
#define PSP_CONFIG_FILE "ms0:/scummvm.ini"
diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h
index 047fbff97e..7dcae43c1d 100644
--- a/backends/platform/psp/osys_psp.h
+++ b/backends/platform/psp/osys_psp.h
@@ -159,7 +159,7 @@ public:
Audio::Mixer *getMixer() { return _mixer; }
Common::TimerManager *getTimerManager() { return _timer; }
FilesystemFactory *getFilesystemFactory() { return &PSPFilesystemFactory::instance(); }
- void getTimeAndDate(struct tm &t) const;
+ void getTimeAndDate(TimeDate &t) const;
virtual void quit();
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 547720d435..8224bf547c 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -295,9 +295,15 @@ void OSystem_SDL::delayMillis(uint msecs) {
SDL_Delay(msecs);
}
-void OSystem_SDL::getTimeAndDate(struct tm &t) const {
+void OSystem_SDL::getTimeAndDate(TimeDate &td) const {
time_t curTime = time(0);
- t = *localtime(&curTime);
+ struct tm t = *localtime(&curTime);
+ td.tm_sec = t.tm_sec;
+ td.tm_min = t.tm_min;
+ td.tm_hour = t.tm_hour;
+ td.tm_mday = t.tm_mday;
+ td.tm_mon = t.tm_mon;
+ td.tm_year = t.tm_year;
}
Common::TimerManager *OSystem_SDL::getTimerManager() {
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 82c1e7bf1b..4c31414f90 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -183,7 +183,7 @@ public:
// Quit
virtual void quit(); // overloaded by CE backend
- virtual void getTimeAndDate(struct tm &t) const;
+ virtual void getTimeAndDate(TimeDate &t) const;
virtual Common::TimerManager *getTimerManager();
// Mutex handling
diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp
index 00547d55d6..12df2ca7e1 100644
--- a/backends/platform/wii/osystem.cpp
+++ b/backends/platform/wii/osystem.cpp
@@ -264,9 +264,15 @@ FilesystemFactory *OSystem_Wii::getFilesystemFactory() {
return &WiiFilesystemFactory::instance();
}
-void OSystem_Wii::getTimeAndDate(struct tm &t) const {
+void OSystem_Wii::getTimeAndDate(TimeDate &td) const {
time_t curTime = time(0);
- t = *localtime(&curTime);
+ struct tm t = *localtime(&curTime);
+ td.tm_sec = t.tm_sec;
+ td.tm_min = t.tm_min;
+ td.tm_hour = t.tm_hour;
+ td.tm_mday = t.tm_mday;
+ td.tm_mon = t.tm_mon;
+ td.tm_year = t.tm_year;
}
void OSystem_Wii::showOptionsDialog() {
diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h
index 23097dd027..d277aa38b1 100644
--- a/backends/platform/wii/osystem.h
+++ b/backends/platform/wii/osystem.h
@@ -211,7 +211,7 @@ public:
virtual Audio::Mixer *getMixer();
virtual Common::TimerManager *getTimerManager();
virtual FilesystemFactory *getFilesystemFactory();
- virtual void getTimeAndDate(struct tm &t) const;
+ virtual void getTimeAndDate(TimeDate &t) const;
};
#endif
diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp
index b2512e0234..c8ddc5c5e3 100644
--- a/backends/platform/wince/wince-sdl.cpp
+++ b/backends/platform/wince/wince-sdl.cpp
@@ -2523,13 +2523,12 @@ void OSystem_WINCE3::quit() {
OSystem_SDL::quit();
}
-void OSystem_WINCE3::getTimeAndDate(struct tm &t) const {
+void OSystem_WINCE3::getTimeAndDate(TimeDate &t) const {
SYSTEMTIME systime;
GetLocalTime(&systime);
t.tm_year = systime.wYear - 1900;
t.tm_mon = systime.wMonth - 1;
- t.tm_wday = systime.wDayOfWeek;
t.tm_mday = systime.wDay;
t.tm_hour = systime.wHour;
t.tm_min = systime.wMinute;
diff --git a/backends/platform/wince/wince-sdl.h b/backends/platform/wince/wince-sdl.h
index 6900d4fb79..a47df42476 100644
--- a/backends/platform/wince/wince-sdl.h
+++ b/backends/platform/wince/wince-sdl.h
@@ -85,7 +85,7 @@ public:
void setupMixer();
// Overloaded from OSystem
void engineInit();
- void getTimeAndDate(struct tm &t) const;
+ void getTimeAndDate(TimeDate &t) const;
virtual Common::SeekableReadStream *createConfigReadStream();
virtual Common::WriteStream *createConfigWriteStream();
diff --git a/common/system.h b/common/system.h
index 446249d1a6..9790b09dd8 100644
--- a/common/system.h
+++ b/common/system.h
@@ -54,6 +54,24 @@ namespace Common {
class FilesystemFactory;
/**
+ * A structure describing time and date. This is a clone of struct tm
+ * from time.h. We roll our own since not all systems provide time.h.
+ * We also do not imitate all files of struct tm, only those we
+ * actually need.
+ *
+ * @note For now, the members are named exactly as in struct tm to ease
+ * the transition.
+ */
+struct TimeDate {
+ int tm_sec; ///< seconds (0 - 60)
+ int tm_min; ///< minutes (0 - 59)
+ int tm_hour; ///< hours (0 - 23)
+ int tm_mday; ///< day of month (1 - 31)
+ int tm_mon; ///< month of year (0 - 11)
+ int tm_year; ///< year - 1900
+};
+
+/**
* Interface for ScummVM backends. If you want to port ScummVM to a system
* which is not currently covered by any of our backends, this is the place
* to start. ScummVM will create an instance of a subclass of this interface
@@ -805,7 +823,7 @@ public:
* Corresponds on many systems to the combination of time()
* and localtime().
*/
- virtual void getTimeAndDate(struct tm &t) const = 0;
+ virtual void getTimeAndDate(TimeDate &t) const = 0;
/**
* Return the timer manager singleton. For more information, refer
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index 2b03f418ee..e3371329d0 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -28,8 +28,6 @@
// Multi-slots by Claudio Matsuoka <claudio@helllabs.org>
//
-#include <time.h> // for extended infos
-
#include "common/file.h"
#include "graphics/thumbnail.h"
#include "common/config-manager.h"
@@ -79,7 +77,7 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
Graphics::saveThumbnail(*out);
// Creation date/time
- tm curTime;
+ TimeDate curTime;
_system->getTimeAndDate(curTime);
uint32 saveDate = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
diff --git a/engines/draci/saveload.cpp b/engines/draci/saveload.cpp
index f74deb5c14..cebe04bf73 100644
--- a/engines/draci/saveload.cpp
+++ b/engines/draci/saveload.cpp
@@ -23,8 +23,6 @@
*
*/
-#include <time.h> // for extended infos
-
#include "draci/draci.h"
#include "draci/saveload.h"
@@ -95,7 +93,7 @@ Common::Error saveSavegameData(int saveGameIdx, const Common::String &saveName,
if (f == NULL)
return Common::kNoGameDataFoundError;
- tm curTime;
+ TimeDate curTime;
vm._system->getTimeAndDate(curTime);
// Save the savegame header
diff --git a/engines/gob/inter.cpp b/engines/gob/inter.cpp
index afd215a00d..0d48ad719c 100644
--- a/engines/gob/inter.cpp
+++ b/engines/gob/inter.cpp
@@ -23,8 +23,6 @@
*
*/
-#include <time.h> // FIXME: for Inter::renewTimeInVars()
-
#include "common/endian.h"
#include "gob/gob.h"
@@ -159,7 +157,7 @@ void Inter::initControlVars(char full) {
}
void Inter::renewTimeInVars() {
- struct tm t;
+ TimeDate t;
_vm->_system->getTimeAndDate(t);
WRITE_VAR(5, 1900 + t.tm_year);
diff --git a/engines/saga/saveload.cpp b/engines/saga/saveload.cpp
index 56fb366405..bb63e690b2 100644
--- a/engines/saga/saveload.cpp
+++ b/engines/saga/saveload.cpp
@@ -23,8 +23,6 @@
*
*/
-#include <time.h> // for extended infos
-
#include "common/config-manager.h"
#include "common/savefile.h"
#include "common/system.h"
@@ -199,7 +197,7 @@ void SagaEngine::save(const char *fileName, const char *saveName) {
Graphics::saveThumbnail(*out);
// Date / time
- tm curTime;
+ TimeDate curTime;
_system->getTimeAndDate(curTime);
uint32 saveDate = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index dbe562b25a..46533f4e34 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -25,8 +25,6 @@
#include "common/system.h"
-#include <time.h> // FIXME: For struct tm
-
#include "sci/sci.h"
#include "sci/debug.h"
#include "sci/engine/state.h"
@@ -115,7 +113,7 @@ enum {
};
reg_t kGetTime(EngineState *s, int argc, reg_t *argv) {
- tm loc_time;
+ TimeDate loc_time;
uint32 elapsedTime;
int retval = 0; // Avoid spurious warning
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 199c27e1a6..0779085612 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -28,9 +28,6 @@
#include "common/func.h"
#include "common/serializer.h"
-#include <time.h> // FIXME: For struct tm
-
-
#include "sci/sci.h"
#include "sci/gfx/operations.h"
#include "sci/gfx/menubar.h"
@@ -497,7 +494,7 @@ static void sync_songlib_t(Common::Serializer &s, SongLibrary &obj) {
int gamestate_save(EngineState *s, Common::WriteStream *fh, const char* savename, const char *version) {
- tm curTime;
+ TimeDate curTime;
g_system->getTimeAndDate(curTime);
SavegameMetadata meta;
diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp
index 9dad8cd054..db56c44daf 100644
--- a/engines/scumm/saveload.cpp
+++ b/engines/scumm/saveload.cpp
@@ -23,8 +23,6 @@
*
*/
-#include <time.h> // for ScummEngine::saveInfos / ScummEngine::loadInfos
-
#include "common/config-manager.h"
#include "common/savefile.h"
#include "common/system.h"
@@ -779,10 +777,10 @@ void ScummEngine::saveInfos(Common::WriteStream* file) {
section.size = SaveInfoSectionSize;
// still save old format for older versions
- section.timeTValue = time(0);
+ section.timeTValue = 0;
section.playtime = _system->getMillis() / 1000 - _engineStartTime;
- tm curTime;
+ TimeDate curTime;
_system->getTimeAndDate(curTime);
section.date = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp
index 6df3c0c494..435cbf50c7 100644
--- a/engines/scumm/script_v6.cpp
+++ b/engines/scumm/script_v6.cpp
@@ -23,8 +23,6 @@
*
*/
-#include <time.h> // for ScummEngine_v6::o6_getDateTime()
-
#include "common/config-manager.h"
#include "common/system.h"
@@ -2940,7 +2938,7 @@ void ScummEngine_v6::o6_pickVarRandom() {
}
void ScummEngine_v6::o6_getDateTime() {
- struct tm t;
+ TimeDate t;
_system->getTimeAndDate(t);
VAR(VAR_TIMEDATE_YEAR) = t.tm_year;
diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp
index 5a3c614df4..31db54c4c8 100644
--- a/engines/sword1/control.cpp
+++ b/engines/sword1/control.cpp
@@ -23,8 +23,6 @@
*
*/
-#include <time.h> // for extended infos
-
#include "common/file.h"
#include "common/util.h"
#include "common/savefile.h"
@@ -1112,7 +1110,7 @@ void Control::saveGameToFile(uint8 slot) {
Graphics::saveThumbnail(*outf);
// Date / time
- tm curTime;
+ TimeDate curTime;
_system->getTimeAndDate(curTime);
uint32 saveDate = (curTime.tm_mday & 0xFF) << 24 | ((curTime.tm_mon + 1) & 0xFF) << 16 | ((curTime.tm_year + 1900) & 0xFFFF);
@@ -1278,7 +1276,7 @@ bool Control::convertSaveGame(uint8 slot, char* desc) {
newSave->writeByte(SAVEGAME_VERSION);
// Date / time
- tm curTime;
+ TimeDate curTime;
_system->getTimeAndDate(curTime);
uint32 saveDate = (curTime.tm_mday & 0xFF) << 24 | ((curTime.tm_mon + 1) & 0xFF) << 16 | ((curTime.tm_year + 1900) & 0xFFFF);
diff --git a/engines/tinsel/saveload.cpp b/engines/tinsel/saveload.cpp
index 79a47bc026..e265c434ef 100644
--- a/engines/tinsel/saveload.cpp
+++ b/engines/tinsel/saveload.cpp
@@ -95,7 +95,7 @@ struct SaveGameHeader {
uint32 size;
uint32 ver;
char desc[SG_DESC_LEN];
- struct tm dateTime;
+ TimeDate dateTime;
};
enum {
@@ -124,18 +124,13 @@ static char *SaveSceneSsData = 0; // points to 'SAVED_DATA ssdata[MAX_NEST]'
void setNeedLoad() { NeedLoad = true; }
-static void syncTime(Common::Serializer &s, struct tm &t) {
+static void syncTime(Common::Serializer &s, TimeDate &t) {
s.syncAsUint16LE(t.tm_year);
s.syncAsByte(t.tm_mon);
s.syncAsByte(t.tm_mday);
s.syncAsByte(t.tm_hour);
s.syncAsByte(t.tm_min);
s.syncAsByte(t.tm_sec);
- if (s.isLoading()) {
- t.tm_wday = 0;
- t.tm_yday = 0;
- t.tm_isdst = 0;
- }
}
static bool syncSaveGameHeader(Common::Serializer &s, SaveGameHeader &hdr) {
@@ -300,6 +295,28 @@ static char *NewName(void) {
}
/**
+ * Compare two TimeDate structs to see which one was earlier.
+ * Returns 0 if they are equal, a negative value if a is lower / first, and
+ * a positive value if b is lower / first.
+ */
+static int cmpTimeDate(const TimeDate &a, const TimeDate &b) {
+ int tmp;
+
+ #define CMP_ENTRY(x) tmp = a.x - b.x; if (tmp != 0) return tmp
+
+ CMP_ENTRY(tm_year);
+ CMP_ENTRY(tm_mon);
+ CMP_ENTRY(tm_mday);
+ CMP_ENTRY(tm_hour);
+ CMP_ENTRY(tm_min);
+ CMP_ENTRY(tm_sec);
+
+ #undef CMP_ENTRY
+
+ return 0;
+}
+
+/**
* Interrogate the current DOS directory for saved game files.
* Store the file details, ordered by time, in savedFiles[] and return
* the number of files found).
@@ -341,7 +358,7 @@ int getList(Common::SaveFileManager *saveFileMan, const Common::String &target)
i = numSfiles;
#ifndef DISABLE_SAVEGAME_SORTING
for (i = 0; i < numSfiles; i++) {
- if (difftime(mktime(&hdr.dateTime), mktime(&savedFiles[i].dateTime)) > 0) {
+ if (cmpTimeDate(hdr.dateTime, savedFiles[i].dateTime) > 0) {
Common::copy_backward(&savedFiles[i], &savedFiles[numSfiles], &savedFiles[numSfiles + 1]);
break;
}
diff --git a/engines/tinsel/savescn.h b/engines/tinsel/savescn.h
index 0f272c21bb..21e7dd032b 100644
--- a/engines/tinsel/savescn.h
+++ b/engines/tinsel/savescn.h
@@ -27,8 +27,6 @@
#ifndef TINSEL_SAVESCN_H
#define TINSEL_SAVESCN_H
-#include <time.h> // for time_t struct
-
#include "tinsel/actors.h" // SAVED_ACTOR
#include "tinsel/dw.h" // SCNHANDLE
#include "tinsel/rince.h" // SAVED_MOVER
@@ -52,7 +50,7 @@ enum {
struct SFILES {
char name[FNAMELEN];
char desc[SG_DESC_LEN + 2];
- struct tm dateTime;
+ TimeDate dateTime;
};
struct SAVED_DATA {