Thread: [GD-General] time
Brought to you by:
vexxed72
From: Brett B. <res...@ga...> - 2004-02-21 03:03:19
|
Howdy, I have been wrestling with time in my engine for some time now (no pun = intended). I wondered how other people are handling time? Our game = engine is specifically designed for PS2/Gcn, but it runs under Windows = too. Specifically... What are the different components that people are using? We currently = have a single 32-bit time variable initialized to zero at startup and = that's it. Each frame we either count v-blanks, use system ticks/timers = or OS facilities custom for each platform to increment the global time = value, usually stored in microseconds and rounded up to millisecond = resolution for use in the engine. Works well and I have done this for = every game engine I have developed so far. Feels like a change may be warranted though as online gaming becomes = more popular, since if the game was to run for many days it would = overflow and timestamping may be problematic. So now I'm thinking of = adding a time struct (different from ANSI C though) whereby we store the = year, month, day, hour and minute, and second and also a conversion = struct that says how many mins->hour->day->month->year so we can convert = "real" time into game time. I can pack this into 64-bits, but then again = a simple 64-bit timer using the old way to simply count ticks would also = eliminate the overflow problem anyway and so I'm questioning the right = thing to do. Also, I hoping to be able to use absolute time for certain = things where we used to use delta times. What are people using for = timestamps for online games? Does each game session reset the server = session time to prevent eventual overflow? Or is a more robust timing = mechanism used? Are people using microseconds? milliseconds? Thanks, Brett |
From: Mike W. <mi...@ge...> - 2004-02-21 03:20:04
|
for multiplayer games like counter-strike or bf9142, i think that the=20 engine completely 'restarts itself' on every map change to help avoid=20 these types of errors. i recall a bug in quake that would crash it every 'x' hours on clockwork=20 if left running in 'demo mode' for example... for a massively multiplayer game though you would want to use something=20 more robust indeed. other than relying on the system clock itself (or a system-specific=20 high-performance multi-media timer), i'm not sure how i'd approach this. we use the windows internal clock for our own timing, and have routines=20 that check to see if we've 'fallen off the track' at any point, if so,=20 we do a sync between our internal game 'clock' and the windows system clo= ck. for multiplayer games, you may want all games (client or server) to rely=20 on the 'master server' clock possibly, not on a frame-by-frame basis,=20 but on a larger 'sync' basis, where you can make sure that all clients=20 are synced to the same timestamp? i'm not sure how else you'd approach this, aside from just forcing the=20 clients to sync to the server's time, whatever it happens to=20 be...clients would add or drop frames as neceessary to stay in sync... mike w www.gekidodesigns.com Brett Bibby wrote: > Howdy, I have been wrestling with time in my engine for some time now > (no pun intended). I wondered how other people are handling time? Our > game engine is specifically designed for PS2/Gcn, but it runs under > Windows too. Specifically... >=20 > What are the different components that people are using? We currently > have a single 32-bit time variable initialized to zero at startup and > that's it. Each frame we either count v-blanks, use system > ticks/timers or OS facilities custom for each platform to increment > the global time value, usually stored in microseconds and rounded up > to millisecond resolution for use in the engine. Works well and I > have done this for every game engine I have developed so far. >=20 > Feels like a change may be warranted though as online gaming becomes > more popular, since if the game was to run for many days it would > overflow and timestamping may be problematic. So now I'm thinking of > adding a time struct (different from ANSI C though) whereby we store > the year, month, day, hour and minute, and second and also a > conversion struct that says how many mins->hour->day->month->year so > we can convert "real" time into game time. I can pack this into > 64-bits, but then again a simple 64-bit timer using the old way to > simply count ticks would also eliminate the overflow problem anyway > and so I'm questioning the right thing to do. Also, I hoping to be > able to use absolute time for certain things where we used to use > delta times. What are people using for timestamps for online games? > Does each game session reset the server session time to prevent > eventual overflow? Or is a more robust timing mechanism used? Are > people using microseconds? milliseconds? >=20 > Thanks, Brett >=20 >=20 > ------------------------------------------------------- SF.Net is > sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps > & Web services for Linux with a free DVD software kit from IBM. Click > Now! http://ads.osdn.com/?ad_id=1356&alloc_id438&op=CCk=20 > _______________________________________________ Gamedevlists-general > mailing list Gam...@li...=20 > https://lists.sourceforge.net/lists/listinfo/gamedevlists-general=20 > Archives: http://sourceforge.net/mailarchive/forum.php?forum_idU7 >=20 >=20 |
From: Tom S. <to...@pi...> - 2004-02-21 03:20:53
|
http://www.dallasigda.org/notes.htm You'll see a document called "Time in games" which are notes on a presentation done by Squirrel Eiserloh. It covers a lot about time in Win32 and the different methods he's used to tackle it. People may find it helpful. Tom > -----Original Message----- > From: gam...@li...=20 > [mailto:gam...@li...] On=20 > Behalf Of Brett Bibby > Sent: Friday, February 20, 2004 8:59 PM > To: Gam...@li... > Subject: [GD-General] time >=20 >=20 > Howdy, > I have been wrestling with time in my engine for some time=20 > now (no pun intended). I wondered how other people are=20 > handling time? Our game engine is specifically designed for=20 > PS2/Gcn, but it runs under Windows too. Specifically... >=20 > What are the different components that people are using? We=20 > currently have a single 32-bit time variable initialized to=20 > zero at startup and that's it. Each frame we either count=20 > v-blanks, use system ticks/timers or OS facilities custom for=20 > each platform to increment the global time value, usually=20 > stored in microseconds and rounded up to millisecond=20 > resolution for use in the engine. Works well and I have done=20 > this for every game engine I have developed so far. >=20 > Feels like a change may be warranted though as online gaming=20 > becomes more popular, since if the game was to run for many=20 > days it would overflow and timestamping may be problematic.=20 > So now I'm thinking of adding a time struct (different from=20 > ANSI C though) whereby we store the year, month, day, hour=20 > and minute, and second and also a conversion struct that says=20 > how many mins->hour->day->month->year so we can convert=20 > "real" time into game time. I can pack this into 64-bits, but=20 > then again a simple 64-bit timer using the old way to simply=20 > count ticks would also eliminate the overflow problem anyway=20 > and so I'm questioning the right thing to do. Also, I hoping=20 > to be able to use absolute time for certain things where we=20 > used to use delta times. What are people using for timestamps=20 > for online games? Does each game session reset the server=20 > session time to prevent eventual overflow? Or is a more=20 > robust timing mechanism used? Are people using microseconds?=20 > milliseconds? >=20 > Thanks, > Brett >=20 >=20 > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now!=20 > http://ads.osdn.com/?ad_id=1356&alloc_id438> &op=3Dick >=20 > _______________________________________________ >=20 > Gamedevlists-general mailing list=20 > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-general > Archives: http://sourceforge.net/mailarchive/forum.php?forum_idU7 >=20 >=20 |
From: Brett B. <res...@ga...> - 2004-02-21 04:10:49
|
That's a great document and covers pretty much everything we discussed = internally, nice reference! The doc's discussion of different = resolutions combined with independent running (some time keeps running = even when paused) is something I hadn't thought of and I will look into = that. Meanwhile, anybody doing an online game care to comment how you = handle time? As a player of MMORPG I always am wondering how they = timestamp and integrate time into their engines, and if feasible I would = like to make sure we can support arbitrary lengths of time too. Brett ----- Original Message -----=20 From: "Tom Spilman" <to...@pi...> To: <gam...@li...> Sent: Saturday, February 21, 2004 11:14 AM Subject: RE: [GD-General] time >=20 > http://www.dallasigda.org/notes.htm >=20 > You'll see a document called "Time in games" which are notes on a > presentation done by Squirrel Eiserloh. It covers a lot about time in > Win32 and the different methods he's used to tackle it. People may = find > it helpful. >=20 > Tom >=20 >=20 > > -----Original Message----- > > From: gam...@li...=20 > > [mailto:gam...@li...] On=20 > > Behalf Of Brett Bibby > > Sent: Friday, February 20, 2004 8:59 PM > > To: Gam...@li... > > Subject: [GD-General] time > >=20 > >=20 > > Howdy, > > I have been wrestling with time in my engine for some time=20 > > now (no pun intended). I wondered how other people are=20 > > handling time? Our game engine is specifically designed for=20 > > PS2/Gcn, but it runs under Windows too. Specifically... > >=20 > > What are the different components that people are using? We=20 > > currently have a single 32-bit time variable initialized to=20 > > zero at startup and that's it. Each frame we either count=20 > > v-blanks, use system ticks/timers or OS facilities custom for=20 > > each platform to increment the global time value, usually=20 > > stored in microseconds and rounded up to millisecond=20 > > resolution for use in the engine. Works well and I have done=20 > > this for every game engine I have developed so far. > >=20 > > Feels like a change may be warranted though as online gaming=20 > > becomes more popular, since if the game was to run for many=20 > > days it would overflow and timestamping may be problematic.=20 > > So now I'm thinking of adding a time struct (different from=20 > > ANSI C though) whereby we store the year, month, day, hour=20 > > and minute, and second and also a conversion struct that says=20 > > how many mins->hour->day->month->year so we can convert=20 > > "real" time into game time. I can pack this into 64-bits, but=20 > > then again a simple 64-bit timer using the old way to simply=20 > > count ticks would also eliminate the overflow problem anyway=20 > > and so I'm questioning the right thing to do. Also, I hoping=20 > > to be able to use absolute time for certain things where we=20 > > used to use delta times. What are people using for timestamps=20 > > for online games? Does each game session reset the server=20 > > session time to prevent eventual overflow? Or is a more=20 > > robust timing mechanism used? Are people using microseconds?=20 > > milliseconds? > >=20 > > Thanks, > > Brett > >=20 > >=20 > > ------------------------------------------------------- > > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > > Build and deploy apps & Web services for Linux with > > a free DVD software kit from IBM. Click Now!=20 > > http://ads.osdn.com/?ad_id=1356&alloc_id438> &op=3Dick > >=20 > > _______________________________________________ > >=20 > > Gamedevlists-general mailing list=20 > > Gam...@li... > > https://lists.sourceforge.net/lists/listinfo/gamedevlists-general > > Archives: http://sourceforge.net/mailarchive/forum.php?forum_idU7 > >=20 > >=20 >=20 >=20 >=20 > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id438&op=CCk > _______________________________________________ > Gamedevlists-general mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-general > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_idU7 |
From: Brett B. <res...@ga...> - 2004-02-21 05:19:55
|
Forgot to mention another doc. This one at = http://www.codeproject.com/datetime/dstbugs.asp is a really nice = introduciton to higher level timekeeping and it helped me wade through = some of the issues, especially wrt integrating global timestamped stuff. Brett ----- Original Message -----=20 From: "Brett Bibby" <res...@ga...> To: <gam...@li...> Sent: Saturday, February 21, 2004 12:06 PM Subject: Re: [GD-General] time > That's a great document and covers pretty much everything we discussed = internally, nice reference! The doc's discussion of different = resolutions combined with independent running (some time keeps running = even when paused) is something I hadn't thought of and I will look into = that. Meanwhile, anybody doing an online game care to comment how you = handle time? As a player of MMORPG I always am wondering how they = timestamp and integrate time into their engines, and if feasible I would = like to make sure we can support arbitrary lengths of time too. > Brett >=20 > ----- Original Message -----=20 > From: "Tom Spilman" <to...@pi...> > To: <gam...@li...> > Sent: Saturday, February 21, 2004 11:14 AM > Subject: RE: [GD-General] time >=20 >=20 > >=20 > > http://www.dallasigda.org/notes.htm > >=20 > > You'll see a document called "Time in games" which are notes on a > > presentation done by Squirrel Eiserloh. It covers a lot about time = in > > Win32 and the different methods he's used to tackle it. People may = find > > it helpful. > >=20 > > Tom > >=20 > >=20 > > > -----Original Message----- > > > From: gam...@li...=20 > > > [mailto:gam...@li...] On=20 > > > Behalf Of Brett Bibby > > > Sent: Friday, February 20, 2004 8:59 PM > > > To: Gam...@li... > > > Subject: [GD-General] time > > >=20 > > >=20 > > > Howdy, > > > I have been wrestling with time in my engine for some time=20 > > > now (no pun intended). I wondered how other people are=20 > > > handling time? Our game engine is specifically designed for=20 > > > PS2/Gcn, but it runs under Windows too. Specifically... > > >=20 > > > What are the different components that people are using? We=20 > > > currently have a single 32-bit time variable initialized to=20 > > > zero at startup and that's it. Each frame we either count=20 > > > v-blanks, use system ticks/timers or OS facilities custom for=20 > > > each platform to increment the global time value, usually=20 > > > stored in microseconds and rounded up to millisecond=20 > > > resolution for use in the engine. Works well and I have done=20 > > > this for every game engine I have developed so far. > > >=20 > > > Feels like a change may be warranted though as online gaming=20 > > > becomes more popular, since if the game was to run for many=20 > > > days it would overflow and timestamping may be problematic.=20 > > > So now I'm thinking of adding a time struct (different from=20 > > > ANSI C though) whereby we store the year, month, day, hour=20 > > > and minute, and second and also a conversion struct that says=20 > > > how many mins->hour->day->month->year so we can convert=20 > > > "real" time into game time. I can pack this into 64-bits, but=20 > > > then again a simple 64-bit timer using the old way to simply=20 > > > count ticks would also eliminate the overflow problem anyway=20 > > > and so I'm questioning the right thing to do. Also, I hoping=20 > > > to be able to use absolute time for certain things where we=20 > > > used to use delta times. What are people using for timestamps=20 > > > for online games? Does each game session reset the server=20 > > > session time to prevent eventual overflow? Or is a more=20 > > > robust timing mechanism used? Are people using microseconds?=20 > > > milliseconds? > > >=20 > > > Thanks, > > > Brett > > >=20 > > >=20 > > > ------------------------------------------------------- > > > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > > > Build and deploy apps & Web services for Linux with > > > a free DVD software kit from IBM. Click Now!=20 > > > http://ads.osdn.com/?ad_id=1356&alloc_id438> &op=3Dick > > >=20 > > > _______________________________________________ > > >=20 > > > Gamedevlists-general mailing list=20 > > > Gam...@li... > > > https://lists.sourceforge.net/lists/listinfo/gamedevlists-general > > > Archives: http://sourceforge.net/mailarchive/forum.php?forum_idU7 > > >=20 > > >=20 > >=20 > >=20 > >=20 > > ------------------------------------------------------- > > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > > Build and deploy apps & Web services for Linux with > > a free DVD software kit from IBM. Click Now! > > http://ads.osdn.com/?ad_id=1356&alloc_id438&op=CCk > > _______________________________________________ > > Gamedevlists-general mailing list > > Gam...@li... > > https://lists.sourceforge.net/lists/listinfo/gamedevlists-general > > Archives: > > http://sourceforge.net/mailarchive/forum.php?forum_idU7 >=20 >=20 > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id438&op=CCk > _______________________________________________ > Gamedevlists-general mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-general > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_idU7 |