summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgumi <mekolat@users.noreply.github.com>2017-02-26 10:29:20 -0500
committergumi <mekolat@users.noreply.github.com>2017-02-26 12:00:31 -0500
commit489281c3de7d4d2d9370f7352f6d3108c4681e89 (patch)
treef94124b7a00ad8bfcf8ffb888abc306686aa788e /src
parent2cc5c040948b3e6a90e7f344bb74155b79afa942 (diff)
downloadhercules-489281c3de7d4d2d9370f7352f6d3108c4681e89.tar.gz
hercules-489281c3de7d4d2d9370f7352f6d3108c4681e89.tar.bz2
hercules-489281c3de7d4d2d9370f7352f6d3108c4681e89.tar.xz
hercules-489281c3de7d4d2d9370f7352f6d3108c4681e89.zip
fix code style in get_val
Diffstat (limited to 'src')
-rw-r--r--src/map/script.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/map/script.c b/src/map/script.c
index fed00048e..3394e0ed3 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -2825,7 +2825,7 @@ struct script_data *get_val(struct script_state* st, struct script_data* data) {
char postfix;
struct map_session_data *sd = NULL;
- if( !data_isreference(data) )
+ if (!data_isreference(data))
return data;// not a variable/constant
name = reference_getname(data);
@@ -2840,10 +2840,10 @@ struct script_data *get_val(struct script_state* st, struct script_data* data) {
}
//##TODO use reference_tovariable(data) when it's confirmed that it works [FlavioJS]
- if( !reference_toconstant(data) && not_server_variable(prefix) ) {
+ if (!reference_toconstant(data) && not_server_variable(prefix)) {
sd = script->rid2sd(st);
- if( sd == NULL ) {// needs player attached
- if( postfix == '$' ) {// string variable
+ if (sd == NULL) {// needs player attached
+ if (postfix == '$') {// string variable
ShowWarning("script_get_val: cannot access player variable '%s', defaulting to \"\"\n", name);
data->type = C_CONSTSTR;
data->u.str = "";
@@ -2868,18 +2868,20 @@ struct script_data *get_val(struct script_state* st, struct script_data* data) {
str = mapreg->readregstr(data->u.num);
break;
case '#':
- if (name[1] == '#')
+ if (name[1] == '#') {
str = pc_readaccountreg2str(sd, data->u.num);// global
- else
+ } else {
str = pc_readaccountregstr(sd, data->u.num);// local
+ }
break;
case '.':
- if (data->ref)
+ if (data->ref) {
str = script->get_val_ref_str(st, data->ref, data);
- else if (name[1] == '@')
+ } else if (name[1] == '@') {
str = script->get_val_scope_str(st, &st->stack->scope, data);
- else
+ } else {
str = script->get_val_npc_str(st, &st->script->local, data);
+ }
break;
case '\'':
str = script->get_val_instance_str(st, name, data);
@@ -2906,8 +2908,8 @@ struct script_data *get_val(struct script_state* st, struct script_data* data) {
data->u.num = reference_getconstant(data);
} else if( reference_toparam(data) ) {
data->u.num = pc->readparam(sd, reference_getparamtype(data));
- } else
- switch( prefix ) {
+ } else {
+ switch (prefix) {
case '@':
data->u.num = pc->readreg(sd, data->u.num);
break;
@@ -2915,18 +2917,21 @@ struct script_data *get_val(struct script_state* st, struct script_data* data) {
data->u.num = mapreg->readreg(data->u.num);
break;
case '#':
- if( name[1] == '#' )
+ if (name[1] == '#') {
data->u.num = pc_readaccountreg2(sd, data->u.num);// global
- else
+ } else {
data->u.num = pc_readaccountreg(sd, data->u.num);// local
+ }
break;
case '.':
- if (data->ref)
+ if (data->ref) {
data->u.num = script->get_val_ref_num(st, data->ref, data);
- else if (name[1] == '@')
+ } else if (name[1] == '@') {
data->u.num = script->get_val_scope_num(st, &st->stack->scope, data);
- else
+ }
+ else {
data->u.num = script->get_val_npc_num(st, &st->script->local, data);
+ }
break;
case '\'':
data->u.num = script->get_val_instance_num(st, name, data);
@@ -2935,7 +2940,7 @@ struct script_data *get_val(struct script_state* st, struct script_data* data) {
data->u.num = pc_readglobalreg(sd, data->u.num);
break;
}
-
+ }
}
data->ref = NULL;