diff options
author | gumi <git@gumi.ca> | 2018-10-01 20:25:42 -0400 |
---|---|---|
committer | gumi <git@gumi.ca> | 2018-10-01 22:38:24 -0400 |
commit | 3ced983fc5d26f69896ce62230c48d6e2faa04fd (patch) | |
tree | 17cb17f2ddbcee3dfa38200cd30b09006ac9e861 /src/map | |
parent | 852c13305f67948531bd0277eb1922dbd02b1f26 (diff) | |
download | hercules-3ced983fc5d26f69896ce62230c48d6e2faa04fd.tar.gz hercules-3ced983fc5d26f69896ce62230c48d6e2faa04fd.tar.bz2 hercules-3ced983fc5d26f69896ce62230c48d6e2faa04fd.tar.xz hercules-3ced983fc5d26f69896ce62230c48d6e2faa04fd.zip |
fix setting char/account variables of another player
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/script.c | 28 |
1 files changed, 26 insertions, 2 deletions
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; |