ソースを参照

Added core.h config ENABLE_ITEM_GUID
* Enabled by default to take effect of `guid` function.
* When it's disabled, `guid` function will be ignored as suggestion to disable this 'weird. official feature.
* NOTE: If this feature is disabled "in the middle" of your game, the separated is still separated in inventory, storage, or guild storage until player move the item to/from storage/inventory to restack them.

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>

Cydh Ramdh 10 年 前
コミット
b92b8ffefc
7 ファイル変更43 行追加14 行削除
  1. 8 0
      src/config/core.h
  2. 4 0
      src/map/atcommand.c
  3. 2 0
      src/map/clif.c
  4. 17 11
      src/map/itemdb.c
  5. 2 0
      src/map/pc.c
  6. 4 0
      src/map/script.c
  7. 6 3
      src/map/storage.c

+ 8 - 0
src/config/core.h

@@ -64,6 +64,14 @@
 /// Uncomment to enable the job base HP/SP table (job_basehpsp_db.txt)
 //#define HP_SP_TABLES
 
+/// Enable separated item by `guid`. [Cydh]
+/// See db/[pre-]re/item_flag.txt and doc/item_group.txt for the `guid` explanation.
+/// NOTE:
+///    If this feature is disabled "in the middle" of your game, the separated is still
+///    separated in inventory, storage, or guild storage until player move the item
+///    to/from storage/inventory to restack them.
+#define ENABLE_ITEM_GUID
+
 /// Uncomment to enable VIP system.
 //#define VIP_ENABLE
 

+ 4 - 0
src/map/atcommand.c

@@ -1268,8 +1268,10 @@ ACMD_FUNC(item)
 				item_tmp.nameid = item_id;
 				item_tmp.identify = 1;
 				item_tmp.bound = bound;
+#ifdef ENABLE_ITEM_GUID
 				if (item_data[j]->flag.guid)
 					item_tmp.unique_id = pc_generate_unique_id(sd);
+#endif
 				if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
 					clif_additem(sd, 0, 0, flag);
 			}
@@ -1360,8 +1362,10 @@ ACMD_FUNC(item2)
 			item_tmp.card[2] = c3;
 			item_tmp.card[3] = c4;
 			item_tmp.bound = bound;
+#ifdef ENABLE_ITEM_GUID
 			if (item_data->flag.guid)
 				item_tmp.unique_id = pc_generate_unique_id(sd);
+#endif
 			if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND)))
 				clif_additem(sd, 0, 0, flag);
 		}

+ 2 - 0
src/map/clif.c

@@ -13207,9 +13207,11 @@ void clif_parse_GM_Item_Monster(int fd, struct map_session_data *sd)
 		if( !itemdb_isstackable2(id) ) //Nonstackable
 			StringBuf_Printf(&command, "%citem2 %d 1 0 0 0 0 0 0 0", atcommand_symbol, id->nameid);
 		else {
+#ifdef ENABLE_ITEM_GUID
 			if (id->flag.guid)
 				StringBuf_Printf(&command, "%citem %d 1", atcommand_symbol, id->nameid);
 			else
+#endif
 				StringBuf_Printf(&command, "%citem %d 20", atcommand_symbol, id->nameid);
 		}
 		is_atcommand(fd, sd, StringBuf_Value(&command), 1);

+ 17 - 11
src/map/itemdb.c

