diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index d129b1c4e5..5ecf9680a6 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -110,7 +110,7 @@ static const int CBM_NO_BIT = UINT8_MAX; /** Representation on the NewGRF variables. */ struct NIVariable { const char *name; - byte var; + uint16 var; }; struct NIExtraInfoOutput { @@ -551,6 +551,20 @@ struct NewGRFInspectWindow : Window { if (nif->variables != nullptr) { this->DrawString(r, i++, "Variables:"); + uint prefix_width = 0; + for (const NIVariable *niv = nif->variables; niv->name != nullptr; niv++) { + if (niv->var >= 0x100) { + extern const GRFVariableMapDefinition _grf_action2_remappable_variables[]; + for (const GRFVariableMapDefinition *info = _grf_action2_remappable_variables; info->name != nullptr; info++) { + if (niv->var == info->id) { + char buf[512]; + seprintf(buf, lastof(buf), " %s: ", info->name); + prefix_width = std::max(prefix_width, GetStringBoundingBox(buf).width); + break; + } + } + } + } for (const NIVariable *niv = nif->variables; niv->name != nullptr; niv++) { GetVariableExtra extra; uint param = HasVariableParameter(niv->var) ? NewGRFInspectWindow::var60params[GetFeatureNum(this->window_number)][niv->var - 0x60] : 0; @@ -560,6 +574,28 @@ struct NewGRFInspectWindow : Window { if (HasVariableParameter(niv->var)) { this->DrawString(r, i++, " %02x[%02x]: %08x (%s)", niv->var, param, value, niv->name); + } else if (niv->var >= 0x100) { + extern const GRFVariableMapDefinition _grf_action2_remappable_variables[]; + for (const GRFVariableMapDefinition *info = _grf_action2_remappable_variables; info->name != nullptr; info++) { + if (niv->var == info->id) { + if (_current_text_dir == TD_RTL) { + this->DrawString(r, i++, " %s: %08x (%s)", info->name, value, niv->name); + } else { + if (this->log_console) DEBUG(misc, 0, " %s: %08x (%s)", info->name, value, niv->name); + + int offset = i - this->vscroll->GetPosition(); + i++; + if (offset >= 0 && offset < this->vscroll->GetCapacity()) { + char buf[512]; + seprintf(buf, lastof(buf), " %s: ", info->name); + ::DrawString(r.left + LEFT_OFFSET, r.right - RIGHT_OFFSET, r.top + TOP_OFFSET + (offset * this->resize.step_height), buf, TC_BLACK); + seprintf(buf, lastof(buf), "%08x (%s)", value, niv->name); + ::DrawString(r.left + LEFT_OFFSET + prefix_width, r.right - RIGHT_OFFSET, r.top + TOP_OFFSET + (offset * this->resize.step_height), buf, TC_BLACK); + } + } + break; + } + } } else { this->DrawString(r, i++, " %02x: %08x (%s)", niv->var, value, niv->name); } diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index ddd4f0d240..f69d3f0ed3 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -18,6 +18,7 @@ #include "../object_map.h" #include "../waypoint_base.h" #include "../string_func_extra.h" +#include "../newgrf_extension.h" /* Helper for filling property tables */ #define NIP(prop, base, variable, type, name) { name, (ptrdiff_t)cpp_offsetof(base, variable), cpp_sizeof(base, variable), prop, type } @@ -842,6 +843,8 @@ static const NIVariable _niv_objects[] = { NIV(0x62, "land info of nearby tiles"), NIV(0x63, "animation stage of nearby tiles"), NIV(0x64, "distance on nearest object with given type"), + NIV(A2VRI_OBJECT_FOUNDATION_SLOPE, "slope after foundation applied"), + NIV(A2VRI_OBJECT_FOUNDATION_SLOPE_CHANGE, "slope after foundation applied xor non-foundation slope"), NIV_END() };