Skip to content

Commit 3b5d298

Browse files
authored
refactor(specialpower): Clean up ParticleUplinkCannonUpdate::initiateIntentToDoSpecialPower (#1402)
1 parent 88b545e commit 3b5d298

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

Generals/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ Bool ParticleUplinkCannonUpdate::initiateIntentToDoSpecialPower(const SpecialPow
275275

276276
if( !BitIsSet( commandOptions, COMMAND_FIRED_BY_SCRIPT ) )
277277
{
278+
DEBUG_ASSERTCRASH(targetPos, ("Particle Cannon target data must not be NULL"));
279+
278280
//All human players have manual control and must "drive" the beam around!
279281
m_startAttackFrame = TheGameLogic->getFrame();
280282
m_laserStatus = LASERSTATUS_NONE;
@@ -285,14 +287,17 @@ Bool ParticleUplinkCannonUpdate::initiateIntentToDoSpecialPower(const SpecialPow
285287
}
286288
else
287289
{
290+
DEBUG_ASSERTCRASH(targetPos, ("Particle Cannon target data must not be NULL"));
291+
288292
//All computer controlled players have automatic control -- the "S" curve.
289293
UnsignedInt now = TheGameLogic->getFrame();
290-
m_initialTargetPosition.set( targetPos );
291-
m_startAttackFrame = max( now, (UnsignedInt)1 );
292-
m_laserStatus = LASERSTATUS_NONE;
294+
m_initialTargetPosition.set( targetPos );
295+
m_startAttackFrame = max( now, (UnsignedInt)1 );
296+
m_laserStatus = LASERSTATUS_NONE;
293297
setLogicalStatus( STATUS_READY_TO_FIRE );
294298
m_specialPowerModule->setReadyFrame( now );
295299
}
300+
296301
m_startDecayFrame = m_startAttackFrame + data->m_totalFiringFrames;
297302

298303
SpecialPowerModuleInterface *spmInterface = getObject()->getSpecialPowerModule( specialPowerTemplate );

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

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,10 @@ Bool ParticleUplinkCannonUpdate::initiateIntentToDoSpecialPower(const SpecialPow
274274
return FALSE;
275275
}
276276

277-
// getObject()->getControllingPlayer()->getAcademyStats()->recordSpecialPowerUsed( specialPowerTemplate );
278-
279277
if( !BitIsSet( commandOptions, COMMAND_FIRED_BY_SCRIPT ) )
280278
{
279+
DEBUG_ASSERTCRASH(targetPos, ("Particle Cannon target data must not be NULL"));
280+
281281
//All human players have manual control and must "drive" the beam around!
282282
m_startAttackFrame = TheGameLogic->getFrame();
283283
m_laserStatus = LASERSTATUS_NONE;
@@ -293,28 +293,21 @@ Bool ParticleUplinkCannonUpdate::initiateIntentToDoSpecialPower(const SpecialPow
293293
{
294294
//Script fired with a specific waypoint path, so set things up to follow the waypoint!
295295
UnsignedInt now = TheGameLogic->getFrame();
296-
296+
297297
Coord3D pos;
298-
if( way )
299-
{
300-
pos.set( way->getLocation() );
301-
}
302-
else if( targetObj )
303-
{
304-
pos.set( targetObj->getPosition() );
305-
}
306-
m_startAttackFrame = max( now, (UnsignedInt)1 );
298+
pos.set( way->getLocation() );
299+
300+
m_startAttackFrame = max( now, (UnsignedInt)1 );
307301
#if !RETAIL_COMPATIBLE_CRC
308302
m_manualTargetMode = FALSE;
309303
#endif
310304
m_scriptedWaypointMode = TRUE;
311-
m_laserStatus = LASERSTATUS_NONE;
305+
m_laserStatus = LASERSTATUS_NONE;
312306
setLogicalStatus( STATUS_READY_TO_FIRE );
313307
m_specialPowerModule->setReadyFrame( now );
314-
m_initialTargetPosition.set( &pos );
308+
m_initialTargetPosition.set( &pos );
315309
m_currentTargetPosition.set( &pos );
316310

317-
m_nextDestWaypointID = way->getID();
318311
Int linkCount = way->getNumLinks();
319312
Int which = GameLogicRandomValue( 0, linkCount-1 );
320313
Waypoint *next = way->getLink( which );
@@ -323,10 +316,15 @@ Bool ParticleUplinkCannonUpdate::initiateIntentToDoSpecialPower(const SpecialPow
323316
m_nextDestWaypointID = next->getID();
324317
m_overrideTargetDestination.set( next->getLocation() );
325318
}
326-
319+
else
320+
{
321+
m_nextDestWaypointID = way->getID();
322+
}
327323
}
328324
else
329325
{
326+
DEBUG_ASSERTCRASH(targetPos || targetObj, ("Particle Cannon target data must not be NULL"));
327+
330328
//All computer controlled players have automatic control -- the "S" curve.
331329
UnsignedInt now = TheGameLogic->getFrame();
332330

@@ -343,12 +341,13 @@ Bool ParticleUplinkCannonUpdate::initiateIntentToDoSpecialPower(const SpecialPow
343341
m_manualTargetMode = FALSE;
344342
m_scriptedWaypointMode = FALSE;
345343
#endif
346-
m_initialTargetPosition.set( &pos );
347-
m_startAttackFrame = max( now, (UnsignedInt)1 );
348-
m_laserStatus = LASERSTATUS_NONE;
344+
m_initialTargetPosition.set( &pos );
345+
m_startAttackFrame = max( now, (UnsignedInt)1 );
346+
m_laserStatus = LASERSTATUS_NONE;
349347
setLogicalStatus( STATUS_READY_TO_FIRE );
350348
m_specialPowerModule->setReadyFrame( now );
351349
}
350+
352351
m_startDecayFrame = m_startAttackFrame + data->m_totalFiringFrames;
353352

354353
SpecialPowerModuleInterface *spmInterface = getObject()->getSpecialPowerModule( specialPowerTemplate );

0 commit comments

Comments
 (0)