• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSXA [C++] timer

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Gentleman,

my C++ module needs a timer at various places. I found a solution for that months ago, but it's rather quick & dirty and most importantly it doesn't take slew, time compression or pause into account. Therefore I want to ask around how you solved this problem.

Here is my timer code:
Code:
class cTimer{    
	private:        
		FLOAT64 m_OldTime;
		FLOAT64 m_DeltaTime;
	public:        
		cTimer(){}        
		~cTimer(){}        
		void FSAPI StartTimer() {            
			m_OldTime = timeGetTime();        
		}        
		double FSAPI GetDeltaTime() {            
			FLOAT64 NewTime = timeGetTime();
			m_DeltaTime = NewTime - m_OldTime;            
			m_OldTime = NewTime;            
			return m_DeltaTime*0.001;        
		}    
};

cheers,
Vitus
 
Last edited:
Because I'm a programming pygmy I couldn't get a pure C timer to work, so instead I used execute_calculator_code to grab the fsx time and then compare it to prevously stored values to see if they'd expired. E.g. for a five second delay I saved the FSX time in seconds and added five to it, once the FSX time equalled the previously saved value the delay was up. Obvously you can expand on this for other effects. The bonus is that as it's using the FSX time if you alter the sim rate, press pause etc. this is automagically taken into account.
Note I fully expect someone to come up with a better solution in the next 5 posts!
 
Back
Top