Skip to content

Commit 2339194

Browse files
authored
unify(translator): Merge message translators from Zero Hour (#2794)
1 parent d37051f commit 2339194

6 files changed

Lines changed: 89 additions & 21 deletions

File tree

Generals/Code/GameEngine/Include/Common/BuildAssistant.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ enum LegalBuildCode CPP_11(: Int)
9292
LBC_NO_CLEAR_PATH,
9393
LBC_SHROUD,
9494
LBC_TOO_CLOSE_TO_SUPPLIES,
95+
LBC_GENERIC_FAILURE,
9596
};
9697

9798
//-------------------------------------------------------------------------------------------------
@@ -109,12 +110,14 @@ class BuildAssistant : public SubsystemInterface
109110

110111
enum LocalLegalToBuildOptions
111112
{
112-
TERRAIN_RESTRICTIONS = 0x00000001, ///< Check for basic terrain restrictions
113-
CLEAR_PATH = 0x00000002, ///< Must be able to path find to location
114-
NO_OBJECT_OVERLAP = 0X00000004, ///< Can't overlap enemy objects, or locally controlled objects that can't move out of the way
115-
USE_QUICK_PATHFIND = 0x00000008, ///< Use the quick pathfind method for CLEAR_PATH
116-
SHROUD_REVEALED = 0x00000010, ///< Check to make sure the shroud is revealed
117-
NO_ENEMY_OBJECT_OVERLAP=0x00000020, ///< Can't overlap enemy objects only.
113+
TERRAIN_RESTRICTIONS = 0x00000001, ///< Check for basic terrain restrictions
114+
CLEAR_PATH = 0x00000002, ///< Must be able to path find to location
115+
NO_OBJECT_OVERLAP = 0X00000004, ///< Can't overlap enemy objects, or locally controlled objects that can't move out of the way
116+
USE_QUICK_PATHFIND = 0x00000008, ///< Use the quick pathfind method for CLEAR_PATH
117+
SHROUD_REVEALED = 0x00000010, ///< Check to make sure the shroud is revealed
118+
NO_ENEMY_OBJECT_OVERLAP = 0x00000020, ///< Can't overlap enemy objects only.
119+
IGNORE_STEALTHED = 0x00000040, ///< Units that we can't see are legal to "build" on. (when moving mouse around)
120+
FAIL_STEALTHED_WITHOUT_FEEDBACK = 0x00000080 ///< USE WITH IGNORE_STEALTHED except it will fail without BIB feedback (when clicking to place).
118121
};
119122

120123
public:

