fix(logic): Add nullptr check to thisPlayer in GameLogic::logicMessageDispatcher#2383
fix(logic): Add nullptr check to thisPlayer in GameLogic::logicMessageDispatcher#2383Caball009 wants to merge 3 commits intoTheSuperHackers:mainfrom
Conversation
|
on 645 we have I wonder if this needs clarifying that I am guessing that |
I have a PR planned for this one which makes the change that player = thisPlayer, which seemed to pass 1k replays, but wanted to test that a bit more |
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp | Replaces the DEBUG_ASSERTCRASH on thisPlayer with an early return guard, then removes all redundant per-case null checks for player that had been doing the same lookup. Minor consistency cleanup replacing msg->getPlayerIndex() with thisPlayer->getPlayerIndex() in a couple of places. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[logicMessageDispatcher called] --> B[Resolve thisPlayer via msg->getPlayerIndex]
B --> C{thisPlayer == nullptr?}
C -- Yes --> D[DEBUG_CRASH + return early]
C -- No --> E[Initialize currentlySelectedGroup if in-game]
E --> F{switch msg->getType}
F --> G[MSG_CREATE_SELECTED_GROUP\nthisPlayer->getPlayerMask]
F --> H[MSG_REMOVE_FROM_SELECTED_GROUP\nthisPlayer->getPlayerMask]
F --> I[MSG_DESTROY_SELECTED_GROUP\nthisPlayer->setCurrentlySelectedAIGroup]
F --> J[MSG_CREATE_TEAM*\nthisPlayer->processCreateTeamGameMessage]
F --> K[MSG_SELECT_TEAM*\nthisPlayer->processSelectTeamGameMessage]
F --> L[MSG_ADD_TEAM*\nthisPlayer->processAddTeamGameMessage]
F --> M[MSG_LOGIC_CRC\nm_cachedCRCs indexed by thisPlayer->getPlayerIndex]
F --> N[MSG_PURCHASE_SCIENCE\nthisPlayer->attemptToPurchaseScience]
F --> O[... other cases ...]
Last reviewed commit: c0d0f24
This PR changes the
nullptrassertion onthisPlayerinGameLogic::logicMessageDispatcherto 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->getPlayerIndextothisPlayer->getPlayerIndexfor the sole purpose of consistency with code that already uses the latter.TODO: