Skip to content

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.

feat(gameclient): category selection on Ctrl+Q/W/E/Z/X/C/A, screen first then map

Olcay Seygana5600efaca66
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
index a737d5fb7..328523698 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
@@ -252,6 +252,11 @@ public:
MSG_META_SELECT_HERO, ///< selects player's hero character, if exists...
MSG_META_SELECT_ALL, ///< selects all units across screen
MSG_META_SELECT_ALL_AIRCRAFT, ///< selects all air units just like select all
+ MSG_META_SELECT_ALL_MILITARY, ///< selects armed units (KINDOF_CAN_ATTACK), screen first then map (Ctrl+Q/W/Z/X/C)
+ MSG_META_SELECT_ALL_VEHICLES, ///< selects ground vehicles (no dozers / harvesters), screen first then map (Ctrl+Q/W/Z/X/C)
+ MSG_META_SELECT_ALL_BARRACKS, ///< selects barracks, screen first then map (Ctrl+Q/W/Z/X/C)
+ MSG_META_SELECT_ALL_WARFACTORIES, ///< selects war factories, screen first then map (Ctrl+Q/W/Z/X/C)
+ MSG_META_SELECT_ALL_AIRFIELDS, ///< selects airfields, screen first then map (Ctrl+Q/W/Z/X/C)
MSG_META_SCATTER, ///< selected units scatter
MSG_META_STOP, ///< selected units stop
MSG_META_DEPLOY, ///< selected units 'deploy'
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
index e41d96c60..beb1267ef 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
@@ -360,6 +360,11 @@ AsciiString GameMessage::getCommandTypeAsAsciiString(GameMessage::Type t)
CHECK_IF(MSG_META_SELECT_HERO)
CHECK_IF(MSG_META_SELECT_ALL)
CHECK_IF(MSG_META_SELECT_ALL_AIRCRAFT)
+ CHECK_IF(MSG_META_SELECT_ALL_MILITARY)
+ CHECK_IF(MSG_META_SELECT_ALL_VEHICLES)
+ CHECK_IF(MSG_META_SELECT_ALL_BARRACKS)
+ CHECK_IF(MSG_META_SELECT_ALL_WARFACTORIES)
+ CHECK_IF(MSG_META_SELECT_ALL_AIRFIELDS)
CHECK_IF(MSG_META_SCATTER)
CHECK_IF(MSG_META_STOP)
CHECK_IF(MSG_META_DEPLOY)
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index deeca453d..9eed7144a 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -2938,34 +2938,46 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
//-----------------------------------------------------------------------------------------
case GameMessage::MSG_META_SELECT_ALL:
case GameMessage::MSG_META_SELECT_ALL_AIRCRAFT:
- {
+ case GameMessage::MSG_META_SELECT_ALL_MILITARY:
+ case GameMessage::MSG_META_SELECT_ALL_VEHICLES:
+ case GameMessage::MSG_META_SELECT_ALL_BARRACKS:
+ case GameMessage::MSG_META_SELECT_ALL_WARFACTORIES:
+ case GameMessage::MSG_META_SELECT_ALL_AIRFIELDS:
+ {
+ // one category per key; selectAllUnitsByType takes the screen first and the
+ // whole map when the screen has nothing new left, so a second press widens
KindOfMaskType requiredKindofs;
KindOfMaskType disqualifyingKindofs;
- disqualifyingKindofs.set(KINDOF_DOZER);
- disqualifyingKindofs.set(KINDOF_HARVESTER);
disqualifyingKindofs.set(KINDOF_IGNORES_SELECT_ALL);
- Bool selectAircraft = FALSE;
-
- if( t == GameMessage::MSG_META_SELECT_ALL_AIRCRAFT )
- {
- requiredKindofs.set(KINDOF_AIRCRAFT);
- selectAircraft = TRUE;
+ switch( t )
+ {
+ case GameMessage::MSG_META_SELECT_ALL_BARRACKS: requiredKindofs.set(KINDOF_FS_BARRACKS); break;
+ case GameMessage::MSG_META_SELECT_ALL_WARFACTORIES: requiredKindofs.set(KINDOF_FS_WARFACTORY); break;
+ case GameMessage::MSG_META_SELECT_ALL_AIRFIELDS: requiredKindofs.set(KINDOF_FS_AIRFIELD); break;
+ default:
+ // units: never dozers, harvesters or structures
+ disqualifyingKindofs.set(KINDOF_DOZER);
+ disqualifyingKindofs.set(KINDOF_HARVESTER);
+ disqualifyingKindofs.set(KINDOF_STRUCTURE);
+ if( t == GameMessage::MSG_META_SELECT_ALL_AIRCRAFT )
+ requiredKindofs.set(KINDOF_AIRCRAFT);
+ else if( t == GameMessage::MSG_META_SELECT_ALL_MILITARY )
+ requiredKindofs.set(KINDOF_CAN_ATTACK); // armed units of any kind; plain SELECT_ALL takes the unarmed ones too
+ else if( t == GameMessage::MSG_META_SELECT_ALL_VEHICLES )
+ {
+ requiredKindofs.set(KINDOF_VEHICLE);
+ disqualifyingKindofs.set(KINDOF_AIRCRAFT);
+ }
+ break;
}
//Kris: Patch 1.03. We need to deselect all the units if any of the units we have selected
//are incompatible with the select all type we are triggering. This is a fix for the SCUDSTORM
- //exploit.
+ //exploit. (Generalized: anything outside the category drops the old selection first.)
const DrawableList *drawList = TheInGameUI->getAllSelectedDrawables();
- Drawable *draw;
for( DrawableListCIt it = drawList->begin(); it != drawList->end(); ++it )
{
- draw = *it;
- if( selectAircraft && (draw->isAnyKindOf( disqualifyingKindofs ) || !draw->isKindOf( KINDOF_AIRCRAFT )) )
- {
- TheInGameUI->deselectAllDrawables();
- break;
- }
- else if( !selectAircraft && (draw->isAnyKindOf( disqualifyingKindofs ) || draw->isKindOf( KINDOF_STRUCTURE )) )
+ if( !(*it)->isKindOfMulti( requiredKindofs, disqualifyingKindofs ) )
{
TheInGameUI->deselectAllDrawables();
break;
@@ -2977,69 +2989,6 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
disp = DESTROY_MESSAGE;
break;
-
-
-
-
-/*
- TheInGameUI->deselectAllDrawables();
-
- GameMessage *teamMsg = TheMessageStream->appendMessage( GameMessage::MSG_CREATE_SELECTED_GROUP );
- // creating a new team so pass in true
- teamMsg->appendBooleanArgument( TRUE );
-
- // just loop through all the drawables in the world
- Drawable *draw = TheGameClient->firstDrawable();
-
- while( draw )
- {
- const Object *object = draw->getObject();
-
- //Only select the object if it is locally controlled and not contained by anything.
- KindOfMaskType disqualifyingKindofs;
- disqualifyingKindofs.set(KINDOF_DOZER);
- disqualifyingKindofs.set(KINDOF_HARVESTER);
- disqualifyingKindofs.set(KINDOF_IGNORES_SELECT_ALL);
- if( object
- && object->isMobile()
- && object->isLocallyControlled()
- && !object->isContained()
- && !object->isAnyKindOf( disqualifyingKindofs )
- && !object->isEffectivelyDead()
- && object->isMassSelectable()
- )
- {
- // enforce optional unit cap
- if (TheInGameUI->getMaxSelectCount() > 0 && TheInGameUI->getSelectCount() >= TheInGameUI->getMaxSelectCount())
- {
- if ( !TheInGameUI->getDisplayedMaxWarning() )
- {
- TheInGameUI->setDisplayedMaxWarning( TRUE );
- UnicodeString msg;
- msg.format(TheGameText->fetch("GUI:MaxSelectionSize").str(), TheInGameUI->getMaxSelectCount());
- TheInGameUI->message(msg);
- }
- }
- else
- {
- TheInGameUI->selectDrawable(draw);
- teamMsg->appendObjectIDArgument( draw->getObject()->getID() );
- TheInGameUI->setDisplayedMaxWarning( FALSE );
- }
- }
-
- draw = draw->getNextDrawable();
- }
- if( TheInGameUI->getSelectCount() )
- {
- UnicodeString message = TheGameText->fetch( "GUI:SelectedAcrossMap" );
- TheInGameUI->message( message );
- }
-
- disp = DESTROY_MESSAGE;
- break;
-*/
-
} // end select all
//-----------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
index cd17eed22..48ac8498c 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
@@ -165,6 +165,11 @@ static const LookupListRec GameMessageMetaTypeNames[] =
{ "SELECT_HERO", GameMessage::MSG_META_SELECT_HERO },
{ "SELECT_ALL", GameMessage::MSG_META_SELECT_ALL },
{ "SELECT_ALL_AIRCRAFT", GameMessage::MSG_META_SELECT_ALL_AIRCRAFT },
+ { "SELECT_ALL_MILITARY", GameMessage::MSG_META_SELECT_ALL_MILITARY },
+ { "SELECT_ALL_VEHICLES", GameMessage::MSG_META_SELECT_ALL_VEHICLES },
+ { "SELECT_ALL_BARRACKS", GameMessage::MSG_META_SELECT_ALL_BARRACKS },
+ { "SELECT_ALL_WARFACTORIES", GameMessage::MSG_META_SELECT_ALL_WARFACTORIES },
+ { "SELECT_ALL_AIRFIELDS", GameMessage::MSG_META_SELECT_ALL_AIRFIELDS },
{ "VIEW_COMMAND_CENTER", GameMessage::MSG_META_VIEW_COMMAND_CENTER },
{ "VIEW_LAST_RADAR_EVENT", GameMessage::MSG_META_VIEW_LAST_RADAR_EVENT },
{ "SCATTER", GameMessage::MSG_META_SCATTER },