summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2016-12-02 20:10:44 +0100
committerHaru <haru@dotalux.com>2016-12-03 15:38:56 +0100
commit0f5fdca8945ec3afd5ba2e67a9d414f1ef5565c3 (patch)
tree5f1bb716cdc3b44f9c2ffd6f909047657f234844 /src/map/pc.c
parent76801cdf48a979728034cb81b81c989f7f655f5a (diff)
downloadhercules-0f5fdca8945ec3afd5ba2e67a9d414f1ef5565c3.tar.gz
hercules-0f5fdca8945ec3afd5ba2e67a9d414f1ef5565c3.tar.bz2
hercules-0f5fdca8945ec3afd5ba2e67a9d414f1ef5565c3.tar.xz
hercules-0f5fdca8945ec3afd5ba2e67a9d414f1ef5565c3.zip
Ensure that pc->addfame() increments the correct fame points
The function now takes the rank type as argument, rather than guessing it from the character's class. If the wrong fame point type for the current character is requested, the request is ignored. This fixes some (unofficial) edge cases where a Taekwon or an Alchemist refined a signed item, they could obtain rank points. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 11bc511b1..531cc555a 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -388,26 +388,43 @@ 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)
+/**
+ * Increases a player's fame points and displays a notice to them.
+ *
+ * If the character's job class doesn't allow the specified rank type, nothing
+ * happens and the request is ignored.
+ *
+ * @param sd The target character.
+ * @param type The fame list type (@see enum fame_list_type).
+ * @param count The amount of points to add.
+ */
+void pc_addfame(struct map_session_data *sd, int ranktype, 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->job & MAPID_UPPERMASK) {
- case MAPID_BLACKSMITH:
- ranktype = RANKTYPE_BLACKSMITH;
+ switch (ranktype) {
+ case RANKTYPE_BLACKSMITH:
+ if ((sd->job & MAPID_UPPERMASK) != MAPID_BLACKSMITH)
+ return;
break;
- case MAPID_ALCHEMIST:
- ranktype = RANKTYPE_ALCHEMIST;
+ case RANKTYPE_ALCHEMIST:
+ if ((sd->job & MAPID_UPPERMASK) != MAPID_ALCHEMIST)
+ return;
break;
- case MAPID_TAEKWON:
- ranktype = RANKTYPE_TAEKWON;
+ case RANKTYPE_TAEKWON:
+ if ((sd->job & MAPID_UPPERMASK) != MAPID_TAEKWON)
+ return;
break;
+ case RANKTYPE_PK:
+ // Not supported
+ FALLTHROUGH
+ default:
+ Assert_retv(0);
}
- Assert_retv(ranktype != -1);
+
+ sd->status.fame += count;
+ if (sd->status.fame > MAX_FAME)
+ sd->status.fame = MAX_FAME;
clif->update_rankingpoint(sd, ranktype, count);
chrif->updatefamelist(sd);