- Added missing parameter to db_iput
and db_uiput
macros (follow-up to r15682).
- Numeric global variables (mapreg) now utilize `DBMap`'s ability to store integer-type data (follow-up to r15682). - Minor code cleanup: replaced some `DBMap` function calls with macros. git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15683 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
691872fdc7
commit
6aabd3d1b7
@ -628,16 +628,16 @@ struct DBMap {
|
|||||||
#define strdb_put(db,k,d) ( (db)->put((db),db_str2key(k),db_ptr2data(d),NULL) )
|
#define strdb_put(db,k,d) ( (db)->put((db),db_str2key(k),db_ptr2data(d),NULL) )
|
||||||
|
|
||||||
// Put int-type data into DBMaps of various key types
|
// Put int-type data into DBMaps of various key types
|
||||||
#define db_iput(db,k,d) ( (db)->put((db),(k),db_i2data(d)) )
|
#define db_iput(db,k,d) ( (db)->put((db),(k),db_i2data(d),NULL) )
|
||||||
#define idb_iput(db,k,d) ( (db)->put((db),db_i2key(k),db_i2data(d)) )
|
#define idb_iput(db,k,d) ( (db)->put((db),db_i2key(k),db_i2data(d),NULL) )
|
||||||
#define uidb_iput(db,k,d) ( (db)->put((db),db_ui2key(k),db_i2data(d)) )
|
#define uidb_iput(db,k,d) ( (db)->put((db),db_ui2key(k),db_i2data(d),NULL) )
|
||||||
#define strdb_iput(db,k,d) ( (db)->put((db),db_str2key(k),db_i2data(d)) )
|
#define strdb_iput(db,k,d) ( (db)->put((db),db_str2key(k),db_i2data(d),NULL) )
|
||||||
|
|
||||||
// Put uint-type data into DBMaps of various key types
|
// Put uint-type data into DBMaps of various key types
|
||||||
#define db_uiput(db,k,d) ( (db)->put((db),(k),db_ui2data(d)) )
|
#define db_uiput(db,k,d) ( (db)->put((db),(k),db_ui2data(d),NULL) )
|
||||||
#define idb_uiput(db,k,d) ( (db)->put((db),db_i2key(k),db_ui2data(d)) )
|
#define idb_uiput(db,k,d) ( (db)->put((db),db_i2key(k),db_ui2data(d),NULL) )
|
||||||
#define uidb_uiput(db,k,d) ( (db)->put((db),db_ui2key(k),db_ui2data(d)) )
|
#define uidb_uiput(db,k,d) ( (db)->put((db),db_ui2key(k),db_ui2data(d),NULL) )
|
||||||
#define strdb_uiput(db,k,d) ( (db)->put((db),db_str2key(k),db_ui2data(d)) )
|
#define strdb_uiput(db,k,d) ( (db)->put((db),db_str2key(k),db_ui2data(d),NULL) )
|
||||||
|
|
||||||
// Remove entry from DBMaps of various key types
|
// Remove entry from DBMaps of various key types
|
||||||
#define db_remove(db,k) ( (db)->remove((db),(k),NULL) )
|
#define db_remove(db,k) ( (db)->remove((db),(k),NULL) )
|
||||||
|
@ -24,13 +24,13 @@ static bool mapreg_dirty = false;
|
|||||||
/// Looks up the value of an integer variable using its uid.
|
/// Looks up the value of an integer variable using its uid.
|
||||||
int mapreg_readreg(int uid)
|
int mapreg_readreg(int uid)
|
||||||
{
|
{
|
||||||
return (int)idb_get(mapreg_db, uid);
|
return idb_iget(mapreg_db, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Looks up the value of a string variable using its uid.
|
/// Looks up the value of a string variable using its uid.
|
||||||
char* mapreg_readregstr(int uid)
|
char* mapreg_readregstr(int uid)
|
||||||
{
|
{
|
||||||
return (char*)idb_get(mapregstr_db, uid);
|
return idb_get(mapregstr_db, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Modifies the value of an integer variable.
|
/// Modifies the value of an integer variable.
|
||||||
@ -42,10 +42,10 @@ bool mapreg_setreg(int uid, int val)
|
|||||||
|
|
||||||
if( val != 0 )
|
if( val != 0 )
|
||||||
{
|
{
|
||||||
if( idb_put(mapreg_db,uid,(void*)val) )
|
if( idb_iput(mapreg_db,uid,val) )
|
||||||
mapreg_dirty = true; // already exists, delay write
|
mapreg_dirty = true; // already exists, delay write
|
||||||
else if(name[1] != '@')
|
else if(name[1] != '@')
|
||||||
{// write new wariable to database
|
{// write new variable to database
|
||||||
char tmp_str[32*2+1];
|
char tmp_str[32*2+1];
|
||||||
Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32));
|
Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32));
|
||||||
if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg_table, tmp_str, i, val) )
|
if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg_table, tmp_str, i, val) )
|
||||||
@ -134,7 +134,7 @@ static void script_load_mapreg(void)
|
|||||||
if( varname[length-1] == '$' )
|
if( varname[length-1] == '$' )
|
||||||
idb_put(mapregstr_db, (i<<24)|s, aStrdup(value));
|
idb_put(mapregstr_db, (i<<24)|s, aStrdup(value));
|
||||||
else
|
else
|
||||||
idb_put(mapreg_db, (i<<24)|s, (void *)atoi(value));
|
idb_iput(mapreg_db, (i<<24)|s, atoi(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
SqlStmt_Free(stmt);
|
SqlStmt_Free(stmt);
|
||||||
@ -159,7 +159,7 @@ static void script_save_mapreg(void)
|
|||||||
if( name[1] == '@' )
|
if( name[1] == '@' )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d'", mapreg_table, (int)db_data2ptr(data), name, i) )
|
if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d'", mapreg_table, db_data2i(data), name, i) )
|
||||||
Sql_ShowDebug(mmysql_handle);
|
Sql_ShowDebug(mmysql_handle);
|
||||||
}
|
}
|
||||||
dbi_destroy(iter);
|
dbi_destroy(iter);
|
||||||
@ -198,8 +198,8 @@ void mapreg_reload(void)
|
|||||||
if( mapreg_dirty )
|
if( mapreg_dirty )
|
||||||
script_save_mapreg();
|
script_save_mapreg();
|
||||||
|
|
||||||
mapreg_db->clear(mapreg_db, NULL);
|
db_clear(mapreg_db);
|
||||||
mapregstr_db->clear(mapregstr_db, NULL);
|
db_clear(mapregstr_db);
|
||||||
|
|
||||||
script_load_mapreg();
|
script_load_mapreg();
|
||||||
}
|
}
|
||||||
@ -209,8 +209,8 @@ void mapreg_final(void)
|
|||||||
if( mapreg_dirty )
|
if( mapreg_dirty )
|
||||||
script_save_mapreg();
|
script_save_mapreg();
|
||||||
|
|
||||||
mapreg_db->destroy(mapreg_db,NULL);
|
db_destroy(mapreg_db);
|
||||||
mapregstr_db->destroy(mapregstr_db,NULL);
|
db_destroy(mapregstr_db);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapreg_init(void)
|
void mapreg_init(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user