Skip to content

Commit bacee75

Browse files
fix(logic): Improve validation of MSG_DO_SPECIAL_POWER and variants in GameLogicDispatch (#2380)
1 parent aa36cd6 commit bacee75

2 files changed

Lines changed: 96 additions & 0 deletions

File tree

Generals/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,18 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
663663
Object* source = findObjectByID(sourceID);
664664
if (source != nullptr)
665665
{
666+
#if !RETAIL_COMPATIBLE_CRC
667+
// TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object
668+
if ( source->getControllingPlayer() != thisPlayer )
669+
{
670+
DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER: Player '%ls' attempted to control the object '%s' owned by player '%ls'.",
671+
thisPlayer->getPlayerDisplayName().str(),
672+
source->getTemplate()->getName().str(),
673+
source->getControllingPlayer()->getPlayerDisplayName().str()) );
674+
break;
675+
}
676+
#endif
677+
666678
AIGroupPtr theGroup = TheAI->createGroup();
667679
theGroup->add(source);
668680
theGroup->groupDoSpecialPower( specialPowerID, options );
@@ -705,6 +717,18 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
705717
Object* source = findObjectByID(sourceID);
706718
if (source != nullptr)
707719
{
720+
#if !RETAIL_COMPATIBLE_CRC
721+
// TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object
722+
if ( source->getControllingPlayer() != thisPlayer )
723+
{
724+
DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_AT_LOCATION: Player '%ls' attempted to control the object '%s' owned by player '%ls'.",
725+
thisPlayer->getPlayerDisplayName().str(),
726+
source->getTemplate()->getName().str(),
727+
source->getControllingPlayer()->getPlayerDisplayName().str()) );
728+
break;
729+
}
730+
#endif
731+
708732
AIGroupPtr theGroup = TheAI->createGroup();
709733
theGroup->add(source);
710734
theGroup->groupDoSpecialPowerAtLocation( specialPowerID, &targetCoord, INVALID_ANGLE, objectInWay, options );
@@ -748,6 +772,18 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
748772
Object* source = findObjectByID(sourceID);
749773
if (source != nullptr)
750774
{
775+
#if !RETAIL_COMPATIBLE_CRC
776+
// TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object
777+
if ( source->getControllingPlayer() != thisPlayer )
778+
{
779+
DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_AT_OBJECT: Player '%ls' attempted to control the object '%s' owned by player '%ls'.",
780+
thisPlayer->getPlayerDisplayName().str(),
781+
source->getTemplate()->getName().str(),
782+
source->getControllingPlayer()->getPlayerDisplayName().str()) );
783+
break;
784+
}
785+
#endif
786+
751787
AIGroupPtr theGroup = TheAI->createGroup();
752788
theGroup->add(source);
753789
theGroup->groupDoSpecialPowerAtObject( specialPowerID, target, options );
@@ -1189,6 +1225,18 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
11891225
Object* source = findObjectByID(sourceID);
11901226
if (source != nullptr)
11911227
{
1228+
#if !RETAIL_COMPATIBLE_CRC
1229+
// TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object
1230+
if ( source->getControllingPlayer() != thisPlayer )
1231+
{
1232+
DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION: Player '%ls' attempted to control the object '%s' owned by player '%ls'.",
1233+
thisPlayer->getPlayerDisplayName().str(),
1234+
source->getTemplate()->getName().str(),
1235+
source->getControllingPlayer()->getPlayerDisplayName().str()) );
1236+
break;
1237+
}
1238+
#endif
1239+
11921240
AIGroupPtr theGroup = TheAI->createGroup();
11931241
theGroup->add(source);
11941242
theGroup->groupOverrideSpecialPowerDestination( spType, loc, CMD_FROM_PLAYER );

GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,18 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
680680
Object* source = findObjectByID(sourceID);
681681
if (source != nullptr)
682682
{
683+
#if !RETAIL_COMPATIBLE_CRC
684+
// TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object
685+
if ( source->getControllingPlayer() != thisPlayer )
686+
{
687+
DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER: Player '%ls' attempted to control the object '%s' owned by player '%ls'.",
688+
thisPlayer->getPlayerDisplayName().str(),
689+
source->getTemplate()->getName().str(),
690+
source->getControllingPlayer()->getPlayerDisplayName().str()) );
691+
break;
692+
}
693+
#endif
694+
683695
AIGroupPtr theGroup = TheAI->createGroup();
684696
theGroup->add(source);
685697
theGroup->groupDoSpecialPower( specialPowerID, options );
@@ -725,6 +737,18 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
725737
Object* source = findObjectByID(sourceID);
726738
if (source != nullptr)
727739
{
740+
#if !RETAIL_COMPATIBLE_CRC
741+
// TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object
742+
if ( source->getControllingPlayer() != thisPlayer )
743+
{
744+
DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_AT_LOCATION: Player '%ls' attempted to control the object '%s' owned by player '%ls'.",
745+
thisPlayer->getPlayerDisplayName().str(),
746+
source->getTemplate()->getName().str(),
747+
source->getControllingPlayer()->getPlayerDisplayName().str()) );
748+
break;
749+
}
750+
#endif
751+
728752
AIGroupPtr theGroup = TheAI->createGroup();
729753
theGroup->add(source);
730754
theGroup->groupDoSpecialPowerAtLocation( specialPowerID, &targetCoord, angle, objectInWay, options );
@@ -768,6 +792,18 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
768792
Object* source = findObjectByID(sourceID);
769793
if (source != nullptr)
770794
{
795+
#if !RETAIL_COMPATIBLE_CRC
796+
// TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object
797+
if ( source->getControllingPlayer() != thisPlayer )
798+
{
799+
DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_AT_OBJECT: Player '%ls' attempted to control the object '%s' owned by player '%ls'.",
800+
thisPlayer->getPlayerDisplayName().str(),
801+
source->getTemplate()->getName().str(),
802+
source->getControllingPlayer()->getPlayerDisplayName().str()) );
803+
break;
804+
}
805+
#endif
806+
771807
AIGroupPtr theGroup = TheAI->createGroup();
772808
theGroup->add(source);
773809
theGroup->groupDoSpecialPowerAtObject( specialPowerID, target, options );
@@ -1211,6 +1247,18 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )
12111247
Object* source = findObjectByID(sourceID);
12121248
if (source != nullptr)
12131249
{
1250+
#if !RETAIL_COMPATIBLE_CRC
1251+
// TheSuperHackers @fix stephanmeesters 01/03/2026 Validate the origin of the source object
1252+
if ( source->getControllingPlayer() != thisPlayer )
1253+
{
1254+
DEBUG_CRASH( ("MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION: Player '%ls' attempted to control the object '%s' owned by player '%ls'.",
1255+
thisPlayer->getPlayerDisplayName().str(),
1256+
source->getTemplate()->getName().str(),
1257+
source->getControllingPlayer()->getPlayerDisplayName().str()) );
1258+
break;
1259+
}
1260+
#endif
1261+
12141262
AIGroupPtr theGroup = TheAI->createGroup();
12151263
theGroup->add(source);
12161264
theGroup->groupOverrideSpecialPowerDestination( spType, loc, CMD_FROM_PLAYER );

0 commit comments

Comments
 (0)