BVE WorldWide
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Timing of IRuntime Function Calls

2 posters

Go down

Timing of IRuntime Function Calls Empty Timing of IRuntime Function Calls

Post by zbx1425 Wed Jan 06, 2021 1:34 pm

According to the documentation, functions including SetPower,SetBrake,SetReverser,KeyDown,KeyUp,HornBlow,DoorChange,SetSignal and SetBeacon can be called at "any time".
Will it affect the timing (cause operation to be delayed for a frame, for example) if a plugin internally uses an event queue (so that these function calls push events to a queue, which later gets all processed in Elapsed, for a more convenient access to parameters inside ElapseData)?
And in which aspect will handling events like this have disadvantage on?

Posts : 138
Join date : 2017-08-18
Location : China

Back to top Go down

Timing of IRuntime Function Calls Empty Re: Timing of IRuntime Function Calls

Post by leezer3 Wed Jan 06, 2021 3:01 pm

I don't believe it should, although this can get a little complicated; It really depends on exactly what you're trying to do & what you're expecting to happen.
A SetPower, SetBrake etc. call is made by the simulation whenever the internal change is made. Depending on what actually triggered this, it may be before or after the processing of the Elapse call.

For example, comparing the brake / power notch in the ElapseData to that set by the SetBrake / SetPower function may be off for a single elapse call, but I can't see what difference this really makes.

In practice, you're talking milliseconds between calls, and you should be fine handling whatever in the next Elapse call.
Don't forget also that the Elapse call is blocking:


Posts : 1867
Join date : 2011-08-23

zbx1425 likes this post

Back to top Go down

Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum