summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/mmo.h1
-rw-r--r--src/map/chrif.c20
-rw-r--r--src/map/clif.c13
-rw-r--r--src/map/pc.c34
-rw-r--r--src/map/pc.h1
5 files changed, 38 insertions, 31 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 6b886aa41..9c29b8a0e 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -779,6 +779,7 @@ struct fame_list {
};
enum fame_list_type {
+ RANKTYPE_UNKNOWN = -1,
RANKTYPE_BLACKSMITH = 0,
RANKTYPE_ALCHEMIST = 1,
RANKTYPE_TAEKWON = 2,
diff --git a/src/map/chrif.c b/src/map/chrif.c
index e298a7fbc..bf613b029 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -1059,25 +1059,17 @@ int chrif_disconnectplayer(int fd) {
/*==========================================
* Request/Receive top 10 Fame character list
*------------------------------------------*/
-int chrif_updatefamelist(struct map_session_data* sd) {
- char type;
+int chrif_updatefamelist(struct map_session_data *sd)
+{
+ int type;
nullpo_retr(0, sd);
chrif_check(-1);
- switch (sd->job & MAPID_UPPERMASK) {
- case MAPID_BLACKSMITH:
- type = RANKTYPE_BLACKSMITH;
- break;
- case MAPID_ALCHEMIST:
- type = RANKTYPE_ALCHEMIST;
- break;
- case MAPID_TAEKWON:
- type = RANKTYPE_TAEKWON;
- break;
- default:
+ type = pc->famelist_type(sd->job);
+
+ if (type == RANKTYPE_UNKNOWN)
return 0;
- }
WFIFOHEAD(chrif->fd, 11);
WFIFOW(chrif->fd,0) = 0x2b10;
diff --git a/src/map/clif.c b/src/map/clif.c
index 0b8f6c2ee..262ea1c57 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -14220,28 +14220,21 @@ void clif_ranklist(struct map_session_data *sd, enum fame_list_type type)
{
#if PACKETVER >= 20120502
int fd;
- int mypoint = 0;
- int upperMask;
int len = packet_len(0x97d);
nullpo_retv(sd);
fd = sd->fd;
- upperMask = sd->job & MAPID_UPPERMASK;
WFIFOHEAD(fd, len);
WFIFOW(fd, 0) = 0x97d;
WFIFOW(fd, 2) = type;
clif_ranklist_sub(WFIFOP(fd,4), type);
- if( (upperMask == MAPID_BLACKSMITH && type == RANKTYPE_BLACKSMITH)
- || (upperMask == MAPID_ALCHEMIST && type == RANKTYPE_ALCHEMIST)
- || (upperMask == MAPID_TAEKWON && type == RANKTYPE_TAEKWON)
- ) {
- mypoint = sd->status.fame;
+ if (pc->famelist_type(sd->job) == type) {
+ WFIFOL(fd, 284) = sd->status.fame; //mypoint
} else {
- mypoint = 0;
+ WFIFOL(fd, 284) = 0; //mypoint
}
- WFIFOL(fd, 284) = mypoint; //mypoint
WFIFOSET(fd, len);
#endif
}
diff --git a/src/map/pc.c b/src/map/pc.c
index 894880608..8d6910ce4 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -470,6 +470,26 @@ int pc_fame_rank(int char_id, int ranktype)
return 0;
}
+/**
+ * Returns the appropriate fame list type for the given job.
+ *
+ * @param job_mapid The job (in MapID format)
+ * @return the appropriate fame list type (@see enum fame_list_type).
+ * @retval RANKTYPE_UNKNOWN if no appropriate type exists.
+ */
+int pc_famelist_type(uint16 job_mapid) {
+ switch (job_mapid & MAPID_UPPERMASK) {
+ case MAPID_BLACKSMITH:
+ return RANKTYPE_BLACKSMITH;
+ case MAPID_ALCHEMIST:
+ return RANKTYPE_ALCHEMIST;
+ case MAPID_TAEKWON:
+ return RANKTYPE_TAEKWON;
+ default:
+ return RANKTYPE_UNKNOWN;
+ }
+}
+
int pc_setrestartvalue(struct map_session_data *sd,int type) {
struct status_data *st, *bst;
nullpo_ret(sd);
@@ -8624,12 +8644,11 @@ int pc_jobchange(struct map_session_data *sd, int class, int upper)
}
sd->status.class = class;
- if ((sd->job & MAPID_UPPERMASK) == MAPID_BLACKSMITH)
- fame_flag = pc->fame_rank(sd->status.char_id, RANKTYPE_BLACKSMITH);
- else if ((sd->job & MAPID_UPPERMASK) == MAPID_ALCHEMIST)
- fame_flag = pc->fame_rank(sd->status.char_id, RANKTYPE_ALCHEMIST);
- else if ((sd->job & MAPID_UPPERMASK) == MAPID_TAEKWON)
- fame_flag = pc->fame_rank(sd->status.char_id, RANKTYPE_TAEKWON);
+ {
+ int fame_list_type = pc->famelist_type(sd->job);
+ if (fame_list_type != RANKTYPE_UNKNOWN)
+ fame_flag = pc->fame_rank(sd->status.char_id, fame_list_type);
+ }
sd->job = (uint16)job;
sd->status.job_level=1;
sd->status.job_exp=0;
@@ -8715,7 +8734,7 @@ int pc_jobchange(struct map_session_data *sd, int class, int upper)
pc->equiplookall(sd);
//if you were previously famous, not anymore.
- if (fame_flag) {
+ if (fame_flag != 0) {
chrif->save(sd,0);
chrif->buildfamelist();
} else if (sd->status.fame > 0) {
@@ -12131,6 +12150,7 @@ void pc_defaults(void) {
pc->delspiritball = pc_delspiritball;
pc->addfame = pc_addfame;
pc->fame_rank = pc_fame_rank;
+ pc->famelist_type = pc_famelist_type;
pc->set_hate_mob = pc_set_hate_mob;
pc->getmaxspiritball = pc_getmaxspiritball;
diff --git a/src/map/pc.h b/src/map/pc.h
index 5c9bec9f6..0e4f1affd 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -1005,6 +1005,7 @@ END_ZEROED_BLOCK; /* End */
int (*getmaxspiritball) (struct map_session_data *sd, int min);
void (*addfame) (struct map_session_data *sd, int ranktype, int count);
int (*fame_rank) (int char_id, int ranktype);
+ int (*famelist_type) (uint16 job_mapid);
int (*set_hate_mob) (struct map_session_data *sd, int pos, struct block_list *bl);
int (*readdb) (void);