diff options
author | michi_cc <michi_cc@openttd.org> | 2010-10-31 16:16:28 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2010-10-31 16:16:28 +0000 |
commit | 406b4b38735848e35adcd3f7eac69c650f8be848 (patch) | |
tree | 87780151e23b0f038558b77aa66d8d9de1b3dff5 | |
parent | 15179978686721cfc9f51c1b8f2d6b95ae009492 (diff) | |
download | openttd-406b4b38735848e35adcd3f7eac69c650f8be848.tar.xz |
(svn r21065) -Fix (r19733): Crash when displaying 60+x parameters in the NewGRF inspect window.
-rw-r--r-- | src/newgrf_debug_gui.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index ef2802bf9..8b2b4bf96 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -206,13 +206,23 @@ struct NIFeature { #include "table/newgrf_debug_data.h" /** + * Get the feature number related to the window number. + * @param window_number The window to get the feature number for. + * @return The feature number. + */ +static inline GrfSpecFeature GetFeatureNum(uint window_number) +{ + return (GrfSpecFeature)GB(window_number, 24, 8); +} + +/** * Get the NIFeature related to the window number. * @param window_number The window to get the NIFeature for. * @return the NIFeature, or NULL is there isn't one. */ static inline const NIFeature *GetFeature(uint window_number) { - byte idx = GB(window_number, 24, 8); + GrfSpecFeature idx = GetFeatureNum(window_number); return idx < GSF_FAKE_END ? _nifeatures[idx] : NULL; } @@ -324,7 +334,7 @@ struct NewGRFInspectWindow : Window { this->DrawString(r, i++, "Variables:"); for (const NIVariable *niv = nif->variables; niv->name != NULL; niv++) { bool avail = true; - uint param = HasVariableParameter(niv->var) ? NewGRFInspectWindow::var60params[index][niv->var - 0x60] : 0; + uint param = HasVariableParameter(niv->var) ? NewGRFInspectWindow::var60params[GetFeatureNum(this->window_number)][niv->var - 0x60] : 0; uint value = nih->Resolve(index, niv->var, param, &avail); if (!avail) continue; @@ -446,7 +456,7 @@ struct NewGRFInspectWindow : Window { { if (StrEmpty(str)) return; - NewGRFInspectWindow::var60params[GetFeatureIndex(this->window_number)][this->current_edit_param - 0x60] = strtol(str, NULL, 16); + NewGRFInspectWindow::var60params[GetFeatureNum(this->window_number)][this->current_edit_param - 0x60] = strtol(str, NULL, 16); this->SetDirty(); } |