summaryrefslogtreecommitdiff
path: root/src/map/script.h
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2014-02-06 21:12:36 +0100
committerHaru <haru@dotalux.com>2014-03-05 22:35:03 +0100
commita1918e7e9d1585587be270183866797eb1c682f5 (patch)
treed07b30baaed8a40778c2510b5a112838eb1da7e5 /src/map/script.h
parent4f3156b78f807553b11f37a7d0c898f6e358495b (diff)
downloadhercules-a1918e7e9d1585587be270183866797eb1c682f5.tar.gz
hercules-a1918e7e9d1585587be270183866797eb1c682f5.tar.bz2
hercules-a1918e7e9d1585587be270183866797eb1c682f5.tar.xz
hercules-a1918e7e9d1585587be270183866797eb1c682f5.zip
Corrected same-reference check to work on vars with the same name in different scopes
- Fixes bugreport:8008, special thanks to KeyWorld http://hercules.ws/board/tracker/issue-8008-copyarray-fail-on-a-referenced-array-argument/ Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/script.h')
-rw-r--r--src/map/script.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/map/script.h b/src/map/script.h
index ae851a7ec..ff947bf79 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -144,6 +144,13 @@ struct eri;
/// Composes the uid of a reference from the id and the index
#define reference_uid(id,idx) ( (int64) ((uint64)(id) & 0xFFFFFFFF) | ((uint64)(idx) << 32) )
+/// Checks whether two references point to the same variable (or array)
+#define is_same_reference(data1, data2) \
+ ( reference_getid(data1) == reference_getid(data2) \
+ && ( (data1->ref == data2->ref && data1->ref == NULL) \
+ || (data1->ref != NULL && data2->ref != NULL && data1->ref->vars == data2->ref->vars \
+ ) ) )
+
#define script_getvarid(var) ( (int32)(int64)(var & 0xFFFFFFFF) )
#define script_getvaridx(var) ( (uint32)(int64)((var >> 32) & 0xFFFFFFFF) )