[Scummvm-cvs-logs] SF.net SVN: scummvm:[44793] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Oct 8 21:41:38 CEST 2009


Revision: 44793
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44793&view=rev
Author:   fingolfin
Date:     2009-10-08 19:41:38 +0000 (Thu, 08 Oct 2009)

Log Message:
-----------
Introduce a new struct TimeDate, replacing struct tm in client code. May lead to compilation issues in ports, which should be trivial to fix, though

Modified Paths:
--------------
    scummvm/trunk/backends/platform/PalmOS/Src/be_base.cpp
    scummvm/trunk/backends/platform/PalmOS/Src/be_base.h
    scummvm/trunk/backends/platform/dc/dc.h
    scummvm/trunk/backends/platform/dc/dcmain.cpp
    scummvm/trunk/backends/platform/ds/arm9/source/osystem_ds.cpp
    scummvm/trunk/backends/platform/ds/arm9/source/osystem_ds.h
    scummvm/trunk/backends/platform/gp2x/gp2x-common.h
    scummvm/trunk/backends/platform/gp2x/gp2x.cpp
    scummvm/trunk/backends/platform/iphone/osys_main.cpp
    scummvm/trunk/backends/platform/iphone/osys_main.h
    scummvm/trunk/backends/platform/null/null.cpp
    scummvm/trunk/backends/platform/ps2/ps2time.cpp
    scummvm/trunk/backends/platform/ps2/systemps2.h
    scummvm/trunk/backends/platform/psp/osys_psp.cpp
    scummvm/trunk/backends/platform/psp/osys_psp.h
    scummvm/trunk/backends/platform/sdl/sdl.cpp
    scummvm/trunk/backends/platform/sdl/sdl.h
    scummvm/trunk/backends/platform/wii/osystem.cpp
    scummvm/trunk/backends/platform/wii/osystem.h
    scummvm/trunk/backends/platform/wince/wince-sdl.cpp
    scummvm/trunk/backends/platform/wince/wince-sdl.h
    scummvm/trunk/common/system.h
    scummvm/trunk/engines/agi/saveload.cpp
    scummvm/trunk/engines/draci/saveload.cpp
    scummvm/trunk/engines/gob/inter.cpp
    scummvm/trunk/engines/saga/saveload.cpp
    scummvm/trunk/engines/sci/engine/kmisc.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/scumm/saveload.cpp
    scummvm/trunk/engines/scumm/script_v6.cpp
    scummvm/trunk/engines/sword1/control.cpp
    scummvm/trunk/engines/tinsel/saveload.cpp
    scummvm/trunk/engines/tinsel/savescn.h

Modified: scummvm/trunk/backends/platform/PalmOS/Src/be_base.cpp
===================================================================
--- scummvm/trunk/backends/platform/PalmOS/Src/be_base.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/PalmOS/Src/be_base.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -125,9 +125,15 @@
 	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() {

Modified: scummvm/trunk/backends/platform/PalmOS/Src/be_base.h
===================================================================
--- scummvm/trunk/backends/platform/PalmOS/Src/be_base.h	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/PalmOS/Src/be_base.h	2009-10-08 19:41:38 UTC (rev 44793)
@@ -239,7 +239,7 @@
 
 	bool pollEvent(Common::Event &event);
 
-	void getTimeAndDate(struct tm &t) const;
+	void getTimeAndDate(TimeDate &t) const;
 	virtual uint32 getMillis();
 	virtual void delayMillis(uint msecs);
 

Modified: scummvm/trunk/backends/platform/dc/dc.h
===================================================================
--- scummvm/trunk/backends/platform/dc/dc.h	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/dc/dc.h	2009-10-08 19:41:38 UTC (rev 44793)
@@ -123,7 +123,7 @@
   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.

Modified: scummvm/trunk/backends/platform/dc/dcmain.cpp
===================================================================
--- scummvm/trunk/backends/platform/dc/dcmain.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/dc/dcmain.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -193,10 +193,16 @@
   }
 }
 
-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()

Modified: scummvm/trunk/backends/platform/ds/arm9/source/osystem_ds.cpp
===================================================================
--- scummvm/trunk/backends/platform/ds/arm9/source/osystem_ds.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/ds/arm9/source/osystem_ds.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -655,14 +655,20 @@
 }
 
 
