Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(gameclient): scoreboard shows income per second under per minute
Olcay Seygandfc273f18c50
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 59122e7e5..50dfb99e3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -727,6 +727,7 @@ found and fixed — EA's own, not port damage.**- Hold Tab and a scoreboard opens in the top left corner of the screen, beside the menu key; let go and it is gone. All eight seats of a full game fit in the top half of a 720 line screen. It is built from your command bar's steel, grey, red or sand for your side, with the match clock in its corner. Each side sits under a band edged green for yours and red for the enemy, and the band says how many of that side are still in the game, 4/4 down to 0/4. Watching, there is a band for every team. With a group selected, Tab still steps through the units in it as before, so the scoreboard wants one unit or none selected.- Every row on your side opens on a stripe of that player's colour, then the general's flag, the player's name and the general under it. Then rank, money in the bank, income per minute, kills and losses, every promotion bought, once, at the level it has reached, and the unit that player has built the most of. Numbers line up on their last digit, and your own row is lit.+- Under income per minute sits a smaller figure, what that player earned a second over the last half minute. The per-minute number is the average of the whole match, and ten minutes in a lost supply line hardly moves it. The small one falls within half a minute of the trucks stopping, and climbs again once a new line starts paying.- Names are written in white and the player's colour goes on the stripe. Dark red on a black panel measured about 2 to 1 and could barely be read. A player who is out goes grey.- An enemy row is a colour, a name and a team and nothing more. What they are playing and what they have in the bank is theirs to know.- Watching a match, everybody gets the full row, with a team column to say who is with whom.diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex 66fa10592..c475fb3e0 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -1223,6 +1223,10 @@ GUI:ScoreboardPerMinute"PER MIN"END+GUI:ScoreboardPerSecond+"PER SEC"+END+GUI:ScoreboardKills"K"ENDdiff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex 48c20e230..61d815446 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -15741,6 +15741,10 @@ GUI:ScoreboardPerMinute"DAKİKADA"END+GUI:ScoreboardPerSecond+"SANİYEDE"+END+GUI:ScoreboardKills"K"ENDdiff --git a/GeneralsMD/Code/Data/Window/Html/Scoreboard.html b/GeneralsMD/Code/Data/Window/Html/Scoreboard.htmlindex 72802e095..5df44f93b 100644--- a/GeneralsMD/Code/Data/Window/Html/Scoreboard.html+++ b/GeneralsMD/Code/Data/Window/Html/Scoreboard.html@@ -12,7 +12,8 @@{{label}}, {{standing}} of {{seats}} still in, and {{side}} "allies", "enemies" or "team";then its seats, {{kind}} "seat" with {{name}} {{color}} {{team}} and {{state}}: "full" or"hidden", plus " own" on your own seat and " defeated" once a seat is out. A full seat also- has {{portrait}} {{general}} {{rank}} {{cash}} {{income}} {{kills}} {{losses}}, its promotions+ has {{portrait}} {{general}} {{rank}} {{cash}} {{income}}, the match's average a minute, with+ {{persecond}} under it, what it earned a second over the last half minute, {{kills}} {{losses}}, its promotionsas {{skill0}} to {{skill6}}, and {{favourite}} with {{favouritename}}, the unit built most.A hidden seat is an enemy: a name, a colour and a team, nothing else.Every seat has its five soonest superweapons as {{w0.image}} {{w0.time}} {{w0.state}} to@@ -81,6 +82,11 @@.seatrow .team { color: #c9d2d9; font-size: 8px; }.seatrow .num { font-weight: bold; color: #f1f4f6; }.seatrow .cash { color: #e8d27a; }+ /* the income cell stacks the match's average a minute over what it earns a second now, the way+ the name stacks over the general, and its caption stacks the two words the same way */+ .seatrow .income { top: 2px; line-height: 10px; }+ .seatrow .persecond { position: absolute; top: 12px; line-height: 8px; font-size: 7px; text-align: right; color: #c9d2d9; }+ .captions .c-income { line-height: 8px; }.seatrow .skill { position: absolute; top: 4px; width: 13px; height: 13px; }.seatrow .favourite { position: absolute; top: 3px; width: 18px; height: 15px; }.hidden .tray, .hidden .num, .hidden .skill, .hidden .favourite, .hidden .general { display: none; }@@ -114,7 +120,7 @@<span class="c-team">{{text:GUI:ScoreboardTeam}}</span><span class="c-rank">{{text:GUI:ScoreboardLevel}}</span><span class="c-cash">{{text:GUI:ScoreboardMoney}}</span>- <span class="c-income">{{text:GUI:ScoreboardPerMinute}}</span>+ <span class="c-income">{{text:GUI:ScoreboardPerMinute}}<br>{{text:GUI:ScoreboardPerSecond}}</span><span class="c-kills">{{text:GUI:ScoreboardKills}}</span><span class="c-losses">{{text:GUI:ScoreboardDeaths}}</span><span class="c-skills">{{text:GUI:ScoreboardPowers}}</span>@@ -131,7 +137,8 @@<span class="cell team c-team">{{team}}</span><span class="cell num c-rank">{{rank}}</span><span class="cell num cash c-cash">{{cash}}</span>- <span class="cell num c-income">{{income}}</span>+ <span class="cell num income c-income">{{income}}</span>+ <span class="num persecond c-income">{{persecond}}</span><span class="cell num c-kills">{{kills}}</span><span class="cell num c-losses">{{losses}}</span><img class="skill" src="{{skill0}}" style="left: 370px">diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex 6a07b5776..ecbebaf3e 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -421,6 +421,8 @@ public: // ********************************************************************/** The steel frames over one grid's buttons, from Window/Html/ControlBar.html, drawn after them. */void drawCellGridFront( Int grid );void drawScoreboard( void ); ///< that scoreboard, over everything+ void sampleEarnings( void ); ///< every player's money earned, once a game second+ Int earnedPerSecond( Int playerIndex ) const; ///< what that player earned a second over the readings held/** Window/Html/Tooltip.html is there to draw with, in a match. */Bool isTooltipPageReady( void );/** The tooltip page: the command bar's build tooltip over the hovered button while one is up,@@ -1228,6 +1230,21 @@ protected:HtmlOverlay * m_scoreboardOverlay;Bool m_scoreboardPageLoaded; ///< read once a match, like the spectator's pagestd::string m_scoreboardPage;+ // The last half minute of every player's money earned, one reading a game second, oldest first, so+ // a seat can say what it earns now beside its average over the match. The reading's own second+ // goes with it: a pass that runs several logic frames at once skips seconds.+ struct EarnedReading+ {+ UnsignedInt second;+ Int earned[ MAX_PLAYER_COUNT ];+ };+ enum+ {+ EARNINGS_WINDOW_SECONDS = 30, ///< what the per second figure is measured over+ EARNINGS_READINGS = EARNINGS_WINDOW_SECONDS + 1 ///< a reading at each end of that window and every second between+ };+ EarnedReading m_earnedReadings[ EARNINGS_READINGS ];+ Int m_earnedReadingCount; ///< how many of those hold a readingHtmlOverlay * m_controlBarOverlay;Bool m_controlBarPageLoaded;Bool m_controlBarPageShown; ///< drawn this frame, so its buttons can be clickeddiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 39e3668ee..c1a452941 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -1204,6 +1204,7 @@ InGameUI::InGameUI()m_scoreboardOpen = FALSE;m_scoreboardOverlay = NULL;m_scoreboardPageLoaded = FALSE;+ m_earnedReadingCount = 0;m_controlBarOverlay = NULL;m_controlBarPageLoaded = FALSE;m_promotionOverlay = NULL;@@ -3990,6 +3991,8 @@ void InGameUI::update( void )sendLocalAllyCursor();updateAllyCursors();+ sampleEarnings();+} // end update//-------------------------------------------------------------------------------------------------@@ -4020,6 +4023,7 @@ void InGameUI::reset( void )m_isQuitMenuVisible = FALSE;m_scoreboardOpen = FALSE;m_scoreboardPageLoaded = FALSE;+ m_earnedReadingCount = 0; // a new match and a loaded save both come through herem_controlBarPageLoaded = FALSE;m_tooltipPageLoaded = FALSE;m_promotionPageLoaded = FALSE;@@ -10177,9 +10181,51 @@ static UnicodeString scoreboardTeamLabel( const GameSlot *slot )static const char *const SCOREBOARD_PAGE = "Window\\Html\\Scoreboard.html";enum { SCOREBOARD_SKILLS_SHOWN = 7 }; ///< promotions on one row, each once at the level it has reached+//-------------------------------------------------------------------------------------------------+/** Every player's money earned so far, read on the first pass of each game second. Reading the+ * score keeper is all it does, so nothing here reaches the logic. */+//-------------------------------------------------------------------------------------------------+void InGameUI::sampleEarnings( void )+{+ if( !TheGameLogic->isInGame() || TheGameLogic->isInShellGame() )+ return;++ const UnsignedInt second = TheGameLogic->getFrame() / LOGICFRAMES_PER_SECOND;+ if( m_earnedReadingCount > 0 && second == m_earnedReadings[ m_earnedReadingCount - 1 ].second )+ return;++ // full, the oldest reading drops off the front+ if( m_earnedReadingCount == EARNINGS_READINGS )+ std::copy( m_earnedReadings + 1, m_earnedReadings + EARNINGS_READINGS, m_earnedReadings );+ else+ m_earnedReadingCount++;++ EarnedReading &newest = m_earnedReadings[ m_earnedReadingCount - 1 ];+ newest.second = second;+ for( Int index = 0; index < ThePlayerList->getPlayerCount(); index++ )+ newest.earned[ index ] = ThePlayerList->getNthPlayer( index )->getScoreKeeper()->getTotalMoneyEarned();+}++//-------------------------------------------------------------------------------------------------+/** Money a player earned a second between the oldest reading held and the newest, rounded; 0+ * until there are two. It is shared over the whole half minute even before the readings reach+ * back that far, so the first truck of a match reads as a trickle rather than a fortune. */+//-------------------------------------------------------------------------------------------------+Int InGameUI::earnedPerSecond( Int playerIndex ) const+{+ if( m_earnedReadingCount < 2 )+ return 0;++ const EarnedReading &oldest = m_earnedReadings[ 0 ];+ const EarnedReading &newest = m_earnedReadings[ m_earnedReadingCount - 1 ];+ const Int seconds = max( (Int)( newest.second - oldest.second ), (Int)EARNINGS_WINDOW_SECONDS );+ return ( newest.earned[ playerIndex ] - oldest.earned[ playerIndex ] + seconds / 2 ) / seconds;+}+/** One seat on the scoreboard page. `full` is whether the local player may see the numbers: his- * own side, or everybody when watching. An enemy is a name, a colour and a team. */-static HtmlValues scoreboardSeat( Player *player, const GameSlot *slot, Bool full, Bool own )+ * own side, or everybody when watching. An enemy is a name, a colour and a team. `perSecond` is+ * what the seat has earned a second lately, beside {{income}}, its average over the match. */+static HtmlValues scoreboardSeat( Player *player, const GameSlot *slot, Bool full, Bool own, Int perSecond ){const PlayerTemplate *side = player->getPlayerTemplate();const Image *portrait = side ? side->getEnabledImage() : NULL;@@ -10202,6 +10248,7 @@ static HtmlValues scoreboardSeat( Player *player, const GameSlot *slot, Bool fulseat[ "rank" ] = std::to_string( player->getRankLevel() );seat[ "cash" ] = std::to_string( player->getMoney()->countMoney() );seat[ "income" ] = std::to_string( frame > 0 ? (Int)( (Int64)score->getTotalMoneyEarned() * FRAMES_PER_MINUTE / frame ) : 0 );+ seat[ "persecond" ] = std::to_string( perSecond );seat[ "kills" ] = std::to_string( score->getTotalUnitsDestroyed() + score->getTotalBuildingsDestroyed() );seat[ "losses" ] = std::to_string( score->getTotalUnitsLost() + score->getTotalBuildingsLost() );@@ -10355,7 +10402,7 @@ void InGameUI::drawScoreboard( void )for( ; first < end; first++ ){HtmlValues row = scoreboardSeat( seats[ first ].player, seats[ first ].slot, watching || seats[ first ].section == 0,- seats[ first ].player == local );+ seats[ first ].player == local, earnedPerSecond( seats[ first ].player->getPlayerIndex() ) );putSeatSuperweapons( row, seats[ first ].player->getPlayerIndex(), m_spectatorSuperweapons );rows.push_back( row );}