summaryrefslogtreecommitdiff
path: root/saveload.h
diff options
context:
space:
mode:
Diffstat (limited to 'saveload.h')
-rw-r--r--saveload.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/saveload.h b/saveload.h
index 3a0a59010..56c3a314d 100644
--- a/saveload.h
+++ b/saveload.h
@@ -271,6 +271,15 @@ static inline VarType GetVarFileType(VarType type)
return type & 0xF; // GB(type, 0, 4);
}
+/** Get the address of the variable. Which one to pick depends on the object
+ * pointer. If it is NULL we are dealing with global variables so the address
+ * is taken. If non-null only the offset is stored in the union and we need
+ * to add this to the address of the object */
+static inline void *GetVariableAddress(const void *object, const SaveLoad *sld)
+{
+ return (byte*)object + (ptrdiff_t)sld->address;
+}
+
int64 ReadValue(const void *ptr, VarType conv);
void WriteValue(void *ptr, VarType conv, int64 val);