summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/instance.c21
-rw-r--r--src/map/instance.h2
-rw-r--r--src/map/script.c27
3 files changed, 17 insertions, 33 deletions
diff --git a/src/map/instance.c b/src/map/instance.c
index b105a09fa..fcbc03e5e 100644
--- a/src/map/instance.c
+++ b/src/map/instance.c
@@ -82,8 +82,7 @@ int instance_create(int party_id, const char *name)
instance[i].progress_timeout = 0;
instance[i].users = 0;
instance[i].party_id = party_id;
- instance[i].ivar = NULL;
- instance[i].svar = NULL;
+ instance[i].vars = idb_alloc(DB_OPT_RELEASE_DATA);
safestrncpy( instance[i].name, name, sizeof(instance[i].name) );
memset( instance[i].map, 0x00, sizeof(instance[i].map) );
@@ -299,14 +298,6 @@ void instance_del_map(int m)
}
/*--------------------------------------
- * Used for instance variables. Clean each variable from memory.
- *--------------------------------------*/
-void instance_destroy_freesvar(void *key, void *data, va_list args)
-{
- if( data ) aFree(data);
-}
-
-/*--------------------------------------
* Timer to destroy instance by process or idle
*--------------------------------------*/
int instance_destroy_timer(int tid, unsigned int tick, int id, intptr_t data)
@@ -342,19 +333,15 @@ void instance_destroy(int instance_id)
instance_del_map( instance[instance_id].map[0] );
}
- if( instance[instance_id].ivar )
- db_destroy(instance[instance_id].ivar);
-
- if( instance[instance_id].svar )
- db_destroy(instance[instance_id].svar);
+ if( instance[instance_id].vars )
+ db_destroy(instance[instance_id].vars);
if( instance[instance_id].progress_timer != INVALID_TIMER )
delete_timer( instance[instance_id].progress_timer, instance_destroy_timer);
if( instance[instance_id].idle_timer != INVALID_TIMER )
delete_timer( instance[instance_id].idle_timer, instance_destroy_timer);
- instance[instance_id].ivar = NULL;
- instance[instance_id].svar = NULL;
+ instance[instance_id].vars = NULL;
if( instance[instance_id].party_id && (p = party_search(instance[instance_id].party_id)) != NULL )
p->instance_id = 0; // Update Party information
diff --git a/src/map/instance.h b/src/map/instance.h
index e918aa516..f8f7387f7 100644
--- a/src/map/instance.h
+++ b/src/map/instance.h
@@ -21,7 +21,7 @@ struct s_instance {
int num_map;
int users;
- struct DBMap *ivar, *svar; // Instance Variable for scripts
+ struct DBMap* vars; // Instance Variable for scripts
int progress_timer;
time_t progress_timeout;
diff --git a/src/map/script.c b/src/map/script.c
index 0428d7a26..856b2d95e 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -2541,15 +2541,12 @@ void get_val(struct script_state* st, struct script_data* data)
}
break;
case '\'':
- {
- struct DBMap* n = NULL;
if (st->instance_id) {
- n = instance[st->instance_id].svar;
+ data->u.str = (char*)idb_get(instance[st->instance_id].vars,reference_getuid(data));
} else {
- ShowWarning("script:get_val: cannot access instance variable '%s', defaulting to 0\n", name);
+ ShowWarning("script:get_val: cannot access instance variable '%s', defaulting to \"\"\n", name);
+ data->u.str = NULL;
}
- data->u.str = (char*)idb_get(n,reference_getuid(data));
- }
break;
default:
data->u.str = pc_readglobalreg_str(sd, name);
@@ -2606,12 +2603,12 @@ void get_val(struct script_state* st, struct script_data* data)
}
break;
case '\'':
- {
- struct DBMap* n = NULL;
if( st->instance_id )
- n = instance[st->instance_id].ivar;
- data->u.num = (int)idb_iget(n,reference_getuid(data));
- }
+ data->u.num = (int)idb_iget(instance[st->instance_id].vars,reference_getuid(data));
+ else {
+ ShowWarning("script:get_val: cannot access instance variable '%s', defaulting to 0\n", name);
+ data->u.num = 0;
+ }
break;
default:
data->u.num = pc_readglobalreg(sd, name);
@@ -2668,8 +2665,8 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam
return 1;
case '\'':
if( st->instance_id ) {
- idb_remove(instance[st->instance_id].svar, num);
- if( str[0] ) idb_put(instance[st->instance_id].svar, num, aStrdup(str));
+ idb_remove(instance[st->instance_id].vars, num);
+ if( str[0] ) idb_put(instance[st->instance_id].vars, num, aStrdup(str));
}
return 1;
default:
@@ -2716,9 +2713,9 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam
return 1;
case '\'':
if( st->instance_id ) {
- idb_remove(instance[st->instance_id].ivar, num);
+ idb_remove(instance[st->instance_id].vars, num);
if( val != 0 )
- idb_iput(instance[st->instance_id].ivar, num, val);
+ idb_iput(instance[st->instance_id].vars, num, val);
}
return 1;
default: