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): let shift pass through command bar hotkeys

Olcay Seygan0117f0972c69
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp
index 5b4e658d8..4be502295 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp
@@ -96,7 +96,9 @@ GameMessageDisposition HotKeyTranslator::translateGameMessage(const GameMessage
{
newModState |= ALT;
}
- if(newModState != 0)
+ // shift is allowed through: a shift-click on a build button queues a batch of units, and
+ // the label hotkey is meant to be that click's equal. Ctrl and alt still block the hotkey.
+ if(newModState & ~SHIFT)
return disp;
WideChar key = TheKeyboard->getPrintableKey(msg->getArgument(0)->integer, 0);
UnicodeString uKey;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
index 6993ff4ad..0977cfc78 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp
@@ -414,6 +414,19 @@ static const char * findGameMessageNameByType(GameMessage::Type type)
return "???";
}
+//-------------------------------------------------------------------------------------------------
+/** The command bar slot keys have to behave exactly like a click on the cell they press, and a
+ * shift-click on a build button queues a whole batch instead of one unit. Holding shift must
+ * therefore not stop the slot from matching. Every other modifier still has to match exactly,
+ * and a slot the player deliberately bound to shift is compared as-is. */
+//-------------------------------------------------------------------------------------------------
+static Bool metaIgnoresShift(const MetaMapRec *map)
+{
+ return map->m_meta >= GameMessage::MSG_META_COMMAND_SLOT01 &&
+ map->m_meta <= GameMessage::MSG_META_COMMAND_SLOT14 &&
+ (map->m_modState & SHIFT) == 0;
+}
+
//-------------------------------------------------------------------------------------------------
GameMessageDisposition MetaEventTranslator::translateGameMessage(const GameMessage *msg)
{
@@ -490,9 +503,10 @@ GameMessageDisposition MetaEventTranslator::translateGameMessage(const GameMessa
}
// ok, now check for "normal" key transitions.
+ Int cmpModState = metaIgnoresShift(map) ? (newModState & ~SHIFT) : newModState;
if (
map->m_key == key &&
- map->m_modState == newModState &&
+ map->m_modState == cmpModState &&
(
(map->m_transition == UP && (keyState & KEY_STATE_UP)) ||
(map->m_transition == DOWN && (keyState & KEY_STATE_DOWN)) //||