summaryrefslogtreecommitdiff
path: root/src/char/char.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-04-27 13:33:10 -0300
committershennetsind <ind@henn.et>2013-04-27 13:33:10 -0300
commit0f4a50d13538c3e5d3ca4d3822f92217c8da0479 (patch)
tree2daf0a99ca0104d6a7fa95637e0377e7a9a0d6ed /src/char/char.c
parent1f6360f2e157d8eb742a32baed4c5ec7c68c0ef1 (diff)
downloadhercules-0f4a50d13538c3e5d3ca4d3822f92217c8da0479.tar.gz
hercules-0f4a50d13538c3e5d3ca4d3822f92217c8da0479.tar.bz2
hercules-0f4a50d13538c3e5d3ca4d3822f92217c8da0479.tar.xz
hercules-0f4a50d13538c3e5d3ca4d3822f92217c8da0479.zip
Skill ID Processing Overhaul
http://hercules.ws/board/topic/512-skill-id-processing-overhaul/ Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/char/char.c')
-rw-r--r--src/char/char.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/char/char.c b/src/char/char.c
index be98af10e..d5064eee2 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -146,6 +146,8 @@ unsigned int save_flag = 0;
// Initial position (it's possible to set it in conf file)
struct point start_point = { 0, 53, 111 };
+unsigned short skillid2idx[MAX_SKILL_ID];
+
//-----------------------------------------------------
// Auth database
//-----------------------------------------------------
@@ -565,18 +567,10 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
strcat(save_status, " memo");
}
- //FIXME: is this neccessary? [ultramage]
- for(i=0;i<MAX_SKILL;i++)
- if ((p->skill[i].lv != 0) && (p->skill[i].id == 0))
- p->skill[i].id = i; // Fix skill tree
-
-
//skills
- if( memcmp(p->skill, cp->skill, sizeof(p->skill)) )
- {
+ if( memcmp(p->skill, cp->skill, sizeof(p->skill)) ) {
//`skill` (`char_id`, `id`, `lv`)
- if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, p->char_id) )
- {
+ if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", skill_db, p->char_id) ) {
Sql_ShowDebug(sql_handle);
errors++;
}
@@ -1278,10 +1272,9 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
if( tmp_skill.flag != SKILL_FLAG_PERM_GRANTED )
tmp_skill.flag = SKILL_FLAG_PERMANENT;
- for( i = 0; i < MAX_SKILL && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i )
- {
- if( tmp_skill.id < ARRAYLENGTH(p->skill) )
- memcpy(&p->skill[tmp_skill.id], &tmp_skill, sizeof(tmp_skill));
+ for( i = 0; i < MAX_SKILL && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i ) {
+ if( skillid2idx[tmp_skill.id] )
+ memcpy(&p->skill[skillid2idx[tmp_skill.id]], &tmp_skill, sizeof(tmp_skill));
else
ShowWarning("mmo_char_fromsql: ignoring invalid skill (id=%u,lv=%u) of character %s (AID=%d,CID=%d)\n", tmp_skill.id, tmp_skill.lv, p->name, p->account_id, p->char_id);
}
@@ -2702,7 +2695,22 @@ int parse_frommap(int fd)
RFIFOSKIP(fd,RFIFOW(fd,2));
break;
-
+ case 0x2b0b:
+ if( RFIFOREST(fd) < RFIFOW(fd, 2) )
+ return 0;
+ memset(&skillid2idx, 0, sizeof(skillid2idx));
+ j = RFIFOW(fd, 2) - 4;
+ if( j )
+ j /= 4;
+ for(i = 0; i < j; i++) {
+ if( RFIFOW(fd, 4 + (i*4)) > MAX_SKILL_ID ) {
+ ShowWarning("Error skillid2dx[%d] = %d failed, %d is higher than MAX_SKILL_ID (%d)\n",RFIFOW(fd, 4 + (i*4)), RFIFOW(fd, 6 + (i*4)),RFIFOW(fd, 4 + (i*4)),MAX_SKILL_ID);
+ continue;
+ }
+ skillid2idx[RFIFOW(fd, 4 + (i*4))] = RFIFOW(fd, 6 + (i*4));
+ }
+ RFIFOSKIP(fd, RFIFOW(fd, 2));
+ break;
case 0x2afa: // Receiving map names list from the map-server
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
@@ -4920,8 +4928,8 @@ void do_shutdown(void)
}
-int do_init(int argc, char **argv)
-{
+int do_init(int argc, char **argv) {
+ memset(&skillid2idx, 0, sizeof(skillid2idx));
//Read map indexes
mapindex_init();
start_point.map = mapindex_name2id("new_zone01");