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): white bar only for production and superweapons
Olcay Seygan6f3dc39c4c6f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5c7fef5a8..7c066d239 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -138,7 +138,7 @@ found and fixed — EA's own, not port damage.**- A slow moment costs you a dropped frame, not a slow game.- Explosions no longer catch the picture. The first time each kind of fire, smoke or blast reached the screen, the game stopped for 25 to 60ms to prepare it, and the opening volley of a fight cost 300ms at once. That work is kept on disk and ships with the game, so it happens while the map loads, in about 3ms, and the worst frame of the same battle went from 141ms to 38ms.- The price, build time and power figures on the command bar buttons stopped costing you frames. All the buttons shared one piece of text, so every figure on the bar was lettered from scratch every frame, about 33 of them. Each now keeps its own: a battle that averaged 14ms a frame averages 11.7ms, frames slower than 60 a second went from one in six to one in a hundred, and the old renderer gets about 0.8ms back too. The money readout was lettered again every frame as well, for a number that had not changed; it is lettered when the number moves. Over a whole battle the game now letters 163 pieces of text where it lettered 68,227.-- The seconds over a building that is producing, or over one counting down to a payout, were lettered from one shared line. Every building in view with a different time left had that line made again, every frame. Each building keeps its own, and it is made again only when the second changes. Twelve supply zones counting together, 1,200 frames: 313 letters, where the shared line wrote 6,181. The frame stayed at 8.6ms.+- The seconds over a building that is producing, or over a superweapon charging, were lettered from one shared line. Every building in view with a different time left had that line made again, every frame. Each building keeps its own, and it is made again only when the second changes. Twelve supply zones counting together, 1,200 frames: 313 letters, where the shared line wrote 6,181. The frame stayed at 8.6ms.- The new command bar stopped eating half the frame. The clock and the frame counter in the top right corner sat inside the bar's own page, so every tick of them had the whole bar laid out again from scratch, 15ms a time and thirty times a second. The corner box is a page of its own now, the scoreboard counts again twice a second instead of every frame, and a click on the battlefield no longer lays the bar out twice. In the same four-player battle, almost half the frames used to miss 60 a second; now fewer than one in four hundred do, and the game draws more than twice as many frames. When the bar does have to be laid out again, on a hover, a click on it or the scoreboard's twice-a-second count, it takes 2ms where it took 14: the page engine was building an object for every word of the bar's style sheet and every space of its indenting, and reading the same style sheet from scratch each time. All ten pages were laid out both ways and every box and every word came out in the same place, size and colour.- A screen full of fire and smoke is cheaper to draw. Thirty Inferno Cannons shelling twenty Crusaders used to send the graphics card 459 separate batches of see-through effects a frame, mostly the same texture again and again, and the game looked up the same seven card settings from scratch for every one of them. Matching effects go out together now, and settings that have not changed are not looked up again: 177 batches, and the same battle went from 11.6ms a frame to 8.6ms. It is at 6.7ms now, since the game stopped preparing everything it draws a second time for a copy of the picture nobody sees. Nothing on screen changes, the effects are drawn in exactly the order they were.- The same battle with the particle limit turned up costs 7.6ms a frame where it cost 9.1ms, and the old renderer went from 9.3ms to 6.3ms. Both were keeping a count of every kind of draw the game makes, and both did it by writing out and reading back a description of each one, on every draw, for a report no player ever opens. They glance at one draw in sixteen now. The new renderer also stopped re-sending the graphics card settings it had just sent.@@ -887,16 +887,15 @@ A third pass went through the generals' powers, promotions and unit abilities.- Supply piles and docks say what is left in them, in cash, over the pile. No more guessing which expansion is worth taking from the art on the model. Point at a pile and the tooltip puts a percentage beside the cash: what is left of what the pile started with.- Every build button carries its price in the top right corner, opposite the build time already in the other one. It was only ever in the tooltip, which means hovering one button at a time to compare two of them.- A structure's button says what it does to the power grid, in the fourth corner: what it draws, or what a plant puts back. Money and time were already on the button and power is the third thing a base spends; it was the one figure you had to hover for, which is the wrong way round for the building you are putting up because the lights went out.-- A worker fetching or handing over a box shows a bar while it works.-- That bar is now the work itself. A worker used to reset it to empty at the very moment it finished and then walk away, so every trip looked like it left mid-handover; and after taking its last box it stood at the pile for one more full loading cycle, taking nothing. It leaves the instant the load is done - which is a little more money per trip, on every worker you own.-- A worker loads in one go instead of a box at a time. It used to take one, wait a loading cycle, take the next, wait again, and the bar over its head restarted for each of them; now the whole load changes hands once and the wait is that load's worth of time - four boxes cost what four boxes always cost, in one stretch rather than four. Money in the bank is unchanged, which is the point: three headless matches on the same seeds came back within a few percent of what they earned before.+- A worker leaves a supply pile the instant its load is done. After taking its last box it used to stand at the pile for one more full loading cycle, taking nothing. Every worker you own now brings in a little more money per trip.+- A worker loads in one go instead of a box at a time. It used to take one, wait a loading cycle, take the next, wait again; now the whole load changes hands once and the wait is that load's worth of time - four boxes cost what four boxes always cost, in one stretch rather than four. Money in the bank is unchanged, which is the point: three headless matches on the same seeds came back within a few percent of what they earned before.- A GLA worker can no longer mint money standing still. Build a stash as close to a supply pile as the game allows and a worker could end up in the gap between them, touching both. It loaded at the pile and unloaded at the stash without taking a step, a $75 box every second, and the popups stacked over its head. Every hand-over now waits until a worker could have walked the gap, so that worker earns what a worker walking the shortest trip earns: with a stash hugging a pile, two workers brought in 101 boxes in a minute before and 50 now. Workers that do walk are untouched; a stash placed so they have to earned exactly the same, box for box, before and after.- The three sides now mine a supply pile at the same pace. With five GLA workers, three Chinese supply trucks and three Chinooks on one pile, GLA used to bring in 90 dollars a second with the stash beside it and 27 with the stash 250 feet away, China 56 and 47, and the USA 55 at both. Now all three earn between 49 and 60 a second, close or far. A GLA worker carries three boxes a trip and takes longer loading them, a Chinese truck carries six, and the Chinook is untouched. Worker Shoes is now speed alone, with no extra dollars a box: with the old bonus on top of three-box loads, five upgraded workers made 72 a second beside the pile against 60 for three Chinooks with Supply Lines. Now they make 66 beside it and 61 at 250 feet. Replays recorded before this change play out differently.- Supply points refill themselves, slowly, and faster the more of a base has grown around them. A warehouse used to be a fixed lump of money that ran out and left the map with nothing to fight over: whoever mined out the middle first had the game, and the second half of every match was played on income neither side could earn any more. Six hundred dollars comes back every forty seconds standing on its own, every twenty with one supply centre built near it, every thirteen with two - up to what the point started with, never past it. A single box was too little to be worth the trip: a hundred dollars every forty seconds is less than the harvester earns going to fetch it, so a mined-out point stayed mined out as far as anybody playing was concerned. Both sides expanding onto the same patch make it richer and then have to decide which of them keeps it.- Your workers tell you a supply point has run dry once a match. With piles refilling, they ran dry again and again, and every time the same worker said so.- Workers stop hesitating on their way in and out. A dock has a queue outside it and a worker treated its place in that queue as a destination: it drove to the spot, stopped dead, waited a frame, drove to the door, stopped again, and only then went in - twice a load, and nearly every load with nothing else queued. With the dock empty it drives straight in. The first version of that also skipped the walk to a supply pile or a GLA stash, which have no door of their own, so a worker a long way off played its loading animation where it stood and was paid anyway. In a four-player test match 72 loads were picked up or dropped off away from the dock, one of them 613 feet from it; now there are none.- Workers leave other players' supply piles alone. A truck whose pile ran dry went to the nearest pile it could reach, and that was often the one next to a neighbour's supply centre, where it either stood in his queue or stood idle beside the pile with nowhere of its own to carry the boxes. A pile now belongs to whoever has the closest supply centre beside it, and your trucks, Chinooks and workers only pick their own or a free one. The computer counts those piles out too, so it no longer buys trucks for a neighbour's supplies. Across two 4v4 matches on Twilight Flame, trucks were sent to someone else's pile 109 times; now none are, and the money mined stayed within about one percent. A truck you send to a pile yourself still goes where you sent it.-- Hackers show how far off the next payout is. So do the black market and the oil derricks.+- The white bar over a building's health bar means one of two things: a factory working through its queue, or a superweapon charging. Oil derricks, the black market, supply drop zones, hackers and workers carried one too, each on a money clock nobody can hurry, and a base full of them buried the two bars worth reading. They wear only their health bar now.- A hacker already at work stays at work when you tell a group of hackers to hack. It used to fold its laptop away and set it up again, and the payout it was halfway to started over from nothing. One that is packing up takes the order and unpacks again. Replays recorded before this change play out differently.- A hacker working from inside an Internet Center shows what it earns. The green figure floats over the building on every payout, the way it does over one sitting in the field. It never appeared, because the game asked the hacker whether it could be seen and a garrisoned unit is not drawn at all - which is the one place a hacker is meant to work.- Factories take a hundred units in the queue, not nine. The build queue only ever had nine buttons and that had become the limit.@@ -917,7 +916,7 @@ A third pass went through the generals' powers, promotions and unit abilities.- A building's bar sits above its roof rather than inside its art.- A unit that is inside a transport and also disabled wears the blue bar. Being carried and being knocked out were asked as one question, so the two together answered no: a squad EMP'd inside a bunker, or hacked while riding a Battle Bus, looked perfectly healthy from outside.- A building being captured wears a capture clock under its health bar, filling in the colour of whoever is taking it. The building flashes while a rifleman works on it, which says somebody is at the door and nothing about whether that is nearly over: the choice between driving across to shoot him and carrying on with your fight was made blind. The bar runs from the moment he reaches the door to the moment the building changes hands, and Black Lotus hacking one gets the same bar.-- The progress bar stacked over the health bar is white, wherever it turns up - a factory turning out a tank, a silo charging, a supply drop counting down to its payout. It was yellow, which is a colour the game already spends on your own units and on damage, and a strip of it sitting directly above a coloured health bar read as part of the same bar.+- The progress bar stacked over the health bar is white, on a factory turning out a tank and on a silo charging. It was yellow, which is a colour the game already spends on your own units and on damage, and a strip of it sitting directly above a coloured health bar read as part of the same bar.- A slow gun shows when it can fire again. A Nuke Cannon sat still for ten seconds after every shell with nothing on screen to say when the next would come. Now an amber bar over the health bar fills through the reload, on your own unit while it is selected or under the pointer. Only a gun that fires slower than one shot in three seconds gets one: every tank gun in the game reloads in about two, and a bar that empties before you can read it is noise. The Nuke Cannon, the Inferno Cannon, the artillery platform, SCUD and Tomahawk launchers, the Scorpion's missile and the Comanche's anti-tank missiles wear it.- The reload bar stays off the quick shooters. It used to go up whenever a wait ran past three seconds, and a reload after a fast clip does that too: a Paladin that zapped one infantryman with its point defence laser wore the bar for the next four seconds, and so did a Rocket Buggy after every volley and a Comanche after its rocket pods. Those fire about as often as a tank does, so the bar now goes by how many shots a gun gets off in a minute, reload included.- A Dozer clearing mines no longer wears the reload bar. Its scoop takes four seconds between mines, which counted as a slow gun, so the bar came up over every Dozer sweeping a minefield as if it were waiting to fire. Clearing mines is not firing, and the Worker's clearing goes without the bar too.diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cppindex 852c3bd16..4c6156b59 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp@@ -55,7 +55,6 @@#include "GameLogic/ExperienceTracker.h"#include "GameLogic/GameLogic.h" // for logic frame count#include "GameLogic/Object.h"-#include "GameLogic/Module/OCLUpdate.h"#include "GameLogic/Module/SpecialPowerModule.h"#include "Common/SpecialPower.h"// countdown text over a building@@ -65,9 +64,6 @@#include "GameLogic/Module/ContainModule.h"#include "GameLogic/Module/PhysicsUpdate.h"#include "GameLogic/Module/ProductionUpdate.h"-#include "GameLogic/Module/AutoDepositUpdate.h"-#include "GameLogic/Module/HackInternetAIUpdate.h"-#include "GameLogic/Module/SupplyTruckAIUpdate.h"#include "GameLogic/Module/SupplyWarehouseDockUpdate.h"#include "Common/Upgrade.h"#include "GameLogic/Module/StealthUpdate.h"@@ -4818,8 +4814,8 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)}//- // A superweapon charging, or a building on a timed payout (the supply drop zone), gets the- // same white bar the production queue uses - stacked above it rather than on top of it,+ // A superweapon charging gets the same white bar the production queue uses - stacked above+ // it rather than on top of it,// which is what a Chinese nuclear silo researching an upgrade while its missile charges used// to draw: two bars and two countdowns in the same row of pixels. Only powers that carry a public timer count -// that is the flag the superweapon list in the corner goes by.@@ -4874,72 +4870,6 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)}}- if( chargePct < 0.0f )- {- static const NameKeyType key_OCLUpdate = NAMEKEY( "OCLUpdate" );- OCLUpdate *ocl = (OCLUpdate*)obj->findUpdateModule( key_OCLUpdate );- if( ocl != NULL )- {- //- // Both OCLUpdate accessors subtract frame numbers as UnsignedInt, so once the- // creation frame is behind us they wrap to something enormous rather than going- // negative. Clamping the bar hides that; the seconds would print it, so take the- // frame count only while the raw percentage is still inside its own range.- //- const Real rawPct = ocl->getCountdownPercent();-- chargePct = rawPct * 100.0f;- if( chargePct < 0.0f ) chargePct = 0.0f;- if( chargePct > 100.0f ) chargePct = 100.0f;-- if( rawPct >= 0.0f && rawPct < 1.0f )- chargeFramesLeft = ocl->getRemainingFrames();- }- }-- //- // Nothing charging? Then show what the thing is doing for a living instead: a worker- // fetching or handing over a box of supplies, a hacker waiting out the delay before the- // next payout, a black market or oil derrick on its deposit clock. All three of those- // are money arriving on a timer that the player had no way at all to see - the cash just- // appeared - and the worker one doubles as "yes, it really is working".- //- // No seconds are written over these: chargeFramesLeft is left at zero on purpose, the- // bar is the whole message.- //- if( chargePct < 0.0f )- {- Real workPct = -1.0f;-- AIUpdateInterface *ai = obj->getAIUpdateInterface();- if( ai != NULL )- {- SupplyTruckAIInterface *supply = ai->getSupplyTruckAIInterface();- if( supply != NULL )- workPct = supply->getDockActionProgress();-- if( workPct < 0.0f )- {- HackInternetAIInterface *hack = ai->getHackInternetAIInterface();- if( hack != NULL )- workPct = hack->getHackProgress();- }- }-- if( workPct < 0.0f )- {- static const NameKeyType key_autoDeposit = NAMEKEY( "AutoDepositUpdate" );- AutoDepositUpdate *deposit = (AutoDepositUpdate*)obj->findUpdateModule( key_autoDeposit );- if( deposit != NULL )- workPct = deposit->getDepositProgress();- }-- if( workPct > 1.0f )- workPct = 1.0f;- if( workPct >= 0.0f )- chargePct = workPct * 100.0f;- }-if( chargePct >= 0.0f ){Int chargeY = stackY - healthBoxHeight;@@ -4949,18 +4879,10 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)(healthBoxWidth - 2) * chargePct * 0.01f, healthBoxHeight - 2,GameMakeColor( 255, 255, 255, 255 ) );- //- // ... and how long that is, the same way a production bar says it. A bar filling up- // tells you something is coming; it does not tell you whether to wait for it. The- // supply drop zone is the one this matters most for - its whole job is a payout on- // a clock.- //- if( chargeFramesLeft > 0 )- drawOwnCountdown( m_chargeTimeDisplayString,- ControlBar_secondsFromFrames( INT_TO_REAL( chargeFramesLeft ) ),- healthBarRegion->lo.x, chargeY );- else- freeOwnCountdown( m_chargeTimeDisplayString );+ // ... and how long that is, the same way a production bar says it+ drawOwnCountdown( m_chargeTimeDisplayString,+ ControlBar_secondsFromFrames( INT_TO_REAL( chargeFramesLeft ) ),+ healthBarRegion->lo.x, chargeY );}elsefreeOwnCountdown( m_chargeTimeDisplayString );