summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-02-19 18:22:49 +0100
committerHaru <haru@dotalux.com>2016-03-20 18:32:06 +0100
commit138956dcf9415353a4f67de6bc66efa23a04e61c (patch)
tree5c399fdd8497a2163015f1062093a76505683f68 /src/map/atcommand.c
parent63c4304fb3226b53550e9d413820ed3ff7340d08 (diff)
downloadhercules-138956dcf9415353a4f67de6bc66efa23a04e61c.tar.gz
hercules-138956dcf9415353a4f67de6bc66efa23a04e61c.tar.bz2
hercules-138956dcf9415353a4f67de6bc66efa23a04e61c.tar.xz
hercules-138956dcf9415353a4f67de6bc66efa23a04e61c.zip
Added separate char* and const char* data types to struct script_data
Used, respectively, by C_STR and C_CONSTSTR Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 963f5c970..78d935ddc 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -8498,30 +8498,34 @@ ACMD(set)
CREATE(data, struct script_data,1);
- if( is_str ) {// string variable
- switch( reg[0] ) {
+ if (is_str) {
+ // string variable
+ const char *str = NULL;
+ switch (reg[0]) {
case '@':
- data->u.str = pc->readregstr(sd, script->add_str(reg));
+ str = pc->readregstr(sd, script->add_str(reg));
break;
case '$':
- data->u.str = mapreg->readregstr(script->add_str(reg));
+ str = mapreg->readregstr(script->add_str(reg));
break;
case '#':
- if( reg[1] == '#' )
- data->u.str = pc_readaccountreg2str(sd, script->add_str(reg));// global
+ if (reg[1] == '#')
+ str = pc_readaccountreg2str(sd, script->add_str(reg));// global
else
- data->u.str = pc_readaccountregstr(sd, script->add_str(reg));// local
+ str = pc_readaccountregstr(sd, script->add_str(reg));// local
break;
default:
- data->u.str = pc_readglobalreg_str(sd, script->add_str(reg));
+ str = pc_readglobalreg_str(sd, script->add_str(reg));
break;
}
- if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string
+ if (str == NULL || str[0] == '\0') {
+ // empty string
data->type = C_CONSTSTR;
data->u.str = "";
- } else {// duplicate string
+ } else {
+ // duplicate string
data->type = C_STR;
- data->u.str = aStrdup(data->u.str);
+ data->u.mutstr = aStrdup(str);
}
} else {// integer variable
data->type = C_INT;
@@ -8549,7 +8553,7 @@ ACMD(set)
safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1373),reg,data->u.num); // %s value is now :%d
break;
case C_STR:
- safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1374),reg,data->u.str); // %s value is now :%s
+ safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1374),reg,data->u.mutstr); // %s value is now :%s
break;
case C_CONSTSTR:
safesnprintf(atcmd_output, sizeof(atcmd_output),msg_fd(fd,1375),reg); // %s is empty