summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-26 00:55:27 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-12-26 00:55:27 +0000
commit12a2e10be4b50362418551439d6486e4b8d5b09e (patch)
tree4ada919813c9a4701946791eec0c074e83958d38 /src/map
parent64e26b2b25bb639414d16cc9d19703340790f76e (diff)
downloadhercules-12a2e10be4b50362418551439d6486e4b8d5b09e.tar.gz
hercules-12a2e10be4b50362418551439d6486e4b8d5b09e.tar.bz2
hercules-12a2e10be4b50362418551439d6486e4b8d5b09e.tar.xz
hercules-12a2e10be4b50362418551439d6486e4b8d5b09e.zip
* Fixed string variables dereferencing directly to the value instead of dereferencing to a copy of the value. (fixes bugreport:684 bugreport:641)
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11976 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/script.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/map/script.c b/src/map/script.c
index b66197bb5..249d4c321 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -2102,8 +2102,11 @@ TBL_PC *script_rid2sd(struct script_state *st)
return sd;
}
-/// Retrieves the value of a script data
-int get_val(struct script_state* st, struct script_data* data)
+/// Dereferences a variable/constant, replacing it with a copy of the value.
+///
+/// @param st Script state
+/// @param data Variable/constant
+void get_val(struct script_state* st, struct script_data* data)
{
char* name;
char prefix;
@@ -2111,7 +2114,7 @@ int get_val(struct script_state* st, struct script_data* data)
TBL_PC* sd = NULL;
if( !data_isreference(data) )
- return 0;// not a variable
+ return;// not a variable/constant
name = reference_getname(data);
prefix = name[0];
@@ -2135,15 +2138,13 @@ int get_val(struct script_state* st, struct script_data* data)
data->type = C_INT;
data->u.num = 0;
}
- return 0;
+ return;
}
}
if( postfix == '$' )
{// string variable
- data->type = C_CONSTSTR;
-
switch( prefix )
{
case '@':
@@ -2172,8 +2173,16 @@ int get_val(struct script_state* st, struct script_data* data)
break;
}
- if( data->u.str == NULL )
+ if( data->u.str == NULL || data->u.str[0] == '\0' )
+ {// empty string
+ data->type = C_CONSTSTR;
data->u.str = "";
+ }
+ else
+ {// duplicate string
+ data->type = C_STR;
+ data->u.str = aStrdup(data->u.str);
+ }
}
else
@@ -2220,7 +2229,7 @@ int get_val(struct script_state* st, struct script_data* data)
}
- return 0;
+ return;
}
/// Retrieves the value of a reference identified by uid (variable, constant, param)