From ccfe7fae694df85a025cbc7361e6fa17e959f08d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 25 Sep 2022 21:44:29 +0200 Subject: [PATCH] SAGA2: Rename class variables in gamerate.h --- engines/saga2/gamerate.h | 140 +++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/engines/saga2/gamerate.h b/engines/saga2/gamerate.h index e3aa2d79272..52478f52350 100644 --- a/engines/saga2/gamerate.h +++ b/engines/saga2/gamerate.h @@ -33,32 +33,32 @@ enum { }; class frameCounter { - uint32 ticksPerSecond; - uint32 lastTime; + uint32 _ticksPerSecond; + uint32 _lastTime; protected: - uint32 frames; - float instantFrameCount; + uint32 _frames; + float _instantFrameCount; public: frameCounter(uint32 perSec, uint32 now) { - ticksPerSecond = perSec; - frames = 0; - lastTime = now; - instantFrameCount = 0; + _ticksPerSecond = perSec; + _frames = 0; + _lastTime = now; + _instantFrameCount = 0; } virtual ~frameCounter() {} virtual void updateFrameCount() { - int32 frameTime = gameTime - lastTime; - lastTime = gameTime; - frames++; - instantFrameCount = frameTime ? ticksPerSecond / frameTime : 100; + int32 frameTime = gameTime - _lastTime; + _lastTime = gameTime; + _frames++; + _instantFrameCount = frameTime ? _ticksPerSecond / frameTime : 100; } virtual float frameStat(int statID = grFramesPerSecond) { - return instantFrameCount; + return _instantFrameCount; } virtual void whatDoYouKnow(char *buf) { @@ -87,65 +87,65 @@ enum { }; class frameSmoother: public frameCounter { - float desiredFPS; + float _desiredFPS; - uint32 historySize; - float *frameHistory; + uint32 _historySize; + float *_frameHistory; - float avg1Sec[5]; - float avg5Sec; - float secAvg; - float dif1Sec[5]; - float dif5Sec; - float secDif; + float _avg1Sec[5]; + float _avg5Sec; + float _secAvg; + float _dif1Sec[5]; + float _dif5Sec; + float _secDif; float ksHistory(int32 i) { - return 1000.0 * frameHistory[i]; + return 1000.0 * _frameHistory[i]; } void calculateAverages() { // clear averages for (int i = 0; i < 5; i++) - avg1Sec[i] = 0; + _avg1Sec[i] = 0; - avg5Sec = 0; + _avg5Sec = 0; // get totals - for (uint i = 0; i < historySize; i++) - avg1Sec[i / int(desiredFPS)] += ksHistory(i); + for (uint i = 0; i < _historySize; i++) + _avg1Sec[i / int(_desiredFPS)] += ksHistory(i); // get averages for (uint i = 0; i < 5; i++) { - avg5Sec += avg1Sec[i]; - avg1Sec[i] /= desiredFPS; + _avg5Sec += _avg1Sec[i]; + _avg1Sec[i] /= _desiredFPS; } // get broad averages - secAvg = avg5Sec / 5; - avg5Sec /= (5 * desiredFPS); + _secAvg = _avg5Sec / 5; + _avg5Sec /= (5 * _desiredFPS); } void calculateVariance() { // clear variances for (int i = 0; i < 5; i++) - dif1Sec[i] = 0; + _dif1Sec[i] = 0; - dif5Sec = 0; + _dif5Sec = 0; // get variance totals - for (uint i = 0; i < historySize; i++) { - dif1Sec[i / int(desiredFPS)] += ABS(ksHistory(i) - avg1Sec[i / int(desiredFPS)]); - dif5Sec += ABS(ksHistory(i) - avg5Sec); + for (uint i = 0; i < _historySize; i++) { + _dif1Sec[i / int(_desiredFPS)] += ABS(ksHistory(i) - _avg1Sec[i / int(_desiredFPS)]); + _dif5Sec += ABS(ksHistory(i) - _avg5Sec); } // get average variances for (uint i = 0; i < 5; i++) { - secDif += avg1Sec[i] - secAvg; - dif1Sec[i] /= desiredFPS; + _secDif += _avg1Sec[i] - _secAvg; + _dif1Sec[i] /= _desiredFPS; } // get broad variance - dif5Sec /= (5 * desiredFPS); + _dif5Sec /= (5 * _desiredFPS); } @@ -154,54 +154,54 @@ public: virtual ~frameSmoother() { - if (frameHistory) - delete[] frameHistory; + if (_frameHistory) + delete[] _frameHistory; - frameHistory = nullptr; + _frameHistory = nullptr; } virtual void updateFrameCount() { frameCounter::updateFrameCount(); - frameHistory[frames % historySize] = instantFrameCount; - if (0 == (frames % int(desiredFPS))) { + _frameHistory[_frames % _historySize] = _instantFrameCount; + if (0 == (_frames % int(_desiredFPS))) { calculateAverages(); calculateVariance(); } } virtual float frameStat(int statID = grFramesPerSecond) { - int oldestOffset = (frames % historySize) / desiredFPS; + int oldestOffset = (_frames % _historySize) / _desiredFPS; switch (statID) { case grFramesPerKilosecond : - return 1000 * instantFrameCount; + return 1000 * _instantFrameCount; case grFPKS1SecAvgNewest : - return avg1Sec[4 + oldestOffset]; + return _avg1Sec[4 + oldestOffset]; case grFPKS1SecAvgNew : - return avg1Sec[3 + oldestOffset]; + return _avg1Sec[3 + oldestOffset]; case grFPKS1SecAvg : - return avg1Sec[2 + oldestOffset]; + return _avg1Sec[2 + oldestOffset]; case grFPKS1SecAvgOld : - return avg1Sec[1 + oldestOffset]; + return _avg1Sec[1 + oldestOffset]; case grFPKS1SecAvgOldest : - return avg1Sec[0 + oldestOffset]; + return _avg1Sec[0 + oldestOffset]; case grFPKS5SecAvg : - return avg5Sec; + return _avg5Sec; case grFPKSAvg1SecAvg : - return secAvg; + return _secAvg; case grFPKS1SecVarNewest : - return dif1Sec[4 + oldestOffset]; + return _dif1Sec[4 + oldestOffset]; case grFPKS1SecVarNew : - return dif1Sec[3 + oldestOffset]; + return _dif1Sec[3 + oldestOffset]; case grFPKS1SecVar : - return dif1Sec[2 + oldestOffset]; + return _dif1Sec[2 + oldestOffset]; case grFPKS1SecVarOld : - return dif1Sec[1 + oldestOffset]; + return _dif1Sec[1 + oldestOffset]; case grFPKS1SecVarOldest : - return dif1Sec[0 + oldestOffset]; + return _dif1Sec[0 + oldestOffset]; case grFPKS5SecVar : - return dif5Sec; + return _dif5Sec; case grFPKSVar1SecAvg : - return secDif; + return _secDif; default: return frameCounter::frameStat(statID); } @@ -223,20 +223,20 @@ public: frameSmoother::frameSmoother(int32 fps, uint32 perSec, uint32 now) : frameCounter(perSec, now) { assert(fps); - desiredFPS = fps; - historySize = fps * 5; - frameHistory = new float[historySize]; + _desiredFPS = fps; + _historySize = fps * 5; + _frameHistory = new float[_historySize]; - for (uint32 i = 0; i < historySize; i++) - frameHistory[i] = 0; + for (uint32 i = 0; i < _historySize; i++) + _frameHistory[i] = 0; for (int i = 0; i < 5; i++) - dif1Sec[i] = avg1Sec[i] = 0; + _dif1Sec[i] = _avg1Sec[i] = 0; - dif5Sec = 0; - avg5Sec = 0; - secDif = 0; - secAvg = 0; + _dif5Sec = 0; + _avg5Sec = 0; + _secDif = 0; + _secAvg = 0; } } // end of namespace Saga2