[Scummvm-devel] ATTN Engine authors: Advanced engine features
Max Horn
max at quendi.de
Thu Oct 28 01:30:42 CEST 2010
Am 28.10.2010 um 01:08 schrieb Johannes Schickel:
> On 10/27/2010 11:12 PM, Max Horn wrote:
>>
>> Maybe you meant something like the following, though: We could enhance the default pauseEngineIntern to keep track of the time since the engine was instantiated (subtracting the paused time). And add Engine::getTotalPlaytime() and Engine::resetTotalPlaytime(int msecs = 0) methods. (The param would be used when loading a savestate). That would make it pretty simple for engines to implement that feature.
>
> I implemented that now, I inserted the code to Engine::pauseEngine
> instead of Engine::pauseEngineIntern though, so that no subclass has to
> worry about it (or calling the default pauseEngineIntern implementation
> if that is feasible).
Thanks!
>
>> Adding kSavesSupportCreationDate support to an engine is already pretty much trivial: When a new game is started in your engine, record the current time using OSystem::getTimeAndDate. But *when* this should be done is highly engine specific. We could add a "TimeDate _startOfCurrentGame;" member to Engine, and a method to init that; and then we could add two functions (not member of Engine, I'd say) which can read/write a TimeDate struct to a stream; plus a syncTimeDate method to Common::Serializer. An engine then just has to call the init method at the right moment, and would have to read/load the "_startOfCurrentGame" value when syncing a savegame.
>
> I think the creation date is the creation date of the savegame file, so
> I wonder why we need to store a "_startOfCurrentGame" or the like for that.
True enough, I was somehow confused with a "started to play this game on day X" thing (which we don't need, we want to store "hours of played" instead). So, it would indeed suffice to store the current time & date. Which makes it even more trivial ;).
Cheers,
Max
More information about the Scummvm-devel
mailing list