From aa46bf3a2b7db40761e25d8685bfc91e1f74f2d9 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Tue, 29 Dec 2020 21:13:33 +0000 Subject: [PATCH] Debug: Truncate persistent storage printouts when only 0s remain --- src/newgrf_debug_gui.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index da9fded18c..87e57f2062 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -517,9 +517,17 @@ struct NewGRFInspectWindow : Window { this->DrawString(r, i++, "Persistent storage:"); } assert(psa_size % 4 == 0); - for (uint j = 0; j < psa_size; j += 4, psa += 4) { + uint last_non_blank = 0; + for (uint j = 0; j < psa_size; j++) { + if (psa[j] != 0) last_non_blank = j; + } + const uint psa_limit = (last_non_blank + 3) & ~3; + for (uint j = 0; j < psa_limit; j += 4, psa += 4) { this->DrawString(r, i++, " %i: %i %i %i %i", j, psa[0], psa[1], psa[2], psa[3]); } + if (last_non_blank != psa_size) { + this->DrawString(r, i++, " %i to %i are all 0", psa_limit, psa_size - 1); + } } if (nif->properties != nullptr) {