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 /src | |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/map/status.c | 62 |
1 files changed, 39 insertions, 23 deletions
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;
}
|