summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
author(no author) <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-02-03 11:20:57 +0000
committer(no author) <(no author)@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-02-03 11:20:57 +0000
commitf47e370d5cffc16a6ee4888c76768f9309e1fe83 (patch)
tree6442c0e8367a349e98bd47d3dc622dd7d7167c82 /src/map/npc.c
parentaa37b7a6b65b3699c3c62903e6c744ae329de423 (diff)
downloadhercules-f47e370d5cffc16a6ee4888c76768f9309e1fe83.tar.gz
hercules-f47e370d5cffc16a6ee4888c76768f9309e1fe83.tar.bz2
hercules-f47e370d5cffc16a6ee4888c76768f9309e1fe83.tar.xz
hercules-f47e370d5cffc16a6ee4888c76768f9309e1fe83.zip
* When loading shop scripts automatically check if the prices can be exploited with OC/DC
* If the buying price provided in item_db.txt is above 2x higher than selling price for an item no need to reset and redetermine the buying price git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/stable@1024 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 49608720b..cbb6c5495 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1513,15 +1513,21 @@ static int npc_parse_shop(char *w1,char *w2,char *w3,char *w4)
while (p && pos < max) {
int nameid,value;
+ struct item_data *id;
p++;
if (sscanf(p, "%d:%d", &nameid, &value) != 2)
break;
nd->u.shop_item[pos].nameid = nameid;
- if (value < 0) {
- struct item_data *id = itemdb_search(nameid);
+ id = itemdb_search(nameid);
+ if (value < 0)
value = id->value_buy;
- }
nd->u.shop_item[pos].value = value;
+ // check for bad prices that can possibly cause exploits
+ if (value*75/100 < id->value_sell*124/100) {
+ sprintf (tmp_output, "Item %s [%d] buying:%d < selling:%d\n",
+ id->name, id->nameid, value*75/100, id->value_sell*124/100);
+ ShowWarning (tmp_output);
+ }
pos++;
p=strchr(p,',');
}