Quellcode durchsuchen

- Applied a fix to not do xs/ys checks on npc_doevent when the npc is not on a map.
- You can't return to egg a pet that has run away now.
- Added ers support to the delayed mob drops.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@5800 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex vor 19 Jahren
Ursprung
Commit
e94e165db7
4 geänderte Dateien mit 30 neuen und 20 gelöschten Zeilen
  1. 4 0
      Changelog-Trunk.txt
  2. 14 12
      src/map/mob.c
  3. 10 7
      src/map/npc.c
  4. 2 1
      src/map/pet.c

+ 4 - 0
Changelog-Trunk.txt

@@ -4,6 +4,10 @@ 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/03/29
+	* Applied a fix to not do range checks on npc_doevent when the npc is not
+	  on a map. [Skotlex]
+	* You can't return to egg a pet that has run away now. [Skotlex]
+	* Added ers support to the delayed mob drops. [Skotlex]
 	* Some cleaning of the mob_ai. Mobs should stop chasing once you are beyond
 	  their min_chase range. Improved rude-attacked checking when mobs can't
 	  move. [Skotlex]

+ 14 - 12
src/map/mob.c

@@ -8,11 +8,13 @@
 #include <math.h>
 #include <limits.h>
 
-#include "timer.h"
-#include "socket.h"
-#include "db.h"
-#include "nullpo.h"
-#include "malloc.h"
+#include "../common/timer.h"
+#include "../common/db.h"
+#include "../common/nullpo.h"
+#include "../common/malloc.h"
+#include "../common/showmsg.h"
+#include "../common/ers.h"
+
 #include "map.h"
 #include "clif.h"
 #include "intif.h"
@@ -26,11 +28,9 @@
 #include "party.h"
 #include "npc.h"
 #include "log.h"
-#include "showmsg.h"
 #include "script.h"
 #include "atcommand.h"
 #include "date.h"
-
 #include "irc.h"
 
 #define MIN_MOBTHINKTIME 100
@@ -48,6 +48,7 @@ struct mob_db *mob_dummy = NULL;	//Dummy mob to be returned when a non-existant
 
 struct mob_db *mob_db(int index) { if (index < 0 || index > MAX_MOB_DB || mob_db_data[index] == NULL) return mob_dummy; return mob_db_data[index]; }
 
+static struct eri *delay_drop_ers; //For loot drops delay structures.
 #define CLASSCHANGE_BOSS_NUM 21
 
 /*==========================================
@@ -1527,7 +1528,7 @@ struct delay_item_drop {
 static struct delay_item_drop* mob_setdropitem(int nameid, int qty, int m, int x, int y, 
 	struct map_session_data* first_sd, struct map_session_data* second_sd, struct map_session_data* third_sd)
 {
-	struct delay_item_drop *drop = aCalloc(1, sizeof (struct delay_item_drop));
+	struct delay_item_drop *drop = ers_alloc(delay_drop_ers, struct delay_item_drop);
 	drop->item_data.nameid = nameid;
 	drop->item_data.amount = qty;
 	drop->item_data.identify = !itemdb_isequip3(nameid);
@@ -1547,7 +1548,7 @@ static struct delay_item_drop* mob_setdropitem(int nameid, int qty, int m, int x
 static struct delay_item_drop* mob_setlootitem(struct item* item, int m, int x, int y,
 	struct map_session_data* first_sd, struct map_session_data* second_sd, struct map_session_data* third_sd)
 {
-	struct delay_item_drop *drop = aCalloc(1, sizeof (struct delay_item_drop));
+	struct delay_item_drop *drop = ers_alloc(delay_drop_ers, struct delay_item_drop);
 	memcpy(&drop->item_data, item, sizeof(struct item));
 	drop->m = m;
 	drop->x = x;
@@ -1568,7 +1569,7 @@ static int mob_delay_item_drop(int tid,unsigned int tick,int id,int data)
 	ditem=(struct delay_item_drop *)id;
 
 	map_addflooritem(&ditem->item_data,1,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0);
-	aFree(ditem);
+	ers_free(delay_drop_ers, ditem);
 	return 0;
 }
 
@@ -1599,7 +1600,7 @@ static void mob_item_drop(struct mob_data *md, unsigned int tick, struct delay_i
 				NULL,
 			ditem->first_sd,&ditem->item_data) == 0
 		) {
-			aFree(ditem);
+			ers_free(delay_drop_ers, ditem);
 			return;
 		}
 	}
@@ -4086,6 +4087,7 @@ int do_init_mob(void)
 	memset(mob_db_data,0,sizeof(mob_db_data)); //Clear the array
 	mob_db_data[0] = aCalloc(1, sizeof (struct mob_data));	//This mob is used for random spawns
 	mob_makedummymobdb(0); //The first time this is invoked, it creates the dummy mob
+	delay_drop_ers = ers_new((uint32)sizeof(struct delay_item_drop));
 
 #ifndef TXT_ONLY
     if(db_use_sqldbs)
@@ -4132,6 +4134,6 @@ int do_final_mob(void)
 			mob_db_data[i] = NULL;
 		}
 	}
-
+	ers_destroy(delay_drop_ers);
 	return 0;
 }

+ 10 - 7
src/map/npc.c

@@ -821,13 +821,16 @@ int npc_event (struct map_session_data *sd, const unsigned char *eventname, int
 
 	xs=nd->u.scr.xs;
 	ys=nd->u.scr.ys;
-	if (xs>=0 && ys>=0 && (strcmp(((eventname)+strlen(eventname)-6),"Global") != 0) )        {
-		if (nd->bl.m >= 0 && nd->bl.m != sd->bl.m )
-			return 1;
-		if ( xs>0 && (sd->bl.x<nd->bl.x-xs/2 || nd->bl.x+xs/2<sd->bl.x) )
-			return 1;
-		if ( ys>0 && (sd->bl.y<nd->bl.y-ys/2 || nd->bl.y+ys/2<sd->bl.y) )
-			return 1;
+	if (xs>=0 && ys>=0 && (strcmp(((eventname)+strlen(eventname)-6),"Global") != 0) )
+	{
+		if (nd->bl.m >= 0) { //Non-invisible npc
+		  	if (nd->bl.m != sd->bl.m )
+				return 1;
+			if ( xs>0 && (sd->bl.x<nd->bl.x-xs/2 || nd->bl.x+xs/2<sd->bl.x) )
+				return 1;
+			if ( ys>0 && (sd->bl.y<nd->bl.y-ys/2 || nd->bl.y+ys/2<sd->bl.y) )
+				return 1;
+		}
 	}
 
 	if ( sd->npc_id!=0) {

+ 2 - 1
src/map/pet.c

@@ -361,7 +361,8 @@ int pet_return_egg(struct map_session_data *sd)
 	if(sd->status.pet_id && sd->pd) {
 		// ルートしたItemを落とさせる
 		pet_lootitem_drop(sd->pd,sd);
-		if(sd->petDB == NULL)
+		//Avoid returning to egg those pets that already ran away. [Skotlex]
+		if(sd->petDB == NULL || sd->pet.intimate <= 0)
 			return 1;
 		memset(&tmp_item,0,sizeof(tmp_item));
 		tmp_item.nameid = sd->petDB->EggID;