From a25fa700e28eecc436f946bb71f93013285da5e0 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Tue, 11 May 2021 23:40:31 -0400 Subject: [PATCH] Don't show GoL .tmp in HUD, check if create_part was successful while simulating GoL --- src/gui/game/GameView.cpp | 2 +- src/simulation/Simulation.cpp | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index 68b603586..948398a43 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -2191,7 +2191,7 @@ void GameView::OnDraw() } sampleInfo << ", Temp: " << (sample.particle.temp - 273.15f) << " C"; sampleInfo << ", Life: " << sample.particle.life; - if (sample.particle.type != PT_RFRG && sample.particle.type != PT_RFGL) + if (sample.particle.type != PT_RFRG && sample.particle.type != PT_RFGL && sample.particle.type != PT_LIFE) { if (sample.particle.type == PT_CONV) { diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 444a137af..da639ad15 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -4947,15 +4947,18 @@ void Simulation::SimulateGoL() { // * 0x200000: No need to look for colours, they'll be set later anyway. int i = create_part(-1, x, y, PT_LIFE, golnumToCreate | 0x200000); - int xx = (createFromEntry >> 24) & 3; - int yy = (createFromEntry >> 26) & 3; - if (xx == 3) xx = -1; - if (yy == 3) yy = -1; - int ax = ((x - xx + XRES - 3 * CELL) % (XRES - 2 * CELL)) + CELL; - int ay = ((y - yy + YRES - 3 * CELL) % (YRES - 2 * CELL)) + CELL; - auto &sample = parts[ID(pmap[ay][ax])]; - parts[i].dcolour = sample.dcolour; - parts[i].tmp = sample.tmp; + if (i >= 0) + { + int xx = (createFromEntry >> 24) & 3; + int yy = (createFromEntry >> 26) & 3; + if (xx == 3) xx = -1; + if (yy == 3) yy = -1; + int ax = ((x - xx + XRES - 3 * CELL) % (XRES - 2 * CELL)) + CELL; + int ay = ((y - yy + YRES - 3 * CELL) % (YRES - 2 * CELL)) + CELL; + auto &sample = parts[ID(pmap[ay][ax])]; + parts[i].dcolour = sample.dcolour; + parts[i].tmp = sample.tmp; + } } } }