Skip to content

bugfix(specialpower): Fix availability of building based special powers #1444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ SpecialPowerModule::~SpecialPowerModule()
//-------------------------------------------------------------------------------------------------
void SpecialPowerModule::resolveSpecialPower( void )
{
#if !RETAIL_COMPATIBLE_CRC
// TheSuperHackers @info some building based special powers are immediately available
// This means we need to set their available frame to the current frame to make them usable
// The check for a public timer excludes super weapons from the selection criteria
if (getSpecialPowerModuleData()->m_specialPowerTemplate->hasPublicTimer() == FALSE &&
getObject()->isKindOf(KINDOF_STRUCTURE) )
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a Mod creates this kind of setup on something that is not a structure? Is the KINDOF_STRUCTURE test really necessary?

Copy link
Author

@Mauller Mauller Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Infantry don't seem to be affected by this issue, but that could also be because their special powers have been setup in a different way that initialises their special power timer on unit creation.

I still need to double check some powers to make sure they are working still.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worried that it could break a Mod with a setup that is not anticipating here. Is testing for just !getSpecialPowerModuleData()->m_specialPowerTemplate->hasPublicTimer() not enough? If not, why?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure yet, i would need to test first, but it was only building based powers that were not working when i did initially check.

Will do some more testing tomorrow.

Copy link
Author

@Mauller Mauller Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worried that it could break a Mod with a setup that is not anticipating here. Is testing for just !getSpecialPowerModuleData()->m_specialPowerTemplate->hasPublicTimer() not enough? If not, why?

so normal unit creation works down this path

	// if we're pre-built, start counting down
	if( !getObject()->getStatusBits().test( OBJECT_STATUS_UNDER_CONSTRUCTION ) )
	{
		//A sharedNSync special only startPowerRecharges when first scienced or when executed,
		//Since a new modue with same SPTemplates may construct at any time.
		if ( getSpecialPowerTemplate()->isSharedNSync() == FALSE )
			startPowerRecharge();
	}

if a unit has an ability that is instantly available, the reload time being set to zero makes it always available.

If i removed the building check in the code it would actually cause all powers to be instantly available.

When setting breakpoints the only times i see this code get entered is when the above code is not hit. Usually when a building is placed.

i think the reason for this is because a lot of these borken powers use the getSpecialPowerTemplate()->isSharedNSync() set to true, so only one instance of that power is available, like spy satelite and drone etc.

{
m_availableOnFrame = TheGameLogic->getFrame();
}
#endif

/*
// if we're pre-built, and not from a command center, and a building register us with the UI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,17 @@ void SpecialPowerModule::setReadyFrame( UnsignedInt frame )
//-------------------------------------------------------------------------------------------------
void SpecialPowerModule::resolveSpecialPower( void )
{
#if !RETAIL_COMPATIBLE_CRC
// TheSuperHackers @info some building based special powers are immediately available
// This means we need to set their available frame to the current frame to make them usable
// The check for a public timer excludes super weapons from the selection criteria
if (getSpecialPowerModuleData()->m_specialPowerTemplate->hasPublicTimer() == FALSE &&
getObject()->isKindOf(KINDOF_STRUCTURE) )
{
m_availableOnFrame = TheGameLogic->getFrame();
}
#endif

/*

// if we're pre-built, and not from a command center, and a building register us with the UI
Expand Down
Loading