From 045f4be573f9161e9d1d497545160faf491202bc Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Sun, 2 Jul 2017 15:39:35 +0200 Subject: [PATCH] Fixed getequipid returning 0 instead of -1 Fixed #2228 and updated the documentation a little Thanks to @talesvalente --- doc/sample/getequipcardid.txt | 13 +++++++------ doc/sample/getequipid.txt | 4 ++-- doc/script_commands.txt | 2 +- src/map/script.c | 11 +++++++---- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/doc/sample/getequipcardid.txt b/doc/sample/getequipcardid.txt index 77728090c2..0556eb8e77 100644 --- a/doc/sample/getequipcardid.txt +++ b/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?"; diff --git a/doc/sample/getequipid.txt b/doc/sample/getequipid.txt index d38183032c..d654369322 100644 --- a/doc/sample/getequipid.txt +++ b/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; } diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 5f53f61eca..9ddbdedc46 100644 --- a/doc/script_commands.txt +++ b/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; } diff --git a/src/map/script.c b/src/map/script.c index fff62b5d00..e7bcfbae7a 100644 --- a/src/map/script.c +++ b/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; }