summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/script.c93
1 files changed, 13 insertions, 80 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 7eb713211..be608830f 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -3316,95 +3316,28 @@ static void set_reg_npcscope_str(struct script_state *st, struct reg_db *n, int6
static void set_reg_pc_ref_str(struct script_state *st, struct reg_db *n, int64 num, const char *name, const char *str)
{
- struct script_reg_str *p = NULL;
- unsigned int index = script_getvaridx(num);
-
- nullpo_retv(n);
+ struct DBIterator *iter = db_iterator(map->pc_db);
- if ((p = i64db_get(n->vars, num)) != NULL) {
- if (str[0]) {
- if (p->value) {
- aFree(p->value);
- } else if (index) {
- script->array_update(n, num, false);
- }
- p->value = aStrdup(str);
- } else {
- p->value = NULL;
- if (index) {
- script->array_update(n, num, true);
- }
- }
-
- if (!pc->reg_load) {
- p->flag.update = 1;
- }
- } else if (str[0]) {
- struct DBData prev;
- if (index) {
- script->array_update(n, num, false);
- }
-
- p = ers_alloc(pc->str_reg_ers, struct script_reg_str);
- p->value = aStrdup(str);
-
- if (!pc->reg_load) {
- p->flag.update = 1;
- }
- p->flag.type = 1;
-
- if(n->vars->put(n->vars, DB->i642key(num), DB->ptr2data(p), &prev)) {
- p = DB->data2ptr(&prev);
- if (p->value) {
- aFree(p->value);
- }
- ers_free(pc->str_reg_ers, p);
+ for (struct map_session_data *sd = dbi_first(iter); dbi_exists(iter); sd = dbi_next(iter)) {
+ if (sd != NULL && n == &sd->regs) {
+ pc->setregistry_str(sd, num, str);
+ 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)
{
- struct script_reg_num *p = NULL;
- unsigned int index = script_getvaridx(num);
+ struct DBIterator *iter = db_iterator(map->pc_db);
- nullpo_retv(n);
-
- if ((p = i64db_get(n->vars, num)) != NULL) {
- if (val) {
- if (!p->value && index) {
- script->array_update(n, num, false);
- }
- p->value = val;
- } else {
- p->value = 0;
- if (index) {
- script->array_update(n, num, true);
- }
- }
-
- if (!pc->reg_load) {
- p->flag.update = 1;
- }
- } else if (val) {
- struct DBData prev;
- if (index) {
- script->array_update(n, num, false);
- }
-
- p = ers_alloc(pc->num_reg_ers, struct script_reg_num);
- p->value = val;
-
- if (!pc->reg_load) {
- p->flag.update = 1;
- }
- p->flag.type = 1;
-
- if(n->vars->put(n->vars, DB->i642key(num), DB->ptr2data(p), &prev)) {
- p = DB->data2ptr(&prev);
- ers_free(pc->num_reg_ers, p);
+ for (struct map_session_data *sd = dbi_first(iter); dbi_exists(iter); sd = dbi_next(iter)) {
+ if (sd != NULL && n == &sd->regs) {
+ pc->setregistry(sd, num, val);
+ 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)
@@ -20742,7 +20675,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;