Skip to content

Commit ec2c22e

Browse files
authored
Revert "[GEN][ZH] Decouple the Game Logic update in ParticleUplinkCannonUpdate from the Orbit To Ground Laser drawable (#976)" (#1050)
This reverts commit ef17abf.
1 parent 92ea8b3 commit ec2c22e

File tree

2 files changed

+84
-114
lines changed

2 files changed

+84
-114
lines changed

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

Lines changed: 42 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,16 @@ void ParticleUplinkCannonUpdate::killEverything()
211211
removeAllEffects();
212212

213213
//This laser is independent from the other effects and needs to be specially handled.
214-
if( m_orbitToTargetBeamID != INVALID_DRAWABLE_ID )
214+
if( m_orbitToTargetBeamID )
215215
{
216216
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
217217
if( beam )
218218
{
219219
TheGameClient->destroyDrawable( beam );
220220
}
221221
m_orbitToTargetBeamID = INVALID_DRAWABLE_ID;
222+
m_orbitToTargetLaserRadius = LaserRadiusUpdate();
222223
}
223-
m_orbitToTargetLaserRadius = LaserRadiusUpdate();
224224

225225
TheAudio->removeAudioEvent( m_powerupSound.getPlayingHandle() );
226226
TheAudio->removeAudioEvent( m_unpackToReadySound.getPlayingHandle() );
@@ -410,43 +410,40 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
410410
break;
411411
case LASERSTATUS_BORN:
412412
{
413-
if( orbitalDecayStart <= now )
413+
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
414+
if( beam )
414415
{
415-
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
416-
if( beam )
416+
//m_annihilationSound.setPosition( beam->getPosition() );
417+
if( orbitalDecayStart <= now )
417418
{
418-
//m_annihilationSound.setPosition( beam->getPosition() );
419419
static NameKeyType nameKeyClientUpdate = NAMEKEY( "LaserUpdate" );
420420
LaserUpdate *update = (LaserUpdate*)beam->findClientUpdateModule( nameKeyClientUpdate );
421421
if( update )
422422
{
423423
update->setDecayFrames( data->m_widthGrowFrames );
424+
m_orbitToTargetLaserRadius.setDecayFrames( data->m_widthGrowFrames );
424425
}
426+
m_laserStatus = LASERSTATUS_DECAYING;
425427
}
426-
m_orbitToTargetLaserRadius.setDecayFrames( data->m_widthGrowFrames );
427-
m_laserStatus = LASERSTATUS_DECAYING;
428428
}
429429
break;
430430
}
431431
case LASERSTATUS_DECAYING:
432432
{
433-
if( orbitalDeathFrame <= now )
433+
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
434+
if( beam )
434435
{
436+
//m_annihilationSound.setPosition( beam->getPosition() );
435437
TheAudio->removeAudioEvent( m_annihilationSound.getPlayingHandle() );
436-
if ( m_orbitToTargetBeamID != INVALID_DRAWABLE_ID )
438+
if( orbitalDeathFrame <= now )
437439
{
438-
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
439-
if( beam )
440-
{
441-
//m_annihilationSound.setPosition( beam->getPosition() );
442-
TheGameClient->destroyDrawable( beam );
443-
}
440+
TheGameClient->destroyDrawable( beam );
444441
m_orbitToTargetBeamID = INVALID_DRAWABLE_ID;
442+
m_orbitToTargetLaserRadius = LaserRadiusUpdate();
443+
m_laserStatus = LASERSTATUS_DEAD;
444+
m_startAttackFrame = 0;
445+
setLogicalStatus( STATUS_IDLE );
445446
}
446-
m_orbitToTargetLaserRadius = LaserRadiusUpdate();
447-
m_laserStatus = LASERSTATUS_DEAD;
448-
m_startAttackFrame = 0;
449-
setLogicalStatus( STATUS_IDLE );
450447
}
451448
break;
452449
}
@@ -455,8 +452,8 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
455452
break;
456453
}
457454

