Quellcode durchsuchen

Add support for unsetting bit flag in item_noequip (Closes #1319).
* Unset the flag by passing in negative value.
* Thanks to @Everade

Jittapan Pluemsumran vor 9 Jahren
Ursprung
Commit
5287f82a0e
4 geänderte Dateien mit 15 neuen und 1 gelöschten Zeilen
  1. 3 0
      db/import-tmpl/item_noequip.txt
  2. 3 0
      db/pre-re/item_noequip.txt
  3. 3 0
      db/re/item_noequip.txt
  4. 6 1
      src/map/itemdb.c

+ 3 - 0
db/import-tmpl/item_noequip.txt

@@ -18,10 +18,13 @@
 // 1024 - restricted in zone 6
 // 2048 - restricted in zone 7
 //
+// Passing negative value as flag will unset the flag instead.
+//
 // Examples:
 // 1201,1   // Knife can't be worn on normal maps
 // 608,4    // Yggdrasil Seed can't be consumed in both GvG and WoE Castles
 // 4174,6   // Deviling Card has no effect in every PVP or GVG map, and during WoE
 // 501,32   // Red Potion can't be consumed on maps marked as 'restricted zone 1'
 // 519,322  // Milk can't be consumed in PVP and maps marked as 'restricted zone 2' or 'restricted zone 4' (256+64+2)
+// 519,-2   // Unset `restricted in PVP` flag from Milk. Making it usable in PVP again.
 

+ 3 - 0
db/pre-re/item_noequip.txt

@@ -18,12 +18,15 @@
 // 1024 - restricted in zone 6
 // 2048 - restricted in zone 7
 //
+// Passing negative value as flag will unset the flag instead.
+//
 // Examples:
 // 1201,1   // Knife can't be worn on normal maps
 // 608,4    // Yggdrasil Seed can't be consumed in both GvG and WoE Castles
 // 4174,6   // Deviling Card has no effect in every PVP or GVG map, and during WoE
 // 501,32   // Red Potion can't be consumed on maps marked as 'restricted zone 1'
 // 519,322  // Milk can't be consumed in PVP and maps marked as 'restricted zone 2' or 'restricted zone 4' (256+64+2)
+// 519,-2   // Unset `restricted in PVP` flag from Milk. Making it usable in PVP again.
 
 //----------------------------------------------------------------------------
 // Normal maps

+ 3 - 0
db/re/item_noequip.txt

@@ -18,12 +18,15 @@
 // 1024 - restricted in zone 6
 // 2048 - restricted in zone 7
 //
+// Passing negative value as flag will unset the flag instead.
+//
 // Examples:
 // 1201,1   // Knife can't be worn on normal maps
 // 608,4    // Yggdrasil Seed can't be consumed in both GvG and WoE Castles
 // 4174,6   // Deviling Card has no effect in every PVP or GVG map, and during WoE
 // 501,32   // Red Potion can't be consumed on maps marked as 'restricted zone 1'
 // 519,322  // Milk can't be consumed in PVP and maps marked as 'restricted zone 2' or 'restricted zone 4' (256+64+2)
+// 519,-2   // Unset `restricted in PVP` flag from Milk. Making it usable in PVP again.
 
 //----------------------------------------------------------------------------
 // Normal maps

+ 6 - 1
src/map/itemdb.c

@@ -707,9 +707,11 @@ static void itemdb_read_itemgroup(const char* basedir, bool silent) {
 */
 static bool itemdb_read_noequip(char* str[], int columns, int current) {
 	unsigned short nameid;
+	int flag;
 	struct item_data *id;
 
 	nameid = atoi(str[0]);
+	flag = atoi(str[1]);
 
 	if( ( id = itemdb_exists(nameid) ) == NULL )
 	{
@@ -717,7 +719,10 @@ static bool itemdb_read_noequip(char* str[], int columns, int current) {
 		return false;
 	}
 
-	id->flag.no_equip |= atoi(str[1]);
+	if (flag >= 0)
+		id->flag.no_equip |= flag;
+	else
+		id->flag.no_equip &= ~abs(flag);
 
 	return true;
 }