Skip to content

Commit dea07e6

Browse files
committed
Target designator V1 updates
1 parent 3754462 commit dea07e6

6 files changed

Lines changed: 39 additions & 17 deletions

File tree

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/RadiusDecalBehavior.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class RadiusDecalBehaviorModuleData : public UpdateModuleData
4242
public:
4343
UpgradeMuxData m_upgradeMuxData;
4444
Bool m_initiallyActive;
45-
45+
Bool m_worksWhileContained;
4646
RadiusDecalTemplate m_decalTemplate;
4747
Real m_decalRadius;
4848

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerDesignatorUpdate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class SpecialPowerDesignatorUpdate : public RadiusDecalBehavior
7171
// UpdateModuleInterface
7272
virtual UpdateSleepTime update();
7373

74-
//virtual DisabledMaskType getDisabledTypesToProcess() const { return MAKE_DISABLED_MASK(DISABLED_HELD); }
74+
// virtual DisabledMaskType getDisabledTypesToProcess() const { return getSpecialPowerDesignatorUpdateModuleData()->m_worksWhileContained ? DISABLEDMASK_ALL : MAKE_DISABLED_MASK(DISABLED_HELD); }
7575

7676
Real getDesignatorRadius() { return getSpecialPowerDesignatorUpdateModuleData()->m_designatorRadius; }
7777

