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(gameengine): shift+number adds selection to control group
Olcay Seygan4da2720b9cc7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d23e9af23..08f3a6e86 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -271,6 +271,7 @@ found and fixed — EA's own, not port damage.**- What the circle picks up is what you can see, and a stealthed unit is not that. Shroud was the only test, so a hidden tank parked in ground you had already cleared went on the list like anything else: drag a circle over open country and the group opened fire on air, one order per hidden unit, which is a stealth detector drawn with the mouse. An undetected unit is not in the circle.- Ctrl+D takes every unit of the kinds you have selected that is on the screen, and pressed twice inside half a second takes them across the whole map. One tank selected and two keystrokes is your whole armour, wherever it is standing. It was on Shift+Ctrl+E, which is three fingers for something you do in every fight, and it only ever reached across the map when the screen had nothing left to give - so the wide selection happened to you instead of being asked for.- U takes you to the next combat unit standing with no orders: it is selected and the view centres on it. Press again for the one after. Idle workers stay on I.+- Shift and a number puts what you have selected into that control group and keeps everyone already in it, the way StarCraft does it. Fresh tanks off the line join group 1 with one key, where you used to select group 1, shift-click the new tanks in and press Ctrl+1 again. The selection stays as it is. Retail used Shift and a number to pull a group into your selection instead; that is gone, and Alt and the number still centres the view on the group.## Aircraft, guards, and orders that used to be ignoreddiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h b/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.hindex 68a8d8fb5..720089c36 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionXlat.h@@ -65,6 +65,7 @@ private:UnsignedInt m_pendingSquadLands[ NUM_HOTKEY_SQUADS ];Bool isSquadPending( Int group ) const;+ Bool isTakenByLaterSquad( ObjectID id, Int group ) const;void selectHotkeySquad( Player *player, Int group, Bool ownOnly ); ///< what the logic will have in the squad by the time a select sent now landsBool selectFriends( Drawable *draw, GameMessage *createTeamMsg, Bool dragSelecting );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cppindex c8cce3f5b..70560d0b3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp@@ -1335,61 +1335,54 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessacase GameMessage::MSG_META_ADD_TEAM8:case GameMessage::MSG_META_ADD_TEAM9:{+ // Shift and a number puts the selection into that squad and keeps what the squad already+ // held. Retail used the key the other way round, to add the squad to the selection. The+ // logic only fills a squad from scratch, so the squad goes out again whole as a create: its+ // members as the logic will hold them when this lands, then the selection after them.Int group = t - GameMessage::MSG_META_ADD_TEAM0;if ( isValidHotkeySquadIndex( group ) ){- DEBUG_LOG(("META: select team %d\n",group));-- UnsignedInt now = TheGameLogic->getFrame();- if ( m_lastGroupSelTime == 0 )+ std::vector<ObjectID> members;+ if ( isSquadPending( group ) ){- m_lastGroupSelTime = now;+ members = m_pendingSquad[ group ];}-- // check for double-press to jump view-- if ( now - m_lastGroupSelTime < 20 && group == m_lastGroupSelGroup )+ else{- DEBUG_LOG(("META: DOUBLETAP select team %d\n",group));- Player *player = ThePlayerList->getLocalPlayer();- if (player)- {- Squad *selectedSquad = player->getHotkeySquad(group);- if (selectedSquad != NULL)- {- VecObjectPtr objlist = selectedSquad->getLiveObjects();- Int numObjs = objlist.size();- if (numObjs > 0)- {- // if theres someone in the group, center the camera on them.- TheTacticalView->lookAt( objlist[numObjs-1]->getDrawable()->getPosition() );- }- }- }-+ // every member, not just the selectable ones: a unit riding in a transport stays in the squad+ const VecObjectPtr &objlist = ThePlayerList->getLocalPlayer()->getHotkeySquad( group )->getAllObjects();+ for ( size_t i = 0; i < objlist.size(); ++i )+ members.push_back( objlist[ i ]->getID() );}- else++ std::vector<ObjectID> squad;+ for ( size_t i = 0; i < members.size(); ++i ){+ if ( !isTakenByLaterSquad( members[ i ], group ) )+ squad.push_back( members[ i ] );+ }- Drawable *draw = TheInGameUI->getFirstSelectedDrawable();- if( draw && draw->isKindOf( KINDOF_STRUCTURE ) )+ Bool added = FALSE;+ for ( Drawable *drawable = TheGameClient->getDrawableList(); drawable != NULL; drawable = drawable->getNextDrawable() )+ {+ Object *obj = drawable->getObject();+ if ( drawable->isSelected() && obj && obj->isLocallyControlled()+ && std::find( squad.begin(), squad.end(), obj->getID() ) == squad.end() ){- //Kris: Jan 12, 2005- //Can't select other units if you have a structure selected. So deselect the structure to prevent- //group force attack exploit.- TheInGameUI->deselectAllDrawables();+ squad.push_back( obj->getID() );+ added = TRUE;}+ }- // no need to send two messages for selecting the same group.- TheMessageStream->appendMessage((GameMessage::Type)(GameMessage::MSG_ADD_TEAM0 + group));- Player *player = ThePlayerList->getLocalPlayer();- if (player)- {- selectHotkeySquad( player, group, FALSE );- }+ if ( added )+ {+ DEBUG_LOG(("META: add selection to team %d\n",group));+ GameMessage *newmsg = TheMessageStream->appendMessage((GameMessage::Type)(GameMessage::MSG_CREATE_TEAM0 + group));+ for ( size_t i = 0; i < squad.size(); ++i )+ newmsg->appendObjectIDArgument( squad[ i ] );+ m_pendingSquad[ group ] = squad;+ m_pendingSquadLands[ group ] = TheNetwork ? (UnsignedInt)TheNetwork->getExecutionFrame() + 1 : 0;}- m_lastGroupSelTime = now;- m_lastGroupSelGroup = group;}disp = DESTROY_MESSAGE;break;@@ -1536,16 +1529,33 @@ Bool SelectionTranslator::isSquadPending( Int group ) constreturn m_pendingSquadLands[ group ] != 0 && TheGameLogic->getFrame() <= m_pendingSquadLands[ group ];}+//-----------------------------------------------------------------------------+/** A team key on the way takes this unit into another squad after this squad's own key lands, and+ * the logic removes a unit from every squad but its new one. */+//-----------------------------------------------------------------------------+Bool SelectionTranslator::isTakenByLaterSquad( ObjectID id, Int group ) const+{+ const UnsignedInt groupLands = isSquadPending( group ) ? m_pendingSquadLands[ group ] : 0;+ for( Int other = 0; other < NUM_HOTKEY_SQUADS; ++other )+ {+ if( other == group || !isSquadPending( other ) || m_pendingSquadLands[ other ] <= groupLands )+ continue;+ const std::vector<ObjectID> &sent = m_pendingSquad[ other ];+ if( std::find( sent.begin(), sent.end(), id ) != sent.end() )+ return TRUE;+ }+ return FALSE;+}+//-----------------------------------------------------------------------------/** Select on screen what the logic will hold in this squad by the time a select sent now lands:* the members a team key sent for it if they are still on the way, and never a unit that a key- * on the way takes into another squad, which the logic removes from every squad but its new one. */+ * on the way takes into another squad. *///-----------------------------------------------------------------------------void SelectionTranslator::selectHotkeySquad( Player *player, Int group, Bool ownOnly ){VecObjectPtr objlist;- const UnsignedInt groupLands = isSquadPending( group ) ? m_pendingSquadLands[ group ] : 0;- if( groupLands != 0 )+ if( isSquadPending( group ) ){for( size_t i = 0; i < m_pendingSquad[ group ].size(); ++i ){@@ -1568,16 +1578,7 @@ void SelectionTranslator::selectHotkeySquad( Player *player, Int group, Bool ownif( ownOnly && obj->getControllingPlayer() != player )continue;- Bool movedAway = FALSE;- for( Int other = 0; other < NUM_HOTKEY_SQUADS && !movedAway; ++other )- {- // only a key that lands after this squad's own can still take a member out of it- if( other == group || !isSquadPending( other ) || m_pendingSquadLands[ other ] <= groupLands )- continue;- const std::vector<ObjectID> &sent = m_pendingSquad[ other ];- movedAway = std::find( sent.begin(), sent.end(), obj->getID() ) != sent.end();- }- if( !movedAway )+ if( !isTakenByLaterSquad( obj->getID(), group ) )TheInGameUI->selectDrawable( obj->getDrawable() );}}