Browse Source

- Cleaned up the pet_ai_hard_lootsearch function to avoid doing map_id2sd calls.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@5910 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 19 years ago
parent
commit
7aa1324af3
1 changed files with 4 additions and 5 deletions
  1. 4 5
      src/map/pet.c

+ 4 - 5
src/map/pet.c

@@ -1091,20 +1091,19 @@ int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
 {
 {
 	struct pet_data* pd;
 	struct pet_data* pd;
 	struct flooritem_data *fitem = (struct flooritem_data *)bl;
 	struct flooritem_data *fitem = (struct flooritem_data *)bl;
-	struct map_session_data *sd = NULL;
+	int sd_id =0;
 	int *itc;
 	int *itc;
 
 
 	pd=va_arg(ap,struct pet_data *);
 	pd=va_arg(ap,struct pet_data *);
 	itc=va_arg(ap,int *);
 	itc=va_arg(ap,int *);
 
 
-	// ƒ‹�[ƒgŒ –³‚µ
-	if(fitem && fitem->first_get_id)
-	sd = map_id2sd(fitem->first_get_id);
+	sd_id = fitem->first_get_id;
 	// Removed [Valaris]
 	// Removed [Valaris]
 	//if((pd->lootitem_weight + (itemdb_search(fitem->item_data.))->weight * fitem->item_data.amount) > battle_config.pet_weight)
 	//if((pd->lootitem_weight + (itemdb_search(fitem->item_data.))->weight * fitem->item_data.amount) > battle_config.pet_weight)
 	//	return 0;
 	//	return 0;
 
 
-	if(pd->loot == NULL || pd->loot->item == NULL || (pd->loot->count >= pd->loot->max) || (sd && sd->pd != pd))
+	if(pd->loot == NULL || pd->loot->item == NULL || (pd->loot->count >= pd->loot->max) ||
+	 	(sd_id && pd->msd && pd->msd->bl.id != sd_id))
 		return 0;
 		return 0;
 	if(bl->m == pd->bl.m && check_distance_bl(&pd->bl, bl, pd->db->range2) &&
 	if(bl->m == pd->bl.m && check_distance_bl(&pd->bl, bl, pd->db->range2) &&
 		unit_can_reach(&pd->bl,bl->x,bl->y) && rand()%1000<1000/(++(*itc)))
 		unit_can_reach(&pd->bl,bl->x,bl->y) && rand()%1000<1000/(++(*itc)))