Jump to content

akka

Members
  • Content Count

    8
  • Joined

  • Last visited


Reputation Activity

  1. Upvote
    akka got a reaction from pan in Trying to figure out if there is a player near a mob.   
    Thanks I really appreciate your help. I made a read up on pointers and got it to work! 
  2. Upvote
    akka reacted to pan in Trying to figure out if there is a player near a mob.   
    Just by doing a quick look there's something strange going on, why are you using a pointer?
    int *isnear = 0;It looks as in pc_isnear_sub you are just using this pointer to point things that are in stack, so when this function returns it will point to something that can't really be accessed and will probably raise a SEGFAULT.if (isnear > 0){This line is just checking if there's an address set to '*isnear', not if the dereferenced value is bigger than 0.Also you are incrementing the pointer here not the dereferenced value:
    *isnear++;So you should do something like:int pc_isnear_sub(struct block_list *bl, va_list args){ int *isnear; struct map_session_data *sd; isnear = va_arg(args, int*); sd = (struct map_session_data *)bl; if( isnear == NULL || sd == NULL ) return 0; if (sd->sc.data[SC_TRICKDEAD] || sd->sc.data[SC_HIDING] || sd->sc.data[SC_CLOAKING] || pc_isinvisible(sd) || sd->vd.class_ == INVISIBLE_CLASS || pc_isdead(sd) ) { return 0; } (*isnear)++; return 1;}bool pc_isnear_mob( struct mob_data *md ){ int isnear; isnear = 0; map->foreachinrange((pc_isnear_sub), &md->bl, AREA_SIZE, BL_PC, &isnear); return (isnear > 0)?true:false;}Regards.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.