458-
const Bool isFiring = m_laserStatus != LASERSTATUS_NONE && m_laserStatus != LASERSTATUS_DEAD;
459-
if ( isFiring )
455+
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
456+
if( beam && orbitalBirthFrame <= now && now <= orbitalDeathFrame )
460457
{
461458

462459
if( !m_manualTargetMode )
@@ -551,35 +548,27 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
551548

552549
Real scorchRadius = 0.0f;
553550
Real damageRadius = 0.0f;
554-
Real templateLaserRadius = 13.0f;
555-
Real visualLaserRadius = 0.0f;
556551

557552
//Reset the laser position
558-
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
559-
if ( beam )
553+
static NameKeyType nameKeyClientUpdate = NAMEKEY( "LaserUpdate" );
554+
LaserUpdate *update = (LaserUpdate*)beam->findClientUpdateModule( nameKeyClientUpdate );
555+
if( update )
560556
{
561-
static NameKeyType nameKeyClientUpdate = NAMEKEY( "LaserUpdate" );
562-
LaserUpdate *update = (LaserUpdate*)beam->findClientUpdateModule( nameKeyClientUpdate );
563-
if( update )
564-
{
565-
update->initLaser( NULL, &orbitPosition, &m_currentTargetPosition );
566-
// TheSuperHackers @logic-client-separation The GameLogic has a dependency on this drawable.
567-
// The logical laser radius for the damage should probably be part of ParticleUplinkCannonUpdateModuleData.
568-
templateLaserRadius = update->getTemplateLaserRadius();
569-
visualLaserRadius = update->getCurrentLaserRadius();
570-
}
571-
}
572-
// TheSuperHackers @refactor helmutbuhler/xezon 17/05/2025
573-
// Originally the damageRadius was calculated with a value updated by LaserUpdate::clientUpdate.
574-
// To no longer rely on GameClient updates, this class now maintains a copy of the LaserRadiusUpdate.
575-
m_orbitToTargetLaserRadius.updateRadius();
576-
const Real logicalLaserRadius = templateLaserRadius * m_orbitToTargetLaserRadius.getWidthScale();
577-
damageRadius = logicalLaserRadius * data->m_damageRadiusScalar;
578-
scorchRadius = logicalLaserRadius * data->m_scorchMarkScalar;
579-
#if defined(RETAIL_COMPATIBLE_CRC)
580-
DEBUG_ASSERTCRASH(logicalLaserRadius == visualLaserRadius,
581-
("ParticleUplinkCannonUpdate's laser radius does not match LaserUpdate's laser radius - will cause mismatch in VS6 retail compatible builds\n"));
557+
update->initLaser( NULL, &orbitPosition, &m_currentTargetPosition );
558+
const Real visualLaserRadius = update->getCurrentLaserRadius();
559+
scorchRadius = visualLaserRadius * data->m_scorchMarkScalar;
560+
561+
// TheSuperHackers @refactor helmutbuhler/xezon 17/05/2025
562+
// Originally the damage radius was calculated with a value updated by LaserUpdate::clientUpdate().
563+
// To no longer rely on client updates, this class now maintains a logical copy of the visual laser radius.
564+
m_orbitToTargetLaserRadius.updateRadius();
565+
const Real logicalLaserRadius = update->getTemplateLaserRadius() * m_orbitToTargetLaserRadius.getWidthScale();
566+
damageRadius = logicalLaserRadius * data->m_damageRadiusScalar;
567+
#if RETAIL_COMPATIBLE_CRC
568+
DEBUG_ASSERTCRASH(logicalLaserRadius == visualLaserRadius,
569+
("ParticleUplinkCannonUpdate's laser radius does not match LaserUpdate's laser radius - will cause mismatch in VS6 retail compatible builds\n"));
582570
#endif
571+
}
583572

