From 2b61f45a948bd6c3e10b7bab1b17f476bbbfc12d Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Fri, 6 May 2016 01:14:12 +0200 Subject: [PATCH] Fixed readparam behaviour for variables Readparam now works correctly with variables. This is a follow up to e112fc1 which addressed #647. Fixes #1213, thanks to @Everade. --- src/map/script.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/map/script.c b/src/map/script.c index 9441d781fe..786b166a45 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -7695,7 +7695,7 @@ BUILDIN_FUNC(disableitemuse) *------------------------------------------*/ BUILDIN_FUNC(readparam) { - int type; + int value; struct script_data *data = script_getdata(st, 2); TBL_PC *sd; @@ -7704,14 +7704,15 @@ BUILDIN_FUNC(readparam) return SCRIPT_CMD_FAILURE; } - if (data->type == C_NAME) { // If using constant name, just get the val + // If you use a parameter, return the value behind it + if( reference_toparam(data) ){ get_val_(st, data, sd); - script_pushint(st, (int)data->u.num); - return SCRIPT_CMD_SUCCESS; + value = (int)data->u.num; + }else{ + value = pc_readparam(sd,script_getnum(st, 2)); } - type = script_getnum(st, 2); - script_pushint(st,pc_readparam(sd,type)); + script_pushint(st,value); return SCRIPT_CMD_SUCCESS; }