diff options
author | Haru <haru@dotalux.com> | 2013-09-19 17:12:27 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2013-09-19 17:12:27 +0200 |
commit | 556834d0508101b70660c5904b24adacacced3e0 (patch) | |
tree | ab9e552032ae4d9bccd8a2d66b6d0a388015098b /src/char/char.c | |
parent | 257fd1a8f0aa0b26aa8331b390315567344f4e2b (diff) | |
download | hercules-556834d0508101b70660c5904b24adacacced3e0.tar.gz hercules-556834d0508101b70660c5904b24adacacced3e0.tar.bz2 hercules-556834d0508101b70660c5904b24adacacced3e0.tar.xz hercules-556834d0508101b70660c5904b24adacacced3e0.zip |
Cleaned up and de-duplicated ranklist-related code
Follow-up to 6cf032d. Special thanks to Ind.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/char/char.c')
-rw-r--r-- | src/char/char.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/src/char/char.c b/src/char/char.c index 943d1f52e..dc7966e8d 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -136,7 +136,7 @@ int guild_exp_rate = 100; //Custom limits for the fame lists. [Skotlex] int fame_list_size_chemist = MAX_FAME_LIST; -int fame_list_size_smith = MAX_FAME_LIST; +int fame_list_size_smith = MAX_FAME_LIST; int fame_list_size_taekwon = MAX_FAME_LIST; // Char-server-side stored fame lists [DracoRPG] @@ -2517,8 +2517,7 @@ int save_accreg2(unsigned char* buf, int len) return 0; } -void char_read_fame_list(void) -{ +void char_read_fame_list(void) { int i; char* data; size_t len; @@ -2576,8 +2575,7 @@ void char_read_fame_list(void) } // Send map-servers the fame ranking lists -int char_send_fame_list(int fd) -{ +int char_send_fame_list(int fd) { int i, len = 8; unsigned char buf[32000]; @@ -2612,8 +2610,7 @@ int char_send_fame_list(int fd) return 0; } -void char_update_fame_list(int type, int index, int fame) -{ +void char_update_fame_list(int type, int index, int fame) { unsigned char buf[8]; WBUFW(buf,0) = 0x2b22; WBUFB(buf,2) = type; @@ -3210,12 +3207,11 @@ int parse_frommap(int fd) int player_pos; int fame_pos; - switch(type) - { - case 1: size = fame_list_size_smith; list = smith_fame_list; break; - case 2: size = fame_list_size_chemist; list = chemist_fame_list; break; - case 3: size = fame_list_size_taekwon; list = taekwon_fame_list; break; - default: size = 0; list = NULL; break; + switch(type) { + case RANKTYPE_BLACKSMITH: size = fame_list_size_smith; list = smith_fame_list; break; + case RANKTYPE_ALCHEMIST: size = fame_list_size_chemist; list = chemist_fame_list; break; + case RANKTYPE_TAEKWON: size = fame_list_size_taekwon; list = taekwon_fame_list; break; + default: size = 0; list = NULL; break; } ARR_FIND(0, size, player_pos, list[player_pos].id == cid);// position of the player @@ -3223,22 +3219,20 @@ int parse_frommap(int fd) if( player_pos == size && fame_pos == size ) ;// not on list and not enough fame to get on it - else if( fame_pos == player_pos ) - {// same position + else if( fame_pos == player_pos ) { + // same position list[player_pos].fame = fame; char_update_fame_list(type, player_pos, fame); - } - else - {// move in the list - if( player_pos == size ) - {// new ranker - not in the list + } else { + // move in the list + if( player_pos == size ) { + // new ranker - not in the list ARR_MOVE(size - 1, fame_pos, list, struct fame_list); list[fame_pos].id = cid; list[fame_pos].fame = fame; char_loadName(cid, list[fame_pos].name); - } - else - {// already in the list + } else { + // already in the list if( fame_pos == size ) --fame_pos;// move to the end of the list ARR_MOVE(player_pos, fame_pos, list, struct fame_list); |