584573
//Create scorch marks periodically
585574
if( m_nextScorchMarkFrame <= now )
@@ -928,15 +917,13 @@ void ParticleUplinkCannonUpdate::createOrbitToTargetLaser( UnsignedInt growthFra
928917
{
929918
const ParticleUplinkCannonUpdateModuleData *data = getParticleUplinkCannonUpdateModuleData();
930919

931-
if ( m_orbitToTargetBeamID != INVALID_DRAWABLE_ID )
920+
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
921+
if( beam )
932922
{
933-
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
934-
if( beam )
935-
{
936-
TheAudio->removeAudioEvent( m_annihilationSound.getPlayingHandle() );
937-
TheGameClient->destroyDrawable( beam );
938-
}
923+
TheAudio->removeAudioEvent( m_annihilationSound.getPlayingHandle() );
924+
TheGameClient->destroyDrawable( beam );
939925
m_orbitToTargetBeamID = INVALID_DRAWABLE_ID;
926+
m_orbitToTargetLaserRadius = LaserRadiusUpdate();
940927
}
941928

942929
if( data->m_particleBeamLaserName.isNotEmpty() )
@@ -956,6 +943,7 @@ void ParticleUplinkCannonUpdate::createOrbitToTargetLaser( UnsignedInt growthFra
956943
orbitPosition.set( &m_initialTargetPosition );
957944
orbitPosition.z += 500.0f;
958945
update->initLaser( NULL, &orbitPosition, &m_initialTargetPosition, growthFrames );
946+
m_orbitToTargetLaserRadius.initRadius( growthFrames );
959947
}
960948
}
961949
}
@@ -966,9 +954,6 @@ void ParticleUplinkCannonUpdate::createOrbitToTargetLaser( UnsignedInt growthFra
966954
m_annihilationSound.setPlayingHandle( TheAudio->addAudioEvent( &m_annihilationSound ) );
967955
}
968956
}
969-
970-
m_orbitToTargetLaserRadius = LaserRadiusUpdate();
971-
m_orbitToTargetLaserRadius.initRadius( growthFrames );
972957
}
973958

974959
//-------------------------------------------------------------------------------------------------

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

Lines changed: 42 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,16 @@ void ParticleUplinkCannonUpdate::killEverything()
212212
removeAllEffects();
213213

214214
//This laser is independent from the other effects and needs to be specially handled.
215-
if( m_orbitToTargetBeamID != INVALID_DRAWABLE_ID )
215+
if( m_orbitToTargetBeamID )
216216
{
217217
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
218218
if( beam )
219219
{
220220
TheGameClient->destroyDrawable( beam );
221221
}
222222
m_orbitToTargetBeamID = INVALID_DRAWABLE_ID;
223+
m_orbitToTargetLaserRadius = LaserRadiusUpdate();
223224
}
224-
m_orbitToTargetLaserRadius = LaserRadiusUpdate();
225225

