summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--npc/dev/test.txt2
-rw-r--r--src/map/script.c12
-rw-r--r--src/map/script.h1
3 files changed, 11 insertions, 4 deletions
diff --git a/npc/dev/test.txt b/npc/dev/test.txt
index 036a94916..bdbc52ed4 100644
--- a/npc/dev/test.txt
+++ b/npc/dev/test.txt
@@ -762,7 +762,7 @@ function script HerculesSelfTestHelper {
callsub(OnCheck, "Getdatatype (numeric variable)", getdatatype(.@x), DATATYPE_INT | DATATYPE_VAR);
callsub(OnCheck, "Getdatatype (string variable)", getdatatype(.@x$), DATATYPE_STR | DATATYPE_VAR);
callsub(OnCheck, "Getdatatype (label)", getdatatype(OnTestGetdatatype), DATATYPE_LABEL);
- //callsub(OnCheck, "Getdatatype (constant)", getdatatype(DATATYPE_CONST), DATATYPE_CONST); // FIXME
+ callsub(OnCheck, "Getdatatype (constant)", getdatatype(DATATYPE_CONST), DATATYPE_INT | DATATYPE_CONST);
callsub(OnCheck, "Getdatatype (returned integer)", getdatatype(callsub(OnTestReturnValue, 5)), DATATYPE_INT);
callsub(OnCheck, "Getdatatype (returned string)", getdatatype(callsub(OnTestReturnValue, "foo")), DATATYPE_STR | DATATYPE_CONST);
callsub(OnCheck, "Getdatatype (getarg default value)", callsub(OnTestGetdatatypeDefault), DATATYPE_INT);
diff --git a/src/map/script.c b/src/map/script.c
index f9b23cc45..67e3e5fc2 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -1378,6 +1378,11 @@ static const char *parse_simpleexpr_name(const char *p)
disp_error_message("parse_simpleexpr: unmatched ']'", p);
++p;
script->addc(C_FUNC);
+ } else if (script->str_data[l].type == C_INT) {
+ script->addc(C_NAME);
+ script->addb(l);
+ script->addb(l >> 8);
+ script->addb(l >> 16);
} else {
script->addl(l);
}
@@ -2898,8 +2903,7 @@ static struct script_data *get_val(struct script_state *st, struct script_data *
return data;
}
- //##TODO use reference_tovariable(data) when it's confirmed that it works [FlavioJS]
- if (!reference_toconstant(data) && not_server_variable(prefix) && reference_getref(data) == NULL) {
+ if (((reference_tovariable(data) && not_server_variable(prefix)) || reference_toparam(data)) && reference_getref(data) == NULL) {
sd = script->rid2sd(st);
if (sd == NULL) {// needs player attached
if (postfix == '$') {// string variable
@@ -3044,6 +3048,10 @@ static const void *get_val2(struct script_state *st, int64 uid, struct reg_db *r
script->get_val(st, data);
if (data->type == C_INT) // u.num is int32 because it comes from script->get_val
return (const void *)h64BPTRSIZE((int32)data->u.num);
+ else if (data_isreference(data) && reference_toconstant(data))
+ return (const void *)h64BPTRSIZE((int32)reference_getconstant(data));
+ else if (data_isreference(data) && reference_toparam(data))
+ return (const void *)h64BPTRSIZE((int32)reference_getparamtype(data));
else
return (const void *)h64BPTRSIZE(data->u.str);
}
diff --git a/src/map/script.h b/src/map/script.h
index b6b54ca5f..9c72b793c 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -143,7 +143,6 @@ struct item_data;
/// Returns if this a reference to a param
#define reference_toparam(data) ( script->str_data[reference_getid(data)].type == C_PARAM )
/// Returns if this a reference to a variable
-//##TODO confirm it's C_NAME [FlavioJS]
#define reference_tovariable(data) ( script->str_data[reference_getid(data)].type == C_NAME )
/// Returns the unique id of the reference (id and index)
#define reference_getuid(data) ( (data)->u.num )