GeneralsMD/Code/GameEngine/Source/Common/RTS/ActionManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,8 +1594,8 @@ Bool ActionManager::canDoSpecialPowerAtLocation( const Object *obj, const Coord3
15941594
if (update->isValidDesignatorForSpecialPower(spTemplate)) {
15951595

15961596
Real distSqr = ThePartitionManager->getDistanceSquared(obj2, loc, FROM_CENTER_2D);
1597-
Real radiusSqr = update->getDesignatorRadius();
1598-
if (distSqr <= radiusSqr) {
1597+
Real radius = update->getDesignatorRadius();
1598+
if (distSqr <= (radius*radius)) {
15991599
isDesignatorInRange = true;
16001600
break;
16011601
}

GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,9 @@ InGameUI::InGameUI()
11021102

11031103
m_tooltipsDisabledUntil = 0;
11041104

1105+
m_showDesignatorDecals = FALSE;
1106+
m_designatorCommand = NULL;
1107+
11051108
// init hint lists
11061109
for( i = 0; i < MAX_MOVE_HINTS; i++ )
11071110
{
@@ -3246,6 +3249,21 @@ void InGameUI::setGUICommand( const CommandButton *command )
32463249
// set the command
32473250
m_pendingGUICommand = command;
32483251

3252+
// Target designator checks
3253+
if (m_designatorCommand && m_designatorCommand != m_pendingGUICommand) {
3254+
hideDesignatorDecals();
3255+
m_designatorCommand = NULL;
3256+
}
3257+
3258+
if (command && BitIsSet(command->getOptions(), COMMAND_OPTION_NEED_TARGET)) {
3259+
const SpecialPowerTemplate* sp = command->getSpecialPowerTemplate();
3260+
if (sp != nullptr && sp->isNeedsTargetDesignator()) {
3261+
m_showDesignatorDecals = TRUE;
3262+
showDesignatorDecals(command->getSpecialPowerTemplate());
3263+
m_designatorCommand = command;
3264+
}
3265+
}
3266+
32493267
// set the mouse cursor for commands that need a targeting or to normal with no command
32503268
if( command && BitIsSet( command->getOptions(), COMMAND_OPTION_NEED_TARGET ) && !command->isContextCommand() )
32513269
{
@@ -3256,13 +3274,6 @@ void InGameUI::setGUICommand( const CommandButton *command )
32563274
setRadiusCursor(command->getRadiusCursorType(), //*****************************************************************
32573275
command->getSpecialPowerTemplate(),
32583276
command->getWeaponSlot());
3259-
3260-
const SpecialPowerTemplate* sp = command->getSpecialPowerTemplate();
3261-
if (sp != nullptr && sp->isNeedsTargetDesignator()) {
3262-
m_showDesignatorDecals = TRUE;
3263-
showDesignatorDecals(command->getSpecialPowerTemplate());
3264-
m_designatorCommand = command;
3265-
}
32663277
}
32673278
else
32683279
{

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/RadiusDecalBehavior.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ RadiusDecalBehaviorModuleData::RadiusDecalBehaviorModuleData()
4242
{
4343
m_initiallyActive = false;
4444
m_decalRadius = 0.0f;
45+
m_worksWhileContained = false;
4546
}
4647
//-------------------------------------------------------------------------------------------------
4748
//-------------------------------------------------------------------------------------------------
@@ -53,6 +54,7 @@ RadiusDecalBehaviorModuleData::RadiusDecalBehaviorModuleData()
5354
{ "StartsActive", INI::parseBool, NULL, offsetof(RadiusDecalBehaviorModuleData, m_initiallyActive) },
5455
{ "RadiusDecal", RadiusDecalTemplate::parseRadiusDecalTemplate, NULL, offsetof( RadiusDecalBehaviorModuleData, m_decalTemplate) },
5556
{ "Radius", INI::parseReal, NULL, offsetof( RadiusDecalBehaviorModuleData, m_decalRadius) },
57+
{ "WorksWhileContained", INI::parseBool, NULL, offsetof(RadiusDecalBehaviorModuleData, m_worksWhileContained) },
5658
{ 0, 0, 0, 0 }
5759
};
5860

@@ -120,7 +122,7 @@ void RadiusDecalBehavior::clearDecal()
120122
//-------------------------------------------------------------------------------------------------
121123
UpdateSleepTime RadiusDecalBehavior::update( void )
122124
{
123-
if (getObject()->isDisabledByType(DISABLED_HELD)) {
125+
if (getObject()->isDisabledByType(DISABLED_HELD) && !getRadiusDecalBehaviorModuleData()->m_worksWhileContained) {
124126
if (!m_radiusDecal.isEmpty())
125127
clearDecal();
126128
return UPDATE_SLEEP_NONE; // We wait to be re-enabled

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialPowerDesignatorUpdate.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ SpecialPowerDesignatorUpdateModuleData::SpecialPowerDesignatorUpdateModuleData()
5757
{ "SpecialPowerTemplate", INI::parseSpecialPowerTemplate, NULL, offsetof(SpecialPowerDesignatorUpdateModuleData, m_specialPowerTemplate) },
5858
{ "DesignatorRadius", INI::parseReal, NULL, offsetof(SpecialPowerDesignatorUpdateModuleData, m_designatorRadius) },
5959
{ "AlwaysShowDecal", INI::parseBool, NULL, offsetof(SpecialPowerDesignatorUpdateModuleData, m_alwaysShowDecal) },
60+
// { "WorksWhileContained", INI::parseBool, NULL, offsetof(SpecialPowerDesignatorUpdateModuleData, m_worksWhileContained) },
6061
{ "TriggerStatusTime", INI::parseDurationUnsignedInt, NULL, offsetof(SpecialPowerDesignatorUpdateModuleData, m_triggerStatusTime) },
6162
{ "TriggerStatusType", ObjectStatusMaskType::parseSingleBitFromINI, NULL, offsetof(SpecialPowerDesignatorUpdateModuleData, m_triggerStatusType) },
6263
{ "DecalRadius", INI::parseReal, NULL, offsetof( RadiusDecalBehaviorModuleData, m_decalRadius) },
@@ -107,6 +108,8 @@ SpecialPowerDesignatorUpdate::~SpecialPowerDesignatorUpdate( void )
107108
//-------------------------------------------------------------------------------------------------
108109
void SpecialPowerDesignatorUpdate::setActive(bool status)
109110
{
111+
DEBUG_LOG((">>> SpecialPowerDesignatorUpdate::setActive = %d", status));
112+
110113
const SpecialPowerDesignatorUpdateModuleData* data = getSpecialPowerDesignatorUpdateModuleData();
111114

112115
m_targetingActive = status;
@@ -149,30 +152,36 @@ UpdateSleepTime SpecialPowerDesignatorUpdate::update( void )
149152
{
150153
const SpecialPowerDesignatorUpdateModuleData* data = getSpecialPowerDesignatorUpdateModuleData();
151154

155+
UpdateSleepTime result = UPDATE_SLEEP_FOREVER;
152156
// First handle status
153157
if (m_statusClearFrame > 0 && data->m_triggerStatusType != OBJECT_STATUS_NONE) {
154158
if (TheGameLogic->getFrame() == m_statusClearFrame) {
155159
getObject()->clearStatus(MAKE_OBJECT_STATUS_MASK(data->m_triggerStatusType));
156160
}
157161
else {
158-
return UPDATE_SLEEP_NONE;
162+
result = UPDATE_SLEEP_NONE;
159163
}
160164
}
161165

162-
// Then decal
166+
//if (m_statusClearFrame > 0 && data->m_triggerStatusType != OBJECT_STATUS_NONE && TheGameLogic->getFrame() == m_statusClearFrame) {
167+
// getObject()->clearStatus(MAKE_OBJECT_STATUS_MASK(data->m_triggerStatusType));
168+
//}
163169

170+
// Then decal
164171
if (!m_targetingActive && !data->m_alwaysShowDecal) {
165-
return UPDATE_SLEEP_FOREVER;
172+
return MIN(result, UPDATE_SLEEP_FOREVER);
166173
}
167174

168-
return RadiusDecalBehavior::update();
175+
return MIN(RadiusDecalBehavior::update(), UPDATE_SLEEP_FOREVER);
169176
}
170177

171178
// ------------------------------------------------------------------------------------------------
172179
// ------------------------------------------------------------------------------------------------
173180
Bool SpecialPowerDesignatorUpdate::isValidDesignatorForSpecialPower(const SpecialPowerTemplate* templ)
174181
{
175-
return (isUpgradeActive() && templ == getSpecialPowerDesignatorUpdateModuleData()->m_specialPowerTemplate);
182+
return isUpgradeActive() && templ == getSpecialPowerDesignatorUpdateModuleData()->m_specialPowerTemplate &&
183+
(getSpecialPowerDesignatorUpdateModuleData()->m_worksWhileContained || !getObject()->isDisabledByType(DISABLED_HELD));
184+
176185
}
177186

178187
// ------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)