* 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://svn.code.sf.net/p/rathena/svn/trunk@11976 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
FlavioJS 2007-12-26 00:55:27 +00:00
parent 67088ee436
commit 214feac880
2 changed files with 20 additions and 8 deletions

View File

@ -3,6 +3,9 @@ Date Added
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/12/26
* Fixed string variables dereferencing directly to the value instead of
dereferencing to a copy of the value. (fixes bugreport:684 bugreport:641) [FlavioJS]
2007/12/23 2007/12/23
* Added a generic vector implementation (dynamic array) based on defines. [FlavioJS] * Added a generic vector implementation (dynamic array) based on defines. [FlavioJS]
* Fixed horrible handling of skill_abra_db which leads to memory corruption * Fixed horrible handling of skill_abra_db which leads to memory corruption

View File

@ -2102,8 +2102,11 @@ TBL_PC *script_rid2sd(struct script_state *st)
return sd; return sd;
} }
/// Retrieves the value of a script data /// Dereferences a variable/constant, replacing it with a copy of the value.
int get_val(struct script_state* st, struct script_data* data) ///
/// @param st Script state
/// @param data Variable/constant
void get_val(struct script_state* st, struct script_data* data)
{ {
char* name; char* name;
char prefix; char prefix;
@ -2111,7 +2114,7 @@ int get_val(struct script_state* st, struct script_data* data)
TBL_PC* sd = NULL; TBL_PC* sd = NULL;
if( !data_isreference(data) ) if( !data_isreference(data) )
return 0;// not a variable return;// not a variable/constant
name = reference_getname(data); name = reference_getname(data);
prefix = name[0]; prefix = name[0];
@ -2135,15 +2138,13 @@ int get_val(struct script_state* st, struct script_data* data)
data->type = C_INT; data->type = C_INT;
data->u.num = 0; data->u.num = 0;
} }
return 0; return;
} }
} }
if( postfix == '$' ) if( postfix == '$' )
{// string variable {// string variable
data->type = C_CONSTSTR;
switch( prefix ) switch( prefix )
{ {
case '@': case '@':
@ -2172,8 +2173,16 @@ int get_val(struct script_state* st, struct script_data* data)
break; 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 = ""; data->u.str = "";
}
else
{// duplicate string
data->type = C_STR;
data->u.str = aStrdup(data->u.str);
}
} }
else 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) /// Retrieves the value of a reference identified by uid (variable, constant, param)