diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-09-27 16:52:41 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-09-27 16:52:41 +0000 |
commit | da971e54d636b57b0486c4ba95665d5f8cb26152 (patch) | |
tree | f45431b35fd77440bb026780fb4192d8822658aa | |
parent | 344be8d138d359fd0be0ee72820a7982a9a8d39f (diff) | |
download | hercules-da971e54d636b57b0486c4ba95665d5f8cb26152.tar.gz hercules-da971e54d636b57b0486c4ba95665d5f8cb26152.tar.bz2 hercules-da971e54d636b57b0486c4ba95665d5f8cb26152.tar.xz hercules-da971e54d636b57b0486c4ba95665d5f8cb26152.zip |
- Cleaned up status_get_party/guild_id, it should also fix a possible crash when invoking such a functio on a masterless pet.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8889 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | Changelog-Trunk.txt | 2 | ||||
-rw-r--r-- | src/map/status.c | 62 |
2 files changed, 41 insertions, 23 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 45d7ed604..f648bafda 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/09/27
+ * Cleaned up status_get_party/guild_id, it should also fix a possible crash
+ when invoking such a functio on a masterless pet. [Skotlex]
* Sharp-Shooting will now display a skill animation. [Skotlex]
* The no_spawn_on_player setting will now also work for static mobs, but
only if the setting is set to 100 or higher. [Skotlex]
diff --git a/src/map/status.c b/src/map/status.c index ab81d41ac..f5a739f76 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -4055,12 +4055,16 @@ unsigned char status_get_attack_lelement(struct block_list *bl) int status_get_party_id(struct block_list *bl)
{
nullpo_retr(0, bl);
- if(bl->type==BL_PC)
- return ((struct map_session_data *)bl)->status.party_id;
- if(bl->type==BL_PET)
- return ((struct pet_data *)bl)->msd->status.party_id;
- if(bl->type==BL_MOB){
- struct mob_data *md=(struct mob_data *)bl;
+ switch (bl->type) {
+ case BL_PC:
+ return ((TBL_PC*)bl)->status.party_id;
+ case BL_PET:
+ if (((TBL_PET*)bl)->msd)
+ return ((TBL_PET*)bl)->msd->status.party_id;
+ break;
+ case BL_MOB:
+ {
+ struct mob_data *md=(TBL_MOB*)bl;
if( md->master_id>0 )
{
struct map_session_data *msd;
@@ -4068,23 +4072,30 @@ int status_get_party_id(struct block_list *bl) return msd->status.party_id;
return -md->master_id;
}
- return 0; //No party.
+
+ }
+ break;
+ case BL_HOM:
+ if (((TBL_HOM*)bl)->master)
+ return ((TBL_HOM*)bl)->master->status.party_id;
+ break;
+ case BL_SKILL:
+ return ((TBL_SKILL*)bl)->group->party_id;
}
- if(bl->type==BL_HOM && ((TBL_HOM*)bl)->master)
- return ((TBL_HOM*)bl)->master->status.party_id;
- if(bl->type==BL_SKILL)
- return ((struct skill_unit *)bl)->group->party_id;
return 0;
}
int status_get_guild_id(struct block_list *bl)
{
nullpo_retr(0, bl);
- if(bl->type==BL_PC)
- return ((struct map_session_data *)bl)->status.guild_id;
- if(bl->type==BL_PET)
- return ((struct pet_data *)bl)->msd->status.guild_id;
- if(bl->type==BL_MOB)
+ switch (bl->type) {
+ case BL_PC:
+ return ((TBL_PC*)bl)->status.guild_id;
+ case BL_PET:
+ if (((TBL_PET*)bl)->msd)
+ return ((TBL_PET*)bl)->msd->status.guild_id;
+ break;
+ case BL_MOB:
{
struct map_session_data *msd;
struct mob_data *md = (struct mob_data *)bl;
@@ -4092,14 +4103,19 @@ int status_get_guild_id(struct block_list *bl) return md->guardian_data->guild_id;
if (md->special_state.ai && (msd = map_id2sd(md->master_id)) != NULL)
return msd->status.guild_id; //Alchemist's mobs [Skotlex]
- return 0; //No guild.
}
- if(bl->type==BL_HOM && ((TBL_HOM*)bl)->master)
- return ((TBL_HOM*)bl)->master->status.guild_id;
- if (bl->type == BL_NPC && bl->subtype == SCRIPT)
- return ((TBL_NPC*)bl)->u.scr.guild_id;
- if(bl->type==BL_SKILL)
- return ((struct skill_unit *)bl)->group->guild_id;
+ break;
+ case BL_HOM:
+ if (((TBL_HOM*)bl)->master)
+ return ((TBL_HOM*)bl)->master->status.guild_id;
+ break;
+ case BL_NPC:
+ if (bl->subtype == SCRIPT)
+ return ((TBL_NPC*)bl)->u.scr.guild_id;
+ break;
+ case BL_SKILL:
+ return ((TBL_SKILL*)bl)->group->guild_id;
+ }
return 0;
}
|