summaryrefslogtreecommitdiff
path: root/src/newgrf_debug_gui.cpp
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2011-06-12 20:41:17 +0000
committerterkhen <terkhen@openttd.org>2011-06-12 20:41:17 +0000
commit281bed03f4c7e7021a0b7c079cefe246f56e3fb9 (patch)
tree744141caf35170355b30e0d290afda69c9910ebc /src/newgrf_debug_gui.cpp
parent0749c65d74e7368643e3c4f4f70768993e8b7f41 (diff)
downloadopenttd-281bed03f4c7e7021a0b7c079cefe246f56e3fb9.tar.xz
(svn r22565) -Codechange: Use helper functions for getting the persistent storage in the NewGRF debug GUI.
Diffstat (limited to 'src/newgrf_debug_gui.cpp')
-rw-r--r--src/newgrf_debug_gui.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp
index eb9d16f06..edb44fdc9 100644
--- a/src/newgrf_debug_gui.cpp
+++ b/src/newgrf_debug_gui.cpp
@@ -156,6 +156,28 @@ public:
return ro.GetVariable(&ro, var, param, avail);
}
+ /**
+ * Allows to know the size of the persistent storage.
+ * @param index Unused.
+ * @param grfid Unused.
+ * @return Size of the persistent storage in indices.
+ */
+ virtual uint GetPSASize(uint index, uint32 grfid) const
+ {
+ return 0;
+ }
+
+ /**
+ * Gets the first position of the array containing the persistent storage.
+ * @param index Unused.
+ * @param grfid Unused.
+ * @return Pointer to the first position of the storage array or NULL if not present.
+ */
+ virtual int32 *GetPSAFirstPosition(uint index, uint32 grfid) const
+ {
+ return NULL;
+ }
+
protected:
/**
* Actually execute the real resolving for a given (instance) index.
@@ -199,8 +221,6 @@ struct NIFeature {
const NICallback *callbacks; ///< The callbacks associated with this feature.
const NIVariable *variables; ///< The variables associated with this feature.
const NIHelper *helper; ///< The class container all helper functions.
- uint psa_size; ///< The size of the persistent storage in indices.
- size_t psa_offset; ///< Offset to the array in the PSA.
};
/* Load all the NewGRF debug data; externalised as it is just a huge bunch of tables. */
@@ -348,11 +368,12 @@ struct NewGRFInspectWindow : Window {
}
}
- if (nif->psa_size != 0) {
+ uint psa_size = nih->GetPSASize(0, 0);
+ if (psa_size != 0) {
this->DrawString(r, i++, "Persistent storage:");
- assert(nif->psa_size % 4 == 0);
- int32 *psa = (int32*)((byte*)base + nif->psa_offset);
- for (uint j = 0; j < nif->psa_size; j += 4, psa += 4) {
+ assert(psa_size % 4 == 0);
+ int32 *psa = nih->GetPSAFirstPosition(0, 0);
+ for (uint j = 0; j < psa_size; j += 4, psa += 4) {
this->DrawString(r, i++, " %i: %i %i %i %i", j, psa[0], psa[1], psa[2], psa[3]);
}
}