@@ -199,7 +199,9 @@ static void itemdb_pc_get_itemgroup_sub(struct map_session_data *sd, struct s_it
 	// Do loop for non-stackable item
 	for (i = 0; i < data->amount; i++) {
 		char flag = 0;
+#ifdef ENABLE_ITEM_GUID
 		tmp.unique_id = data->GUID ? pc_generate_unique_id(sd) : 0; // Generate UID
+#endif
 		if ((flag = pc_additem(sd, &tmp, tmp.amount, LOG_TYPE_SCRIPT)))
 			clif_additem(sd, 0, 0, flag);
 		else if (!flag && data->isAnnounced) {
@@ -442,17 +444,17 @@ bool itemdb_isequip2(struct item_data *id)
 */
 bool itemdb_isstackable2(struct item_data *id)
 {
-  nullpo_ret(id);
-  switch(id->type) {
-	  case IT_WEAPON:
-	  case IT_ARMOR:
-	  case IT_PETEGG:
-	  case IT_PETARMOR:
-	  case IT_SHADOWGEAR:
-		  return false;
-	  default:
-		  return true;
-  }
+	nullpo_ret(id);
+	switch(id->type) {
+		case IT_WEAPON:
+		case IT_ARMOR:
+		case IT_PETEGG:
+		case IT_PETARMOR:
+		case IT_SHADOWGEAR:
+			return false;
+		default:
+		return true;
+	}
 }
 
 
@@ -662,7 +664,9 @@ static void itemdb_read_itemgroup_sub(const char* filename, bool silent)
 		if (str[3] != NULL) entry.amount = cap_value(atoi(str[3]),1,MAX_AMOUNT);
 		if (str[5] != NULL) entry.isAnnounced= atoi(str[5]);
 		if (str[6] != NULL) entry.duration = cap_value(atoi(str[6]),0,UINT16_MAX);
+#ifdef ENABLE_ITEM_GUID
 		if (str[7] != NULL) entry.GUID = atoi(str[7]);
+#endif
 		if (str[8] != NULL) entry.bound = cap_value(atoi(str[8]),BOUND_NONE,BOUND_MAX-1);
 		if (str[9] != NULL) entry.isNamed = atoi(str[9]);
 
@@ -917,7 +921,9 @@ static bool itemdb_read_flag(char* fields[], int columns, int current) {
 
 	if (flag&1) id->flag.dead_branch = set ? 1 : 0;
 	if (flag&2) id->flag.group = set ? 1 : 0;
+#ifdef ENABLE_ITEM_GUID
 	if (flag&4 && itemdb_isstackable2(id)) id->flag.guid = set ? 1 : 0;
+#endif
 
 	return true;
 }

+ 2 - 0
src/map/pc.c

@@ -4292,7 +4292,9 @@ char pc_additem(struct map_session_data *sd,struct item *item,int amount,e_log_p
 			if( sd->status.inventory[i].nameid == item->nameid &&
 				sd->status.inventory[i].bound == item->bound &&
 				sd->status.inventory[i].expire_time == 0 &&
+#ifdef ENABLE_ITEM_GUID
 				sd->status.inventory[i].unique_id == item->unique_id &&
+#endif
 				memcmp(&sd->status.inventory[i].card, &item->card, sizeof(item->card)) == 0
 				)
 			{

+ 4 - 0
src/map/script.c

@@ -6559,7 +6559,9 @@ BUILDIN_FUNC(getitem)
 		// if not pet egg
 		if (!pet_create_egg(sd, nameid))
 		{
+#ifdef ENABLE_ITEM_GUID
 			it.unique_id = (id->flag.guid) ? pc_generate_unique_id(sd) : 0;
+#endif
 			if ((flag = pc_additem(sd, &it, get_count, LOG_TYPE_SCRIPT)))
 			{
 				clif_additem(sd, 0, 0, flag);
@@ -6679,7 +6681,9 @@ BUILDIN_FUNC(getitem2)
 			if (!pet_create_egg(sd, nameid))
 			{
 				unsigned char flag = 0;
+#ifdef ENABLE_ITEM_GUID
 				item_tmp.unique_id = (item_data->flag.guid) ? pc_generate_unique_id(sd) : 0;
+#endif
 				if ((flag = pc_additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT)))
 				{
 					clif_additem(sd, 0, 0, flag);

+ 6 - 3
src/map/storage.c

@@ -131,7 +131,7 @@ int storage_storageopen(struct map_session_data *sd)
 }
 
 /**
- * check if 2 item a and b have same values
+ * Check if 2 item a and b have same values
  * @param a : item 1
  * @param b : item 2
  * @return 1:same, 0:are different
@@ -143,8 +143,11 @@ int compare_item(struct item *a, struct item *b)
 		a->refine == b->refine &&
 		a->attribute == b->attribute &&
 		a->expire_time == b->expire_time &&
-		a->bound == b->bound &&
-		a->unique_id == b->unique_id )
+		a->bound == b->bound
+#ifdef ENABLE_ITEM_GUID
+		&& a->unique_id == b->unique_id
+#endif
+		)
 	{
 		int i;