Explorar o código

Added minor autolootitem code improvement. saves from scenarios like:
Kill a monsters on a aoe, with 10 drops looking up a empty autolootitem array -- 100 times ? -- (10 per loot with AUTOLOOITEM_SIZE as 10).

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

shennetsind %!s(int64=13) %!d(string=hai) anos
pai
achega
1f958f879d
Modificáronse 3 ficheiros con 9 adicións e 0 borrados
  1. 6 0
      src/map/atcommand.c
  2. 2 0
      src/map/pc.c
  3. 1 0
      src/map/pc.h

+ 6 - 0
src/map/atcommand.c

@@ -6280,6 +6280,7 @@ ACMD_FUNC(autolootitem)
 		sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
 		sprintf(atcmd_output, "Autolooting item: '%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
 		clif_displaymessage(fd, atcmd_output);
+		sd->state.autolooting = 1;
 		break;
 	case 2:
 		ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
@@ -6290,6 +6291,10 @@ ACMD_FUNC(autolootitem)
 		sd->state.autolootid[i] = 0;
 		sprintf(atcmd_output, "Removed item: '%s'/'%s' {%d} from your autolootitem list.", item_data->name, item_data->jname, item_data->nameid);
 		clif_displaymessage(fd, atcmd_output);
+		ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
+		if (i == AUTOLOOTITEM_SIZE) {
+			sd->state.autolooting = 0;
+		}
 		break;
 	case 3:
 		sprintf(atcmd_output, "You can have %d items on your autolootitem list.", AUTOLOOTITEM_SIZE);
@@ -6317,6 +6322,7 @@ ACMD_FUNC(autolootitem)
 	case 4:
 		memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
 		clif_displaymessage(fd, "Your autolootitem list has been reset.");
+		sd->state.autolooting = 0;
 		break;
 	}
 	return 0;

+ 2 - 0
src/map/pc.c

@@ -8249,6 +8249,8 @@ void pc_overheat(struct map_session_data *sd, int val) {
 bool pc_isautolooting(struct map_session_data *sd, int nameid)
 {
 	int i;
+	if( !sd->state.autolooting )
+		return false;
 	ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == nameid);
 	return (i != AUTOLOOTITEM_SIZE);
 }

+ 1 - 0
src/map/pc.h

@@ -140,6 +140,7 @@ struct map_session_data {
 		short pmap; // Previous map on Map Change
 		unsigned short autoloot;
 		unsigned short autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus]
+		unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid
 		unsigned short autobonus; //flag to indicate if an autobonus is activated. [Inkfish]
 		struct guild *gmaster_flag;
 		unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.