summaryrefslogtreecommitdiff
path: root/src/map/mapreg_sql.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-05-15 16:47:08 -0300
committershennetsind <ind@henn.et>2013-05-15 16:47:08 -0300
commit0aee4fd57f2f4135361f4182a08a98cf52ed9d10 (patch)
treed7f43f0a5a63e73e21291f906e33109232ce7830 /src/map/mapreg_sql.c
parent75942979098d34d52adc2537b6f28e02be7d7bae (diff)
downloadhercules-0aee4fd57f2f4135361f4182a08a98cf52ed9d10.tar.gz
hercules-0aee4fd57f2f4135361f4182a08a98cf52ed9d10.tar.bz2
hercules-0aee4fd57f2f4135361f4182a08a98cf52ed9d10.tar.xz
hercules-0aee4fd57f2f4135361f4182a08a98cf52ed9d10.zip
HPM Update
Made SQL and strlib functions HPM-friendly, special thanks to Yommy for bringing the issue up. Added partial map.c support, for the all-handy map[] array, beware that soon the whole map.c renewal design will be commit and when that happens your usage of map.c functions in plugins might require some updates. Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/mapreg_sql.c')
-rw-r--r--src/map/mapreg_sql.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c
index bac3cea13..484da5641 100644
--- a/src/map/mapreg_sql.c
+++ b/src/map/mapreg_sql.c
@@ -62,8 +62,8 @@ bool mapreg_setreg(int uid, int val) {
if(name[1] != '@') {// 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) )
+ 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) )
Sql_ShowDebug(mmysql_handle);
}
idb_put(mapreg_db, uid, m);
@@ -75,7 +75,7 @@ bool mapreg_setreg(int uid, int val) {
idb_remove(mapreg_db,uid);
if( name[1] != '@' ) {// Remove from database because it is unused.
- if( SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) )
+ if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) )
Sql_ShowDebug(mmysql_handle);
}
}
@@ -92,7 +92,7 @@ bool mapreg_setregstr(int uid, const char* str) {
if( str == NULL || *str == 0 ) {
if(name[1] != '@') {
- if( SQL_ERROR == Sql_Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) )
+ if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) )
Sql_ShowDebug(mmysql_handle);
}
if( (m = idb_get(mapregstr_db,uid)) ) {
@@ -120,9 +120,9 @@ bool mapreg_setregstr(int uid, const char* str) {
if(name[1] != '@') { //put returned null, so we must insert.
char tmp_str[32*2+1];
char tmp_str2[255*2+1];
- Sql_EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32));
- Sql_EscapeStringLen(mmysql_handle, tmp_str2, str, strnlen(str, 255));
- if( SQL_ERROR == Sql_Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg_table, tmp_str, i, tmp_str2) )
+ SQL->EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32));
+ SQL->EscapeStringLen(mmysql_handle, tmp_str2, str, strnlen(str, 255));
+ if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg_table, tmp_str, i, tmp_str2) )
Sql_ShowDebug(mmysql_handle);
}
idb_put(mapregstr_db, uid, m);
@@ -206,7 +206,7 @@ static void script_save_mapreg(void) {
int i = (m->uid & 0xff000000) >> 24;
const char* name = get_str(num);
- if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, m->u.i, name, i) )
+ if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, m->u.i, name, i) )
Sql_ShowDebug(mmysql_handle);
m->save = false;
}
@@ -224,8 +224,8 @@ static void script_save_mapreg(void) {
const char* name = get_str(num);
char tmp_str2[2*255+1];
- Sql_EscapeStringLen(mmysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, 255));
- if( SQL_ERROR == Sql_Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, tmp_str2, name, i) )
+ SQL->EscapeStringLen(mmysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, 255));
+ if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, tmp_str2, name, i) )
Sql_ShowDebug(mmysql_handle);
m->save = false;
}