summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-03-13 15:20:58 +0000
committergepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-03-13 15:20:58 +0000
commitd09a65227657845550ba2ea310c5cf669646d433 (patch)
treeccadc7a28c93df704d269717cd29aa68098b9fa4 /src
parentdc5babf8c3fb943a22c440f5afd6957b121926c5 (diff)
downloadhercules-d09a65227657845550ba2ea310c5cf669646d433.tar.gz
hercules-d09a65227657845550ba2ea310c5cf669646d433.tar.bz2
hercules-d09a65227657845550ba2ea310c5cf669646d433.tar.xz
hercules-d09a65227657845550ba2ea310c5cf669646d433.zip
- 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://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15683 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/common/db.h16
-rw-r--r--src/map/mapreg_sql.c20
2 files changed, 18 insertions, 18 deletions
diff --git a/src/common/db.h b/src/common/db.h
index 49a95a135..4fe6a93d6 100644
--- a/src/common/db.h
+++ b/src/common/db.h
@@ -628,16 +628,16 @@ struct DBMap {
#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
-#define db_iput(db,k,d) ( (db)->put((db),(k),db_i2data(d)) )
-#define idb_iput(db,k,d) ( (db)->put((db),db_i2key(k),db_i2data(d)) )
-#define uidb_iput(db,k,d) ( (db)->put((db),db_ui2key(k),db_i2data(d)) )
-#define strdb_iput(db,k,d) ( (db)->put((db),db_str2key(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),NULL) )
+#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),NULL) )
// Put uint-type data into DBMaps of various key types
-#define db_uiput(db,k,d) ( (db)->put((db),(k),db_ui2data(d)) )
-#define idb_uiput(db,k,d) ( (db)->put((db),db_i2key(k),db_ui2data(d)) )
-#define uidb_uiput(db,k,d) ( (db)->put((db),db_ui2key(k),db_ui2data(d)) )
-#define strdb_uiput(db,k,d) ( (db)->put((db),db_str2key(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),NULL) )
+#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),NULL) )
// Remove entry from DBMaps of various key types
#define db_remove(db,k) ( (db)->remove((db),(k),NULL) )
diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c
index c8b177c7e..7782f7f02 100644
--- a/src/map/mapreg_sql.c
+++ b/src/map/mapreg_sql.c
@@ -24,13 +24,13 @@ static bool mapreg_dirty = false;
/// Looks up the value of an integer variable using its 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.
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.
@@ -42,10 +42,10 @@ bool mapreg_setreg(int uid, int val)
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
else if(name[1] != '@')
- {// write new wariable to database
+ {// write new variable to database
char tmp_str[32*2+1];
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) )
@@ -134,7 +134,7 @@ static void script_load_mapreg(void)
if( varname[length-1] == '$' )
idb_put(mapregstr_db, (i<<24)|s, aStrdup(value));
else
- idb_put(mapreg_db, (i<<24)|s, (void *)atoi(value));
+ idb_iput(mapreg_db, (i<<24)|s, atoi(value));
}
SqlStmt_Free(stmt);
@@ -159,7 +159,7 @@ static void script_save_mapreg(void)
if( name[1] == '@' )
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);
}
dbi_destroy(iter);
@@ -198,8 +198,8 @@ void mapreg_reload(void)
if( mapreg_dirty )
script_save_mapreg();
- mapreg_db->clear(mapreg_db, NULL);
- mapregstr_db->clear(mapregstr_db, NULL);
+ db_clear(mapreg_db);
+ db_clear(mapregstr_db);
script_load_mapreg();
}
@@ -209,8 +209,8 @@ void mapreg_final(void)
if( mapreg_dirty )
script_save_mapreg();
- mapreg_db->destroy(mapreg_db,NULL);
- mapregstr_db->destroy(mapregstr_db,NULL);
+ db_destroy(mapreg_db);
+ db_destroy(mapregstr_db);
}
void mapreg_init(void)