diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-09-01 08:06:46 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-09-01 08:06:46 +0000 |
commit | ff6a7baa2a4ac1896980cadede3ed53dc091caee (patch) | |
tree | afd5ee2aa4c45eff33a21aae42de1f8a5df49bca /src/map | |
parent | 6f14691e22610707e4ea859c47f44e8a8f8e14a9 (diff) | |
download | hercules-ff6a7baa2a4ac1896980cadede3ed53dc091caee.tar.gz hercules-ff6a7baa2a4ac1896980cadede3ed53dc091caee.tar.bz2 hercules-ff6a7baa2a4ac1896980cadede3ed53dc091caee.tar.xz hercules-ff6a7baa2a4ac1896980cadede3ed53dc091caee.zip |
Removed hardcoded equip position names from getequipname (bugreport:2156).
Now it's the npc's responsibility to store and display the names.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13171 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/script.c | 79 |
1 files changed, 46 insertions, 33 deletions
diff --git a/src/map/script.c b/src/map/script.c index dd3a2cc15..8897c4082 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -5901,33 +5901,43 @@ BUILDIN_FUNC(strnpcinfo) } -unsigned int equip[10]={EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_GARMENT,EQP_SHOES,EQP_ACC_L,EQP_ACC_R,EQP_HEAD_MID,EQP_HEAD_LOW}; +// aegis->athena slot position conversion table +static unsigned int equip[] = {EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_GARMENT,EQP_SHOES,EQP_ACC_L,EQP_ACC_R,EQP_HEAD_MID,EQP_HEAD_LOW}; /*========================================== * GetEquipID(Pos); Pos: 1-10 *------------------------------------------*/ BUILDIN_FUNC(getequipid) { - int i=-1,num; - TBL_PC *sd; + int i, num; + TBL_PC* sd; struct item_data* item; - sd=script_rid2sd(st); - if(sd == NULL) + sd = script_rid2sd(st); + if( sd == NULL ) return 0; - num=script_getnum(st,2); - if (num > 0 && num <= ARRAYLENGTH(equip)) - i=pc_checkequip(sd,equip[num-1]); - if(i >= 0){ - item=sd->inventory_data[i]; - if(item) - script_pushint(st,item->nameid); - else - script_pushint(st,0); - }else{ + num = script_getnum(st,2) - 1; + if( num < 0 || num >= ARRAYLENGTH(equip) ) + { script_pushint(st,-1); + return 0; } + + // get inventory position of item + i = pc_checkequip(sd,equip[num]); + if( i < 0 ) + { + script_pushint(st,-1); + return 0; + } + + item = sd->inventory_data[i]; + if( item != 0 ) + script_pushint(st,item->nameid); + else + script_pushint(st,0); + return 0; } @@ -5936,31 +5946,34 @@ BUILDIN_FUNC(getequipid) *------------------------------------------*/ BUILDIN_FUNC(getequipname) { - int i=-1,num; - TBL_PC *sd; + int i, num; + TBL_PC* sd; struct item_data* item; - char *buf; - - static char pos[11][100] = {"Head","Body","Left hand","Right hand","Robe","Shoes","Accessory 1","Accessory 2","Head 2","Head 3","Not Equipped"}; sd = script_rid2sd(st); if( sd == NULL ) return 0; - buf=(char *)aMallocA(64*sizeof(char)); - num=script_getnum(st,2); - if (num > 0 && num <= ARRAYLENGTH(equip)) - i=pc_checkequip(sd,equip[num-1]); - if(i >= 0){ - item=sd->inventory_data[i]; - if(item) - sprintf(buf,"%s-[%s]",pos[num-1],item->jname); - else - sprintf(buf,"%s-[%s]",pos[num-1],pos[10]); - }else{ - sprintf(buf,"%s-[%s]",pos[num-1],pos[10]); + num = script_getnum(st,2) - 1; + if( num < 0 || num >= ARRAYLENGTH(equip) ) + { + script_pushconststr(st,""); + return 0; } - script_pushstr(st,buf); + + // get inventory position of item + i = pc_checkequip(sd,equip[num]); + if( i < 0 ) + { + script_pushint(st,-1); + return 0; + } + + item = sd->inventory_data[i]; + if( item != 0 ) + script_pushstrcopy(st,item->jname); + else + script_pushconststr(st,""); return 0; } |