Created
October 10, 2010 00:35
-
-
Save anonymous/618773 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BUILDIN_FUNC(callnpcevent) | |
{ | |
int i, j; | |
const char *event_name = script_getstr(st, 2); | |
struct event_data *event = 0; | |
struct script_retinfo *ri; | |
event = strdb_get(ev_db, event_name); | |
if (!event) | |
{ | |
ShowError("script:callnpcevent: argument is not an event\n"); | |
script_reportdata(script_getdata(st,2)); | |
st->state = END; | |
return 1; | |
} | |
for( i = st->start+3, j = 0; i < st->end; i++, j++ ) | |
{ | |
struct script_data* data = push_copy(st->stack,i); | |
if( data_isreference(data) && !data->ref ) | |
{ | |
const char* name = reference_getname(data); | |
if( name[0] == '.' && name[1] == '@' ) | |
data->ref = st->stack->var_function; | |
else if( name[0] == '.' ) | |
data->ref = &st->script->script_vars; | |
} | |
} | |
CREATE(ri, struct script_retinfo, 1); | |
ri->script = st->script; | |
ri->var_function = st->stack->var_function; | |
ri->pos = st->pos; | |
ri->nargs = j; | |
ri->defsp = st->stack->defsp; | |
ri->oid = st->oid; | |
push_retinfo(st->stack, ri); | |
st->pos = event->pos; | |
st->script = event->nd->u.scr.script; | |
st->stack->defsp = st->stack->sp; | |
st->state = GOTO; | |
st->stack->var_function = (struct linkdb_node**)aCalloc(1, sizeof(struct linkdb_node*)); | |
st->oid = event->nd->bl.id; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment