From: curt Date: Thu, 9 Apr 1998 18:40:13 +0000 (+0000) Subject: We had unified some of the platform disparate time handling code, and X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=575d57249c81b42d20436a4293c4c0cabf7b28ee;p=flightgear.git We had unified some of the platform disparate time handling code, and there was a bug in timesum() which calculated a new time stamp based on the current time stamp + offset. This hosed the periodic event processing logic because you'd never arrive at the time the event was scheduled for. Sky updates and lighting changes are handled via this event mechanism so they never changed ... it is fixed now. --- diff --git a/Time/event.c b/Time/event.c index 89d22026e..5bb788246 100644 --- a/Time/event.c +++ b/Time/event.c @@ -274,12 +274,17 @@ void fgEventProcess( void ) { /* get the current time */ timestamp(¤t); + fgPrintf(FG_EVENT, FG_DEBUG, " Current timestamp = %ld\n", current.seconds); + /* printf("Checking if anything is ready to move to the run queue\n"); */ /* see if anything else is ready to be placed on the run queue */ for ( i = 0; i < event_ptr; i++ ) { if ( events[i].status == FG_EVENT_READY ) { - if ( 0 > timediff(¤t,&(events[i].next_run)) ) { + fgPrintf(FG_EVENT, FG_DEBUG, + " Item %d, current %d, next run @ %ld\n", + i, current.seconds, events[i].next_run.seconds); + if ( timediff(¤t, &(events[i].next_run)) <= 0) { addq(i); } } @@ -296,10 +301,18 @@ void fgEventProcess( void ) { /* $Log$ -/* Revision 1.11 1998/04/03 22:12:55 curt -/* Converting to Gnu autoconf system. -/* Centralized time handling differences. +/* Revision 1.12 1998/04/09 18:40:13 curt +/* We had unified some of the platform disparate time handling code, and +/* there was a bug in timesum() which calculated a new time stamp based on +/* the current time stamp + offset. This hosed the periodic event processing +/* logic because you'd never arrive at the time the event was scheduled for. +/* Sky updates and lighting changes are handled via this event mechanism so +/* they never changed ... it is fixed now. /* + * Revision 1.11 1998/04/03 22:12:55 curt + * Converting to Gnu autoconf system. + * Centralized time handling differences. + * * Revision 1.10 1998/03/14 00:28:34 curt * replaced a printf() with an fgPrintf(). * diff --git a/Time/fg_time.c b/Time/fg_time.c index f6d2e5bda..20441a818 100644 --- a/Time/fg_time.c +++ b/Time/fg_time.c @@ -100,13 +100,9 @@ long timediff(fg_timestamp *first, fg_timestamp *last) { /* Return new timestamp given a time stamp and an interval to add in */ void timesum(fg_timestamp *res, fg_timestamp *start, long millis) { - res->millis = start->millis + millis; - if (1000 < res->millis) { - res->seconds = start->millis + 1; - res->millis -= 1000; - } else { - res->seconds = start->millis; - } + res->seconds = start->seconds + + ( start->millis + millis ) / 1000; + res->millis = ( start->millis + millis ) % 1000; } @@ -372,9 +368,17 @@ void fgTimeUpdate(fgFLIGHT *f, struct fgTIME *t) { /* $Log$ -/* Revision 1.38 1998/04/08 23:35:40 curt -/* Tweaks to Gnu automake/autoconf system. +/* Revision 1.39 1998/04/09 18:40:14 curt +/* We had unified some of the platform disparate time handling code, and +/* there was a bug in timesum() which calculated a new time stamp based on +/* the current time stamp + offset. This hosed the periodic event processing +/* logic because you'd never arrive at the time the event was scheduled for. +/* Sky updates and lighting changes are handled via this event mechanism so +/* they never changed ... it is fixed now. /* + * Revision 1.38 1998/04/08 23:35:40 curt + * Tweaks to Gnu automake/autoconf system. + * * Revision 1.37 1998/04/03 22:12:55 curt * Converting to Gnu autoconf system. * Centralized time handling differences.