From 3ced983fc5d26f69896ce62230c48d6e2faa04fd Mon Sep 17 00:00:00 2001 From: gumi Date: Mon, 1 Oct 2018 20:25:42 -0400 Subject: fix setting char/account variables of another player --- src/map/script.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/map/script.c b/src/map/script.c index b787d0138..094e32127 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -3361,6 +3361,18 @@ static void set_reg_pc_ref_str(struct script_state *st, struct reg_db *n, int64 ers_free(pc->str_reg_ers, p); } } + + if (!pc->reg_load && p != NULL) { + struct DBIterator *iter = db_iterator(map->pc_db); + + for (struct map_session_data *sd = dbi_first(iter); dbi_exists(iter); sd = dbi_next(iter)) { + if (sd != NULL && n == &sd->regs) { + sd->vars_dirty = true; // tell char server to update our vars! + break; + } + } + dbi_destroy(iter); + } } static void set_reg_pc_ref_num(struct script_state *st, struct reg_db *n, int64 num, const char *name, int val) @@ -3398,13 +3410,25 @@ static void set_reg_pc_ref_num(struct script_state *st, struct reg_db *n, int64 if (!pc->reg_load) { p->flag.update = 1; } - p->flag.type = 1; + p->flag.type = 0; if(n->vars->put(n->vars, DB->i642key(num), DB->ptr2data(p), &prev)) { p = DB->data2ptr(&prev); ers_free(pc->num_reg_ers, p); } } + + if (!pc->reg_load && p != NULL) { + struct DBIterator *iter = db_iterator(map->pc_db); + + for (struct map_session_data *sd = dbi_first(iter); dbi_exists(iter); sd = dbi_next(iter)) { + if (sd != NULL && n == &sd->regs) { + sd->vars_dirty = true; // tell char server to update our vars! + break; + } + } + dbi_destroy(iter); + } } static void set_reg_npcscope_num(struct script_state *st, struct reg_db *n, int64 num, const char *name, int val) @@ -20698,7 +20722,7 @@ static BUILDIN(getvariableofpc) } if (!sd->regs.vars) - sd->regs.vars = i64db_alloc(DB_OPT_RELEASE_DATA); + sd->regs.vars = i64db_alloc(DB_OPT_BASE); script->push_val(st->stack, C_NAME, reference_getuid(data), &sd->regs); return true; -- cgit v1.2.3-70-g09d2