Forráskód Böngészése

Fixed getequipid returning 0 instead of -1

Fixed #2228 and updated the documentation a little

Thanks to @talesvalente
Lemongrass3110 7 éve
szülő
commit
045f4be573

+ 7 - 6
doc/sample/getequipcardid.txt

@@ -3,21 +3,22 @@
 //===== By: ==================================================
 //= Lupus
 //===== Last Updated: ========================================
-//= 20140208
+//= 20170702
 //===== Description: ========================================= 
 //= Demonstrates the 'getequipcardid' command.
 //============================================================
 
 prontera,155,177,4	script	Check My Hat	810,{
+	.@slot = EQI_HEAD_TOP;
 	mes "Checking your head...";
-	if (getequipisequiped(1)) {
-		.@id = getequipid(1);
-		.@ref = getequiprefinerycnt(1);
+	if (getequipisequiped(.@slot)) {
+		.@id = getequipid(.@slot);
+		.@ref = getequiprefinerycnt(.@slot);
 		mes "Your hat is... " + getitemname(.@id) + "...";
 		if (.@ref)
 			mes "It has been refined " + .@ref + " times.";
-		mes "Card Slot 0:" + getequipcardid(1,0) + " 1:" + getequipcardid(1,1);
-		mes "Card Slot 2:" + getequipcardid(1,2) + " 3:" + getequipcardid(1,3);
+		mes "Card Slot 0:" + getequipcardid(.@slot,0) + " 1:" + getequipcardid(.@slot,1);
+		mes "Card Slot 2:" + getequipcardid(.@slot,2) + " 3:" + getequipcardid(.@slot,3);
 		close;
 	}
 	mes "Nothing?";

+ 2 - 2
doc/sample/getequipid.txt

@@ -3,13 +3,13 @@
 //===== By: ==================================================
 //= rAthena Dev Team
 //===== Last Updated: ========================================
-//= 20140208
+//= 20170702
 //===== Description: ========================================= 
 //= Demonstrates the 'getequipid' command.
 //============================================================
 
 prontera,161,181,6	script	getequipid sample	105,{
-	for (.@i = 1; .@i < 11; .@i++)
+	for (.@i = EQI_ACC_L; .@i < EQI_MAX; .@i++)
 		mes "getequipid(" + .@i + ") : " + getequipid(.@i);
 	close;
 }

+ 1 - 1
doc/script_commands.txt

@@ -2704,7 +2704,7 @@ Examples:
     }
 
 // Left hand can hold either a weapon or shield.
-    if (getequipid(EQI_HAND_R) == 0) {
+    if (!getequipisequiped(EQI_HAND_R)) {
         mes "Seems you have nothing equipped here.";
         close;
     }

+ 7 - 4
src/map/script.c

@@ -8521,7 +8521,7 @@ BUILDIN_FUNC(strnpcinfo)
  **/
 BUILDIN_FUNC(getequipid)
 {
-	int i, num = EQI_COMPOUND_ON;
+	int i, num;
 	TBL_PC* sd;
 
 	if (!script_charid2sd(3, sd)) {
@@ -8531,20 +8531,23 @@ BUILDIN_FUNC(getequipid)
 
 	if (script_hasdata(st, 2))
 		num = script_getnum(st, 2);
+	else
+		num = EQI_COMPOUND_ON;
 
 	if (num == EQI_COMPOUND_ON)
 		i = current_equip_item_index;
 	else if (equip_index_check(num)) // get inventory position of item
 		i = pc_checkequip(sd, equip_bitmask[num]);
 	else {
+		ShowError( "buildin_getequipid: Unknown equip index '%d'\n", num );
 		script_pushint(st,-1);
-		return SCRIPT_CMD_SUCCESS;
+		return SCRIPT_CMD_FAILURE;
 	}
 
-	if (i >= EQI_ACC_L && sd->inventory_data[i])
+	if (i >= 0 && i < MAX_INVENTORY && sd->inventory_data[i])
 		script_pushint(st, sd->inventory_data[i]->nameid);
 	else
-		script_pushint(st, 0);
+		script_pushint(st, -1);
 
 	return SCRIPT_CMD_SUCCESS;
 }