diff options
author | panikon <panikon@zoho.com> | 2014-02-19 20:24:56 -0300 |
---|---|---|
committer | panikon <panikon@zoho.com> | 2014-02-19 20:24:56 -0300 |
commit | d6cd24a757c7254914ef048f71aa7e9d4f493fda (patch) | |
tree | 53b779650a2821dc8bf2a9deb00d5a03890449fe /src/map/script.c | |
parent | e6b107b80355201fa958a74860d59a5034bb839d (diff) | |
download | hercules-d6cd24a757c7254914ef048f71aa7e9d4f493fda.tar.gz hercules-d6cd24a757c7254914ef048f71aa7e9d4f493fda.tar.bz2 hercules-d6cd24a757c7254914ef048f71aa7e9d4f493fda.tar.xz hercules-d6cd24a757c7254914ef048f71aa7e9d4f493fda.zip |
Readding last merge as last revert was unintended. Sorry for the trouble.
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/src/map/script.c b/src/map/script.c index be346cb92..1dff4c202 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2609,7 +2609,7 @@ void* get_val2(struct script_state* st, int64 uid, struct DBMap** ref) { **/ void script_array_ensure_zero(struct script_state *st, struct map_session_data *sd, int64 uid, struct DBMap** ref) { const char *name = script->get_str(script_getvarid(uid)); - struct DBMap *src = script->array_src(st, sd ? sd : st->rid ? map->id2sd(st->rid) : NULL, name, ref);\ + struct DBMap *src = script->array_src(st, sd ? sd : st->rid ? map->id2sd(st->rid) : NULL, name, ref); struct script_array *sa = NULL; bool insert = false; @@ -4847,8 +4847,17 @@ BUILDIN(callfunc) const char* name = reference_getname(data); if( name[0] == '.' ) { if( !ref ) { - ref = (struct DBMap**)aCalloc(sizeof(struct DBMap*), 1); + ref = (struct DBMap**)aCalloc(sizeof(struct DBMap*), 2); ref[0] = (name[1] == '@' ? st->stack->var_function : st->script->script_vars); + if( name[1] == '@' ) { + if( !st->stack->array_function_db ) + st->stack->array_function_db = idb_alloc(DB_OPT_BASE); + ref[1] = st->stack->array_function_db; + } else { + if( !st->script->script_arrays_db ) + st->script->script_arrays_db = idb_alloc(DB_OPT_BASE); + ref[1] = st->script->script_arrays_db; + } } data->ref = ref; } @@ -4897,8 +4906,11 @@ BUILDIN(callsub) const char* name = reference_getname(data); if( name[0] == '.' && name[1] == '@' ) { if ( !ref ) { - ref = (struct DBMap**)aCalloc(sizeof(struct DBMap*), 1); + ref = (struct DBMap**)aCalloc(sizeof(struct DBMap*), 2); ref[0] = st->stack->var_function; + if( !st->stack->array_function_db ) + st->stack->array_function_db = idb_alloc(DB_OPT_BASE); + ref[1] = st->stack->array_function_db; } data->ref = ref; } @@ -4971,12 +4983,16 @@ BUILDIN(return) const char* name = reference_getname(data); if( name[0] == '.' && name[1] == '@' ) {// scope variable - if( !data->ref || data->ref == (DBMap**)&st->stack->var_function ) + if( !data->ref || data->ref[0] == st->stack->var_function ) script->get_val(st, data);// current scope, convert to value } else if( name[0] == '.' && !data->ref ) {// script variable, link to current script - data->ref = &st->script->script_vars; + data->ref = (struct DBMap**)aCalloc(sizeof(struct DBMap*), 2); + data->ref[0] = st->script->script_vars; + if( !st->script->script_arrays_db ) + st->script->script_arrays_db = idb_alloc(DB_OPT_BASE); + data->ref[1] = st->script->script_arrays_db; } } } @@ -9868,7 +9884,7 @@ BUILDIN(sc_start) { } if( bl ) - status->change_start(bl, type, 10000, val1, 0, 0, val4, tick, 2); + status->change_start(NULL, bl, type, 10000, val1, 0, 0, val4, tick, 2); return true; } @@ -9906,7 +9922,7 @@ BUILDIN(sc_start2) { } if( bl ) - status->change_start(bl, type, rate, val1, 0, 0, val4, tick, 2); + status->change_start(NULL, bl, type, rate, val1, 0, 0, val4, tick, 2); return true; } @@ -9946,7 +9962,7 @@ BUILDIN(sc_start4) { } if( bl ) - status->change_start(bl, type, 10000, val1, val2, val3, val4, tick, 2); + status->change_start(NULL, bl, type, 10000, val1, val2, val3, val4, tick, 2); return true; } @@ -10013,7 +10029,7 @@ BUILDIN(getscrate) { bl = map->id2bl(st->rid); if (bl) - rate = status->get_sc_def(bl, (sc_type)type, 10000, 10000, 0); + rate = status->get_sc_def(bl, bl, (sc_type)type, 10000, 10000, 0); script_pushint(st,rate); return true; @@ -13259,7 +13275,7 @@ BUILDIN(summon) md->deletetimer = timer->add(tick+(timeout>0?timeout*1000:60000),mob->timer_delete,md->bl.id,0); mob->spawn (md); //Now it is ready for spawning. clif->specialeffect(&md->bl,344,AREA); - sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000); + sc_start4(NULL, &md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000); } return true; } @@ -15812,7 +15828,7 @@ BUILDIN(mercenary_sc_start) { tick = script_getnum(st,3); val1 = script_getnum(st,4); - status->change_start(&sd->md->bl, type, 10000, val1, 0, 0, 0, tick, 2); + status->change_start(NULL, &sd->md->bl, type, 10000, val1, 0, 0, 0, tick, 2); return true; } @@ -17044,7 +17060,7 @@ BUILDIN(setmounting) { if( sd->sc.data[SC_ALL_RIDING] ) status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER); else - sc_start(&sd->bl, SC_ALL_RIDING, 100, 0, -1); + sc_start(NULL,&sd->bl, SC_ALL_RIDING, 100, 0, -1); script_pushint(st,1);//in both cases, return 1. } return true; @@ -17595,8 +17611,8 @@ BUILDIN(montransform) { sprintf(msg, msg_txt(1485), monster->name); // Traaaansformation-!! %s form!! clif->ShowScript(&sd->bl, msg); status_change_end(bl, SC_MONSTER_TRANSFORM, INVALID_TIMER); // Clear previous - sc_start2(bl, SC_MONSTER_TRANSFORM, 100, mob_id, type, tick); - sc_start4(bl, type, 100, val1, val2, val3, val4, tick); + sc_start2(NULL, bl, SC_MONSTER_TRANSFORM, 100, mob_id, type, tick); + sc_start4(NULL, bl, type, 100, val1, val2, val3, val4, tick); } return true; } |