diff options
author | Inkfish <Inkfish@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2009-05-07 10:38:00 +0000 |
---|---|---|
committer | Inkfish <Inkfish@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2009-05-07 10:38:00 +0000 |
commit | a609245253626fd1d8112d4b05959471723b7d8f (patch) | |
tree | fc9ec0ed252398bc3b2276626891275d63ee9adb /src/map/script.c | |
parent | 236e19c49cbcbff7cde02e4ffeb1ee524d13ea07 (diff) | |
download | hercules-a609245253626fd1d8112d4b05959471723b7d8f.tar.gz hercules-a609245253626fd1d8112d4b05959471723b7d8f.tar.bz2 hercules-a609245253626fd1d8112d4b05959471723b7d8f.tar.xz hercules-a609245253626fd1d8112d4b05959471723b7d8f.zip |
* Added check on stackable items to 'checkweight' (bugreport:1569, bugreport:2756, bugreport 2994) [Inkfish]
* Fixed flee penalty wasn't applied for battleground and wouldn't be restored on map change [Inkfish]
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13735 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/map/script.c b/src/map/script.c index a29b08423..6fb3d662c 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -5104,18 +5104,21 @@ BUILDIN_FUNC(checkweight) } weight = itemdb_weight(nameid)*amount; - if(amount > MAX_AMOUNT || weight + sd->weight > sd->max_weight){ + if( amount > MAX_AMOUNT || weight + sd->weight > sd->max_weight ) script_pushint(st,0); - } else { - //Check if the inventory ain't full. - //TODO: Currently does not checks if you can just stack it on top of another item you already have.... - - i = pc_search_inventory(sd,0); - if (i >= 0) //Empty slot available. - script_pushint(st,1); - else //Inventory full - script_pushint(st,0); - + else if( itemdb_isstackable(nameid) ) + { + if( (i = pc_search_inventory(sd,nameid)) >= 0 ) + script_pushint(st,amount + sd->status.inventory[i].amount > MAX_AMOUNT ? 0 : 1); + else + script_pushint(st,pc_search_inventory(sd,0) >= 0 ? 1 : 0); + } + else + { + for( i = 0; i < MAX_INVENTORY && amount; ++i ) + if( sd->status.inventory[i].nameid == 0 ) + amount--; + script_pushint(st,amount ? 0 : 1); } return 0; |