Procházet zdrojové kódy

Corrected an issue with UniqueId (#6146)

* Corrected an issue with UniqueId
* On Aegis some stackable items have the same GUID, the commit adds a setting to give the stackable items stacked (or not) to the player
* Removed IG_MAX in the parsing to allow new entries from const.txt
* Added more information about the 'Group' in a warning

* Removed exp_guild.txt (mistake from previous PR)
Atemo před 3 roky
rodič
revize
3f9b051ebc

+ 1 - 0
db/import-tmpl/item_group_db.yml

@@ -32,6 +32,7 @@
 #          Duration            Makes the item a rental item which will expire within the given amount in minutes. Not intended for use with stackable items. (Default: 0)
 #          Announced           If player obtains this item it will be broadcasted to the server. (Default: false)
 #          UniqueId            Makes the given item(s) have a Unique ID. (Default: UniqueId from item_db)
+#          Stacked             Whether stackable items are given stacked or not. (Default: true)
 #          Named               Inscribes the item with the obtainer's name. (Default: false)
 #          Bound               Binds the obtained item. (Default: None)
 #          Clear               Remove the given item. (Optional)

+ 1 - 0
db/item_group_db.yml

@@ -32,6 +32,7 @@
 #          Duration            Makes the item a rental item which will expire within the given amount in minutes. Not intended for use with stackable items. (Default: 0)
 #          Announced           If player obtains this item it will be broadcasted to the server. (Default: false)
 #          UniqueId            Makes the given item(s) have a Unique ID. (Default: false)
+#          Stacked             Whether stackable items are given stacked or not. (Default: true)
 #          Named               Inscribes the item with the obtainer's name. (Default: false)
 #          Bound               Binds the obtained item. (Default: None)
 #          Clear               Remove the given item. (Optional)

+ 1 - 0
db/pre-re/item_group_db.yml

@@ -32,6 +32,7 @@
 #          Duration            Makes the item a rental item which will expire within the given amount in minutes. Not intended for use with stackable items. (Default: 0)
 #          Announced           If player obtains this item it will be broadcasted to the server. (Default: false)
 #          UniqueId            Makes the given item(s) have a Unique ID. (Default: UniqueId from item_db)
+#          Stacked             Whether stackable items are given stacked or not. (Default: true)
 #          Named               Inscribes the item with the obtainer's name. (Default: false)
 #          Bound               Binds the obtained item. (Default: None)
 #          Clear               Remove the given item. (Optional)

+ 16 - 9
db/re/item_group_db.yml

@@ -32,6 +32,7 @@
 #          Duration            Makes the item a rental item which will expire within the given amount in minutes. Not intended for use with stackable items. (Default: 0)
 #          Announced           If player obtains this item it will be broadcasted to the server. (Default: false)
 #          UniqueId            Makes the given item(s) have a Unique ID. (Default: UniqueId from item_db)
+#          Stacked             Whether stackable items are given stacked or not. (Default: true)
 #          Named               Inscribes the item with the obtainer's name. (Default: false)
 #          Bound               Binds the obtained item. (Default: None)
 #          Clear               Remove the given item. (Optional)
@@ -890,6 +891,7 @@ Body:
           - Item: Aquarius_Diadem_Scroll
             Amount: 10
             UniqueId: true
+            Stacked: false
   - Group: ARCHER_CARD_BOX
     SubGroups:
       - SubGroup: 0
@@ -948,6 +950,7 @@ Body:
           - Item: Aries_Scroll_
             Amount: 10
             UniqueId: true
+            Stacked: false
   - Group: ASGARD_SCROLL
     SubGroups:
       - SubGroup: 1
@@ -4028,6 +4031,7 @@ Body:
           - Item: Capricon_Di_Scroll
             Amount: 10
             UniqueId: true
+            Stacked: false
   - Group: CAPRI_CROWN_SCROLL
     SubGroups:
       - SubGroup: 1
@@ -4084,6 +4088,7 @@ Body:
           - Item: Capri_Crown_Scroll
             Amount: 10
             UniqueId: true
+            Stacked: false
   - Group: CARACAS_RING_BOX
     SubGroups:
       - SubGroup: 0
@@ -5852,9 +5857,7 @@ Body:
           - Item: Malang_Sp_Can
             Rate: 800
           - Item: Egrade_Coin
-            Rate: 50
-          - Item: Egrade_Coin
-            Rate: 150
+            Rate: 200
       - SubGroup: 3
         List:
           - Item: Malang_Sp_Can
@@ -6704,7 +6707,7 @@ Body:
             Rate: 156
           - Item: LexAeternaStone_Middle
             Rate: 156
-          - Item: BlueAuraEffect_Middle
+          - Item: ShadowEffect_Middle
             Rate: 156
           - Item: ATKStone_Middle
             Rate: 234
@@ -8195,6 +8198,7 @@ Body:
           - Item: Energetic_Pisces_Scroll
             Amount: 10
             UniqueId: true
+            Stacked: false
   - Group: ENERGETIC_PISCES_SCROLL
     SubGroups:
       - SubGroup: 1
@@ -9185,6 +9189,7 @@ Body:
           - Item: Gemi_Crown_Scroll
             Amount: 10
             UniqueId: true
+            Stacked: false
   - Group: GEMI_DIADEM_SCROLL
     SubGroups:
       - SubGroup: 1
@@ -9225,6 +9230,7 @@ Body:
           - Item: Gemi_Diadem_Scroll
             Amount: 10
             UniqueId: true
+            Stacked: false
   - Group: GEMSTONE
     SubGroups:
       - SubGroup: 1
@@ -12497,6 +12503,7 @@ Body:
           - Item: Lovely_Aquarius_Scroll
             Amount: 10
             UniqueId: true
+            Stacked: false
   - Group: LOVELY_AQUARIUS_SCROLL
     SubGroups:
       - SubGroup: 1
@@ -15619,6 +15626,7 @@ Body:
           - Item: Pisces_Diadem_Scroll
             Amount: 10
             UniqueId: true
+            Stacked: false
   - Group: PISCES_DIADEM_SCROLL
     SubGroups:
       - SubGroup: 1
@@ -16373,9 +16381,6 @@ Body:
           - Item: Blacksmith_Blessing
             Rate: 580
             Amount: 4
-          - Item: Blacksmith_Blessing
-            Rate: 1500
-            Amount: 2
           - Item: Unbreak_Weap_Box
             Rate: 2500
           - Item: Unbreak_Def_Box
@@ -16438,6 +16443,7 @@ Body:
           - Item: Sagittarius_Scroll
             Amount: 10
             UniqueId: true
+            Stacked: false
   - Group: SAGITTAR_DIADEM_SCROLL
     SubGroups:
       - SubGroup: 1
@@ -16489,6 +16495,7 @@ Body:
           - Item: Sagittar_Diadem_Scroll
             Amount: 10
             UniqueId: true
+            Stacked: false
   - Group: SAHKKAT_BOX
     SubGroups:
       - SubGroup: 0
@@ -19249,6 +19256,7 @@ Body:
           - Item: Taurus_Crown_Scroll
             Amount: 10
             UniqueId: true
+            Stacked: false
   - Group: TAURUS_DIADEM_SCROLL
     SubGroups:
       - SubGroup: 1
@@ -19293,6 +19301,7 @@ Body:
           - Item: Taurus_Diadem_Scroll
             Amount: 10
             UniqueId: true
+            Stacked: false
   - Group: TCG_CARD_SCROLL
     SubGroups:
       - SubGroup: 0
@@ -20276,8 +20285,6 @@ Body:
             Amount: 10
           - Item: Golden_Treasure_Box
             Amount: 11
-          - Item: Red_Booster
-            Amount: 10
           - Item: Sealed_Pharaoh_Scroll
   - Group: UNLIMITED_BOX_II_10
     SubGroups:

+ 3 - 3
doc/item_group.txt

@@ -29,7 +29,7 @@ The table below explains which fields are accessed in each.
 +===============+=================+====================+================+
 | Duration      |       no        |        no          |      YES       |
 +===============+=================+====================+================+
-| GUID          |       no        |        no          |      YES       |
+| UniqueId      |       no        |        no          |      YES       |
 +===============+=================+====================+================+
 | Bound         |       no        |        no          |      YES       |
 +===============+=================+====================+================+
@@ -151,10 +151,10 @@ Duration: Makes the item a rental item, which will be expire in the given amount
 
 ---------------------------------------
 
-GUID: Makes the given item(s) with Unique ID. Item will be stacked ONLY each group
+UniqueId: Makes the given item(s) with Unique ID. Item will be stacked ONLY each group
       when it obtained. Cannot be stacked with same item, even it's stackable item.
 	  Example, there is Box (just call it Apple_Box) that contains 3x Apples with
-	  GUID = 1. When Apples appear it will stack for each 3 even another 3x Apples
+	  UniqueId = 1. When Apples appear it will stack for each 3 even another 3x Apples
 	  are appeared by same box. So it will be filled in inventory as:
 	        3x Apples | 3x Apples | so on... | nx Apples (normal)
 

+ 1 - 0
doc/yaml/db/item_group_db.yml

@@ -15,6 +15,7 @@
 #          Duration            Makes the item a rental item which will expire within the given amount in minutes. Not intended for use with stackable items. (Default: 0)
 #          Announced           If player obtains this item it will be broadcasted to the server. (Default: false)
 #          UniqueId            Makes the given item(s) have a Unique ID. (Default: UniqueId from item_db)
+#          Stacked             Whether stackable items are given stacked or not. (Default: true)
 #          Named               Inscribes the item with the obtainer's name. (Default: false)
 #          Bound               Binds the obtained item. (Default: None)
 #          Clear               Remove the given item. (Optional)

+ 19 - 4
src/map/itemdb.cpp

@@ -1301,14 +1301,14 @@ static void itemdb_pc_get_itemgroup_sub(map_session_data *sd, bool identify, std
 
 	uint16 get_amt = 0;
 
-	if (itemdb_isstackable(data->nameid) && !data->GUID)
+	if (itemdb_isstackable(data->nameid) && data->isStacked)
 		get_amt = data->amount;
 	else
 		get_amt = 1;
 
 	tmp.amount = get_amt;
 
-	// Do loop for non-stackable item / stackable item with GUID
+	// Do loop for non-stackable item
 	for (uint16 i = 0; i < data->amount; i += get_amt) {
 		char flag = 0;
 		tmp.unique_id = data->GUID ? pc_generate_unique_id(sd) : 0; // Generate GUID
@@ -1587,8 +1587,11 @@ uint64 ItemGroupDatabase::parseBodyNode(const YAML::Node &node) {
 	std::string group_name_constant = "IG_" + group_name;
 	int64 constant;
 
-	if (!script_get_constant(group_name_constant.c_str(), &constant) || constant < IG_BLUEBOX || constant >= IG_MAX) {
-		this->invalidWarning(node["Group"], "Invalid group %s.\n", group_name.c_str());
+	if (!script_get_constant(group_name_constant.c_str(), &constant) || constant < IG_BLUEBOX) {
+		if (strncasecmp(group_name.c_str(), "IG_", 3) != 0)
+			this->invalidWarning(node["Group"], "Invalid group %s.\n", group_name.c_str());
+		else
+			this->invalidWarning(node["Group"], "Invalid group %s. Note that 'IG_' is automatically appended to the group name.\n", group_name.c_str());
 		return 0;
 	}
 
@@ -1751,6 +1754,18 @@ uint64 ItemGroupDatabase::parseBodyNode(const YAML::Node &node) {
 						entry->GUID = item->flag.guid;
 				}
 
+				if (this->nodeExists(listit, "Stacked")) {
+					bool isStacked;
+
+					if (!this->asBool(listit, "Stacked", isStacked))
+						continue;
+
+					entry->isStacked = isStacked;
+				} else {
+					if (!entry_exists)
+						entry->isStacked = true;
+				}
+
 				if (this->nodeExists(listit, "Named")) {
 					bool named;
 

+ 1 - 0
src/map/itemdb.hpp

@@ -835,6 +835,7 @@ struct s_item_group_entry
 		amount; /// Amount of item will be obtained
 	bool isAnnounced, /// Broadcast if player get this item
 		GUID, /// Gives Unique ID for items in each box opened
+		isStacked, /// Whether stackable items are given stacked
 		isNamed; /// Named the item (if possible)
 	uint8 bound; /// Makes the item as bound item (according to bound type)
 };

+ 0 - 1
src/map/map-server.vcxproj

@@ -305,7 +305,6 @@
     <Copy SourceFiles="$(SolutionDir)db\import-tmpl\create_arrow_db.yml" DestinationFolder="$(SolutionDir)db\import\" ContinueOnError="true" Condition="!Exists('$(SolutionDir)db\import\create_arrow_db.yml')" />
     <Copy SourceFiles="$(SolutionDir)db\import-tmpl\elemental_db.txt" DestinationFolder="$(SolutionDir)db\import\" ContinueOnError="true" Condition="!Exists('$(SolutionDir)db\import\elemental_db.txt')" />
     <Copy SourceFiles="$(SolutionDir)db\import-tmpl\elemental_skill_db.txt" DestinationFolder="$(SolutionDir)db\import\" ContinueOnError="true" Condition="!Exists('$(SolutionDir)db\import\elemental_skill_db.txt')" />
-    <Copy SourceFiles="$(SolutionDir)db\import-tmpl\exp_guild.txt" DestinationFolder="$(SolutionDir)db\import\" ContinueOnError="true" Condition="!Exists('$(SolutionDir)db\import\exp_guild.txt')" />
     <Copy SourceFiles="$(SolutionDir)db\import-tmpl\exp_homun.yml" DestinationFolder="$(SolutionDir)db\import\" ContinueOnError="true" Condition="!Exists('$(SolutionDir)db\import\exp_homun.yml')" />
     <Copy SourceFiles="$(SolutionDir)db\import-tmpl\exp_guild.yml" DestinationFolder="$(SolutionDir)db\import\" ContinueOnError="true" Condition="!Exists('$(SolutionDir)db\import\exp_guild.yml')" />
     <Copy SourceFiles="$(SolutionDir)db\import-tmpl\guild_skill_tree.yml" DestinationFolder="$(SolutionDir)db\import\" ContinueOnError="true" Condition="!Exists('$(SolutionDir)db\import\guild_skill_tree.yml')" />