From dd0be765ea09542db90c67c4784131792db6f93b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Mustoha?= Date: Mon, 15 Apr 2024 23:06:15 +0200 Subject: [PATCH] Cleaned the score code --- src/common/Score.h | 104 ++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 62 deletions(-) diff --git a/src/common/Score.h b/src/common/Score.h index 4981989f2..1f2532681 100644 --- a/src/common/Score.h +++ b/src/common/Score.h @@ -1,77 +1,57 @@ -#ifndef SCORE_H -#define SCORE_H +#pragma once -class CScore -{ - public: - CScore(short iPlace) { - place = iPlace; - displayorder = iPlace; +#include - score = 0; - for (short iSubScore = 0; iSubScore < 3; iSubScore++) - subscore[iSubScore] = 0; +class CScore { +public: + CScore(short iPlace) + : place(iPlace) + , displayorder(iPlace) + { + subscore.fill(0); + } - x = 0; - y = 0; - destx = 0; - desty = 0; - order = 0; - fromx = 0; - fromy = 0; - iDigitRight = 0; - iDigitMiddle = 0; - iDigitLeft = 0; - } + void AdjustScore(short iValue); - ~CScore() {} + void SetScore(short iValue) { + score = iValue; + SetDigitCounters(); + } - void AdjustScore(short iValue); + //keeps track of what the actual score value is + short score = 0; - void SetScore(short iValue) { - score = iValue; - SetDigitCounters(); - } + //keeps track of other scoring elements for some games (health, collected cards, etc) + std::array subscore; - //keeps track of what the actual score value is - short score; + //Where to display score + short x = 0; + short y = 0; - //keeps track of other scoring elements for some games (health, collected cards, etc) - short subscore[3]; + short destx = 0; + short desty = 0; - //Where to display score - short x; - short y; + short place = 0; + short displayorder = 0; + short order = 0; //the order in which the team died - short destx; - short desty; + short fromx = 0; + short fromy = 0; - short place; - short displayorder; - short order; //the order in which the team died + //One less array dereference doing vars like this + short iDigitRight = 0; + short iDigitMiddle = 0; + short iDigitLeft = 0; - short fromx; - short fromy; +private: + void SetDigitCounters() { + short iDigits = score; + while (iDigits > 999) + iDigits -= 1000; - //One less array dereference doing vars like this - short iDigitRight; - short iDigitMiddle; - short iDigitLeft; - - private: - - void SetDigitCounters() { - short iDigits = score; - while (iDigits > 999) - iDigits -= 1000; - - iDigitLeft = iDigits / 100 * 16; - iDigitMiddle = iDigits % 100 / 10 * 16; - iDigitRight = iDigits % 10 * 16; - } - - //friend class CGM_Star; + iDigitLeft = iDigits / 100 * 16; + iDigitMiddle = iDigits % 100 / 10 * 16; + iDigitRight = iDigits % 10 * 16; + } }; - -#endif // SCORE_H