summaryrefslogtreecommitdiff
path: root/src/newgrf_text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/newgrf_text.cpp')
-rw-r--r--src/newgrf_text.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index a1b07ad3b..ff77c441c 100644
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -863,6 +863,13 @@ struct TextRefStack {
TextRefStack() : used(false) {}
+ TextRefStack(const TextRefStack &stack) :
+ position(stack.position),
+ used(stack.used)
+ {
+ memcpy(this->stack, stack.stack, sizeof(this->stack));
+ }
+
uint8 PopUnsignedByte() { assert(this->position < lengthof(this->stack)); return this->stack[this->position++]; }
int8 PopSignedByte() { return (int8)this->PopUnsignedByte(); }
@@ -920,6 +927,34 @@ static TextRefStack _newgrf_error_textrefstack;
static TextRefStack *_newgrf_textrefstack = &_newgrf_normal_textrefstack;
/**
+ * Check whether the NewGRF text stack is in use.
+ * @return True iff the NewGRF text stack is used.
+ */
+bool UsingNewGRFTextStack()
+{
+ return _newgrf_textrefstack->used;
+}
+
+/**
+ * Create a backup of the current NewGRF text stack.
+ * @return A copy of the current text stack.
+ */
+struct TextRefStack *CreateTextRefStackBackup()
+{
+ return new TextRefStack(*_newgrf_textrefstack);
+}
+
+/**
+ * Restore a copy of the text stack to the used stack.
+ * @param backup The copy to restore.
+ */
+void RestoreTextRefStackBackup(struct TextRefStack *backup)
+{
+ *_newgrf_textrefstack = *backup;
+ delete backup;
+}
+
+/**
* Prepare the TTDP compatible string code parsing
* @param numEntries number of entries to copy from the registers
*/