bitburner-official / bitburner-src

Bitburner source code.
Other
826 stars 270 forks source link

Error in Warehouse.ts:65 -> warehouse size exceeded the limit #683

Closed AssenD closed 1 year ago

AssenD commented 1 year ago

I'm trying to automate buying boosts for a division. And came to this error:

2023-07-28 15_27_47-ERROR

It happened after/during buying boosts in a cycle like that:

// should consider warehouse size (and qty already stored in the warehouse)
    for (let city of division.cities) {
        let wh = corp.getWarehouse(divName, city);
        let freeSize = wh.size - wh.sizeUsed;
        for (let [boost, prc] of pctBoostsDist) {
            mat = corp.getMaterial(divName, city, boost);
            let marketPrice = mat.marketPrice;
            let qty = mat.stored;
            let matSize = corp.getMaterialData(boost).size;
            let boostBudget = Math.floor(budgetPerCity * prc); // ensure we stay in the budget
            let qtyToBuy = boostBudget / marketPrice;
            if (freeSize * 0.5 > qtyToBuy * matSize) { // reserve 50% of the warehouse space
                corp.bulkPurchase(divName, city, boost, qtyToBuy);
            }
        }
    }

I found my error in above code - should refresh warehouse size after each purchase, but still :)

AssenD commented 1 year ago

Could someone explain, please, how the boosts work: a) based on size they occupy in the warehouse or b) based on quantity bought or maybe it's something more complex?

Found it in the sources - it's a) "boosts" material.stored in the wh...

Hoekstraa commented 1 year ago

The game should at least handle the warning/error differently. Thanks for the report!