From 5287f82a0e97b9c2dbbae55fc268b04ff331a126 Mon Sep 17 00:00:00 2001 From: Jittapan Pluemsumran Date: Sat, 28 May 2016 00:20:08 +0700 Subject: [PATCH] Add support for unsetting bit flag in item_noequip (Closes #1319). * Unset the flag by passing in negative value. * Thanks to @Everade --- db/import-tmpl/item_noequip.txt | 3 +++ db/pre-re/item_noequip.txt | 3 +++ db/re/item_noequip.txt | 3 +++ src/map/itemdb.c | 7 ++++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/db/import-tmpl/item_noequip.txt b/db/import-tmpl/item_noequip.txt index 6d426aa5c5..084e493228 100644 --- a/db/import-tmpl/item_noequip.txt +++ b/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. diff --git a/db/pre-re/item_noequip.txt b/db/pre-re/item_noequip.txt index 47d26f23e4..6a87d043be 100644 --- a/db/pre-re/item_noequip.txt +++ b/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 diff --git a/db/re/item_noequip.txt b/db/re/item_noequip.txt index 1af0a5807c..f49f0f7078 100644 --- a/db/re/item_noequip.txt +++ b/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 diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 3128f34bb1..fcfadc5331 100644 --- a/src/map/itemdb.c +++ b/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; }