summaryrefslogtreecommitdiff
path: root/src/map/itemdb.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/itemdb.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/itemdb.c')
-rw-r--r--src/map/itemdb.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index dd8de15d4..971f6cacf 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -326,13 +326,29 @@ static int itemdb_readdb(void)
memcpy(id->name,str[1],24);
memcpy(id->jname,str[2],24);
id->type=atoi(str[3]);
- // buy≠sell*2 は item_value_db.txt で指定してください。
- if (atoi(str[5])) { // sell値を優先とする
- id->value_buy=atoi(str[5])*2;
- id->value_sell=atoi(str[5]);
- } else {
- id->value_buy=atoi(str[4]);
- id->value_sell=atoi(str[4])/2;
+
+ {
+ int buy = atoi(str[4]), sell = atoi(str[5]);
+ // if buying price > selling price * 2 consider it valid and don't change it [celest]
+ if (buy && sell && buy > sell*2){
+ id->value_buy = buy;
+ id->value_sell = sell;
+ } else {
+ // buy≠sell*2 は item_value_db.txt で指定してください。
+ if (sell) { // sell値を優先とする
+ id->value_buy = sell*2;
+ id->value_sell = sell;
+ } else {
+ id->value_buy = buy;
+ id->value_sell = buy/2;
+ }
+ }
+ // check for bad prices that can possibly cause exploits
+ if (id->value_buy*75/100 < id->value_sell*124/100) {
+ sprintf (tmp_output, "Item %s [%d] buying:%d < selling:%d\n",
+ id->name, id->nameid, id->value_buy*75/100, id->value_sell*124/100);
+ ShowWarning (tmp_output);
+ }
}
id->weight=atoi(str[6]);
id->atk=atoi(str[7]);