-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() {

Modified: scummvm/trunk/backends/platform/ds/arm9/source/osystem_ds.h
===================================================================
--- scummvm/trunk/backends/platform/ds/arm9/source/osystem_ds.h	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/ds/arm9/source/osystem_ds.h	2009-10-08 19:41:38 UTC (rev 44793)
@@ -118,7 +118,7 @@
 	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);

Modified: scummvm/trunk/backends/platform/gp2x/gp2x-common.h
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x-common.h	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/gp2x/gp2x-common.h	2009-10-08 19:41:38 UTC (rev 44793)
@@ -138,7 +138,7 @@
 	// Quit
 	void quit();
 
-	void getTimeAndDate(struct tm &t) const;
+	void getTimeAndDate(TimeDate &t) const;
 	virtual Common::TimerManager *getTimerManager();
 
 	// Mutex handling

Modified: scummvm/trunk/backends/platform/gp2x/gp2x.cpp
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/gp2x/gp2x.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -301,9 +301,15 @@
 	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() {

Modified: scummvm/trunk/backends/platform/iphone/osys_main.cpp
===================================================================
--- scummvm/trunk/backends/platform/iphone/osys_main.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/iphone/osys_main.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -198,9 +198,15 @@
 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() {

Modified: scummvm/trunk/backends/platform/iphone/osys_main.h
===================================================================
--- scummvm/trunk/backends/platform/iphone/osys_main.h	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/iphone/osys_main.h	2009-10-08 19:41:38 UTC (rev 44793)
@@ -169,7 +169,7 @@
 
 	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();

Modified: scummvm/trunk/backends/platform/null/null.cpp
===================================================================
--- scummvm/trunk/backends/platform/null/null.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/null/null.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -115,7 +115,7 @@
 
 	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 @@
 	return _timer;
 }
 
-void OSystem_NULL::getTimeAndDate(struct tm &t) const {
+void OSystem_NULL::getTimeAndDate(TimeDate &t) const {
 }
 
 FilesystemFactory *OSystem_NULL::getFilesystemFactory() {

Modified: scummvm/trunk/backends/platform/ps2/ps2time.cpp
===================================================================
--- scummvm/trunk/backends/platform/ps2/ps2time.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/ps2/ps2time.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -106,7 +106,7 @@
 		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 @@
 	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;
 }

Modified: scummvm/trunk/backends/platform/ps2/systemps2.h
===================================================================
--- scummvm/trunk/backends/platform/ps2/systemps2.h	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/ps2/systemps2.h	2009-10-08 19:41:38 UTC (rev 44793)
@@ -124,7 +124,7 @@
 	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);

Modified: scummvm/trunk/backends/platform/psp/osys_psp.cpp
===================================================================
--- scummvm/trunk/backends/platform/psp/osys_psp.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/psp/osys_psp.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -1155,9 +1155,15 @@
 	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"

Modified: scummvm/trunk/backends/platform/psp/osys_psp.h
===================================================================
--- scummvm/trunk/backends/platform/psp/osys_psp.h	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/psp/osys_psp.h	2009-10-08 19:41:38 UTC (rev 44793)
@@ -159,7 +159,7 @@
 	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();
 

Modified: scummvm/trunk/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/sdl/sdl.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -295,9 +295,15 @@
 	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() {

Modified: scummvm/trunk/backends/platform/sdl/sdl.h
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.h	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/sdl/sdl.h	2009-10-08 19:41:38 UTC (rev 44793)
@@ -183,7 +183,7 @@
 	// 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

Modified: scummvm/trunk/backends/platform/wii/osystem.cpp
===================================================================
--- scummvm/trunk/backends/platform/wii/osystem.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/wii/osystem.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -264,9 +264,15 @@
 	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() {

Modified: scummvm/trunk/backends/platform/wii/osystem.h
===================================================================
--- scummvm/trunk/backends/platform/wii/osystem.h	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/wii/osystem.h	2009-10-08 19:41:38 UTC (rev 44793)
@@ -211,7 +211,7 @@
 	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

Modified: scummvm/trunk/backends/platform/wince/wince-sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/wince/wince-sdl.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/wince/wince-sdl.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -2523,13 +2523,12 @@
 	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;

Modified: scummvm/trunk/backends/platform/wince/wince-sdl.h
===================================================================
--- scummvm/trunk/backends/platform/wince/wince-sdl.h	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/backends/platform/wince/wince-sdl.h	2009-10-08 19:41:38 UTC (rev 44793)
@@ -85,7 +85,7 @@
 	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();
 

Modified: scummvm/trunk/common/system.h
===================================================================
--- scummvm/trunk/common/system.h	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/common/system.h	2009-10-08 19:41:38 UTC (rev 44793)
@@ -54,6 +54,24 @@
 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 @@
 	 * 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

Modified: scummvm/trunk/engines/agi/saveload.cpp
===================================================================
--- scummvm/trunk/engines/agi/saveload.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/engines/agi/saveload.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -28,8 +28,6 @@
 // Multi-slots by Claudio Matsuoka <claudio at 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 @@
 	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);

Modified: scummvm/trunk/engines/draci/saveload.cpp
===================================================================
--- scummvm/trunk/engines/draci/saveload.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/engines/draci/saveload.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -23,8 +23,6 @@
  *
  */
 
-#include <time.h>	// for extended infos
-
 #include "draci/draci.h"
 #include "draci/saveload.h"
 
@@ -95,7 +93,7 @@
 	if (f == NULL)
 		return Common::kNoGameDataFoundError;
 
-	tm curTime;
+	TimeDate curTime;
 	vm._system->getTimeAndDate(curTime);
 
 	// Save the savegame header

Modified: scummvm/trunk/engines/gob/inter.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/engines/gob/inter.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -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::renewTimeInVars() {
-	struct tm t;
+	TimeDate t;
 	_vm->_system->getTimeAndDate(t);
 
 	WRITE_VAR(5, 1900 + t.tm_year);

Modified: scummvm/trunk/engines/saga/saveload.cpp
===================================================================
--- scummvm/trunk/engines/saga/saveload.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/engines/saga/saveload.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -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 @@
 	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);

Modified: scummvm/trunk/engines/sci/engine/kmisc.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmisc.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/engines/sci/engine/kmisc.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -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 @@
 };
 
 reg_t kGetTime(EngineState *s, int argc, reg_t *argv) {
-	tm loc_time;
+	TimeDate loc_time;
 	uint32 elapsedTime;
 	int retval = 0; // Avoid spurious warning
 

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -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 @@
 
 
 int gamestate_save(EngineState *s, Common::WriteStream *fh, const char* savename, const char *version) {
-	tm curTime;
+	TimeDate curTime;
 	g_system->getTimeAndDate(curTime);
 
 	SavegameMetadata meta;

Modified: scummvm/trunk/engines/scumm/saveload.cpp
===================================================================
--- scummvm/trunk/engines/scumm/saveload.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/engines/scumm/saveload.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -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 @@
 	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);

Modified: scummvm/trunk/engines/scumm/script_v6.cpp
===================================================================
--- scummvm/trunk/engines/scumm/script_v6.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/engines/scumm/script_v6.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -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_getDateTime() {
-	struct tm t;
+	TimeDate t;
 	_system->getTimeAndDate(t);
 
 	VAR(VAR_TIMEDATE_YEAR) = t.tm_year;

Modified: scummvm/trunk/engines/sword1/control.cpp
===================================================================
--- scummvm/trunk/engines/sword1/control.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/engines/sword1/control.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -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 @@
 		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 @@
 	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);

Modified: scummvm/trunk/engines/tinsel/saveload.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/saveload.cpp	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/engines/tinsel/saveload.cpp	2009-10-08 19:41:38 UTC (rev 44793)
@@ -95,7 +95,7 @@
 	uint32 size;
 	uint32 ver;
 	char desc[SG_DESC_LEN];
-	struct tm dateTime;
+	TimeDate dateTime;
 };
 
 enum {
@@ -124,18 +124,13 @@
 
 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 @@
 }
 
 /**
+ * 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 @@
 		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;
 			}

Modified: scummvm/trunk/engines/tinsel/savescn.h
===================================================================
--- scummvm/trunk/engines/tinsel/savescn.h	2009-10-08 19:14:58 UTC (rev 44792)
+++ scummvm/trunk/engines/tinsel/savescn.h	2009-10-08 19:41:38 UTC (rev 44793)
@@ -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 @@
 struct SFILES {
 	char	name[FNAMELEN];
 	char	desc[SG_DESC_LEN + 2];
-	struct tm dateTime;
+	TimeDate dateTime;
 };
 
 struct SAVED_DATA {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list