summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/clif.c99
-rw-r--r--src/map/clif.h10
-rw-r--r--src/map/packets.h3
-rw-r--r--src/map/pc.c14
4 files changed, 117 insertions, 9 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 8f82141b2..d26f11ba3 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -14037,6 +14037,102 @@ void clif_parse_PVPInfo(int fd,struct map_session_data *sd)
clif->PVPInfo(sd);
}
+/// Ranking list
+
+/// ranking pointlist { <name>.24B <point>.L }*10
+void clif_sub_ranklist(unsigned char *buf,int idx,struct map_session_data* sd, int16 rankingtype){
+ const char* name;
+ struct fame_list* list;
+ int i, skip = 0;
+
+ switch(rankingtype+1) { //to keep the same case as char.c
+ case 1: list = smith_fame_list; break;
+ case 2: list = chemist_fame_list; break;
+ case 3: list = taekwon_fame_list; break;
+ default: skip=1; break;
+ }
+
+ if(!skip) {
+ //Packet size limits this list to 10 elements. [Skotlex]
+ for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
+ if (list[i].id > 0) {
+ if (strcmp(list[i].name, "-") == 0 && (name = iMap->charid2nick(list[i].id)) != NULL) {
+ strncpy((char *)(WBUFP(buf,idx + 24 * i)), name, NAME_LENGTH);
+ } else {
+ strncpy((char *)(WBUFP(buf,idx + 24 * i)), list[i].name, NAME_LENGTH);
+ }
+ } else {
+ strncpy((char *)(WBUFP(buf, idx + 24 * i)), "None", 5);
+ }
+ WBUFL(buf, idx + 24 * 10 + i * 4) = list[i].fame; //points
+ }
+ for(;i < 10; i++) { //In case the MAX is less than 10.
+ strncpy((char *)(WBUFP(buf, idx + 24 * i)), "Unavailable", 12);
+ WBUFL(buf, idx + 24 * 10 + i * 4) = 0;
+ }
+ }
+}
+
+/// 097d <RankingType>.W {<CharName>.24B <point>L}*10 <mypoint>L (ZC_ACK_RANKING)
+void clif_ranklist(struct map_session_data *sd, int16 rankingType){
+ unsigned char buf[MAX_FAME_LIST * sizeof(struct fame_list)];
+ int mypoint = 0;
+ int upperMask = sd->class_&MAPID_UPPERMASK;
+
+ WBUFW(buf, 0) = 0x97d;
+ WBUFW(buf, 2) = rankingType;
+ clif_sub_ranklist(buf, 4, sd, rankingType);
+
+
+ if(
+ (upperMask == MAPID_BLACKSMITH && rankingType == RANKTYPE_BLACKSMITH) ||
+ (upperMask == MAPID_ALCHEMIST && rankingType == RANKTYPE_ALCHEMIST) ||
+ (upperMask == MAPID_TAEKWON && rankingType == RANKTYPE_TAEKWON)
+ ) {
+ mypoint = sd->status.fame;
+ } else {
+ mypoint = 0;
+ }
+
+ WBUFL(buf, 284) = mypoint; //mypoint
+ clif_send(buf, 288, &sd->bl, SELF);
+}
+
+/*
+ * 097c <type> (CZ_REQ_RANKING)
+ * */
+void clif_parse_ranklist(int fd,struct map_session_data *sd) {
+ int16 rankingtype = RFIFOW(fd, 2);//type
+
+ switch(rankingtype) {
+ case RANKTYPE_BLACKSMITH:
+ case RANKTYPE_ALCHEMIST:
+ case RANKTYPE_TAEKWON:
+ clif_ranklist(sd,rankingtype); // pk_list unsuported atm
+ break;
+ }
+}
+
+// 097e <RankingType>.W <point>.L <TotalPoint>.L (ZC_UPDATE_RANKING_POINT)
+void clif_update_rankingpoint(struct map_session_data *sd, int16 rankingtype, int point){
+#if PACKETVER < 20130710
+ switch(rankingtype){
+ case RANKTYPE_BLACKSMITH: clif->fame_blacksmith(sd,point); break; // Blacksmith
+ case RANKTYPE_ALCHEMIST: clif->fame_alchemist(sd,point); break; //Alchemist
+ case RANKTYPE_TAEKWON: clif->fame_taekwon(sd,point); break; // Taekwon
+ }
+#else
+ int fd=sd->fd;
+ WFIFOHEAD(fd, 14);
+ WFIFOW(fd, 0) = 0x97e;
+ WFIFOW(fd, 2) = rankingtype;
+ WFIFOL(fd, 4) = point;
+ WFIFOL(fd, 8) = sd->status.fame;
+ WFIFOSET(fd, 12);
+#endif
+}
+
+
/// /blacksmith list (ZC_BLACKSMITH_RANK).
/// 0219 { <name>.24B }*10 { <point>.L }*10
@@ -18068,6 +18164,9 @@ void clif_defaults(void) {
clif->fame_blacksmith = clif_fame_blacksmith;
clif->fame_alchemist = clif_fame_alchemist;
clif->fame_taekwon = clif_fame_taekwon;
+ clif->ranklist = clif_ranklist;
+ clif->parse_ranklist = clif_parse_ranklist;
+ clif->update_rankingpoint = clif_update_rankingpoint;
clif->hotkeys = clif_hotkeys_send;
clif->insight = clif_insight;
clif->outsight = clif_outsight;
diff --git a/src/map/clif.h b/src/map/clif.h
index 73d3611a2..3a42b54da 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -339,6 +339,13 @@ typedef enum useskill_fail_cause { // clif_skill_fail
USESKILL_FAIL_THERE_ARE_NPC_AROUND = 83,
}useskill_fail_cause;
+enum rank_type {
+ RANKTYPE_BLACKSMITH = 0,
+ RANKTYPE_ALCHEMIST = 1,
+ RANKTYPE_TAEKWON = 2,
+ RANKTYPE_PK = 3 //Not supported yet
+};
+
enum clif_messages {
SKILL_CANT_USE_AREA = 0x536,
ITEM_CANT_USE_AREA = 0x537,
@@ -597,6 +604,9 @@ struct clif_interface {
void (*fame_blacksmith) (struct map_session_data *sd, int points);
void (*fame_alchemist) (struct map_session_data *sd, int points);
void (*fame_taekwon) (struct map_session_data *sd, int points);
+ void (*ranklist) (struct map_session_data *sd, int16 rankingType);
+ void (*update_rankingpoint) (struct map_session_data *sd, int16 rankingtype, int point);
+ void (*parse_ranklist) (int fd,struct map_session_data *sd);
void (*hotkeys) (struct map_session_data *sd);
int (*insight) (struct block_list *bl,va_list ap);
int (*outsight) (struct block_list *bl,va_list ap);
diff --git a/src/map/packets.h b/src/map/packets.h
index 091c48a77..86ae3af30 100644
--- a/src/map/packets.h
+++ b/src/map/packets.h
@@ -2366,8 +2366,11 @@ packet(0x020d,-1);
packet(0x0360,26,clif->pFriendsListAdd,2);
packet(0x094A,5,clif->pHomMenu,2,4);
packet(0x0873,36,clif->pStoragePassword,0);
+ packet(0x097c,4, clif->parse_ranklist);
+ packet(0x97D,288, clif->update_rankingpoint); //ZC_ACK_RANKING
#endif
+
/* PacketKeys: http://hercules.ws/board/topic/1105-hercules-wpe-free-june-14th-patch/ */
#if PACKETVER >= 20110817
packetKeys(0x053D5CED,0x3DED6DED,0x6DED6DED); /* Thanks to Shakto */
diff --git a/src/map/pc.c b/src/map/pc.c
index 421099ce1..d2740c76a 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -400,21 +400,17 @@ int pc_banding(struct map_session_data *sd, uint16 skill_lv) {
// Increases a player's fame points and displays a notice to him
void pc_addfame(struct map_session_data *sd,int count)
{
+ int ranktype = -1;
nullpo_retv(sd);
sd->status.fame += count;
if(sd->status.fame > MAX_FAME)
sd->status.fame = MAX_FAME;
switch(sd->class_&MAPID_UPPERMASK){
- case MAPID_BLACKSMITH: // Blacksmith
- clif->fame_blacksmith(sd,count);
- break;
- case MAPID_ALCHEMIST: // Alchemist
- clif->fame_alchemist(sd,count);
- break;
- case MAPID_TAEKWON: // Taekwon
- clif->fame_taekwon(sd,count);
- break;
+ case MAPID_BLACKSMITH: ranktype = RANKTYPE_BLACKSMITH; break;
+ case MAPID_ALCHEMIST: ranktype = RANKTYPE_ALCHEMIST; break;
+ case MAPID_TAEKWON: ranktype = RANKTYPE_TAEKWON; break;
}
+ clif->update_rankingpoint(sd, ranktype, count);
chrif->updatefamelist(sd);
}