summaryrefslogtreecommitdiff
path: root/src/char/char.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-05-04 17:22:57 -0300
committershennetsind <ind@henn.et>2013-05-04 17:22:57 -0300
commit18b1965ce16909613f0a53515d40553742082ce2 (patch)
treec17d031f20d140f289113a5e632eb551961ad475 /src/char/char.c
parentad9a13be6ef115de1d5e124283a1d63a0bc5cd4d (diff)
downloadhercules-18b1965ce16909613f0a53515d40553742082ce2.tar.gz
hercules-18b1965ce16909613f0a53515d40553742082ce2.tar.bz2
hercules-18b1965ce16909613f0a53515d40553742082ce2.tar.xz
hercules-18b1965ce16909613f0a53515d40553742082ce2.zip
mapindex update
Fixed a mapindex_name2id problem that'd persistently not fix a broken mapindex data (e.g. char save/last map data being incorrect). It'll now align it to MAP_DEFAULT when such error occurs. Also speeded up mapindex_name2id queries, replaced the loop by the red-black-tree db lookup. Special Thanks to yommy~! Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/char/char.c')
-rw-r--r--src/char/char.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/char/char.c b/src/char/char.c
index ba3179ef9..d07995cc1 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -1170,6 +1170,18 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
p->last_point.map = mapindex_name2id(last_map);
p->save_point.map = mapindex_name2id(save_map);
+ if( p->last_point.map == 0 ) {
+ p->last_point.map = strdb_iget(mapindex_db, MAP_DEFAULT);
+ p->last_point.x = MAP_DEFAULT_X;
+ p->last_point.y = MAP_DEFAULT_Y;
+ }
+
+ if( p->save_point.map == 0 ) {
+ p->save_point.map = strdb_iget(mapindex_db, MAP_DEFAULT);
+ p->save_point.x = MAP_DEFAULT_X;
+ p->save_point.y = MAP_DEFAULT_Y;
+ }
+
strcat(t_msg, " status");
if (!load_everything) // For quick selection of data when displaying the char menu
@@ -1188,8 +1200,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
|| SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT, &tmp_point.y, 0, NULL, NULL) )
SqlStmt_ShowDebug(stmt);
- for( i = 0; i < MAX_MEMOPOINTS && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i )
- {
+ for( i = 0; i < MAX_MEMOPOINTS && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) {
tmp_point.map = mapindex_name2id(point_map);
memcpy(&p->memo_point[i], &tmp_point, sizeof(tmp_point));
}
@@ -3294,7 +3305,6 @@ int parse_frommap(int fd)
WFIFOW(fd,0) = 0x2b24;
WFIFOSET(fd,2);
RFIFOSKIP(fd,2);
- ShowDebug("Received 2b23, sending 2b24\n");
break;
case 0x2b26: // auth request from map-server