Skip to content

fix(logic): Add nullptr check to thisPlayer in GameLogic::logicMessageDispatcher#2383

Draft
Caball009 wants to merge 3 commits intoTheSuperHackers:mainfrom
Caball009:fix_thisPlayer_logicMessageDispatcher
Draft

fix(logic): Add nullptr check to thisPlayer in GameLogic::logicMessageDispatcher#2383
Caball009 wants to merge 3 commits intoTheSuperHackers:mainfrom
Caball009:fix_thisPlayer_logicMessageDispatcher

Conversation

@Caball009
Copy link

This PR changes the nullptr assertion on thisPlayer in GameLogic::logicMessageDispatcher to an early return. Although there are a couple of places in this function that check explicitly for it, a lot of code assumes that this pointer is not null, so it makes sense to check that up front.

Commit 1 adds the check.
Commit 2 removes code that's become redundant (implicitly).
Commit 3 changes msg->getPlayerIndex to thisPlayer->getPlayerIndex for the sole purpose of consistency with code that already uses the latter.

TODO:

  • Replicate in Generals.

@Caball009 Caball009 added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour labels Mar 2, 2026
@Mauller
Copy link

Mauller commented Mar 3, 2026

on 645 we have

case GameMessage::MSG_ENABLE_RETALIATION_MODE:
{
	//Logically turns on or off retaliation mode for a specified player.
	Int playerIndex = msg->getArgument( 0 )->integer;
	Bool enableRetaliation = msg->getArgument( 1 )->boolean;

	Player *player = ThePlayerList->getNthPlayer( playerIndex );
	if( player )
	{
		player->setLogicalRetaliationModeEnabled( enableRetaliation );
	}
	break;
}

I wonder if this needs clarifying that player here is a targetPlayer and not the same as thisPlayer

I am guessing that Int playerIndex = msg->getArgument( 0 )->integer; returns a different value compared to msg->getPlayerID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants