Skip to content

Commit

Permalink
Fixed readparam behaviour for variables
Browse files Browse the repository at this point in the history
Readparam now works correctly with variables.
This is a follow up to e112fc1 which addressed #647.

Fixes #1213, thanks to @Everade.
  • Loading branch information
Lemongrass3110 committed May 5, 2016
1 parent 55165ac commit 2b61f45
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/map/script.c
Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down

1 comment on commit 2b61f45

@RadianFord
Copy link
Contributor

@RadianFord RadianFord commented on 2b61f45 May 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lemongrass3110 this is different from this issue right? #1195

xd yea its different.

Please sign in to comment.