Browse Source

* Fixed 'unequip' removing items in the wrong position (bugreport:252)
* Fixed #refine unequpping the caller's item by mistake (bugreport:265)

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

ultramage 17 years ago
parent
commit
28dcdcdf9e
3 changed files with 10 additions and 8 deletions
  1. 2 0
      Changelog-Trunk.txt
  2. 1 1
      src/map/charcommand.c
  3. 7 7
      src/map/script.c

+ 2 - 0
Changelog-Trunk.txt

@@ -4,6 +4,8 @@ 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.
 
 2007/10/20
+	* Fixed 'unequip' removing items in the wrong position (bugreport:252)
+	* Fixed #refine unequpping the caller's item by mistake (bugreport:265)
 	* Fixed a nasty bug from r11410 which let people create chars with
 	  already taken char names, and (in TXT's case) even cause a crash.
 	- Bug was a variable name collision between the total number of chars

+ 1 - 1
src/map/charcommand.c

@@ -2434,7 +2434,7 @@ int charcommand_refine(const int fd, struct map_session_data* sd, const char* co
 		if (pl_sd->status.inventory[i].refine != final_refine) {
 			pl_sd->status.inventory[i].refine = final_refine;
 			current_position = pl_sd->status.inventory[i].equip;
-			pc_unequipitem(sd, i, 3);
+			pc_unequipitem(pl_sd, i, 3);
 			clif_refine(fd, 0, i, pl_sd->status.inventory[i].refine);
 			clif_delitem(pl_sd, i, 1);
 			clif_additem(pl_sd, i, 1, 0);

+ 7 - 7
src/map/script.c

@@ -11941,11 +11941,11 @@ BUILDIN_FUNC(unequip)
 	size_t num;
 	TBL_PC *sd;
 
-	num = script_getnum(st,2) - 1;
-	sd=script_rid2sd(st);
-	if(sd!=NULL && num > 0 && num <= ARRAYLENGTH(equip))
+	num = script_getnum(st,2);
+	sd = script_rid2sd(st);
+	if( sd != NULL && num >= 1 && num <= ARRAYLENGTH(equip) )
 	{
-		i=pc_checkequip(sd,equip[num-1]);
+		i = pc_checkequip(sd,equip[num-1]);
 		if (i >= 0)
 			pc_unequipitem(sd,i,2);
 		return 0;
@@ -11968,10 +11968,10 @@ BUILDIN_FUNC(equip)
 			ShowError("wrong item ID : equipitem(%i)\n",nameid);
 		return 1;
 	}
-	for(i=0;i<MAX_INVENTORY && sd->status.inventory[i].nameid!=nameid;i++);
-	if(i==MAX_INVENTORY) return 0;
+	ARR_FIND( 0, MAX_INVENTORY, i, sd->status.inventory[i].nameid == nameid );
+	if( i < MAX_INVENTORY )
+		pc_equipitem(sd,i,item_data->equip);
 
-	pc_equipitem(sd,i,item_data->equip);
 	return 0;
 }