From ffcda2f3b7f7675dfe22ffccddbb3411f40ae514 Mon Sep 17 00:00:00 2001 From: DracoRPG Date: Fri, 26 May 2006 01:35:17 +0000 Subject: I'm still here! Rewrote fame ranking lists git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6764 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/chrif.c | 57 ++++++++++++++++++++++++++++++++++++++------------ src/map/chrif.h | 3 ++- src/map/pc.c | 63 ++++++++++++++++++++++++++++---------------------------- src/map/pc.h | 2 +- src/map/skill.c | 4 ++-- src/map/status.c | 6 +++--- 6 files changed, 83 insertions(+), 52 deletions(-) (limited to 'src/map') diff --git a/src/map/chrif.c b/src/map/chrif.c index 9a3f8deee..a5f48dbb8 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -73,18 +73,18 @@ static const int packet_len_table[0x3d] = { //2b0d: Incomming, chrif_changedsex -> 'Change sex of acc XY' //2b0e: Outgoing, chrif_char_ask_name -> 'Do some operations (change sex, ban / unban etc)' //2b0f: Incomming, chrif_char_ask_name_answer -> 'answer of the 2b0e' -//2b10: FREE +//2b10: Outgoing, chrif_updatefamelist -> 'Update the fame ranking lists and send them' //2b11: Outgoing, chrif_changesex -> 'change sex of acc X' //2b12: Incomming, chrif_divorce -> 'divorce a wedding of charid X and partner id X' //2b13: Incomming, chrif_accountdeletion -> 'Delete acc XX, if the player is on, kick ....' //2b14: Incomming, chrif_accountban -> 'not sure: kick the player with message XY' -//2b15: Incomming, chrif_recvgmaccounts -> 'recive gm accs from charserver (seems to be incomplete !)' +//2b15: Incomming, chrif_recvgmaccounts -> 'recieve gm accs from charserver (seems to be incomplete !)' //2b16: Outgoing, chrif_ragsrvinfo -> 'sends motd / rates ....' //2b17: Outgoing, chrif_char_offline -> 'tell the charserver that the char is now offline' //2b18: Outgoing, chrif_char_reset_offline -> 'set all players OFF!' //2b19: Outgoing, chrif_char_online -> 'tell the charserver that the char .. is online' -//2b1a: Outgoing, chrif_reqfamelist -> 'Request the fame list (top10)' -//2b1b: Incomming, chrif_recvfamelist -> 'answer of 2b1a ..... the famelist top10^^' +//2b1a: Outgoing, chrif_buildfamelist -> 'Build the fame ranking lists and send them' +//2b1b: Incomming, chrif_recvfamelist -> 'Receive fame ranking lists' //2b1c: Outgoing, chrif_save_scdata -> 'Send sc_data of player for saving.' //2b1d: Incomming, chrif_load_scdata -> 'received sc_data of player for loading.' //2b1e: FREE @@ -1107,19 +1107,50 @@ int chrif_recvgmaccounts(int fd) * Request/Receive top 10 Fame character list *------------------------------------------ */ -int chrif_reqfamelist(void) + +int chrif_updatefamelist(struct map_session_data *sd) { + char type; chrif_check(-1); - WFIFOHEAD(char_fd, 2); - WFIFOW(char_fd,0) = 0x2b1a; + switch(sd->class_&MAPID_UPPERMASK) { + case MAPID_BLACKSMITH: + type = 1; + break; + case MAPID_ALCHEMIST: + type = 2; + break; + case MAPID_TAEKWON: + type = 3; + break; + default: + return 0; + } + + WFIFOHEAD(char_fd, 12); + WFIFOW(char_fd, 0) = 0x2b10; + WFIFOL(char_fd, 2) = sd->char_id; + WFIFOL(char_fd, 6) = sd->status.fame; + WFIFOB(char_fd, 10) = type; + WFIFOB(char_fd, 11) = pc_famerank(sd->char_id, sd->class_&MAPID_UPPERMASK); + WFIFOSET(char_fd, 12); + + return 0; +} + +int chrif_buildfamelist(void) +{ + chrif_check(-1); + + WFIFOHEAD(char_fd, 2); + WFIFOW(char_fd, 0) = 0x2b1a; WFIFOSET(char_fd, 2); return 0; } int chrif_recvfamelist(int fd) -{ // response from 0x2b1b +{ int num, size; int total = 0, len = 8; RFIFOHEAD(fd); @@ -1128,21 +1159,21 @@ int chrif_recvfamelist(int fd) memset (chemist_fame_list, 0, sizeof(chemist_fame_list)); memset (taekwon_fame_list, 0, sizeof(taekwon_fame_list)); - size = RFIFOW(fd,6); //Blacksmith block size + size = RFIFOW(fd, 6); //Blacksmith block size for (num = 0; len < size && num < MAX_FAME_LIST; num++) { memcpy(&smith_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list)); len += sizeof(struct fame_list); } total += num; - size = RFIFOW(fd,4); //Alchemist block size + size = RFIFOW(fd, 4); //Alchemist block size for (num = 0; len < size && num < MAX_FAME_LIST; num++) { memcpy(&chemist_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list)); len += sizeof(struct fame_list); } total += num; - size = RFIFOW(fd,2); //Total packet length + size = RFIFOW(fd, 2); //Total packet length for (num = 0; len < size && num < MAX_FAME_LIST; num++) { memcpy(&taekwon_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list)); len += sizeof(struct fame_list); @@ -1254,7 +1285,7 @@ int chrif_load_scdata(int fd) chrif_check(-1); - WFIFOHEAD(char_fd, sizeof(buf) + 10); + WFIFOHEAD(char_fd, sizeof(buf) + 10); WFIFOW(char_fd,0) = 0x2b16; WFIFOW(char_fd,2) = base_rate; WFIFOW(char_fd,4) = job_rate; @@ -1426,7 +1457,7 @@ int chrif_parse(int fd) switch(cmd) { case 0x2af9: chrif_connectack(fd); break; - case 0x2afb: chrif_sendmapack(fd); chrif_reqfamelist(); break; + case 0x2afb: chrif_sendmapack(fd); chrif_buildfamelist(); break; case 0x2afd: chrif_authok(fd); break; case 0x2b00: map_setusers(fd); break; case 0x2b03: clif_charselectok(RFIFOL(fd,2)); break; diff --git a/src/map/chrif.h b/src/map/chrif.h index c5d3950e3..d6b9d2b6a 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -34,7 +34,8 @@ int chrif_changegm(int id,const char *pass,int len); int chrif_changeemail(int id, const char *actual_email, const char *new_email); int chrif_char_ask_name(int id, char * character_name, short operation_type, int year, int month, int day, int hour, int minute, int second); int chrif_reloadGMdb(void); -int chrif_reqfamelist(void); +int chrif_updatefamelist(struct map_session_data *sd); +int chrif_buildfamelist(void); int chrif_save_scdata(struct map_session_data *sd); int chrif_ragsrvinfo(int base_rate,int job_rate, int drop_rate); int chrif_char_offline(struct map_session_data *sd); diff --git a/src/map/pc.c b/src/map/pc.c index 80d269a6b..2cce8cfa6 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -242,7 +242,7 @@ int pc_delspiritball(struct map_session_data *sd,int count,int type) { return 0; } -// Increases a player's and displays a notice to him +// Increases a player's fame points and displays a notice to him void pc_addfame(struct map_session_data *sd,int count) { nullpo_retv(sd); sd->status.fame += count; @@ -251,41 +251,40 @@ void pc_addfame(struct map_session_data *sd,int count) { switch(sd->class_&MAPID_UPPERMASK){ case MAPID_BLACKSMITH: // Blacksmith clif_fame_blacksmith(sd,count); - break; + break; case MAPID_ALCHEMIST: // Alchemist clif_fame_alchemist(sd,count); - break; + break; case MAPID_TAEKWON: // Taekwon clif_fame_taekwon(sd,count); - break; + break; } - //FIXME: Is this needed? It places unnecessary stress on the char server.... >.< [Skotlex] - chrif_save(sd,0); // Save to allow up-to-date fame list refresh - chrif_reqfamelist(); // Refresh the fame list + chrif_updatefamelist(sd); } -// Check whether a player ID is in the Top 10 fame list of its job -int pc_istop10fame(int char_id,int job) { +// Check whether a player ID is in the fame rankers' list of its job, returns his/her position if so, 0 else +unsigned char pc_famerank(int char_id,int job) { int i; + switch(job){ - case MAPID_BLACKSMITH: // Blacksmith - for(i=0;iclass_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc_istop10fame(sd->char_id, MAPID_TAEKWON)) { + if ((sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc_famerank(sd->char_id, MAPID_TAEKWON)) { //Grant all Taekwon Tree, but only as bonus skills in case they drop from ranking. [Skotlex] for(i=0;i < MAX_SKILL_TREE && (id=skill_tree[c][i].id)>0;i++){ if ((skill_get_inf2(id)&(INF2_QUEST_SKILL|INF2_WEDDING_SKILL))) @@ -2701,7 +2700,7 @@ int pc_useitem(struct map_session_data *sd,int n) pc_delitem(sd,n,1,1); } if(sd->status.inventory[n].card[0]==0x00fe && - pc_istop10fame(MakeDWord(sd->status.inventory[n].card[2],sd->status.inventory[n].card[3]), MAPID_ALCHEMIST)) + pc_famerank(MakeDWord(sd->status.inventory[n].card[2],sd->status.inventory[n].card[3]), MAPID_ALCHEMIST)) { potion_flag = 2; // Famous player's potions have 50% more efficiency if (sd->sc.data[SC_SPIRIT].timer != -1 && sd->sc.data[SC_SPIRIT].val2 == SL_ROGUE) @@ -5271,7 +5270,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) sd->status.class_ = job; status_set_viewdata(&sd->bl, job); - fame_flag = pc_istop10fame(sd->status.char_id,sd->class_&MAPID_UPPERMASK); + fame_flag = pc_famerank(sd->status.char_id,sd->class_&MAPID_UPPERMASK); sd->class_ = (unsigned short)b_class; sd->status.job_level=1; sd->status.job_exp=0; @@ -5305,7 +5304,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) //if you were previously famous, not anymore. if (fame_flag) { chrif_save(sd,0); - chrif_reqfamelist(); + chrif_buildfamelist(); } else if (sd->status.fame > 0) { //It may be that now they are famous? switch (sd->class_&MAPID_UPPERMASK) { @@ -5313,7 +5312,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) case MAPID_ALCHEMIST: case MAPID_TAEKWON: chrif_save(sd,0); - chrif_reqfamelist(); + chrif_buildfamelist(); break; } } diff --git a/src/map/pc.h b/src/map/pc.h index 6cf8ca0b2..ae3b2480f 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -234,7 +234,7 @@ int pc_delinvincibletimer(struct map_session_data *sd); int pc_addspiritball(struct map_session_data *sd,int,int); int pc_delspiritball(struct map_session_data *sd,int,int); void pc_addfame(struct map_session_data *sd,int count); -int pc_istop10fame(int char_id, int job); +unsigned char pc_famerank(int char_id, int job); int pc_eventtimer(int tid,unsigned int tick,int id,int data); // for npc_dequeue extern struct fame_list smith_fame_list[MAX_FAME_LIST]; diff --git a/src/map/skill.c b/src/map/skill.c index 689844657..70719a360 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1825,7 +1825,7 @@ int skill_attack( int attack_type, struct block_list* src, struct block_list *ds //set this skill as previous one. sd->skillid_old = skillid; sd->skilllv_old = skilllv; - if (pc_istop10fame(sd->char_id,MAPID_TAEKWON)) + if (pc_famerank(sd->char_id,MAPID_TAEKWON)) break; //Do not end combo state. default: status_change_end(src,SC_COMBO,-1); @@ -7784,7 +7784,7 @@ int skill_check_condition(struct map_session_data *sd,int skill, int lv, int typ case TK_COUNTER: if(sd->sc.data[SC_COMBO].timer == -1) return 0; //Combo needs to be ready - if (pc_istop10fame(sd->char_id,MAPID_TAEKWON)) + if (pc_famerank(sd->char_id,MAPID_TAEKWON)) { //Unlimited Combo if (skill == sd->skillid_old) { status_change_end(&sd->bl, SC_COMBO, -1); diff --git a/src/map/status.c b/src/map/status.c index 20bd840a7..b8b38b5d9 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -919,7 +919,7 @@ int status_calc_pc(struct map_session_data* sd,int first) { // Forged weapon wd->star += (sd->status.inventory[index].card[1]>>8); if(wd->star >= 15) wd->star = 40; // 3 Star Crumbs now give +40 dmg - if(pc_istop10fame( MakeDWord(sd->status.inventory[index].card[2],sd->status.inventory[index].card[3]) ,MAPID_BLACKSMITH)) + if(pc_famerank( MakeDWord(sd->status.inventory[index].card[2],sd->status.inventory[index].card[3]) ,MAPID_BLACKSMITH)) wd->star += 10; if (!wd->atk_ele) //Do not overwrite element from previous bonuses. @@ -1420,7 +1420,7 @@ int status_calc_pc(struct map_session_data* sd,int first) index += index * 30/100; else if (sd->class_&JOBL_BABY) index -= index * 30/100; - if ((sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc_istop10fame(sd->char_id, MAPID_TAEKWON)) + if ((sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc_famerank(sd->char_id, MAPID_TAEKWON)) index *= 3; //Triple max HP for top ranking Taekwons over level 90. sd->status.max_hp += index; @@ -1482,7 +1482,7 @@ int status_calc_pc(struct map_session_data* sd,int first) index += index * 30/100; else if (sd->class_&JOBL_BABY) index -= index * 30/100; - if ((sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc_istop10fame(sd->char_id, MAPID_TAEKWON)) + if ((sd->class_&MAPID_UPPERMASK) == MAPID_TAEKWON && sd->status.base_level >= 90 && pc_famerank(sd->char_id, MAPID_TAEKWON)) index *= 3; //Triple max SP for top ranking Taekwons over level 90. sd->status.max_sp += index; -- cgit v1.2.3-70-g09d2