diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp index d5d1fd7f29..bcb6ad2d85 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp @@ -3213,12 +3213,19 @@ void W3DModelDraw::replaceIndicatorColor(Color color) { m_hexColor = newColor; - // set these to nullptr to force a regen of everything in setModelState. - const ModelConditionInfo* tmp = m_curState; - m_curState = nullptr; - m_nextState = nullptr; - m_nextStateAnimLoopDuration = NO_NEXT_DURATION; - setModelState(tmp); + // TheSuperHackers @bugfix Do not call setModelState with a null state pointer, as this + // can happen when replaceIndicatorColor is called before the draw module has been fully + // initialized (e.g. during object creation in friend_bindToObject). In such cases, the + // updated m_hexColor will be picked up on the next proper setModelState call. + if (m_curState != nullptr) + { + // set these to nullptr to force a regen of everything in setModelState. + const ModelConditionInfo* tmp = m_curState; + m_curState = nullptr; + m_nextState = nullptr; + m_nextStateAnimLoopDuration = NO_NEXT_DURATION; + setModelState(tmp); + } } } }