summaryrefslogtreecommitdiff
path: root/src/map/mapreg_sql.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-10-02 14:31:46 -0300
committershennetsind <ind@henn.et>2013-10-02 14:31:46 -0300
commit2f2afbd3b63a75695f8f96e3bcb4db9fff5a7dc6 (patch)
tree9f8d7692f8d1e23837ca7b7ca6b5c3ba874eedc3 /src/map/mapreg_sql.c
parent7c711d608a454abea0037d79b3e805d8d7cfca55 (diff)
downloadhercules-2f2afbd3b63a75695f8f96e3bcb4db9fff5a7dc6.tar.gz
hercules-2f2afbd3b63a75695f8f96e3bcb4db9fff5a7dc6.tar.bz2
hercules-2f2afbd3b63a75695f8f96e3bcb4db9fff5a7dc6.tar.xz
hercules-2f2afbd3b63a75695f8f96e3bcb4db9fff5a7dc6.zip
HPM: Map.c Completed
Fully Interfaced. Moved missing vars and declarations of interest into the interface, removed duplicate mentions of map within calls to shorten wherever it made sense to. Ladies and Gentleman its my pleasure to announce that with this commit we've revised all of map-server, we've learned a hell lot from this, improved many things on the go and have a number of features to be released thanks to this. *cough* hpm hooking *cough*. Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/mapreg_sql.c')
-rw-r--r--src/map/mapreg_sql.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c
index 0a0b8f75f..902b7c39b 100644
--- a/src/map/mapreg_sql.c
+++ b/src/map/mapreg_sql.c
@@ -10,7 +10,7 @@
#include "../common/sql.h"
#include "../common/strlib.h"
#include "../common/timer.h"
-#include "map.h" // mmysql_handle
+#include "map.h" // map->mysql_handle
#include "script.h"
#include "mapreg.h"
#include <stdlib.h>
@@ -55,9 +55,9 @@ 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_ShowDebug(mmysql_handle);
+ SQL->EscapeStringLen(map->mysql_handle, tmp_str, name, strnlen(name, 32));
+ if( SQL_ERROR == SQL->Query(map->mysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg->table, tmp_str, i, val) )
+ Sql_ShowDebug(map->mysql_handle);
}
idb_put(mapreg->db, uid, m);
}
@@ -68,8 +68,8 @@ 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) )
- Sql_ShowDebug(mmysql_handle);
+ if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) )
+ Sql_ShowDebug(map->mysql_handle);
}
}
@@ -85,8 +85,8 @@ 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) )
- Sql_ShowDebug(mmysql_handle);
+ if( SQL_ERROR == SQL->Query(map->mysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) )
+ Sql_ShowDebug(map->mysql_handle);
}
if( (m = idb_get(mapreg->str_db,uid)) ) {
if( m->u.str != NULL )
@@ -113,10 +113,10 @@ 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_ShowDebug(mmysql_handle);
+ SQL->EscapeStringLen(map->mysql_handle, tmp_str, name, strnlen(name, 32));
+ SQL->EscapeStringLen(map->mysql_handle, tmp_str2, str, strnlen(str, 255));
+ if( SQL_ERROR == SQL->Query(map->mysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg->table, tmp_str, i, tmp_str2) )
+ Sql_ShowDebug(map->mysql_handle);
}
idb_put(mapreg->str_db, uid, m);
}
@@ -133,7 +133,7 @@ void script_load_mapreg(void) {
| varname | index | value |
+-------------------------+
*/
- SqlStmt* stmt = SQL->StmtMalloc(mmysql_handle);
+ SqlStmt* stmt = SQL->StmtMalloc(map->mysql_handle);
char varname[32+1];
int index;
char value[255+1];
@@ -199,8 +199,8 @@ void script_save_mapreg(void) {
int i = (m->uid & 0xff000000) >> 24;
const char* name = script->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) )
- Sql_ShowDebug(mmysql_handle);
+ if( SQL_ERROR == SQL->Query(map->mysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, m->u.i, name, i) )
+ Sql_ShowDebug(map->mysql_handle);
m->save = false;
}
}
@@ -217,9 +217,9 @@ void script_save_mapreg(void) {
const char* name = script->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_ShowDebug(mmysql_handle);
+ SQL->EscapeStringLen(map->mysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, 255));
+ if( SQL_ERROR == SQL->Query(map->mysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, tmp_str2, name, i) )
+ Sql_ShowDebug(map->mysql_handle);
m->save = false;
}
}