summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorepoque11 <epoque11@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-04-28 22:15:18 +0000
committerepoque11 <epoque11@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-04-28 22:15:18 +0000
commitb6a5ac44371ff714d18a04f3acbe29955ace07aa (patch)
treeea97e1dc9254a40f2b6eb0bdac6418c024fda20d
parent4f2de079cdabfa86b609a5ad15df3a4c1c58437b (diff)
downloadhercules-b6a5ac44371ff714d18a04f3acbe29955ace07aa.tar.gz
hercules-b6a5ac44371ff714d18a04f3acbe29955ace07aa.tar.bz2
hercules-b6a5ac44371ff714d18a04f3acbe29955ace07aa.tar.xz
hercules-b6a5ac44371ff714d18a04f3acbe29955ace07aa.zip
- Fixed an issue with the instance variable storage system never being initialised (since unknown revision)
- Combined both string and integer instance variables into a single DBMap* structure - Fixed a missing new-line at the end of src/common/conf.h causing warnings git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15998 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--src/common/conf.h2
-rw-r--r--src/map/instance.c21
-rw-r--r--src/map/instance.h2
-rw-r--r--src/map/script.c27
4 files changed, 18 insertions, 34 deletions
diff --git a/src/common/conf.h b/src/common/conf.h
index 4c3dec89f..666853ba6 100644
--- a/src/common/conf.h
+++ b/src/common/conf.h
@@ -10,4 +10,4 @@
int conf_read_file(config_t *config, const char *config_filename);
int config_setting_copy(config_setting_t *parent, const config_setting_t *src);
-#endif // _CONF_H_ \ No newline at end of file
+#endif // _CONF_H_
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: