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): Classic mouse and keys are Zero Hour 1.04's
Olcay Seygand194d9bac08e
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h b/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.hindex 9b95be3bc..0bd7e7feb 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/MetaEvent.h@@ -366,7 +366,11 @@ class MetaMap : public SubsystemInterfacefriend class MetaEventTranslator;private:- MetaMapRec *m_metaMaps;+ MetaMapRec *m_metaMaps; ///< Reforged: the language's CommandMap.ini with CommandMapReforged.ini over it+ MetaMapRec *m_classicMaps; ///< Classic: the language's CommandMap.ini alone, the game's own keys+ Bool m_parsingClassic; ///< parseMetaMap is filling m_classicMaps++ static void freeList( MetaMapRec *&list );protected:GameMessage::Type findGameMessageMetaType(const char* name);@@ -383,7 +387,14 @@ public:static void parseMetaMap(INI* ini);- const MetaMapRec *getFirstMetaMapRec() const { return m_metaMaps; }+ /** Fill the Classic list from the language's CommandMap.ini alone, the game's own map out of its+ * own archives. Everything this fork binds is in CommandMapReforged.ini, and only the Reforged+ * list reads that. */+ void loadClassicBindings( const AsciiString& languageMapFile );++ /// the bindings the interface style in use answers to+ const MetaMapRec *getFirstMetaMapRec() const;+ const MetaMapRec *getFirstMetaMapRec( Bool classic ) const { return classic ? m_classicMaps : m_metaMaps; }};extern MetaMap *TheMetaMap;diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cppindex 34800891d..575ce0d81 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp@@ -1190,6 +1190,8 @@ void GameEngine::init( int argc, char *argv[] )AsciiString fname;fname.format("Data\\%s\\CommandMap.ini", GetRegistryLanguage().str());initSubsystem(TheMetaMap,"TheMetaMap", MSGNEW("GameEngineSubsystem") MetaMap(), NULL, fname.str(), "Data\\INI\\CommandMapReforged.ini");+ // Classic answers to the game's own map and to nothing this fork binds+ TheMetaMap->loadClassicBindings(fname);#if defined(_DEBUG) || defined(_INTERNAL)ini.load("Data\\INI\\CommandMapDebug.ini", INI_LOAD_MULTIFILE, NULL);diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 91c2a3fe7..6d5689571 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -4203,6 +4203,10 @@ CommandSet *ControlBar::newCommandSetOverride( CommandSet *setToOverride )//-------------------------------------------------------------------------------------------------Int getBuildBatchCount( void ){+ // Classic's click is one unit, as the game shipped+ if( TheGlobalData->isClassicUI() )+ return 1;+if( TheKeyboard->isCtrl() )return TheKeyboard->isShift() ? CTRL_SHIFT_BUILD_QUEUE_COUNT : CTRL_BUILD_QUEUE_COUNT;@@ -5262,7 +5266,14 @@ void ControlBar::setControlCommand( GameWindow *button, const CommandButton *comsetCommandBarBorder(button, commandButton->getCommandButtonMappedBorderType());// the key in the button's top left corner is its place's, and a place is only known once the- // whole set is on the bar: labelCommandPlaces paints it+ // whole set is on the bar: labelCommandPlaces paints it. Classic has no places: its key is the+ // letter after the '&' in the button's own label, as the game shipped+ if( TheHotKeyManager && TheGlobalData->isClassicUI() )+ {+ AsciiString hotKey = TheHotKeyManager->searchHotKey( commandButton->getTextLabel() );+ if( hotKey.isNotEmpty() )+ TheHotKeyManager->addHotKey( button, hotKey );+ }GadgetButtonSetAltSound(button, "GUICommandBarClick");diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cppindex ba33bcef5..5318478fc 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommandProcessing.cpp@@ -758,7 +758,7 @@ CBCommandStatus ControlBar::processCommandUI( GameWindow *control,break;// shift: the unit buys it when its list gets there, and the money is looked at then- const Bool queued = TheInGameUI->isInWaypointMode();+ const Bool queued = TheInGameUI->isInWaypointMode() && !TheGlobalData->isClassicUI();//Make sure the player can really make thisif( !queued && TheUpgradeCenter->canAffordUpgrade( ThePlayerList->getLocalPlayer(), upgradeT, TRUE ) == FALSE )diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cppindex 23c35c0b6..96efe8ed3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarCallback.cpp@@ -336,8 +336,10 @@ WindowMsgHandledType LeftHUDInput( GameWindow *window, UnsignedInt msg,const DrawableList *drawableList = TheInGameUI->getAllSelectedLocalDrawables(); // locally-owned only// see if the user wants to move the tactical view- // Left on the radar looks and right orders, the same division the world has.- if( drawableList->empty() || msg == GWM_LEFT_DOWN )+ // Left on the radar looks and right orders, the same division the world has. Classic+ // divides the world the other way round, and so did the radar in the game as shipped.+ const UnsignedInt lookButton = TheGlobalData->isClassicUI() ? GWM_RIGHT_DOWN : GWM_LEFT_DOWN;+ if( drawableList->empty() || msg == lookButton ){radarLookAt( &world );s_radarLookDrag = (msg == GWM_LEFT_DOWN) ? GWM_LEFT_DRAG : GWM_RIGHT_DRAG;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 422657845..317ff4bb8 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -1609,7 +1609,10 @@ void InGameUI::setRadiusCursor(RadiusCursorType cursorType, const SpecialPowerTebreak;case RADIUSCURSOR_GUARD_AREA:// no decal: its size was fixed when the button was pressed, and the wheel changes the radius- // after that. The area pick ring takes its place (isAreaPicking)+ // after that. The area pick ring takes its place (isAreaPicking). Classic has no ring and+ // no wheel, so it wears EA's decal at the standard range the guard will hold+ if( TheGlobalData->isClassicUI() )+ radius = AIGuardMachine::getStdGuardRange(obj);break;case RADIUSCURSOR_FRIENDLY_SPECIALPOWER:case RADIUSCURSOR_OFFENSIVE_SPECIALPOWER:@@ -6396,6 +6399,10 @@ Bool InGameUI::isHiddenByShroud( const Object *obj ) const//-------------------------------------------------------------------------------------------------void InGameUI::markNextOrderQueued( OrderQueueMode mode ){+ // the game as shipped had no order list, and Classic sends the logic nothing it did not have+ if( TheGlobalData->isClassicUI() )+ return;+GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_QUEUE_NEXT_ORDER );msg->appendIntegerArgument( mode );}@@ -7041,11 +7048,17 @@ void InGameUI::createCommandHint( const GameMessage *msg )}//--------------------------------------------------------------------------------------------------/** Force fire is the attack key alone. */+/** Force fire is the attack key alone in Reforged. Ctrl held is how the game as shipped force+ * fired, and Classic is that game. *///-------------------------------------------------------------------------------------------------+Bool InGameUI_isForceFireOn( Bool forceAttackArmed, Bool ctrlHeld, Bool classicUI )+{+ return forceAttackArmed || ( classicUI && ctrlHeld );+}+Bool InGameUI::isForceFireOn( void ) const{- return m_forceAttackArmed;+ return InGameUI_isForceFireOn( m_forceAttackArmed, m_forceAttackMode, TheGlobalData->isClassicUI() );}//-------------------------------------------------------------------------------------------------@@ -7622,6 +7635,10 @@ static const Real AREA_SWEEP_RADIUS = 300.0f; ///< a search and destroy's circle//-------------------------------------------------------------------------------------------------Bool InGameUI::isAreaPicking( void ) const{+ // Classic's guard holds the standard range: no ring under the cursor and nothing for the wheel+ if( TheGlobalData->isClassicUI() )+ return FALSE;+if( m_guardArmed || m_areaOrder != AREA_ORDER_NONE )return TRUE;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cppindex d5fff9143..bb17d20aa 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp@@ -177,6 +177,10 @@ SignalKind Command_signalKindForMeta( GameMessage::Type meta )static Bool isFormationDragArmed( void ){+ // Classic's left drag is the selection box it always was+ if( TheGlobalData->isClassicUI() )+ return FALSE;+return Command_formationDragArmed( TheGlobalData->m_formationDrag,TheInGameUI->getSelectCount() > 0&& TheInGameUI->areSelectedObjectsControllable(),@@ -978,8 +982,13 @@ GameMessage::Type CommandTranslator::issueMoveToLocationCommand( const Coord3D *Bool forceAttackHere = isForceAttackTargeting() && isForceAttackable;// the guard key posts the selection where it is pointed. Under shift it joins the list as its- // last order: clear this, then sit there- if( TheInGameUI->isGuardArmed() )+ // last order: clear this, then sit there. Classic's waypoint key is the game's own: Alt held+ // adds a point to the path instead of queueing an order+ if( TheGlobalData->isClassicUI() && TheInGameUI->isInWaypointMode() )+ {+ msgType = GameMessage::MSG_ADD_WAYPOINT;+ }+ else if( TheInGameUI->isGuardArmed() ){msgType = GameMessage::MSG_DO_GUARD_POSITION;}@@ -1012,7 +1021,9 @@ GameMessage::Type CommandTranslator::issueMoveToLocationCommand( const Coord3D *if (msgType == GameMessage::MSG_DO_GUARD_POSITION){movemsg->appendIntegerArgument( GUARDMODE_GUARD_WITHOUT_PURSUIT );- movemsg->appendRealArgument( TheInGameUI->getAreaPickRadius() );+ // Classic sends the game's own two arguments and the logic guards its standard range+ if( !TheGlobalData->isClassicUI() )+ movemsg->appendRealArgument( TheInGameUI->getAreaPickRadius() );}} // end if@@ -1676,6 +1687,23 @@ GameMessage::Type CommandTranslator::evaluateContextCommand( Drawable *draw,{GameMessage *hintMessage;+ // Classic keeps the game's waypoint mode: with Alt held every click is a point on the path+ if( TheGlobalData->isClassicUI() && TheInGameUI->isInWaypointMode() )+ {+ if( type == DO_COMMAND || type == EVALUATE_ONLY )+ {+ if( TheTerrainLogic )+ msgType = issueMoveToLocationCommand( pos, draw, type );+ }+ else+ {+ msgType = GameMessage::MSG_ADD_WAYPOINT_HINT;+ hintMessage = TheMessageStream->appendMessage( msgType );+ hintMessage->appendLocationArgument( *pos );+ }+ return msgType;+ }+// shift used to turn every click into a point on the path. Now whatever the click orders - an// attack, a capture, a ride in a transport - goes on the end of the units' list, and the logic// keeps it there (OrderQueue.h). A click that orders nothing is dropped by the logic with it@@ -2392,8 +2420,9 @@ GameMessage::Type CommandTranslator::evaluateContextCommand( Drawable *draw,// ********************************************************************************************// A right click on a selected building takes the rally point away from everything selected.// Only the click is answered: the hover and SelectionXlat's EVALUATE_ONLY fall through as- // they always did, so the building keeps its selection cursor.- else if( type == DO_COMMAND && draw && draw->isSelected()+ // they always did, so the building keeps its selection cursor. The game as shipped had no+ // such order, and Classic sends none.+ else if( type == DO_COMMAND && draw && draw->isSelected() && !TheGlobalData->isClassicUI()&& TheInGameUI->canSelectedObjectsDoAction( InGameUI::ACTIONTYPE_SET_RALLY_POINT, NULL, InGameUI::SELECTION_ALL, FALSE ) ){msgType = GameMessage::MSG_CLEAR_RALLY_POINT;@@ -4150,7 +4179,7 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage//-----------------------------------------------------------------------------case GameMessage::MSG_MOUSE_RIGHT_DOUBLE_CLICK:{- if( TheGlobalData->m_doubleClickAttackMove )+ if( TheGlobalData->m_doubleClickAttackMove && !TheGlobalData->isClassicUI() ){// create the message and append arguments for a guard locationGameMessage *newMsg = TheMessageStream->appendMessage( GameMessage::MSG_DO_GUARD_POSITION );@@ -4169,6 +4198,11 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage}case GameMessage::MSG_MOUSE_RIGHT_CLICK:{+ // A Classic right button never orders at all: it scrolls and deselects, which LookAtXlat+ // and SelectionXlat do, as the game shipped.+ if( TheGlobalData->isClassicUI() )+ break;+// A right click is an order. A right drag pans the camera (LookAtXlat), so a release that// travelled past the drag tolerance, or was held too long, gives no order at all.const Bool isRightClick = TheMouse->isClick(&m_mouseRightDragAnchor, &m_mouseRightDragLift,@@ -4227,6 +4261,25 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage//-----------------------------------------------------------------------------case GameMessage::MSG_MOUSE_LEFT_DOUBLE_CLICK:+ {+ // Classic's orders are on the left button, so its double-click guard is here, the game's+ // own guard with its own two arguments. Reforged's is on the right button.+ if( TheGlobalData->isClassicUI() && TheGlobalData->m_doubleClickAttackMove )+ {+ GameMessage *newMsg = TheMessageStream->appendMessage( GameMessage::MSG_DO_GUARD_POSITION );+ Coord3D pos;+ TheTacticalView->screenToTerrain( &msg->getArgument( 0 )->pixel, &pos );+ newMsg->appendLocationArgument(pos);+ newMsg->appendIntegerArgument(GUARDMODE_NORMAL);++ ThePlayerList->getLocalPlayer()->getAcademyStats()->recordDoubleClickAttackMoveOrderGiven();++ TheInGameUI->triggerDoubleClickAttackMoveGuardHint();++ break;+ }+ //intentional fall through+ }case GameMessage::MSG_MOUSE_LEFT_CLICK:{Bool isPoint = (msg->getArgument(0)->pixelRegion.height() == 0 && msg->getArgument(0)->pixelRegion.width() == 0);@@ -4254,9 +4307,11 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage// The left button selects and nothing else. The exceptions are a GUI command that is// already armed and waiting for a target, and the attack, attack move and guard keys: all of- // them are aimed with the left button, because the right one cancels them.+ // them are aimed with the left button, because the right one cancels them. In Classic the+ // left button is the order button as well, as it was in the game as shipped.+ const Bool classic = TheGlobalData->isClassicUI();const Bool isOrderKey = TheInGameUI->isOrderKeyArmed();- if( !isFiringGUICommand && !isOrderKey )+ if( !isFiringGUICommand && !isOrderKey && !classic )break;Bool controllable = TheInGameUI->areSelectedObjectsControllable()@@ -4275,7 +4330,10 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage}disp = DESTROY_MESSAGE;- TheInGameUI->spendOrderKey();+ if( classic )+ TheInGameUI->clearAttackMoveToMode();+ else+ TheInGameUI->spendOrderKey();//issueMoveToLocationCommand( &pos, draw, DO_COMMAND );}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cppindex 852180c5f..6fa02cf2e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp@@ -230,7 +230,9 @@ static CommandStatus doGuardCommand( const CommandButton *command, GuardMode guamsg = TheMessageStream->appendMessage( GameMessage::MSG_DO_GUARD_OBJECT );msg->appendObjectIDArgument( target->getID() );msg->appendIntegerArgument(guardMode);- msg->appendRealArgument( TheInGameUI->getAreaPickRadius() );+ // Classic sends the game's own guard and the logic guards its standard range+ if( !TheGlobalData->isClassicUI() )+ msg->appendRealArgument( TheInGameUI->getAreaPickRadius() );pickAndPlayUnitVoiceResponse(TheInGameUI->getAllSelectedDrawables(), GameMessage::MSG_DO_GUARD_OBJECT);}}@@ -255,7 +257,8 @@ static CommandStatus doGuardCommand( const CommandButton *command, GuardMode guamsg = TheMessageStream->appendMessage( GameMessage::MSG_DO_GUARD_POSITION );msg->appendLocationArgument(world);msg->appendIntegerArgument(guardMode);- msg->appendRealArgument( TheInGameUI->getAreaPickRadius() );+ if( !TheGlobalData->isClassicUI() )+ msg->appendRealArgument( TheInGameUI->getAreaPickRadius() );pickAndPlayUnitVoiceResponse(TheInGameUI->getAllSelectedDrawables(), GameMessage::MSG_DO_GUARD_POSITION);}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cppindex 7df6e1894..40ec19382 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HotKey.cpp@@ -100,7 +100,8 @@ GameMessageDisposition HotKeyTranslator::translateGameMessage(const GameMessage}// 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)+ // Classic blocks every modifier, as the game shipped+ if( TheGlobalData->isClassicUI() ? newModState != 0 : ( newModState & ~SHIFT ) != 0 )return disp;// Ctrl+F let go of Ctrl first ends on a bare F release; it is still Ctrl+Fif( keyState & KEY_STATE_PRESSED_WITH_CTRL_ALT )diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cppindex 0c94ced18..be36f749c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/MetaEvent.cpp@@ -456,7 +456,8 @@ static const char * findGameMessageNameByType(GameMessage::Type type)//-------------------------------------------------------------------------------------------------static Bool metaIgnoresShift(const MetaMapRec *map){- return map->m_meta >= GameMessage::MSG_META_COMMAND_SLOT01 &&+ return !TheGlobalData->isClassicUI() &&+ map->m_meta >= GameMessage::MSG_META_COMMAND_SLOT01 &&map->m_meta <= GameMessage::MSG_META_COMMAND_SLOT18 &&(map->m_modState & SHIFT) == 0;}@@ -494,9 +495,11 @@ GameMessageDisposition MetaEventTranslator::translateGameMessage(const GameMessa//// Tab / Shift-Tab walks the focus through a multi-selection's units on the control bar.// Handled here rather than through the MetaMap because CommandMap.ini lives in the- // shipped game data and has no slot for it. The game as it shipped did nothing with Tab.+ // shipped game data and has no slot for it. The game as it shipped did nothing with Tab,+ // and neither does Classic.//- if( t == GameMessage::MSG_RAW_KEY_DOWN && key == MK_TAB &&+ if( !TheGlobalData->isClassicUI() &&+ t == GameMessage::MSG_RAW_KEY_DOWN && key == MK_TAB &&( newModState & ( CTRL | ALT ) ) == 0 &&!( keyState & KEY_STATE_AUTOREPEAT ) &&TheGameClient->getFrame() >= 1 &&@@ -514,13 +517,14 @@ GameMessageDisposition MetaEventTranslator::translateGameMessage(const GameMessa// the key came up while the modifier was still held. Letting go of Ctrl first meant the// key's own release carried no Ctrl, the record no longer matched, and whatever the DOWN// had switched on stayed on. Every key remembers the combinations it was pressed with, so- // a modifier release can finish them off in whatever order the player let go.+ // a modifier release can finish them off in whatever order the player let go. Classic keeps+ // the game's own rule, where the order of letting go mattered.//const Bool isModifierKey = ( key == KEY_LCTRL || key == KEY_RCTRL ||key == KEY_LSHIFT || key == KEY_RSHIFT ||key == KEY_LALT || key == KEY_RALT );- if( isModifierKey && ( keyState & KEY_STATE_UP ) )+ if( isModifierKey && ( keyState & KEY_STATE_UP ) && !TheGlobalData->isClassicUI() ){for( Int keyIndex = 0; keyIndex < NUM_MAPPABLE_KEYS; ++keyIndex ){@@ -597,7 +601,10 @@ GameMessageDisposition MetaEventTranslator::translateGameMessage(const GameMessadisp = DESTROY_MESSAGE;// every record on this modifier fires, not the first one found: shift is both "add to// the selection" on the left button and "queue the order" on the right, and the two- // are separate records that have to come on and go off together.+ // are separate records that have to come on and go off together. Classic stops at the+ // first, as the game did.+ if( TheGlobalData->isClassicUI() )+ break;continue;}@@ -788,21 +795,45 @@ GameMessageDisposition MetaEventTranslator::translateGameMessage(const GameMessa//-------------------------------------------------------------------------------------------------MetaMap::MetaMap() :- m_metaMaps(NULL)+ m_metaMaps(NULL),+ m_classicMaps(NULL),+ m_parsingClassic(FALSE){}//--------------------------------------------------------------------------------------------------MetaMap::~MetaMap()+void MetaMap::freeList( MetaMapRec *&list ){- while (m_metaMaps)+ while (list){- MetaMapRec *next = m_metaMaps->m_next;- m_metaMaps->deleteInstance();- m_metaMaps = next;+ MetaMapRec *next = list->m_next;+ list->deleteInstance();+ list = next;}}+//-------------------------------------------------------------------------------------------------+MetaMap::~MetaMap()+{+ freeList( m_metaMaps );+ freeList( m_classicMaps );+}++//-------------------------------------------------------------------------------------------------+const MetaMapRec *MetaMap::getFirstMetaMapRec() const+{+ return getFirstMetaMapRec( TheGlobalData->isClassicUI() );+}++//-------------------------------------------------------------------------------------------------+void MetaMap::loadClassicBindings( const AsciiString& languageMapFile )+{+ m_parsingClassic = TRUE;+ INI ini;+ ini.load( languageMapFile, INI_LOAD_OVERWRITE, NULL );+ m_parsingClassic = FALSE;+}+//-------------------------------------------------------------------------------------------------GameMessage::Type MetaMap::findGameMessageMetaType(const char* name){@@ -817,7 +848,8 @@ GameMessage::Type MetaMap::findGameMessageMetaType(const char* name)//-------------------------------------------------------------------------------------------------MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t){- for (MetaMapRec *map = m_metaMaps; map; map = map->m_next)+ MetaMapRec *&list = m_parsingClassic ? m_classicMaps : m_metaMaps;+ for (MetaMapRec *map = list; map; map = map->m_next){if (map->m_meta == t)return map;@@ -833,8 +865,8 @@ MetaMapRec *MetaMap::getMetaMapRec(GameMessage::Type t)m->m_category = CATEGORY_MISC;m->m_description.clear();m->m_displayName.clear();- m->m_next = m_metaMaps;- m_metaMaps = m;+ m->m_next = list;+ list = m;return m;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cppindex 5b24994d1..c8d79e051 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp@@ -432,7 +432,9 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa// with attack move or guard armed a left drag draws the order line over in CommandXlat, so// no selection box grows under it. Search and destroy has no line to draw, and its drag// is no box either: the key stays armed for the click that aims it- const Bool leftDragIsOrder = (TheInGameUI->isLineOrderArmed()+ // Classic draws no lines: its left drag is always the box+ const Bool leftDragIsOrder = !TheGlobalData->isClassicUI()+ && (TheInGameUI->isLineOrderArmed()|| TheInGameUI->getAreaOrderArmed() != InGameUI::AREA_ORDER_NONE)&& TheInGameUI->getSelectCount() > 0;if (m_leftMouseButtonIsDown && !leftDragIsOrder)@@ -479,9 +481,10 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa//// a click on a health bar selects its owner, so the cursor has to say so before the// click - the same fallback, in the same order, as the point pick in- // W3DView::iterateDrawablesInRegion+ // W3DView::iterateDrawablesInRegion. Classic is the game as shipped, where a bar was only+ // ever a picture.//- if( underCursor == NULL )+ if( underCursor == NULL && !TheGlobalData->isClassicUI() )underCursor = TheGameClient->pickDrawableByHealthBar( &pixel );Object *objUnderCursor = underCursor ? underCursor->getObject() : NULL;@@ -714,8 +717,8 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessawas a way to take things back out and a way to leave the base staff behind: Alt keepsonly what can shoot, Ctrl removes the box from the selection instead of replacing it.Both are drag-only. A point click has to stay exactly what it was - a filter that eats- single clicks reads as a broken mouse. */- if (!isPoint)+ single clicks reads as a broken mouse. Classic has neither: its Ctrl is force fire. */+ if (!isPoint && !TheGlobalData->isClassicUI()){if (TheKeyboard->isAlt()){@@ -774,8 +777,9 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa}// A box with an army in it takes the army and leaves the dozers and trucks standing among- // it; a box of workers alone still takes the workers. Drag-only, like the filters above.- if (!isPoint)+ // it; a box of workers alone still takes the workers. Drag-only, like the filters above,+ // and not in Classic, which is the 2003 box.+ if (!isPoint && !TheGlobalData->isClassicUI())prioritizeMilitaryBoxSelection(drawablesThatWillSelect, isSelectableMilitaryInBox);SelectionInfo si;@@ -1144,8 +1148,9 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessaif( !TheInGameUI->getGUICommand() && !TheInGameUI->isOrderKeyArmed()&& !TheKeyboard->isShift() && !TheKeyboard->isCtrl() && !TheKeyboard->isAlt() ){- //No GUI command mode, so a click on empty ground deselects everyone.- if( TheInGameUI->getPendingPlaceSourceObjectID() == INVALID_ID )+ //No GUI command mode, so a click on empty ground deselects everyone. Not in Classic,+ //where that click is a move order and the right button is what deselects.+ if( TheInGameUI->getPendingPlaceSourceObjectID() == INVALID_ID && !TheGlobalData->isClassicUI() ){if( !TheInGameUI->getPreventLeftClickDeselectionInAlternateMouseModeForOneClick() ){@@ -1179,6 +1184,15 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessabreak;}+ // Classic is the game as shipped: a right click with nothing armed deselects everyone, and+ // with something armed it only takes that back, below. A right drag panned and is gone above.+ if( TheGlobalData->isClassicUI() && TheInGameUI->getGUICommand() == NULL+ && TheInGameUI->getPendingPlaceType() == NULL )+ {+ deselectAll();+ break;+ }+//// The right button drops whatever is armed, and it does so on a release that wobbled as// well as on a strict click. A dozer placing a row of structures with shift held is the@@ -1267,7 +1281,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa// A screen that fills the middle of the display and answers nothing on the keyboard is// the thing being fixed, so group selection gives way for as long as it is up.//- if( TheControlBar && TheControlBar->isPurchaseScienceVisible()+ if( TheControlBar && TheControlBar->isPurchaseScienceVisible() && !TheGlobalData->isClassicUI()&& group >= 1 && group <= PURCHASE_SCIENCE_COLUMNS ){TheControlBar->pressPurchaseScienceColumn( group - 1 );@@ -1340,6 +1354,50 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa// 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;++ // Classic keeps the key the way the game shipped it: the squad joins the selection, and a+ // second press jumps the camera to it+ if ( TheGlobalData->isClassicUI() )+ {+ if ( isValidHotkeySquadIndex( group ) )+ {+ UnsignedInt now = TheGameLogic->getFrame();+ if ( m_lastGroupSelTime == 0 )+ m_lastGroupSelTime = now;++ if ( now - m_lastGroupSelTime < 20 && group == m_lastGroupSelGroup )+ {+ Player *player = ThePlayerList->getLocalPlayer();+ Squad *selectedSquad = player ? player->getHotkeySquad(group) : NULL;+ if (selectedSquad != NULL)+ {+ VecObjectPtr objlist = selectedSquad->getLiveObjects();+ Int numObjs = objlist.size();+ if (numObjs > 0)+ TheTacticalView->lookAt( objlist[numObjs-1]->getDrawable()->getPosition() );+ }+ }+ else+ {+ //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.+ Drawable *draw = TheInGameUI->getFirstSelectedDrawable();+ if( draw && draw->isKindOf( KINDOF_STRUCTURE ) )+ TheInGameUI->deselectAllDrawables();++ TheMessageStream->appendMessage((GameMessage::Type)(GameMessage::MSG_ADD_TEAM0 + group));+ Player *player = ThePlayerList->getLocalPlayer();+ if (player)+ selectHotkeySquad( player, group, FALSE );+ }+ m_lastGroupSelTime = now;+ m_lastGroupSelGroup = group;+ }+ disp = DESTROY_MESSAGE;+ break;+ }+if ( isValidHotkeySquadIndex( group ) ){std::vector<ObjectID> members;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/SelectionInfo.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/SelectionInfo.cppindex 86d183ec2..1a3a05e59 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/SelectionInfo.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/SelectionInfo.cpp@@ -139,6 +139,11 @@ extern Bool contextCommandForNewSelection(const DrawableList *currentlySelectedD}}+ Drawable *newMine = NULL;+ Drawable *newFriendly = NULL;+ Drawable *newEnemy = NULL;+ Drawable *newCivilian = NULL;+for (it = newlySelectedDrawables->begin(); it != newlySelectedDrawables->end(); ++it) {if (!(*it)) {continue;@@ -158,16 +163,20 @@ extern Bool contextCommandForNewSelection(const DrawableList *currentlySelectedDif (obj->isLocallyControlled()) {++outSelectionInfo->newCountMine;+ newMine = *it;if (obj->isKindOf(KINDOF_STRUCTURE)) {++outSelectionInfo->newCountMineBuildings;}} else {Relationship rel = localPlayer->getRelationship(obj->getTeam());if (rel == ALLIES) {+ newFriendly = *it;++outSelectionInfo->newCountFriends;} else if (rel == ENEMIES) {+ newEnemy = *it;++outSelectionInfo->newCountEnemies;} else if (rel == NEUTRAL) {+ newCivilian = *it;++outSelectionInfo->newCountCivilians;}}@@ -177,10 +186,66 @@ extern Bool contextCommandForNewSelection(const DrawableList *currentlySelectedDDEBUG_ASSERTCRASH(outSelectionInfo->currentCountFriends <= 1, ("Selection bug. jkmcd"));DEBUG_ASSERTCRASH(outSelectionInfo->currentCountCivilians <= 1, ("Selection bug. jkmcd"));- // The left button selects and the right button orders, so a left click never commands. The- // counting above is still wanted - the caller reads the counts for the cursor and the selection- // filters.- return FALSE;+ // In Reforged the left button selects and the right button orders, so a left click never+ // commands. The counting above is still wanted - the caller reads the counts for the cursor and+ // the selection filters.+ if (!TheGlobalData->isClassicUI()) {+ return FALSE;+ }++ if (outSelectionInfo->currentCountEnemies > 0 || outSelectionInfo->currentCountFriends > 0+ || outSelectionInfo->currentCountCivilians > 0) {+ // with somebody else's unit selected there are no context sensitive commands+ return FALSE;+ }++ // In Classic the left button is both, and this is the game's own rule for which one a click on+ // an enemy, an ally, a garrisonable building or a crate is.+ if (outSelectionInfo->currentCountMine > 0) {+ if (outSelectionInfo->newCountEnemies > 0) {+ if (outSelectionInfo->newCountEnemies == 1 && selectionIsPoint) {+ return TheGameClient->evaluateContextCommand(newEnemy, newEnemy->getPosition(), CommandTranslator::EVALUATE_ONLY) != GameMessage::MSG_INVALID;+ }++ return selectionIsPoint;+ }++ if (outSelectionInfo->newCountMine > 0) {+ if (outSelectionInfo->newCountMine == 1 && selectionIsPoint && !TheInGameUI->isInPreferSelectionMode()) {+ return TheGameClient->evaluateContextCommand(newMine, newMine->getPosition(), CommandTranslator::EVALUATE_ONLY) != GameMessage::MSG_INVALID;+ }++ return FALSE;+ }++ if (outSelectionInfo->newCountFriends > 0) {+ if (outSelectionInfo->newCountFriends == 1 && selectionIsPoint) {+ return TheGameClient->evaluateContextCommand(newFriendly, newFriendly->getPosition(), CommandTranslator::EVALUATE_ONLY) != GameMessage::MSG_INVALID;+ }+ return FALSE;+ }++ if (outSelectionInfo->currentCountMineInfantry > 0 && outSelectionInfo->newCountGarrisonableBuildings == 1) {+ return TRUE;+ }++ if (outSelectionInfo->newCountCivilians > 0) {+ if (outSelectionInfo->newCountCivilians == 1 && selectionIsPoint) {+ return TheGameClient->evaluateContextCommand(newCivilian, newCivilian->getPosition(), CommandTranslator::EVALUATE_ONLY) != GameMessage::MSG_INVALID;+ }+ return FALSE;+ }++ if (outSelectionInfo->newCountCrates > 0) {+ return (outSelectionInfo->newCountCrates == 1 && selectionIsPoint);+ }+ }++ if (outSelectionInfo->currentCountMine == 0) {+ return FALSE;+ }++ return selectionIsPoint;}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cppindex 28f74a661..1ca0904d8 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp@@ -2760,9 +2760,10 @@ Int W3DView::iterateDrawablesInRegion( IRegion2D *screenRegion,// hidden behind a building or lost in a crowd - and infantry at full zoom out is a handful of// pixels of model under a bar that is easier to hit than the man. Fallback order matters: a// bar hangs in the air above its own unit and so overlaps whatever stands behind it, so it may- // only answer a click that would otherwise have missed everything.+ // only answer a click that would otherwise have missed everything. Classic is the game as+ // shipped, where a bar was only ever a picture.//- if (onlyDrawableToTest == NULL)+ if (onlyDrawableToTest == NULL && !TheGlobalData->isClassicUI())onlyDrawableToTest = TheGameClient->pickDrawableByHealthBar(&screenRegion->lo);if (onlyDrawableToTest == NULL) {diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cppindex 5be22dd54..e098bba59 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp@@ -195,7 +195,57 @@ void W3DWaypointBuffer::drawWaypoints(RenderInfoClass &rinfo)// isInWaypointMode() (shift held) was true. The shift queue now has its own colored, per-order// hint threads (InGameUI::updateOrderHints / W3DInGameUI::drawOrderHints), which cover the same// ground and stay up after the key is let go, so the white duplicate is gone rather than merely- // hidden - its only firing condition was this same isInWaypointMode() check.+ // hidden - its only firing condition was this same isInWaypointMode() check. Classic has no+ // threads and its waypoint key is Alt, so it draws the white path the game shipped with.+ if( TheGlobalData->isClassicUI() && TheInGameUI->isInWaypointMode() )+ {+ //Create a default light environment with no lights and only full ambient.+ //@todo: Fix later by copying default scene light environement from W3DScene.cpp.+ LightEnvironmentClass lightEnv;+ lightEnv.Reset(Vector3(0,0,0), Vector3(1.0f,1.0f,1.0f));+ lightEnv.Pre_Render_Update(rinfo.Camera.Get_Transform());+ RenderInfoClass localRinfo(rinfo.Camera);+ localRinfo.light_environment=&lightEnv;+ Vector3 points[ MAX_DISPLAY_NODES + 1 ]; //Lines have nodes + 1 points.++ const DrawableList *selected = TheInGameUI->getAllSelectedDrawables();+ for( DrawableListCIt it = selected->begin(); it != selected->end(); ++it )+ {+ Object *obj = (*it)->getObject();+ Int numPoints = 1;+ if( obj && ! obj->isKindOf( KINDOF_IGNORED_IN_GUI ))//so mobs and stuff sont make a gazillion lines+ {+ AIUpdateInterface *ai = obj->getAI();+ Int goalSize = ai ? ai->friend_getWaypointGoalPathSize() : 0;+ Int gpIdx = ai ? ai->friend_getCurrentGoalPathIndex() : 0;++ if( ai && gpIdx >= 0 && gpIdx < goalSize )+ {+ const Coord3D *pos = obj->getPosition();+ points[ 0 ].Set( Vector3( pos->x, pos->y, pos->z ) );++ for( int i = gpIdx; i < goalSize; i++ )+ {+ const Coord3D *waypoint = ai->friend_getGoalPathPosition( i );+ if( waypoint )+ {+ if( numPoints < MAX_DISPLAY_NODES + 1 )+ {+ points[ numPoints ].Set( Vector3( waypoint->x, waypoint->y, waypoint->z ) );+ numPoints++;+ }++ m_waypointNodeRobj->Set_Position(Vector3(waypoint->x,waypoint->y,waypoint->z));+ WW3D::Render(*m_waypointNodeRobj,localRinfo);+ }+ }+ //Now render the lines in one pass!+ queueLine( numPoints, points );+ }+ }+ }+ renderQueuedLines( localRinfo );+ }// Rally points, drawn whenever we are not actively laying down waypoints. This used to be the// else of the block above, which is why turning that block on full time hid every rally line.diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex e4bf7fc32..ad70032d1 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -1256,6 +1256,17 @@ TEST(force_fire_is_the_attack_key_and_nothing_else)CHECK( !CommandXlat_isForceAttackTargeting( false, true ) );}+/* InGameUI.cpp: Classic is the game as shipped, where ctrl held was force fire. */+extern Bool InGameUI_isForceFireOn( Bool forceAttackArmed, Bool ctrlHeld, Bool classicUI );++TEST(ctrl_force_fires_in_classic_and_only_there)+{+ CHECK( InGameUI_isForceFireOn( FALSE, TRUE, TRUE ) );+ CHECK( !InGameUI_isForceFireOn( FALSE, TRUE, FALSE ) );+ CHECK( InGameUI_isForceFireOn( TRUE, FALSE, FALSE ) );+ CHECK( !InGameUI_isForceFireOn( FALSE, FALSE, TRUE ) );+}+/* Player.cpp: the lobby's unit limit is 840 units shared out by the players who are not watching. */TEST(unit_limit_shares_840_between_the_players){diff --git a/GeneralsMD/Code/Tests/test_minimap_input.inc b/GeneralsMD/Code/Tests/test_minimap_input.incindex 95a9fff5c..81a097fc8 100644--- a/GeneralsMD/Code/Tests/test_minimap_input.inc+++ b/GeneralsMD/Code/Tests/test_minimap_input.inc@@ -246,9 +246,14 @@ struct MinimapInputFixtureui->scrolling = ui->selecting = FALSE;ui->enabled = TRUE;TheInGameUI = ui;+ // Reforged's radar: left looks, right orders. Classic swaps them, and says so in its own test+ savedStyle = TheGlobalData->m_interfaceStyleInUse;+ TheWritableGlobalData->m_interfaceStyleInUse = INTERFACE_STYLE_REFORGED;}+ Int savedStyle;~MinimapInputFixture(){+ TheWritableGlobalData->m_interfaceStyleInUse = savedStyle;windows.winDestroyAll();TheRadar = savedRadar;TheTerrainLogic = savedTerrain;@@ -294,6 +299,21 @@ TEST(minimap_drag_tracks_held_left_click_and_stops_on_release_with_units_selecteCHECK(messages.commands.getFirstMessage() == NULL);}+/* Classic's radar is the game as shipped: with units selected the right button looks and drags. */+TEST(minimap_classic_right_button_looks_with_units_selected)+{+ CHECK(bootOnce());+ MinimapInputFixture f;+ MinimapMessages messages;+ messages.stream.attachTranslator(NEW WindowTranslator, 10);+ TheWritableGlobalData->m_interfaceStyleInUse = INTERFACE_STYLE_CLASSIC;+ ((MinimapTestUI*)TheInGameUI)->selected.push_back(NULL);+ f.event(messages, GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_DOWN, 120, 220);+ CHECK(f.engine.view.lookAtCalls == 1);+ f.event(messages, GameMessage::MSG_RAW_MOUSE_RIGHT_BUTTON_UP, 120, 220);+ CHECK(messages.commands.getFirstMessage() == NULL);+}+/* Off the radar the drag pins to the picture's edge, so the camera waits at the map's edge instead ofwherever the last move inside left it. A release outside never reaches the radar, and the next dragthat starts on the battlefield and crosses the radar must still leave the camera alone. */