• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Fixed Build 14 Beta 4.0: Game crashes on worldmap almost instantly after loading

Have anybody being looking at the System log ?
 

Attachments

  • system.log
    534 bytes · Views: 91
The stack overflow error happens for example in an endless loop. Something like this seems to be happening here.
 
Found the problem after some tracing. it's in this function:
Code:
void SetCharacterGoods(ref _refCharacter,int _Goods,int _Quantity)
{
//    if (IsTrader(_refCharacter)) return; // KK - PB: Quest traders need cargo too
    string goodsName = Goods[_Goods].name;
    string goodsAttr = "Ship.Cargo.Goods." + goodsName; // PB: Prevent errors
    if (sti(GetAttribute(_refCharacter, goodsAttr)) == _Quantity) return; // KK
    _refCharacter.Ship.Cargo.Goods.(goodsName) = _Quantity;
    int curLoad = RecalculateCargoLoad(_refCharacter);
    trace("curload ="+curLoad);
    int maxLoad = GetCargoMaxSpace(_refCharacter);
    trace("maxload ="+maxLoad);
    if(curLoad>maxLoad)
    {
// KK -->
        //Trace("ERROR! Cargo space overup (character=" + _refCharacter.index + ",Quantity=" + _Quantity + ", curload=" + curLoad + ",maxload=" + maxLoad + ")"); // NK 05-04-06
        trace("overload");
        ClearCharacterGoods(_refCharacter, _Goods);
        SetCharacterGoods(_refCharacter, _Goods, GetGoodQuantityByWeight(_Goods, GetCargoFreeSpace(_refCharacter)));
// <-- KK
    }
}
this is what I get in the compile
Code:
curload =4737
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
curload =4681
maxload =4679
overload
And that goes on and on.
Will now look more into it
 
'SetCharacterGoods' does end up calling itself there.
Though of course when it does, it should do so only ONCE and not keep going.

Apparently 'GetGoodQuantityByWeight(_Goods, GetCargoFreeSpace(_refCharacter))' somehow returns a value that ALSO triggers an overload.
Which should be impossible, because how can you overload a ship by filling up only the empty space?
Maybe there are some rounding errors going on?

Additionally, how can the amount of goods on the ship go UP at Midnight?
It should only go DOWN due to food/rum consumption! :shock
 
For some reason the ship has a bit more cargo. I have no idea what causes it, when I go to the sea it show the cargo properly.
I sugest this change so at least there is an escape:

Code:
void SetCharacterGoods(ref _refCharacter,int _Goods,int _Quantity)
{
//    if (IsTrader(_refCharacter)) return; // KK - PB: Quest traders need cargo too
    string goodsName = Goods[_Goods].name;
    string goodsAttr = "Ship.Cargo.Goods." + goodsName; // PB: Prevent errors
    if (sti(GetAttribute(_refCharacter, goodsAttr)) == _Quantity) return; // KK
    _refCharacter.Ship.Cargo.Goods.(goodsName) = _Quantity;
    int curLoad = RecalculateCargoLoad(_refCharacter);
    trace("curload ="+curLoad);
    int maxLoad = GetCargoMaxSpace(_refCharacter);
    trace("maxload ="+maxLoad);
    if(curLoad>maxLoad && _Quantity>0)
    {
// KK -->
        //Trace("ERROR! Cargo space overup (character=" + _refCharacter.index + ",Quantity=" + _Quantity + ", curload=" + curLoad + ",maxload=" + maxLoad + ")"); // NK 05-04-06
        trace("overload");
        ClearCharacterGoods(_refCharacter, _Goods);
        SetCharacterGoods(_refCharacter, _Goods, GetGoodQuantityByWeight(_Goods, GetCargoFreeSpace(_refCharacter)));
// <-- KK
    }
}

Included is a file with this fix. Place it in:
...\PROGRAM\Characters

You do need to have the latest zip from 13-9 installed. Else do the mod yourself in this file. its only 1 line to change.
I've tested this and it doesn't crash the game anymore
 

Attachments

  • CharacterUtilite.c
    146.4 KB · Views: 105
For some reason the ship has a bit more cargo.
So the ship somehow had MORE cargo than actually fit in the ship BEFORE the crash occurred?
And that 'overload' failsafe was doing its best, but all it was doing was to set the goods to 0 for one type of good and that wasn't actually enough to solve the overload?

I can see how that might be a problem.
Beats me how it can even happen though! o_O
 
So the ship somehow had MORE cargo than actually fit in the ship BEFORE the crash occurred?
And that 'overload' failsafe was doing its best, but all it was doing was to set the goods to 0 for one type of good and that wasn't actually enough to solve the overload?

I can see how that might be a problem.
Beats me how it can even happen though! o_O
Beats me too. After applying this fix the goods are set right and the next day I have less cargo because food etc is also deducted. This will prevent the function from going into an endless loop. And personally I'm not feeling up to the task of decyphering the whole daily update code to see what is happening there if this fixes it too
 
Beats me too. After applying this fix the goods are set right and the next day I have less cargo because food etc is also deducted. This will prevent the function from going into an endless loop. And personally I'm not feeling up to the task of decyphering the whole daily update code to see what is happening there if this fixes it too
Fair enough. It may not address the root cause, but does solve the main issue of the game crashing. :onya
 
Back
Top