- 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://svn.code.sf.net/p/rathena/svn/trunk@15998 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
02e4daf67d
commit
ab8f7490a0
@ -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_
|
||||
#endif // _CONF_H_
|
||||
|
@ -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) );
|
||||
@ -298,14 +297,6 @@ void instance_del_map(int m)
|
||||
memset(&map[m], 0x00, sizeof(map[0]));
|
||||
}
|
||||
|
||||
/*--------------------------------------
|
||||
* 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
|
||||
*--------------------------------------*/
|
||||
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user