<commit_before>////////////////////////////////////////////////////////////////////////////
///
///			WraithOne tech Engine
///
///			https://github.com/WraithOne/WOtech
///			by https://twitter.com/WraithOne
///
///			File: Gametimer.cpp
///
///			Description:
///
///			Created:	12.05.2014
///			Edited:		06.11.2016
///
////////////////////////////////////////////////////////////////////////////

//////////////
// INCLUDES //
//////////////
#include "pch.h"
#include "GameTimer.h"

namespace WOtech
{
	GameTimer::GameTimer() : m_active(false)
	{
		LARGE_INTEGER frequency;

		if (!QueryPerformanceFrequency(&frequency))
		{
			//g_pLogfile->Textout(RED, false, "QueryPreformanceFrequency FAILED <frequency>");
		}
		m_secondsPerCount = 1.0f / static_cast<float32>(frequency.QuadPart);

		Reset();
	}

	float32 GameTimer::PlayingTime()
	{
		if (m_active)
		{
			// The distance m_currentTime - m_baseTime includes paused time,
			// which we do not want to count.  To correct this, we can subtract
			// the paused time from m_currentTime:
			return static_cast<float32>(((m_currentTime.QuadPart - m_pausedTime.QuadPart) - m_baseTime.QuadPart)*m_secondsPerCount);
		}
		else
		{
			// The clock is currently not running so don't count the time since
			// the clock was stopped
			return static_cast<float32>(((m_stopTime.QuadPart - m_pausedTime.QuadPart) - m_baseTime.QuadPart)*m_secondsPerCount);
		}
	}

	void GameTimer::PlayingTime(_In_ float32 time)
	{
		// Reset the internal state to reflect a PlayingTime of 'time'
		// Offset the baseTime by this 'time'.

		m_baseTime.QuadPart = m_stopTime.QuadPart - static_cast<__int64>(time / m_secondsPerCount);
	}

	float32 GameTimer::DeltaTime()
	{
		return m_deltaTime;
	}

	void GameTimer::Reset()
	{
		LARGE_INTEGER currentTime;

		if (!QueryPerformanceCounter(&currentTime))
		{
			//g_pLogfile->Textout(RED, false, "QueryPreformanceFrequency FAILED <currentTime>");
		}
		m_baseTime = currentTime;
		m_previousTime = currentTime;
		m_stopTime = currentTime;
		m_currentTime = currentTime;
		m_pausedTime.QuadPart = 0;
		m_active = false;
	}

	void GameTimer::Start()
	{
		LARGE_INTEGER startTime;

		if (!QueryPerformanceCounter(&startTime))
		{
			//g_pLogfile->Textout(RED, false, "QueryPreformanceFrequency FAILED <startTime>");
		}
		if (!m_active)
		{
			// Accumulate the time elapsed between stop and start pairs.
			m_pausedTime.QuadPart += (startTime.QuadPart - m_stopTime.QuadPart);

			m_previousTime = startTime;
			m_stopTime.QuadPart = 0;
			m_active = true;
		}
	}

	void GameTimer::Stop()
	{
		if (m_active)
		{
			// Set the stop time to the time of the last update.
			m_stopTime = m_currentTime;
			m_active = false;
		}
	}

	void GameTimer::Update()
	{
		if (!m_active)
		{
			m_deltaTime = 0.0;
			return;
		}

		LARGE_INTEGER currentTime;

		if (!QueryPerformanceCounter(&currentTime))
		{
			//g_pLogfile->Textout(RED, false, "QueryPreformanceFrequency FAILED <currentTime>");
		}
		m_currentTime = currentTime;

		m_deltaTime = (m_currentTime.QuadPart - m_previousTime.QuadPart)*m_secondsPerCount;
		m_previousTime = m_currentTime;

		if (m_deltaTime < 0.0)
		{
			m_deltaTime = 0.0;
		}
	}
}//namespace WOtech<commit_msg>fixed variable initialisation<commit_after>////////////////////////////////////////////////////////////////////////////
///
///			WraithOne tech Engine
///
///			https://github.com/WraithOne/WOtech
///			by https://twitter.com/WraithOne
///
///			File: Gametimer.cpp
///
///			Description:
///
///			Created:	12.05.2014
///			Edited:		06.11.2016
///
////////////////////////////////////////////////////////////////////////////

//////////////
// INCLUDES //
//////////////
#include "pch.h"
#include "GameTimer.h"

namespace WOtech
{
	GameTimer::GameTimer() : m_active(false), m_secondsPerCount(0.0f), m_deltaTime(0.0f)
	{
		LARGE_INTEGER frequency;

		if (!QueryPerformanceFrequency(&frequency))
		{
			//g_pLogfile->Textout(RED, false, "QueryPreformanceFrequency FAILED <frequency>");
		}
		m_secondsPerCount = 1.0f / static_cast<float32>(frequency.QuadPart);

		Reset();
	}

	float32 GameTimer::PlayingTime()
	{
		if (m_active)
		{
			// The distance m_currentTime - m_baseTime includes paused time,
			// which we do not want to count.  To correct this, we can subtract
			// the paused time from m_currentTime:
			return static_cast<float32>(((m_currentTime.QuadPart - m_pausedTime.QuadPart) - m_baseTime.QuadPart)*m_secondsPerCount);
		}
		else
		{
			// The clock is currently not running so don't count the time since
			// the clock was stopped
			return static_cast<float32>(((m_stopTime.QuadPart - m_pausedTime.QuadPart) - m_baseTime.QuadPart)*m_secondsPerCount);
		}
	}

	void GameTimer::PlayingTime(_In_ float32 time)
	{
		// Reset the internal state to reflect a PlayingTime of 'time'
		// Offset the baseTime by this 'time'.

		m_baseTime.QuadPart = m_stopTime.QuadPart - static_cast<__int64>(time / m_secondsPerCount);
	}

	float32 GameTimer::DeltaTime()
	{
		return m_deltaTime;
	}

	void GameTimer::Reset()
	{
		LARGE_INTEGER currentTime;

		if (!QueryPerformanceCounter(&currentTime))
		{
			//g_pLogfile->Textout(RED, false, "QueryPreformanceFrequency FAILED <currentTime>");
		}
		m_baseTime = currentTime;
		m_previousTime = currentTime;
		m_stopTime = currentTime;
		m_currentTime = currentTime;
		m_pausedTime.QuadPart = 0;
		m_active = false;
	}

	void GameTimer::Start()
	{
		LARGE_INTEGER startTime;

		if (!QueryPerformanceCounter(&startTime))
		{
			//g_pLogfile->Textout(RED, false, "QueryPreformanceFrequency FAILED <startTime>");
		}
		if (!m_active)
		{
			// Accumulate the time elapsed between stop and start pairs.
			m_pausedTime.QuadPart += (startTime.QuadPart - m_stopTime.QuadPart);

			m_previousTime = startTime;
			m_stopTime.QuadPart = 0;
			m_active = true;
		}
	}

	void GameTimer::Stop()
	{
		if (m_active)
		{
			// Set the stop time to the time of the last update.
			m_stopTime = m_currentTime;
			m_active = false;
		}
	}

	void GameTimer::Update()
	{
		if (!m_active)
		{
			m_deltaTime = 0.0;
			return;
		}

		LARGE_INTEGER currentTime;

		if (!QueryPerformanceCounter(&currentTime))
		{
			//g_pLogfile->Textout(RED, false, "QueryPreformanceFrequency FAILED <currentTime>");
		}
		m_currentTime = currentTime;

		m_deltaTime = (m_currentTime.QuadPart - m_previousTime.QuadPart)*m_secondsPerCount;
		m_previousTime = m_currentTime;

		if (m_deltaTime < 0.0)
		{
			m_deltaTime = 0.0;
		}
	}
}//namespace WOtech
{'fraction_non_alphanumeric': 0.17414166408908135, 'fraction_numerical': 0.012991030003093103, 'mean_word_length': 2.819846426461902, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2600025', 'n_tokens_mistral': 2555, 'n_tokens_neox': 2228, 'n_words': 445}