summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-11-21 15:44:24 +0100
committerHaru <haru@dotalux.com>2015-12-06 15:18:59 +0100
commit9fef13d4d2e0eab3376ea95b3cb8783d48d19dda (patch)
treed1d66ac73e72bc18a96b88d202586b1c41b6ff36 /src/map/map.c
parentcea55140cc2b5d1012813f8abc028ba04bd625c6 (diff)
downloadhercules-9fef13d4d2e0eab3376ea95b3cb8783d48d19dda.tar.gz
hercules-9fef13d4d2e0eab3376ea95b3cb8783d48d19dda.tar.bz2
hercules-9fef13d4d2e0eab3376ea95b3cb8783d48d19dda.tar.xz
hercules-9fef13d4d2e0eab3376ea95b3cb8783d48d19dda.zip
Refactored/fixed race handling for bonuses that store it as a bitmask
- The following bonuses now work correctly with RC_DemiPlayer, RC_NonDemiPlayer, RC_NonDemiHuman, RC_Nonplayer: * bIgnoreDefRace * bIgnoreMdefRace * bDefRatioAtkRace * bAddMonsterDropChainItem (bonus3) * bAddMonsterDropItem (bonus3) - A new function (map->race_id2mask) is provided, to easily and efficiently generate a bitmask from a race ID. - The RC_ALL race ID is mapped to RC_BOSS and RC_NONBOSS, for backwards compatibility. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/map/map.c b/src/map/map.c
index fff1593a4..7a0dde260 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2040,6 +2040,37 @@ struct mob_data * map_id2boss(int id)
return (struct mob_data*)idb_get(map->bossid_db,id);
}
+/**
+ * Returns the equivalent bitmask to the given race ID.
+ *
+ * @param race A race identifier (@see enum Race)
+ *
+ * @return The equivalent race bitmask.
+ */
+uint32 map_race_id2mask(int race)
+{
+ if (race >= RC_FORMLESS && race < RC_MAX)
+ return 1 << race;
+
+ if (race == RC_ALL)
+ return RCMASK_ALL;
+
+ if (race == RC_NONPLAYER)
+ return RCMASK_NONPLAYER;
+
+ if (race == RC_NONDEMIHUMAN)
+ return RCMASK_NONDEMIHUMAN;
+
+ if (race == RC_DEMIPLAYER)
+ return RCMASK_DEMIPLAYER;
+
+ if (race == RC_NONDEMIPLAYER)
+ return RCMASK_NONDEMIPLAYER;
+
+ ShowWarning("map_race_id2mask: Invalid race: %d\n", race);
+ return RCMASK_NONE;
+}
+
/// Applies func to all the players in the db.
/// Stops iterating if func returns -1.
void map_vforeachpc(int (*func)(struct map_session_data* sd, va_list args), va_list args) {
@@ -6127,6 +6158,7 @@ void map_defaults(void) {
map->nick2sd = map_nick2sd;
map->getmob_boss = map_getmob_boss;
map->id2boss = map_id2boss;
+ map->race_id2mask = map_race_id2mask;
// reload config file looking only for npcs
map->reloadnpc = map_reloadnpc;