226226
TheAudio->removeAudioEvent( m_powerupSound.getPlayingHandle() );
227227
TheAudio->removeAudioEvent( m_unpackToReadySound.getPlayingHandle() );
@@ -457,43 +457,40 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
457457
break;
458458
case LASERSTATUS_BORN:
459459
{
460-
if( orbitalDecayStart <= now )
460+
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
461+
if( beam )
461462
{
462-
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
463-
if( beam )
463+
//m_annihilationSound.setPosition( beam->getPosition() );
464+
if( orbitalDecayStart <= now )
464465
{
465-
//m_annihilationSound.setPosition( beam->getPosition() );
466466
static NameKeyType nameKeyClientUpdate = NAMEKEY( "LaserUpdate" );
467467
LaserUpdate *update = (LaserUpdate*)beam->findClientUpdateModule( nameKeyClientUpdate );
468468
if( update )
469469
{
470470
update->setDecayFrames( data->m_widthGrowFrames );
471+
m_orbitToTargetLaserRadius.setDecayFrames( data->m_widthGrowFrames );
471472
}
473+
m_laserStatus = LASERSTATUS_DECAYING;
472474
}
473-
m_orbitToTargetLaserRadius.setDecayFrames( data->m_widthGrowFrames );
474-
m_laserStatus = LASERSTATUS_DECAYING;
475475
}
476476
break;
477477
}
478478
case LASERSTATUS_DECAYING:
479479
{
480-
if( orbitalDeathFrame <= now )
480+
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
481+
if( beam )
481482
{
483+
//m_annihilationSound.setPosition( beam->getPosition() );
482484
TheAudio->removeAudioEvent( m_annihilationSound.getPlayingHandle() );
483-
if ( m_orbitToTargetBeamID != INVALID_DRAWABLE_ID )
485+
if( orbitalDeathFrame <= now )
484486
{
485-
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
486-
if( beam )
487-
{
488-
//m_annihilationSound.setPosition( beam->getPosition() );
489-
TheGameClient->destroyDrawable( beam );
490-
}
487+
TheGameClient->destroyDrawable( beam );
491488
m_orbitToTargetBeamID = INVALID_DRAWABLE_ID;
489+
m_orbitToTargetLaserRadius = LaserRadiusUpdate();
490+
m_laserStatus = LASERSTATUS_DEAD;
491+
m_startAttackFrame = 0;
492+
setLogicalStatus( STATUS_IDLE );
492493
}
493-
m_orbitToTargetLaserRadius = LaserRadiusUpdate();
494-
m_laserStatus = LASERSTATUS_DEAD;
495-
m_startAttackFrame = 0;
496-
setLogicalStatus( STATUS_IDLE );
497494
}
498495
break;
499496
}
@@ -502,8 +499,8 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
502499
break;
503500
}
504501

505-
const Bool isFiring = m_laserStatus != LASERSTATUS_NONE && m_laserStatus != LASERSTATUS_DEAD;
506-
if ( isFiring )
502+
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
503+
if( beam && orbitalBirthFrame <= now && now <= orbitalDeathFrame )
507504
{
508505

509506
if( !m_manualTargetMode && !m_scriptedWaypointMode )
@@ -612,35 +609,27 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
612609

613610
Real scorchRadius = 0.0f;
614611
Real damageRadius = 0.0f;
615-
Real templateLaserRadius = 13.0f;
616-
Real visualLaserRadius = 0.0f;
617612

618613
//Reset the laser position
619-
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
620-
if ( beam )
614+
static NameKeyType nameKeyClientUpdate = NAMEKEY( "LaserUpdate" );
615+
LaserUpdate *update = (LaserUpdate*)beam->findClientUpdateModule( nameKeyClientUpdate );
616+
if( update )
621617
{
622-
static NameKeyType nameKeyClientUpdate = NAMEKEY( "LaserUpdate" );
623-
LaserUpdate *update = (LaserUpdate*)beam->findClientUpdateModule( nameKeyClientUpdate );
624-
if( update )
625-
{
626-
update->initLaser( NULL, NULL, &orbitPosition, &m_currentTargetPosition, "" );
627-
// TheSuperHackers @logic-client-separation The GameLogic has a dependency on this drawable.
628-
// The logical laser radius for the damage should probably be part of ParticleUplinkCannonUpdateModuleData.
629-
templateLaserRadius = update->getTemplateLaserRadius();
630-
visualLaserRadius = update->getCurrentLaserRadius();
631-
}
632-
}
633-
// TheSuperHackers @refactor helmutbuhler/xezon 17/05/2025
634-
// Originally the damageRadius was calculated with a value updated by LaserUpdate::clientUpdate.
635-
// To no longer rely on GameClient updates, this class now maintains a copy of the LaserRadiusUpdate.
636-
m_orbitToTargetLaserRadius.updateRadius();
637-
const Real logicalLaserRadius = templateLaserRadius * m_orbitToTargetLaserRadius.getWidthScale();
638-
damageRadius = logicalLaserRadius * data->m_damageRadiusScalar;
639-
scorchRadius = logicalLaserRadius * data->m_scorchMarkScalar;
640-
#if defined(RETAIL_COMPATIBLE_CRC)
641-
DEBUG_ASSERTCRASH(logicalLaserRadius == visualLaserRadius,
642-
("ParticleUplinkCannonUpdate's laser radius does not match LaserUpdate's laser radius - will cause mismatch in VS6 retail compatible builds\n"));
618+
update->initLaser( NULL, NULL, &orbitPosition, &m_currentTargetPosition, "" );
619+
const Real visualLaserRadius = update->getCurrentLaserRadius();
620+
scorchRadius = visualLaserRadius * data->m_scorchMarkScalar;
621+
622+
// TheSuperHackers @refactor helmutbuhler/xezon 17/05/2025
623+
// Originally the damage radius was calculated with a value updated by LaserUpdate::clientUpdate().
624+
// To no longer rely on client updates, this class now maintains a logical copy of the visual laser radius.
625+
m_orbitToTargetLaserRadius.updateRadius();
626+
const Real logicalLaserRadius = update->getTemplateLaserRadius() * m_orbitToTargetLaserRadius.getWidthScale();
627+
damageRadius = logicalLaserRadius * data->m_damageRadiusScalar;
628+
#if RETAIL_COMPATIBLE_XFER_CRC
629+
DEBUG_ASSERTCRASH(logicalLaserRadius == visualLaserRadius,
630+
("ParticleUplinkCannonUpdate's laser radius does not match LaserUpdate's laser radius - will cause mismatch in VS6 retail compatible builds\n"));
643631
#endif
632+
}
644633

