summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/chrif.c18
-rw-r--r--src/map/clif.c193
-rw-r--r--src/map/clif.h13
-rw-r--r--src/map/packets.h3
4 files changed, 72 insertions, 155 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 524286da1..c79cf9e4a 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -1073,9 +1073,9 @@ int chrif_updatefamelist(struct map_session_data* sd) {
chrif_check(-1);
switch(sd->class_ & MAPID_UPPERMASK) {
- case MAPID_BLACKSMITH: type = 1; break;
- case MAPID_ALCHEMIST: type = 2; break;
- case MAPID_TAEKWON: type = 3; break;
+ case MAPID_BLACKSMITH: type = RANKTYPE_BLACKSMITH; break;
+ case MAPID_ALCHEMIST: type = RANKTYPE_ALCHEMIST; break;
+ case MAPID_TAEKWON: type = RANKTYPE_TAEKWON; break;
default:
return 0;
}
@@ -1104,9 +1104,9 @@ int chrif_recvfamelist(int fd) {
int num, size;
int total = 0, len = 8;
- memset (smith_fame_list, 0, sizeof(smith_fame_list));
- memset (chemist_fame_list, 0, sizeof(chemist_fame_list));
- memset (taekwon_fame_list, 0, sizeof(taekwon_fame_list));
+ memset(smith_fame_list, 0, sizeof(smith_fame_list));
+ 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
@@ -1147,9 +1147,9 @@ int chrif_updatefamelist_ack(int fd) {
uint8 index;
switch (RFIFOB(fd,2)) {
- case 1: list = smith_fame_list; break;
- case 2: list = chemist_fame_list; break;
- case 3: list = taekwon_fame_list; break;
+ case RANKTYPE_BLACKSMITH: list = smith_fame_list; break;
+ case RANKTYPE_ALCHEMIST: list = chemist_fame_list; break;
+ case RANKTYPE_TAEKWON: list = taekwon_fame_list; break;
default: return 0;
}
diff --git a/src/map/clif.c b/src/map/clif.c
index 342f1d943..bb012c24d 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -14040,143 +14040,115 @@ void clif_parse_PVPInfo(int fd,struct map_session_data *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){
+void clif_ranklist_sub(unsigned char *buf, enum fame_list_type type) {
const char* name;
struct fame_list* list;
- int i, skip = 0;
+ int i;
- 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;
+ switch( type ) {
+ case RANKTYPE_BLACKSMITH: list = smith_fame_list; break;
+ case RANKTYPE_ALCHEMIST: list = chemist_fame_list; break;
+ case RANKTYPE_TAEKWON: list = taekwon_fame_list; break;
+ default: return; // Unsupported
}
- 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);
- }
+ // 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, 24 * i)), name, NAME_LENGTH);
} else {
- strncpy((char *)(WBUFP(buf, idx + 24 * i)), "None", 5);
+ strncpy((char *)(WBUFP(buf, 24 * i)), list[i].name, NAME_LENGTH);
}
- 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;
+ } else {
+ strncpy((char *)(WBUFP(buf, 24 * i)), "None", 5);
}
+ WBUFL(buf, 24 * 10 + i * 4) = list[i].fame; //points
+ }
+ for( ;i < 10; i++ ) { // In case the MAX is less than 10.
+ strncpy((char *)(WBUFP(buf, 24 * i)), "Unavailable", 12);
+ WBUFL(buf, 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)];
+void clif_ranklist(struct map_session_data *sd, enum fame_list_type type) {
+ int fd = sd->fd;
int mypoint = 0;
int upperMask = sd->class_&MAPID_UPPERMASK;
- WBUFW(buf, 0) = 0x97d;
- WBUFW(buf, 2) = rankingType;
- clif_sub_ranklist(buf, 4, sd, rankingType);
+ WFIFOHEAD(fd, 288);
+ WFIFOW(fd, 0) = 0x97d;
+ WFIFOW(fd, 2) = type;
+ clif_ranklist_sub(WFIFOP(fd,4), type);
-
- if(
- (upperMask == MAPID_BLACKSMITH && rankingType == RANKTYPE_BLACKSMITH) ||
- (upperMask == MAPID_ALCHEMIST && rankingType == RANKTYPE_ALCHEMIST) ||
- (upperMask == MAPID_TAEKWON && rankingType == RANKTYPE_TAEKWON)
+ if( (upperMask == MAPID_BLACKSMITH && type == RANKTYPE_BLACKSMITH)
+ || (upperMask == MAPID_ALCHEMIST && type == RANKTYPE_ALCHEMIST)
+ || (upperMask == MAPID_TAEKWON && type == RANKTYPE_TAEKWON)
) {
mypoint = sd->status.fame;
} else {
mypoint = 0;
}
- WBUFL(buf, 284) = mypoint; //mypoint
- clif_send(buf, 288, &sd->bl, SELF);
+ WFIFOL(fd, 284) = mypoint; //mypoint
+ WFIFOSET(fd, 288);
}
/*
* 097c <type> (CZ_REQ_RANKING)
* */
-void clif_parse_ranklist(int fd,struct map_session_data *sd) {
- int16 rankingtype = RFIFOW(fd, 2);//type
+void clif_parse_ranklist(int fd, struct map_session_data *sd) {
+ int16 type = RFIFOW(fd, 2); //type
- switch(rankingtype) {
+ switch( type ) {
case RANKTYPE_BLACKSMITH:
case RANKTYPE_ALCHEMIST:
case RANKTYPE_TAEKWON:
- clif_ranklist(sd,rankingtype); // pk_list unsuported atm
+ clif->ranklist(sd, type); // 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){
+void clif_update_rankingpoint(struct map_session_data *sd, enum fame_list_type type, int points) {
#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
+ switch( type ) {
+ case RANKTYPE_BLACKSMITH: clif->fame_blacksmith(sd,points); break;
+ case RANKTYPE_ALCHEMIST: clif->fame_alchemist(sd,points); break;
+ case RANKTYPE_TAEKWON: clif->fame_taekwon(sd,points); break;
}
#else
- int fd=sd->fd;
- WFIFOHEAD(fd, 14);
+ int fd = sd->fd;
+ WFIFOHEAD(fd, 12);
WFIFOW(fd, 0) = 0x97e;
- WFIFOW(fd, 2) = rankingtype;
- WFIFOL(fd, 4) = point;
+ WFIFOW(fd, 2) = type;
+ WFIFOL(fd, 4) = points;
WFIFOL(fd, 8) = sd->status.fame;
WFIFOSET(fd, 12);
#endif
}
-
-
/// /blacksmith list (ZC_BLACKSMITH_RANK).
/// 0219 { <name>.24B }*10 { <point>.L }*10
-void clif_blacksmith(struct map_session_data* sd)
-{
- int i, fd = sd->fd;
- const char* name;
+void clif_blacksmith(struct map_session_data* sd) {
+ int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x219));
WFIFOW(fd,0) = 0x219;
- //Packet size limits this list to 10 elements. [Skotlex]
- for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
- if (smith_fame_list[i].id > 0) {
- if (strcmp(smith_fame_list[i].name, "-") == 0 &&
- (name = iMap->charid2nick(smith_fame_list[i].id)) != NULL)
- {
- strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), name, NAME_LENGTH);
- } else
- strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), smith_fame_list[i].name, NAME_LENGTH);
- } else
- strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), "None", 5);
- WFIFOL(fd, 242 + i * 4) = smith_fame_list[i].fame;
- }
- for(;i < 10; i++) { //In case the MAX is less than 10.
- strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), "Unavailable", 12);
- WFIFOL(fd, 242 + i * 4) = 0;
- }
-
+ clif_ranklist_sub(WFIFOP(fd, 2), RANKTYPE_BLACKSMITH);
WFIFOSET(fd, packet_len(0x219));
}
-
/// /blacksmith (CZ_BLACKSMITH_RANK).
/// 0217
-void clif_parse_Blacksmith(int fd,struct map_session_data *sd)
-{
+void clif_parse_Blacksmith(int fd,struct map_session_data *sd) {
clif->blacksmith(sd);
}
-
/// Notification about backsmith points (ZC_BLACKSMITH_POINT).
/// 021b <points>.L <total points>.L
-void clif_fame_blacksmith(struct map_session_data *sd, int points)
-{
+void clif_fame_blacksmith(struct map_session_data *sd, int points) {
int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x21b));
@@ -14186,49 +14158,26 @@ void clif_fame_blacksmith(struct map_session_data *sd, int points)
WFIFOSET(fd, packet_len(0x21b));
}
-
/// /alchemist list (ZC_ALCHEMIST_RANK).
/// 021a { <name>.24B }*10 { <point>.L }*10
void clif_alchemist(struct map_session_data* sd) {
- int i, fd = sd->fd;
- const char* name;
+ int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x21a));
WFIFOW(fd,0) = 0x21a;
- //Packet size limits this list to 10 elements. [Skotlex]
- for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
- if (chemist_fame_list[i].id > 0) {
- if (strcmp(chemist_fame_list[i].name, "-") == 0 &&
- (name = iMap->charid2nick(chemist_fame_list[i].id)) != NULL)
- {
- memcpy(WFIFOP(fd, 2 + 24 * i), name, NAME_LENGTH);
- } else
- memcpy(WFIFOP(fd, 2 + 24 * i), chemist_fame_list[i].name, NAME_LENGTH);
- } else
- memcpy(WFIFOP(fd, 2 + 24 * i), "None", NAME_LENGTH);
- WFIFOL(fd, 242 + i * 4) = chemist_fame_list[i].fame;
- }
- for(;i < 10; i++) { //In case the MAX is less than 10.
- memcpy(WFIFOP(fd, 2 + 24 * i), "Unavailable", NAME_LENGTH);
- WFIFOL(fd, 242 + i * 4) = 0;
- }
-
+ clif_ranklist_sub(WFIFOP(fd,2), RANKTYPE_ALCHEMIST);
WFIFOSET(fd, packet_len(0x21a));
}
-
/// /alchemist (CZ_ALCHEMIST_RANK).
/// 0218
-void clif_parse_Alchemist(int fd,struct map_session_data *sd)
-{
+void clif_parse_Alchemist(int fd,struct map_session_data *sd) {
clif->alchemist(sd);
}
-
/// Notification about alchemist points (ZC_ALCHEMIST_POINT).
/// 021c <points>.L <total points>.L
-void clif_fame_alchemist(struct map_session_data *sd, int points)
-{
+void clif_fame_alchemist(struct map_session_data *sd, int points) {
int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x21c));
@@ -14238,48 +14187,26 @@ void clif_fame_alchemist(struct map_session_data *sd, int points)
WFIFOSET(fd, packet_len(0x21c));
}
-
/// /taekwon list (ZC_TAEKWON_RANK).
/// 0226 { <name>.24B }*10 { <point>.L }*10
void clif_taekwon(struct map_session_data* sd) {
- int i, fd = sd->fd;
- const char* name;
+ int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x226));
WFIFOW(fd,0) = 0x226;
- //Packet size limits this list to 10 elements. [Skotlex]
- for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
- if (taekwon_fame_list[i].id > 0) {
- if (strcmp(taekwon_fame_list[i].name, "-") == 0 &&
- (name = iMap->charid2nick(taekwon_fame_list[i].id)) != NULL)
- {
- memcpy(WFIFOP(fd, 2 + 24 * i), name, NAME_LENGTH);
- } else
- memcpy(WFIFOP(fd, 2 + 24 * i), taekwon_fame_list[i].name, NAME_LENGTH);
- } else
- memcpy(WFIFOP(fd, 2 + 24 * i), "None", NAME_LENGTH);
- WFIFOL(fd, 242 + i * 4) = taekwon_fame_list[i].fame;
- }
- for(;i < 10; i++) { //In case the MAX is less than 10.
- memcpy(WFIFOP(fd, 2 + 24 * i), "Unavailable", NAME_LENGTH);
- WFIFOL(fd, 242 + i * 4) = 0;
- }
+ clif_ranklist_sub(WFIFOP(fd,2), RANKTYPE_TAEKWON);
WFIFOSET(fd, packet_len(0x226));
}
-
/// /taekwon (CZ_TAEKWON_RANK).
/// 0225
-void clif_parse_Taekwon(int fd,struct map_session_data *sd)
-{
+void clif_parse_Taekwon(int fd,struct map_session_data *sd) {
clif->taekwon(sd);
}
-
/// Notification about taekwon points (ZC_TAEKWON_POINT).
/// 0224 <points>.L <total points>.L
-void clif_fame_taekwon(struct map_session_data *sd, int points)
-{
+void clif_fame_taekwon(struct map_session_data *sd, int points) {
int fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x224));
@@ -14289,7 +14216,6 @@ void clif_fame_taekwon(struct map_session_data *sd, int points)
WFIFOSET(fd, packet_len(0x224));
}
-
/// /pk list (ZC_KILLER_RANK).
/// 0238 { <name>.24B }*10 { <point>.L }*10
void clif_ranking_pk(struct map_session_data* sd) {
@@ -14307,8 +14233,7 @@ void clif_ranking_pk(struct map_session_data* sd) {
/// /pk (CZ_KILLER_RANK).
/// 0237
-void clif_parse_RankingPk(int fd,struct map_session_data *sd)
-{
+void clif_parse_RankingPk(int fd,struct map_session_data *sd) {
clif->ranking_pk(sd);
}
@@ -18165,7 +18090,7 @@ void clif_defaults(void) {
clif->fame_alchemist = clif_fame_alchemist;
clif->fame_taekwon = clif_fame_taekwon;
clif->ranklist = clif_ranklist;
- clif->parse_ranklist = clif_parse_ranklist;
+ clif->pRanklist = clif_parse_ranklist;
clif->update_rankingpoint = clif_update_rankingpoint;
clif->hotkeys = clif_hotkeys_send;
clif->insight = clif_insight;
diff --git a/src/map/clif.h b/src/map/clif.h
index b364765e5..4559e4209 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -339,13 +339,6 @@ 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,
@@ -604,9 +597,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 (*ranklist) (struct map_session_data *sd, enum fame_list_type type);
+ void (*update_rankingpoint) (struct map_session_data *sd, enum fame_list_type type, int points);
+ void (*pRanklist) (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 86ae3af30..8fcc6c863 100644
--- a/src/map/packets.h
+++ b/src/map/packets.h
@@ -2366,8 +2366,7 @@ 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
+ packet(0x097C,4,clif->pRanklist);
#endif