summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/map/mob.c2
-rw-r--r--src/map/pc.c43
-rw-r--r--src/map/pc.h2
-rw-r--r--src/map/script.c18
-rw-r--r--src/map/skill.c29
5 files changed, 56 insertions, 38 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index 9bfa81857..c3fdbead2 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -2635,7 +2635,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) {
if( sd ) {
if( sd->mission_mobid == md->class_) { //TK_MISSION [Skotlex]
if (++sd->mission_count >= 100 && (temp = mob->get_random_id(0, 0xE, sd->status.base_level)) != 0) {
- pc->addfame(sd, 1);
+ pc->addfame(sd, RANKTYPE_TAEKWON, 1);
sd->mission_mobid = temp;
pc_setglobalreg(sd,script->add_str("TK_MISSION_ID"), temp);
sd->mission_count = 0;
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);
diff --git a/src/map/pc.h b/src/map/pc.h
index 5b0cc4cba..f73a015ca 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -1003,7 +1003,7 @@ END_ZEROED_BLOCK; /* End */
int (*addspiritball) (struct map_session_data *sd,int interval,int max);
int (*delspiritball) (struct map_session_data *sd,int count,int type);
int (*getmaxspiritball) (struct map_session_data *sd, int min);
- void (*addfame) (struct map_session_data *sd,int count);
+ void (*addfame) (struct map_session_data *sd, int ranktype, int count);
int (*famerank) (int char_id, uint32 job);
int (*set_hate_mob) (struct map_session_data *sd, int pos, struct block_list *bl);
diff --git a/src/map/script.c b/src/map/script.c
index f876f1072..27db206cf 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -9168,15 +9168,15 @@ BUILDIN(successrefitem)
sd->status.char_id == (int)MakeDWord(sd->status.inventory[i].card[2],sd->status.inventory[i].card[3])
) { // Fame point system [DracoRPG]
switch (sd->inventory_data[i]->wlv) {
- case 1:
- pc->addfame(sd,1); // Success to refine to +10 a lv1 weapon you forged = +1 fame point
- break;
- case 2:
- pc->addfame(sd,25); // Success to refine to +10 a lv2 weapon you forged = +25 fame point
- break;
- case 3:
- pc->addfame(sd,1000); // Success to refine to +10 a lv3 weapon you forged = +1000 fame point
- break;
+ case 1:
+ pc->addfame(sd, RANKTYPE_BLACKSMITH, 1); // Success to refine to +10 a lv1 weapon you forged = +1 fame point
+ break;
+ case 2:
+ pc->addfame(sd, RANKTYPE_BLACKSMITH, 25); // Success to refine to +10 a lv2 weapon you forged = +25 fame point
+ break;
+ case 3:
+ pc->addfame(sd, RANKTYPE_BLACKSMITH, 1000); // Success to refine to +10 a lv3 weapon you forged = +1000 fame point
+ break;
}
}
}
diff --git a/src/map/skill.c b/src/map/skill.c
index dce372b6a..41135920f 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -15674,16 +15674,16 @@ void skill_weaponrefine (struct map_session_data *sd, int idx)
item->card[0] == CARD0_FORGE &&
(int)MakeDWord(item->card[2],item->card[3]) == sd->status.char_id)
{ // Fame point system [DracoRPG]
- switch(ditem->wlv){
- case 1:
- pc->addfame(sd,1); // Success to refine to +10 a lv1 weapon you forged = +1 fame point
- break;
- case 2:
- pc->addfame(sd,25); // Success to refine to +10 a lv2 weapon you forged = +25 fame point
- break;
- case 3:
- pc->addfame(sd,1000); // Success to refine to +10 a lv3 weapon you forged = +1000 fame point
- break;
+ switch (ditem->wlv) {
+ case 1:
+ pc->addfame(sd, RANKTYPE_BLACKSMITH, 1); // Success to refine to +10 a lv1 weapon you forged = +1 fame point
+ break;
+ case 2:
+ pc->addfame(sd, RANKTYPE_BLACKSMITH, 25); // Success to refine to +10 a lv2 weapon you forged = +25 fame point
+ break;
+ case 3:
+ pc->addfame(sd, RANKTYPE_BLACKSMITH, 1000); // Success to refine to +10 a lv3 weapon you forged = +1000 fame point
+ break;
}
}
} else {
@@ -17855,8 +17855,8 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
if(equip){
clif->produce_effect(sd,0,nameid);
clif->misceffect(&sd->bl,3);
- if(itemdb_wlv(nameid) >= 3 && ((ele? 1 : 0) + sc) >= 3) // Fame point system [DracoRPG]
- pc->addfame(sd,10); // Success to forge a lv3 weapon with 3 additional ingredients = +10 fame point
+ if (itemdb_wlv(nameid) >= 3 && ((ele? 1 : 0) + sc) >= 3) // Fame point system [DracoRPG]
+ pc->addfame(sd, RANKTYPE_BLACKSMITH, 10); // Success to forge a lv3 weapon with 3 additional ingredients = +10 fame point
} else {
int fame = 0;
tmp_item.amount = 0;
@@ -17896,8 +17896,9 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid,
sd->potion_success_counter = 0;
}
- if (fame)
- pc->addfame(sd,fame);
+ if (fame != 0 && (skill_id == AM_PHARMACY || skill_id == AM_TWILIGHT1 || skill_id == AM_TWILIGHT2 || skill_id == AM_TWILIGHT3)) {
+ pc->addfame(sd, RANKTYPE_ALCHEMIST, fame);
+ }
//Visual effects and the like.
switch (skill_id) {
case AM_PHARMACY: