From 5b0c9763b43cd9e0221cde3328783d98a0f50607 Mon Sep 17 00:00:00 2001 From: Benau Date: Fri, 25 Jun 2021 13:09:16 +0800 Subject: [PATCH] Fix crash when using check debug with ghost replay and server --- src/tracks/check_line.cpp | 3 ++- src/tracks/check_structure.cpp | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tracks/check_line.cpp b/src/tracks/check_line.cpp index b3669b532..3f614809f 100644 --- a/src/tracks/check_line.cpp +++ b/src/tracks/check_line.cpp @@ -179,7 +179,8 @@ void CheckLine::resetAfterKartMove(unsigned int kart_index) // ---------------------------------------------------------------------------- void CheckLine::changeDebugColor(bool is_active) { - assert(m_debug_dy_dc); + if (!m_debug_dy_dc) + return; video::SColor color = is_active ? video::SColor(192, 255, 0, 0) : video::SColor(192, 128, 128, 128); for(unsigned int i = 0; i < 4; i++) diff --git a/src/tracks/check_structure.cpp b/src/tracks/check_structure.cpp index 5da815ac9..d2b2106dd 100644 --- a/src/tracks/check_structure.cpp +++ b/src/tracks/check_structure.cpp @@ -144,9 +144,12 @@ void CheckStructure::changeStatus(const std::vector &indices, int kart_index, ChangeState change_state) { + int player_kart_index = 0; + if (World::getWorld()->getPlayerKart(0)) + player_kart_index = World::getWorld()->getPlayerKart(0)->getWorldKartId(); bool update_debug_colors = UserConfigParams::m_check_debug && RaceManager::get()->getNumPlayers()>0 && - kart_index == (int)World::getWorld()->getPlayerKart(0)->getWorldKartId(); + kart_index == player_kart_index; CheckManager* cm = Track::getCurrentTrack()->getCheckManager(); for(unsigned int i=0; i