diff options
author | Kpy! <ouroboros.ai@gmail.com> | 2015-04-22 17:53:32 +0200 |
---|---|---|
committer | Kpy! <ouroboros.ai@gmail.com> | 2015-04-22 17:53:32 +0200 |
commit | 2970847b879821f738bb892e9079c0ae2a5d08c7 (patch) | |
tree | 7822c4f597824bf2ac215f57fe4c1ff14e1ce639 | |
parent | 7e76bbb730679d4fe310198891499edeec241c31 (diff) | |
download | hercules-2970847b879821f738bb892e9079c0ae2a5d08c7.tar.gz hercules-2970847b879821f738bb892e9079c0ae2a5d08c7.tar.bz2 hercules-2970847b879821f738bb892e9079c0ae2a5d08c7.tar.xz hercules-2970847b879821f738bb892e9079c0ae2a5d08c7.zip |
Minor refactoring of script function return.
-rw-r--r-- | src/map/script.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/map/script.c b/src/map/script.c index 335f45509..265c4a549 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -5702,16 +5702,19 @@ BUILDIN(return) { script->get_val(st, data);// current scope, convert to value if( data->ref && data->ref->vars == st->stack->stack_data[st->stack->defsp-1].u.ri->scope.vars ) data->ref = NULL; // Reference to the parent scope, remove reference pointer - } else if( name[0] == '.' && !data->ref ) { - // script variable without a reference set, link to current script - data->ref = (struct reg_db *)aCalloc(sizeof(struct reg_db), 1); - script->add_pending_ref(st, data->ref); - data->ref->vars = st->script->local.vars; - if( !st->script->local.arrays ) - st->script->local.arrays = idb_alloc(DB_OPT_BASE); - data->ref->arrays = st->script->local.arrays; - } else if ( name[0] == '.' && data->ref->vars == st->stack->stack_data[st->stack->defsp-1].u.ri->script->local.vars ) { - data->ref = NULL; // Reference to the parent scope's script, remove reference pointer. + } else if( name[0] == '.' ) { + // npc variable + if( !data->ref ) { + // npc variable without a reference set, link to current script + data->ref = (struct reg_db *)aCalloc(sizeof(struct reg_db), 1); + script->add_pending_ref(st, data->ref); + data->ref->vars = st->script->local.vars; + if( !st->script->local.arrays ) + st->script->local.arrays = idb_alloc(DB_OPT_BASE); + data->ref->arrays = st->script->local.arrays; + } else if( data->ref->vars == st->stack->stack_data[st->stack->defsp-1].u.ri->script->local.vars ) { + data->ref = NULL; // Reference to the parent scope's script, remove reference pointer. + } } } } |