Generals/Code/GameEngine/Source/GameClient/MessageStream/GUICommandTranslator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ GameMessageDisposition GUICommandTranslator::translateGameMessage(const GameMess
451451
//Special weapons are now always context commands...
452452
//---------------------------------------------------------------------------------------
453453
case GUI_COMMAND_SPECIAL_POWER:
454-
case GUI_COMMAND_SPECIAL_POWER_FROM_COMMAND_CENTER:
454+
case GUI_COMMAND_SPECIAL_POWER_FROM_SHORTCUT:
455455
{
456456
return KEEP_MESSAGE;
457457
break;

Generals/Code/GameEngine/Source/GameClient/MessageStream/HintSpy.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ GameMessageDisposition HintSpyTranslator::translateGameMessage(const GameMessage
7878
case GameMessage::MSG_RESUME_CONSTRUCTION_HINT:
7979
case GameMessage::MSG_ENTER_HINT:
8080
case GameMessage::MSG_HIJACK_HINT:
81+
case GameMessage::MSG_SABOTAGE_HINT:
8182
case GameMessage::MSG_CONVERT_TO_CARBOMB_HINT:
8283
#ifdef ALLOW_SURRENDER
8384
case GameMessage::MSG_PICK_UP_PRISONER_HINT:

Generals/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
261261
m_anchor = msg->getArgument( 0 )->pixel;
262262
m_currentPos = msg->getArgument( 0 )->pixel;
263263

264-
// disable mouse scrolling in alternate mouse mode, per Harvard 7/15/03
265-
if (!TheGlobalData->m_useAlternateMouse && !TheInGameUI->isSelecting() && !m_isScrolling)
264+
if (!TheInGameUI->isSelecting() && !m_isScrolling)
266265
{
267266
setScrolling(SCROLL_RMB);
268267
}
@@ -611,6 +610,18 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
611610
}
612611
#endif // #if defined(RTS_DEBUG)
613612

613+
// ------------------------------------------------------------------------
614+
#if defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
615+
case GameMessage::MSG_CHEAT_DESHROUD:
616+
{
617+
if (!TheGameLogic->isInMultiplayerGame())
618+
{
619+
ThePartitionManager->revealMapForPlayerPermanently( ThePlayerList->getLocalPlayer()->getPlayerIndex() );
620+
}
621+
break;
622+
}
623+
#endif // #if defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
624+
614625
// ------------------------------------------------------------------------
615626
#if defined(RTS_DEBUG)
616627
case GameMessage::MSG_META_DEMO_ENSHROUD:
@@ -626,7 +637,7 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
626637
#if defined(RTS_DEBUG)
627638
case GameMessage::MSG_META_DEMO_BEGIN_ADJUST_FOV:
628639
{
629-
DEBUG_ASSERTCRASH(!m_isChangingFOV, ("hmm, mismatched m_isChangingFOV"));
640+
//DEBUG_ASSERTCRASH(!m_isChangingFOV, ("hmm, mismatched m_isChangingFOV"));
630641
m_isChangingFOV = true;
631642
m_anchor = m_currentPos;
632643
disp = DESTROY_MESSAGE;
@@ -638,7 +649,7 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
638649
#if defined(RTS_DEBUG)
639650
case GameMessage::MSG_META_DEMO_END_ADJUST_FOV:
640651
{
641-
DEBUG_ASSERTCRASH(m_isChangingFOV, ("hmm, mismatched m_isChangingFOV"));
652+
// DEBUG_ASSERTCRASH(m_isChangingFOV, ("hmm, mismatched m_isChangingFOV"));
642653
m_isChangingFOV = false;
643654
disp = DESTROY_MESSAGE;
644655
break;

Generals/Code/GameEngine/Source/GameClient/MessageStream/PlaceEventTranslator.cpp

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,25 @@
2727

2828
#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine
2929

30+
#include "Common/BuildAssistant.h"
3031
#include "Common/GameAudio.h"
3132
#include "Common/Player.h"
3233
#include "Common/PlayerList.h"
34+
#include "Common/SpecialPower.h"
3335
#include "Common/ThingTemplate.h"
34-
#include "Common/BuildAssistant.h"
35-
36-
#include "GameLogic/Object.h"
37-
#include "GameLogic/GameLogic.h"
3836

3937
#include "GameClient/CommandXlat.h"
40-
#include "GameClient/PlaceEventTranslator.h"
38+
#include "GameClient/ControlBar.h"
4139
#include "GameClient/Drawable.h"
4240
#include "GameClient/Eva.h"
41+
#include "GameClient/PlaceEventTranslator.h"
42+
43+
#include "GameLogic/GameLogic.h"
44+
#include "GameLogic/Object.h"
45+
46+
#include "GameLogic/Module/ProductionUpdate.h"
47+
48+
4349

4450
//-------------------------------------------------------------------------------------------------
4551
PlaceEventTranslator::PlaceEventTranslator() : m_frameOfUpButton(-1)
@@ -218,13 +224,42 @@ GameMessageDisposition PlaceEventTranslator::translateGameMessage(const GameMess
218224
BuildAssistant::TERRAIN_RESTRICTIONS |
219225
BuildAssistant::CLEAR_PATH |
220226
BuildAssistant::NO_OBJECT_OVERLAP |
221-
BuildAssistant::SHROUD_REVEALED,
227+
BuildAssistant::SHROUD_REVEALED |
228+
BuildAssistant::IGNORE_STEALTHED |
229+
BuildAssistant::FAIL_STEALTHED_WITHOUT_FEEDBACK,
222230
builderObj, nullptr );
223231
if( lbc == LBC_OK )
224232
{
225-
226-
/** @todo Do not send local player id as argument once we have player ids
227-
tied into all messages automatically */
233+
//Are we building this structure via the special power system? (special case for sneak attack)
234+
if( builderObj )
235+
{
236+
ProductionUpdateInterface *puInterface = builderObj->getProductionUpdateInterface();
237+
if( puInterface )
238+
{
239+
const CommandButton *commandButton = puInterface->getSpecialPowerConstructionCommandButton();
240+
if( commandButton )
241+
{
242+
//If we get this far, then we aren't going to really build the object using the production update
243+
//interface. Instead, we're going to trigger the special power to create it magically without a
244+
//dozer/worker.
245+
placeMsg = TheMessageStream->appendMessage( GameMessage::MSG_DO_SPECIAL_POWER_AT_LOCATION );
246+
placeMsg->appendIntegerArgument( commandButton->getSpecialPowerTemplate()->getID() ); //The ID of the special power template.
247+
placeMsg->appendLocationArgument( world ); //Position of special to be fired.
248+
placeMsg->appendRealArgument( angle ); //Angle of special to be fired.
249+
placeMsg->appendObjectIDArgument( INVALID_ID ); //There is no object in the way.
250+
placeMsg->appendIntegerArgument( commandButton->getOptions() ); //Command button options.
251+
placeMsg->appendObjectIDArgument( builderObj->getID() ); //The source object responsible for firing the special.
252+
253+
// get out of pending placement mode, this will also clear the arrow anchor status
254+
TheInGameUI->placeBuildAvailable( nullptr, nullptr );
255+
256+
// used the input
257+
disp = DESTROY_MESSAGE;
258+
m_frameOfUpButton = TheGameLogic->getFrame();
259+
break;
260+
}
261+
}
262+
}
228263

229264
// create the right kind of message
230265
if( isLineBuild )

Generals/Code/GameEngine/Source/GameClient/MessageStream/WindowXlat.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,25 @@ GameMessageDisposition WindowTranslator::translateGameMessage(const GameMessage
173173

174174
if (TheTacticalView && TheTacticalView->isMouseLocked())
175175
{
176-
return KEEP_MESSAGE;
176+
//Kris: Aug 15, 2003
177+
//Added the scrolling check that will not return KEEP_MESSAGE if we happen
178+
//to in scrolling mode (via keyboard or mouse) and left click in the controlbar.
179+
//Without this code, the left click goes through the interface ignoring buttons and blockage
180+
//and ends up issuing orders right through the controlbar!
181+
if( TheInGameUI->isScrolling() )
182+
{
183+
if( msg->getType() != GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_UP &&
184+
msg->getType() != GameMessage::MSG_RAW_MOUSE_LEFT_BUTTON_DOWN )
185+
{
186+
//We're scrolling, but unless we're clicking the left button, get out.
187+
return KEEP_MESSAGE;
188+
}
189+
//Pass through and handle button clicks or getting input blocked!
190+
}
191+
else
192+
{
193+
return KEEP_MESSAGE;
194+
}
177195
}
178196

179197
switch( msg->getType() )

0 commit comments

Comments
 (0)