Issue information

Issue ID
#2756
Status
Duplicate
Severity
None
Started
Hercules Elf Bot
Feb 9, 2009 22:31
Last Post
Hercules Elf Bot
Feb 9, 2009 22:31
Confirmation
N/A

Hercules Elf Bot - Feb 9, 2009 22:31

Originally posted by [b]Baltazar[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=2756

Script.c, function checkweight.
//TODO: Currently does not checks if you can just stack it on top of another item you already have....

I wrote some code that will check if you can stack, and if the item is not stackable, it'll check for enough free spaces, instead of just one.
I hope it is implemented, because many bugs could come from this function.

CODE
        if(itemdb_isstackable(nameid)){
            i = pc_search_inventory(sd,nameid);
            if( i >= 0 ) { //If you can stack it on top of another item
                script_pushint(st,1);
            } else {
                i = pc_search_inventory(sd,0);
                if (i >= 0) //Empty slot available.
                    script_pushint(st,1);
                else //Inventory full
                    script_pushint(st,0);
            }
        } else {
            for( i = 0; i < MAX_INVENTORY; ++i ){ //If you cannot stack the item, you'll need several places on the inventory
                if( sd->status.inventory[i].nameid == 0 ){ //If you find an empty space, deduct from the amount of places needed
                    amount--;
                    if(amount == 0){ //There are enough spaces available
                        break;
                    }
                }
            }
            if (amount == 0) //Empty slot available.
                script_pushint(st,1);
            else //Inventory full
                script_pushint(st,0);
        }