Ticket #8765: curtime.patch
File curtime.patch, 5.4 KB (added by , 17 years ago) |
---|
-
engines/scumm/saveload.cpp
23 23 * 24 24 */ 25 25 26 27 28 26 #include "common/config-manager.h" 29 27 #include "common/savefile.h" 30 28 #include "common/system.h" … … 555 553 556 554 // For header version 1, we load the data in with our old method 557 555 if (section.version == 1) { 558 time_t tmp = section.timeTValue; 559 tm *curTime = localtime(&tmp); 560 stuff->date = (curTime->tm_mday & 0xFF) << 24 | ((curTime->tm_mon + 1) & 0xFF) << 16 | (curTime->tm_year + 1900) & 0xFFFF; 561 stuff->time = (curTime->tm_hour & 0xFF) << 8 | (curTime->tm_min) & 0xFF; 556 //time_t tmp = section.timeTValue; 557 //tm *curTime = localtime(&tmp); 558 //stuff->date = (curTime->tm_mday & 0xFF) << 24 | ((curTime->tm_mon + 1) & 0xFF) << 16 | (curTime->tm_year + 1900) & 0xFFFF; 559 //stuff->time = (curTime->tm_hour & 0xFF) << 8 | (curTime->tm_min) & 0xFF; 560 stuff->date = 0; 561 stuff->time = 0; 562 562 } 563 563 564 564 if (section.version >= 2) { … … 588 588 // still save old format for older versions 589 589 section.timeTValue = time(0); 590 590 section.playtime = _system->getMillis() / 1000 - _engineStartTime; 591 592 tm curTime; 593 _system->getTimeAndDate(curTime); 594 595 section.date = (curTime.tm_mday & 0xFF) << 24 | ((curTime.tm_mon + 1) & 0xFF) << 16 | (curTime.tm_year + 1900) & 0xFFFF; 596 section.time = (curTime.tm_hour & 0xFF) << 8 | (curTime.tm_min) & 0xFF; 591 597 592 time_t curTime_ = time(0);593 tm *curTime = localtime(&curTime_);594 section.date = (curTime->tm_mday & 0xFF) << 24 | ((curTime->tm_mon + 1) & 0xFF) << 16 | (curTime->tm_year + 1900) & 0xFFFF;595 section.time = (curTime->tm_hour & 0xFF) << 8 | (curTime->tm_min) & 0xFF;596 597 598 file->writeUint32BE(section.type); 598 599 file->writeUint32BE(section.version); 599 600 file->writeUint32BE(section.size); -
engines/scumm/script_v6.cpp
23 23 * 24 24 */ 25 25 26 27 28 26 #include "common/config-manager.h" 27 #include "common/system.h" 29 28 30 29 #include "scumm/actor.h" 31 30 #include "scumm/charset.h" … … 3003 3002 } 3004 3003 3005 3004 void ScummEngine_v6::o6_getDateTime() { 3006 struct tm *t;3007 time_t now = time(NULL);3005 struct tm t; 3006 _system->getTimeAndDate(t); 3008 3007 3009 t = localtime(&now); 3008 VAR(VAR_TIMEDATE_YEAR) = t.tm_year; 3009 VAR(VAR_TIMEDATE_MONTH) = t.tm_mon; 3010 VAR(VAR_TIMEDATE_DAY) = t.tm_mday; 3011 VAR(VAR_TIMEDATE_HOUR) = t.tm_hour; 3012 VAR(VAR_TIMEDATE_MINUTE) = t.tm_min; 3010 3013 3011 VAR(VAR_TIMEDATE_YEAR) = t->tm_year;3012 VAR(VAR_TIMEDATE_MONTH) = t->tm_mon;3013 VAR(VAR_TIMEDATE_DAY) = t->tm_mday;3014 VAR(VAR_TIMEDATE_HOUR) = t->tm_hour;3015 VAR(VAR_TIMEDATE_MINUTE) = t->tm_min;3016 3017 3014 if (_game.version == 8) 3018 VAR(VAR_TIMEDATE_SECOND) = t ->tm_sec;3015 VAR(VAR_TIMEDATE_SECOND) = t.tm_sec; 3019 3016 } 3020 3017 3021 3018 void ScummEngine_v6::o6_getPixel() { -
engines/gob/inter.cpp
125 125 } 126 126 127 127 void Inter::renewTimeInVars() { 128 struct tm *t;129 time_t now = time(NULL);128 struct tm t; 129 _vm->_system->getTimeAndDate(t); 130 130 131 t = localtime(&now); 132 133 WRITE_VAR(5, 1900 + t->tm_year); 134 WRITE_VAR(6, t->tm_mon + 1); 131 WRITE_VAR(5, 1900 + t.tm_year); 132 WRITE_VAR(6, t.tm_mon + 1); 135 133 WRITE_VAR(7, 0); 136 WRITE_VAR(8, t ->tm_mday);137 WRITE_VAR(9, t ->tm_hour);138 WRITE_VAR(10, t ->tm_min);139 WRITE_VAR(11, t ->tm_sec);134 WRITE_VAR(8, t.tm_mday); 135 WRITE_VAR(9, t.tm_hour); 136 WRITE_VAR(10, t.tm_min); 137 WRITE_VAR(11, t.tm_sec); 140 138 } 141 139 142 140 void Inter::storeMouse() { -
common/system.h
724 724 725 725 /** Delay/sleep for the specified amount of milliseconds. */ 726 726 virtual void delayMillis(uint msecs) = 0; 727 728 /** Get the current time and date. Correspond to time()+localtime(). */ 729 virtual void getTimeAndDate(struct tm &t) const; 727 730 728 731 /** 729 732 * Return the timer manager singleton. For more information, refer -
common/system.cpp
35 35 #include "gui/message.h" 36 36 #include "sound/mixer.h" 37 37 38 #include <time.h> 39 38 40 OSystem *g_system = 0; 39 41 40 42 OSystem::OSystem() { … … 121 123 memset(screen->pixels, 0, screen->h * screen->pitch); 122 124 unlockScreen(); 123 125 } 126 127 void OSystem::getTimeAndDate(struct tm &t) const { 128 time_t curTime = time(0); 129 t = *localtime(&curTime); 130 } -
backends/platform/ps2/ps2time.cpp
104 104 } 105 105 106 106 extern "C" time_t time(time_t *p) { 107 if (p) *p = (time_t)g_timeSecs; 107 108 return (time_t)g_timeSecs; 108 109 } 109 110 110 111 extern "C" struct tm *localtime(const time_t *p) { 112 // FIXME: This function should actually use the value in *p! 113 // But the work needed for that is not necessary -- just implement 114 // OSystem::getTimeAndDate using the code provided here, and 115 // ditch the custom time & localtime methods. 111 116 uint32 currentSecs = g_timeSecs + (msecCount - g_lastTimeCheck) / 1000; 112 117 if (currentSecs >= SECONDS_PER_DAY) { 113 118 buildNewDate(+1);