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(radar): mark the money and the tech buildings on the minimap
Olcay Seyganb9ac107cb3ad
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2cee284ce..b4dcd8a58 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -383,6 +383,8 @@ found and fixed — EA's own, not port damage.**four brutal computers at 7,777 a minute, three of the four spent between 3,400 and 6,200 more inthe first three minutes and put the difference on the map.+- The minimap says where the money and the capturable buildings are, with the dollar and the star from the lobby map preview. Oil derricks, hospitals and repair pads never showed on it at all, and supply piles vanished with the rest of the map under the fog, so the two things worth walking a rifleman across the map for were the two things the minimap would not tell you about. They are marked from the first second now, on ground you have scouted and ground you have not, one mark per place rather than one per pile; a pile that runs dry drops off it.+## Health bars- You pick who wears one. `HealthBars` in `Options.ini` takes 0 for everyone, 1 for smart, 2 for the selection only and 3 for nobody. Smart is the one worth trying: a bar over a unit at full health tells you what its absence would have told you, so healthy units go bare and anything that has been hit stays marked, with whatever you have selected or are pointing at readable either way. 2 is what the original game did. The default is 0, so nothing changes until you change it.diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Radar.h b/GeneralsMD/Code/GameEngine/Include/Common/Radar.hindex 1ab8a1530..969b27fed 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/Radar.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/Radar.h@@ -149,6 +149,18 @@ static const char *RadarPriorityNames[] =};#endif // DEFINE_RADAR_PRIOTITY_NAMES+//-------------------------------------------------------------------------------------------------+/** The map furniture the radar marks out with an icon of its own: the money, and the buildings a+ * single infantryman takes rather than destroys. Neither of them moves and the lobby map+ * preview has already shown where the money is, so the icons are drawn over the shroud. */+//-------------------------------------------------------------------------------------------------+enum RadarLandmarkType+{+ RADAR_LANDMARK_NONE, ///< nothing the radar marks out+ RADAR_LANDMARK_SUPPLY, ///< a supply source: warehouse, dock or pile+ RADAR_LANDMARK_CAPTURABLE ///< a neutral tech building: derrick, hospital, refinery, pad+};+//-------------------------------------------------------------------------------------------------/** Interface for the radar *///-------------------------------------------------------------------------------------------------@@ -180,6 +192,9 @@ public:// priority inquiryBool isPriorityVisible( RadarPriorityType priority ) const; ///< is the priority passed in a "visible" one on the radar+ /// which landmark, if any, this object is on the radar+ static RadarLandmarkType landmarkTypeOf( const Object *obj );+// radar eventsvoid createEvent( const Coord3D *world, RadarEventType type, Real secondsToLive = 4.0f ); ///< create radar event at location in worldvoid createPlayerEvent( Player *player, const Coord3D *world, RadarEventType type, Real secondsToLive = 4.0f ); ///< create radar event using player colorsdiff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cppindex 98bf8a656..d6945e8f8 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp@@ -277,6 +277,28 @@ void Radar::clearAllEvents( void )} // end clearAllEvents+//-------------------------------------------------------------------------------------------------+/** Which landmark this object is, if it is one at all. Supply sources and the neutral tech+ * buildings decide who can afford an army, and both of them stand where the map maker put them+ * for the whole match, so the radar treats them as terrain rather than as contacts. */+//-------------------------------------------------------------------------------------------------+RadarLandmarkType Radar::landmarkTypeOf( const Object *obj )+{++ if( obj->isKindOf( KINDOF_SUPPLY_SOURCE ) )+ return RADAR_LANDMARK_SUPPLY;++ //+ // KINDOF_CAPTURABLE is on every faction structure as well, because Black Lotus takes those,+ // so it is the tech building kind that names the neutral ones a rifleman walks into.+ //+ if( obj->isKindOf( KINDOF_TECH_BUILDING ) )+ return RADAR_LANDMARK_CAPTURABLE;++ return RADAR_LANDMARK_NONE;++} // end landmarkTypeOf+//-------------------------------------------------------------------------------------------------/** Reset radar data *///-------------------------------------------------------------------------------------------------@@ -404,7 +426,20 @@ void Radar::addObject( Object *obj )// get the radar priority for this objectRadarPriorityType newPriority = obj->getRadarPriority();if( isPriorityVisible( newPriority ) == FALSE )- return;+ {++ //+ // TechOilDerrick and TechHospital name no RadarPriority at all, so the template default+ // leaves them off the radar entirely and the buildings the match is fought over are the+ // one thing the minimap never showed. A landmark whose template said nothing joins the+ // list at structure priority; NOT_ON_RADAR is a decision and is still obeyed.+ //+ if( newPriority != RADAR_PRIORITY_INVALID || landmarkTypeOf( obj ) == RADAR_LANDMARK_NONE )+ return;++ newPriority = RADAR_PRIORITY_STRUCTURE;++ } // end if// if this object is on the radar, remove it in favor of the new addRadarObject **list;diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.hindex 47125a37c..cf8728168 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h@@ -73,6 +73,15 @@ public:protected:+ /** One map landmark for the icon pass. Held by value for the same reason the hero positions+ * are: the list is rebuilt every OVERLAY_REFRESH_RATE frames and read on every one of them,+ * so a pointer into an object destroyed in between is a pointer into freed memory. */+ struct RadarLandmark+ {+ Coord3D position; ///< where it stands in the world+ RadarLandmarkType type; ///< which of the preview's two icons to draw+ };+void drawSingleBeaconEvent( Int pixelX, Int pixelY, Int width, Int height, Int index );void drawSingleGenericEvent( Int pixelX, Int pixelY, Int width, Int height, Int index );@@ -80,6 +89,10 @@ protected:void deleteResources( void ); ///< delete resources usedvoid drawEvents( Int pixelX, Int pixelY, Int width, Int height); ///< draw all of the radar eventsvoid drawHeroIcon( Int pixelX, Int pixelY, Int width, Int height, const Coord3D *pos ); //< draw a hero icon+ void drawLandmarkIcon( Int pixelX, Int pixelY, Int width, Int height,+ const RadarLandmark& landmark ); ///< draw one landmark marker+ void cacheLandmarks( void ); ///< rebuild the landmark list from both object lists+ void collectLandmarks( const RadarObject *listHead ); ///< add the landmarks of one list to the cachevoid drawViewBox( Int pixelX, Int pixelY, Int width, Int height ); ///< draw view boxvoid buildTerrainTexture( TerrainLogic *terrain ); ///< create the terrain texture of the radarvoid drawIcons( Int pixelX, Int pixelY, Int width, Int height ); ///< draw all of the radar icons@@ -124,6 +137,10 @@ protected:// frames and read on every one of them, so a hero killed in between left a pointer into a// deleted Object for the icon pass to read.std::list<Coord3D> m_cachedHeroPosList; //< cache of hero positions for drawing icons in radar overlay++ // the supply sources and neutral tech buildings, rebuilt on the same beat as the overlay and+ // drawn after the shroud image so a pile nobody has scouted is still on the map+ std::list<RadarLandmark> m_cachedLandmarkList;};diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cppindex 06fe3429c..99b8ea150 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp@@ -45,6 +45,7 @@#include "GameClient/GameWindow.h"#include "GameClient/Image.h"#include "GameClient/Line2D.h"+#include "GameClient/MapUtil.h"#include "GameClient/PlayerColorScheme.h"#include "GameClient/TerrainVisual.h"#include "GameClient/Water.h"@@ -64,6 +65,29 @@// PRIVATE DATA ///////////////////////////////////////////////////////////////////////////////////enum { OVERLAY_REFRESH_RATE = 6 }; ///< over updates once this many frames+//+// The lobby map preview has marked the money with a dollar coin and the tech buildings with a star+// since 2003 (`W3DControlBar.cpp`, "Cash" and "TecBuilding"), so the radar marks them with the same+// two images and a player who has read the preview needs to learn nothing.+//+static const char *const LANDMARK_SUPPLY_IMAGE_NAME = "Cash";+static const char *const LANDMARK_CAPTURE_IMAGE_NAME = "TecBuilding";++//+// The preview draws them at SUPPLY_TECH_SIZE, in a window several times the size of the radar.+// Scaled to the radar, the same icon covers a fifth of the map, so it is sized against the radar+// and clamped: below the minimum a dollar sign is a smudge, above the preview's own size there is+// no more detail in the image to show.+//+enum { LANDMARK_ICON_RADAR_DIVISOR = 20 };+enum { LANDMARK_ICON_MIN_SIZE = 9 };++//+// A supply dock is eight piles standing together and an icon is about six radar cells across, so+// landmarks of one kind within this many cells of each other are drawn as the one place they are.+//+enum { LANDMARK_MERGE_CELLS = 6 };+//-------------------------------------------------------------------------------------------------/** Is the point legal, that is, inside the resolution of the radar cells *///-------------------------------------------------------------------------------------------------@@ -270,6 +294,120 @@ void W3DRadar::drawHeroIcon( Int pixelX, Int pixelY, Int width, Int height, cons}}+//-------------------------------------------------------------------------------------------------+/** Draw one landmark marker with the lobby preview's own icon: the dollar over the money, the star+ * over a building somebody can walk into and take. This runs after the shroud image, so the+ * marker stays readable over ground the player has never been to. */+//-------------------------------------------------------------------------------------------------+void W3DRadar::drawLandmarkIcon( Int pixelX, Int pixelY, Int width, Int height,+ const RadarLandmark& landmark )+{+ static const Image *supplyImage =+ TheMappedImageCollection->findImageByName( LANDMARK_SUPPLY_IMAGE_NAME );+ static const Image *captureImage =+ TheMappedImageCollection->findImageByName( LANDMARK_CAPTURE_IMAGE_NAME );++ const Image *image = (landmark.type == RADAR_LANDMARK_SUPPLY) ? supplyImage : captureImage;+ if( image == NULL )+ return;++ Int iconSize = width / LANDMARK_ICON_RADAR_DIVISOR;+ if( iconSize < LANDMARK_ICON_MIN_SIZE )+ iconSize = LANDMARK_ICON_MIN_SIZE;+ if( iconSize > SUPPLY_TECH_SIZE )+ iconSize = SUPPLY_TECH_SIZE;++ // convert world to radar coords, then radar coords to the screen+ ICoord2D radarPoint;+ radarPoint.x = landmark.position.x / (m_mapExtent.width() / RADAR_CELL_WIDTH);+ radarPoint.y = landmark.position.y / (m_mapExtent.height() / RADAR_CELL_HEIGHT);++ ICoord2D screenPoint;+ radarToPixel( &radarPoint, &screenPoint, pixelX, pixelY, width, height );++ //+ // centre the icon on the blip and keep the whole of it inside the radar image, so one standing+ // at the edge of the map does not spill onto the HUD frame around it+ //+ Int left = screenPoint.x - (iconSize / 2);+ Int top = screenPoint.y - (iconSize / 2);+ const Int rightLimit = pixelX + width - iconSize;+ const Int bottomLimit = pixelY + height - iconSize;++ if( left < pixelX )+ left = pixelX;+ if( left > rightLimit )+ left = rightLimit;+ if( top < pixelY )+ top = pixelY;+ if( top > bottomLimit )+ top = bottomLimit;++ TheDisplay->drawImage( image, left, top, left + iconSize, top + iconSize );++} // end drawLandmarkIcon++//-------------------------------------------------------------------------------------------------+/** Collect the landmarks out of one radar object list. The shroud is deliberately not read here:+ * a supply pile and an oil derrick stand where the map maker put them, and the lobby map preview+ * has already shown where the money is. */+//-------------------------------------------------------------------------------------------------+void W3DRadar::collectLandmarks( const RadarObject *listHead )+{++ for( const RadarObject *rObj = listHead; rObj; rObj = rObj->friend_getNext() )+ {++ const Object *obj = rObj->friend_getObject();+ const RadarLandmarkType type = Radar::landmarkTypeOf( obj );+ if( type == RADAR_LANDMARK_NONE )+ continue;++ RadarLandmark landmark;+ landmark.position = *obj->getPosition();+ landmark.type = type;++ //+ // A supply dock is eight piles standing together, and eight dollar signs on top of each+ // other is a smear rather than a place. One marker per spot: anything of the same kind+ // this close is the same spot, and the radar has no room to say otherwise.+ //+ const Real mergeX = m_xSample * LANDMARK_MERGE_CELLS;+ const Real mergeY = m_ySample * LANDMARK_MERGE_CELLS;+ Bool alreadyMarked = FALSE;+ for( std::list<RadarLandmark>::const_iterator marked = m_cachedLandmarkList.begin();+ marked != m_cachedLandmarkList.end(); ++marked )+ {++ if( marked->type == landmark.type &&+ fabs( marked->position.x - landmark.position.x ) < mergeX &&+ fabs( marked->position.y - landmark.position.y ) < mergeY )+ {+ alreadyMarked = TRUE;+ break;+ }++ } // end for++ if( alreadyMarked == FALSE )+ m_cachedLandmarkList.push_back( landmark );++ } // end for++} // end collectLandmarks++//-------------------------------------------------------------------------------------------------+/** Rebuild the landmark cache from both object lists */+//-------------------------------------------------------------------------------------------------+void W3DRadar::cacheLandmarks( void )+{++ m_cachedLandmarkList.clear();+ collectLandmarks( getObjectList() );+ collectLandmarks( getLocalObjectList() );++} // end cacheLandmarks+//-------------------------------------------------------------------------------------------------/** Draw a "box" into the texture passed in that represents the viewable area for* the tactical display into the game world */@@ -598,6 +736,14 @@ void W3DRadar::drawEvents( Int pixelX, Int pixelY, Int width, Int height )//-------------------------------------------------------------------------------------------------void W3DRadar::drawIcons( Int pixelX, Int pixelY, Int width, Int height ){+ // draw the money and the buildings worth capturing, under the heroes and over the shroud+ std::list<RadarLandmark>::const_iterator landmark = m_cachedLandmarkList.begin();+ while (landmark != m_cachedLandmarkList.end())+ {+ drawLandmarkIcon( pixelX, pixelY, width, height, *landmark );+ ++landmark;+ }+// draw the hero iconsstd::list<Coord3D>::const_iterator iter = m_cachedHeroPosList.begin();while (iter != m_cachedHeroPosList.end())@@ -979,10 +1125,14 @@ void W3DRadar::reset( void )REF_PTR_RELEASE(surface);}+ // the objects those positions belonged to are gone with the match that had them+ m_cachedLandmarkList.clear();+ m_cachedHeroPosList.clear();+// don't call Clear(); that wips to transparent. do this instead.//gs Dude, it's called CLEARshroud. It needs to clear the shroud.clearShroud();-+} // end reset//-------------------------------------------------------------------------------------------------@@ -1403,7 +1553,10 @@ void W3DRadar::draw( Int pixelX, Int pixelY, Int width, Int height )// rebuild the object overlayrenderObjectList( getObjectList(), m_overlayTexture );renderObjectList( getLocalObjectList(), m_overlayTexture, TRUE );-++ // and the landmarks the icon pass draws on top of the shroud+ cacheLandmarks();+} // end if// draw the overlay image