Fix crash when using check debug with ghost replay and server

This commit is contained in:
Benau 2021-06-25 13:09:16 +08:00
parent 05f029abc0
commit 5b0c9763b4
2 changed files with 6 additions and 2 deletions

View File

@ -179,7 +179,8 @@ void CheckLine::resetAfterKartMove(unsigned int kart_index)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CheckLine::changeDebugColor(bool is_active) 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 color = is_active ? video::SColor(192, 255, 0, 0)
: video::SColor(192, 128, 128, 128); : video::SColor(192, 128, 128, 128);
for(unsigned int i = 0; i < 4; i++) for(unsigned int i = 0; i < 4; i++)

View File

@ -144,9 +144,12 @@ void CheckStructure::changeStatus(const std::vector<int> &indices,
int kart_index, int kart_index,
ChangeState change_state) 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 = bool update_debug_colors =
UserConfigParams::m_check_debug && RaceManager::get()->getNumPlayers()>0 && 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(); CheckManager* cm = Track::getCurrentTrack()->getCheckManager();
for(unsigned int i=0; i<indices.size(); i++) for(unsigned int i=0; i<indices.size(); i++)