summaryrefslogtreecommitdiff
path: root/src/map/itemdb.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-06 21:22:20 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-06 21:22:20 +0000
commit5b1d1678fd03d6c780e933f6e464e3b02a860c0d (patch)
tree65b746ac53e67d12d9958223e095697bb8f20123 /src/map/itemdb.c
parent7afdfd0b4b60c52af9f4e488bb1208a426a5bddc (diff)
downloadhercules-5b1d1678fd03d6c780e933f6e464e3b02a860c0d.tar.gz
hercules-5b1d1678fd03d6c780e933f6e464e3b02a860c0d.tar.bz2
hercules-5b1d1678fd03d6c780e933f6e464e3b02a860c0d.tar.xz
hercules-5b1d1678fd03d6c780e933f6e464e3b02a860c0d.zip
- Rewrote all the item restriction functions so that they will take into account slotted card restrictions as well.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7552 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/itemdb.c')
-rw-r--r--src/map/itemdb.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 80a58a520..669324532 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -289,48 +289,63 @@ static int itemdb_ispetequip(struct item_data *data)
* Trade Restriction functions [Skotlex]
*------------------------------------------
*/
-int itemdb_isdropable(int nameid, int gmlv)
+int itemdb_isdropable_sub(struct item_data *item, int gmlv, int unused)
{
- struct item_data* item = itemdb_exists(nameid);
return (item && (!(item->flag.trade_restriction&1) || gmlv >= item->gm_lv_trade_override));
}
-int itemdb_cantrade(int nameid, int gmlv, int gmlv2)
+int itemdb_cantrade_sub(struct item_data* item, int gmlv, int gmlv2)
{
- struct item_data* item = itemdb_exists(nameid);
return (item && (!(item->flag.trade_restriction&2) || gmlv >= item->gm_lv_trade_override || gmlv2 >= item->gm_lv_trade_override));
}
-int itemdb_canpartnertrade(int nameid, int gmlv, int gmlv2)
+int itemdb_canpartnertrade_sub(struct item_data* item, int gmlv, int gmlv2)
{
- struct item_data* item = itemdb_exists(nameid);
return (item && (item->flag.trade_restriction&4 || gmlv >= item->gm_lv_trade_override || gmlv2 >= item->gm_lv_trade_override));
}
-int itemdb_cansell(int nameid, int gmlv)
+int itemdb_cansell_sub(struct item_data* item, int gmlv, int unused)
{
- struct item_data* item = itemdb_exists(nameid);
return (item && (!(item->flag.trade_restriction&8) || gmlv >= item->gm_lv_trade_override));
}
-int itemdb_cancartstore(int nameid, int gmlv)
+int itemdb_cancartstore_sub(struct item_data* item, int gmlv, int unused)
{
- struct item_data* item = itemdb_exists(nameid);
return (item && (!(item->flag.trade_restriction&16) || gmlv >= item->gm_lv_trade_override));
}
-int itemdb_canstore(int nameid, int gmlv)
+int itemdb_canstore_sub(struct item_data* item, int gmlv, int unused)
{
- struct item_data* item = itemdb_exists(nameid);
return (item && (!(item->flag.trade_restriction&32) || gmlv >= item->gm_lv_trade_override));
}
-int itemdb_canguildstore(int nameid, int gmlv)
+int itemdb_canguildstore_sub(struct item_data* item, int gmlv, int unused)
{
- struct item_data* item = itemdb_exists(nameid);
return (item && (!(item->flag.trade_restriction&64) || gmlv >= item->gm_lv_trade_override));
}
+int itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, int (*func)(struct item_data*, int, int))
+{
+ struct item_data* item_data = itemdb_search(item->nameid);
+ int i;
+
+ if (!func(item_data, gmlv, gmlv2))
+ return 0;
+
+ if(item_data->slot == 0 ||
+ item->card[0] ==(short)0xff00 ||
+ item->card[0]==0x00ff ||
+ item->card[0]==0x00fe)
+ return 1;
+
+ for(i = 0; i < item_data->slot; i++) {
+ if (!item->card[i]) continue;
+ if (!func(itemdb_search(item->card[i]), gmlv, gmlv2))
+ return 0;
+ }
+ return 1;
+}
+
/*==========================================
*
*------------------------------------------