ソースを参照

Use the same code for script commands getitem & getitem2 as @item to avoid bug in bugreport:1324 (non-stackable items are stacked)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12603 54d463be-8e91-2dee-dedb-b68131a5f0ec
toms 17 年 前
コミット
034920992e
2 ファイル変更44 行追加12 行削除
  1. 2 0
      Changelog-Trunk.txt
  2. 42 12
      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.
 
 2008/04/15
+	* Use the same code for script commands getitem & getitem2 as @item to avoid
+	  bug in bugreport:1324 (non-stackable items are stacked) [Toms]
 	* Removed all _ in the second name in item_db.txt and updated item_db.sql [Toms]
 	* Added a forward declaration of the struct quest instead of including mmo.h [Toms]
 	* Corrected some invalid syntax in skill_db.txt (wrong usage of commas)

+ 42 - 12
src/map/script.c

@@ -5310,7 +5310,7 @@ BUILDIN_FUNC(checkweight)
  *------------------------------------------*/
 BUILDIN_FUNC(getitem)
 {
-	int nameid,amount,flag = 0;
+	int nameid,amount,get_count,i,flag = 0;
 	struct item it;
 	TBL_PC *sd;
 	struct script_data *data;
@@ -5362,13 +5362,27 @@ BUILDIN_FUNC(getitem)
 	}
 	if( sd == NULL ) // no target
 		return 0;
-	if( pet_create_egg(sd, nameid) )
-		amount = 1; //This is a pet!
-	else if( (flag=pc_additem(sd,&it,amount)) ){
-		clif_additem(sd,0,0,flag);
-		if( pc_candrop(sd,&it) )
-			map_addflooritem(&it,amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
-	}
+
+
+        //Check if it's stackable.
+	if (!itemdb_isstackable(nameid))
+		get_count = 1;
+	else
+		get_count = amount;
+
+	for (i = 0; i < amount; i += get_count)
+	{
+		// if not pet egg
+		if (!pet_create_egg(sd, nameid))
+		{
+			if ((flag = pc_additem(sd, &it, get_count)))
+			{
+				clif_additem(sd, 0, 0, flag);
+				if( pc_candrop(sd,&it) )
+					map_addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+			}
+                }
+        }
 
 	//Logs items, got from (N)PC scripts [Lupus]
 	if(log_config.enable_logs&LOG_SCRIPT_TRANSACTIONS)
@@ -5382,7 +5396,7 @@ BUILDIN_FUNC(getitem)
  *------------------------------------------*/
 BUILDIN_FUNC(getitem2)
 {
-	int nameid,amount,flag = 0;
+	int nameid,amount,get_count,i,flag = 0;
 	int iden,ref,attr,c1,c2,c3,c4;
 	struct item_data *item_data;
 	struct item item_tmp;
@@ -5451,9 +5465,25 @@ BUILDIN_FUNC(getitem2)
 		item_tmp.card[1]=c2;
 		item_tmp.card[2]=c3;
 		item_tmp.card[3]=c4;
-		if((flag = pc_additem(sd,&item_tmp,amount))) {
-			clif_additem(sd,0,0,flag);
-			map_addflooritem(&item_tmp,amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+
+		//Check if it's stackable.
+		if (!itemdb_isstackable(nameid))
+			get_count = 1;
+		else
+			get_count = amount;
+
+		for (i = 0; i < amount; i += get_count)
+		{
+			// if not pet egg
+			if (!pet_create_egg(sd, nameid))
+			{
+				if ((flag = pc_additem(sd, &item_tmp, get_count)))
+				{
+					clif_additem(sd, 0, 0, flag);
+					if( pc_candrop(sd,&item_tmp) )
+						map_addflooritem(&item_tmp,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+				}
+			}
 		}
 
 		//Logs items, got from (N)PC scripts [Lupus]