645634
//Create scorch marks periodically
646635
if( m_nextScorchMarkFrame <= now )
@@ -999,15 +988,13 @@ void ParticleUplinkCannonUpdate::createOrbitToTargetLaser( UnsignedInt growthFra
999988
{
1000989
const ParticleUplinkCannonUpdateModuleData *data = getParticleUplinkCannonUpdateModuleData();
1001990

1002-
if ( m_orbitToTargetBeamID != INVALID_DRAWABLE_ID )
991+
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
992+
if( beam )
1003993
{
1004-
Drawable *beam = TheGameClient->findDrawableByID( m_orbitToTargetBeamID );
1005-
if( beam )
1006-
{
1007-
TheAudio->removeAudioEvent( m_annihilationSound.getPlayingHandle() );
1008-
TheGameClient->destroyDrawable( beam );
1009-
}
994+
TheAudio->removeAudioEvent( m_annihilationSound.getPlayingHandle() );
995+
TheGameClient->destroyDrawable( beam );
1010996
m_orbitToTargetBeamID = INVALID_DRAWABLE_ID;
997+
m_orbitToTargetLaserRadius = LaserRadiusUpdate();
1011998
}
1012999

10131000
if( data->m_particleBeamLaserName.isNotEmpty() )
@@ -1027,6 +1014,7 @@ void ParticleUplinkCannonUpdate::createOrbitToTargetLaser( UnsignedInt growthFra
10271014
orbitPosition.set( &m_initialTargetPosition );
10281015
orbitPosition.z += 500.0f;
10291016
update->initLaser( NULL, NULL, &orbitPosition, &m_initialTargetPosition, "", growthFrames );
1017+
m_orbitToTargetLaserRadius.initRadius( growthFrames );
10301018
}
10311019
}
10321020
}
@@ -1037,9 +1025,6 @@ void ParticleUplinkCannonUpdate::createOrbitToTargetLaser( UnsignedInt growthFra
10371025
m_annihilationSound.setPlayingHandle( TheAudio->addAudioEvent( &m_annihilationSound ) );
10381026
}
10391027
}
1040-
1041-
m_orbitToTargetLaserRadius = LaserRadiusUpdate();
1042-
m_orbitToTargetLaserRadius.initRadius( growthFrames );
10431028
}
10441029

10451030
//-------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)