• 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!

Unconfirmed Bug Spent the last few days playing and got a ton of bugs, also can't finish(?) main quest in Coruzel

Slight problem:
bombs_for_sale.jpg

And "error.log" contains a lot of this:
Code:
RUNTIME ERROR - file: store\storeutilite.c; line: 288
function must return value
RUNTIME ERROR - file: store\storeutilite.c; line: 288
function 'GetStoreGoodsUsed' stack error
 
And "error.log" contains a lot of this:
Huh? Quick look through the function:
Code:
bool GetStoreGoodsUsed(ref _refStore,int _Goods)
{
    ref ctown = GetTownFromID(GetTownIDFromGroup(_refStore.group));//PW for using island not store attributes
    int tradeType = GetGoodTradeType(Islands[FindIsland(ctown.island)], _Goods);//PW for using island not store attributes

    string tmpstr = Goods[_Goods].name;
    if( !CheckAttribute(_refStore,"Goods."+tmpstr) ) return false;
    if( sti(_refStore.Goods.(tmpstr).NotUsed)==true ) return false;
    //if (sti(_refStore.Goods.(tmpstr).TradeType) == TRADE_TYPE_CONTRABAND) {
    if (tradeType == TRADE_TYPE_CONTRABAND)) {// PW change to function to use island based tradeType
        if (!CheckOfficersPerk(GetMainCharacter(),"Trustworthy") && !LAi_IsCapturedLocation && GetTownNation(GetTownIDFromGroup(_refStore.group)) != PERSONAL_NATION) return false; // KK
    }

    // KNB - Check NoTrade flag for goods.
    if( CheckAttribute(Goods[_Goods],"NoTrade") && Goods[_Goods].NoTrade == true) return false;

    return true;
}
I'd expect that error if there is a 'return' line without 'true/false' in a 'bool' function.
But none of them are missing the value, so at first glance it shouldn't trigger those errors...

That said, if the STORE goods shouldn't be used anymore, does that mean these two lines are superfluous now too?
Code:
    if( !CheckAttribute(_refStore,"Goods."+tmpstr) ) return false;
    if( sti(_refStore.Goods.(tmpstr).NotUsed)==true ) return false;
 
Slight problem:
View attachment 37370

And "error.log" contains a lot of this:
Code:
RUNTIME ERROR - file: store\storeutilite.c; line: 288
function must return value
RUNTIME ERROR - file: store\storeutilite.c; line: 288
function 'GetStoreGoodsUsed' stack error

Huh? Quick look through the function:

I'd expect that error if there is a 'return' line without 'true/false' in a 'bool' function.
But none of them are missing the value, so at first glance it shouldn't trigger those errors...

That said, if the STORE goods shouldn't be used anymore, does that mean these two lines are superfluous now too?
Code:
    if( !CheckAttribute(_refStore,"Goods."+tmpstr) ) return false;
    if( sti(_refStore.Goods.(tmpstr).NotUsed)==true ) return false;

Possibly I was just (stupidly) trying to be simple and change how that TRADE_TYPE_CONTRABAND was acquired, I would have to check how bombs are cut out (since now they apparently aren't - so not via .NotUsed).

Actually @Levis GetStoreGoodsType function returns TRADE_TYPE_CONTRABAND_NAME and I should have changed to using that so I could use the whole function rather than hacking half of it. I guess I will look further into it.
 
Fixed. It's the bane of modders, a misplaced bracket on this line:
Code:
if (tradeType == TRADE_TYPE_CONTRABAND)) {// PW change to function to use island based tradeType
Corrected to:
Code:
    if(tradeType == TRADE_TYPE_CONTRABAND)
   {
Only one ')' after "TRADE_TYPE_CONTRABAND". Also, the '{' is now on its own line and properly indented, aligned with the closing '}' which makes it clearer which code is inside the block.

With that version, the bombs are gone and so is the error message. And it does seem to do what was intended. Start a new game of "Tales of a Sea Hawk", which puts you in Speightstown. Ebony and coffee appear on the contraband list in the "Colonies" interface and do not appear in the store. Paprika is not on the contraband list but is defined as contraband in the island's definition. With the original version of "StoreUtilite.c", paprika does not appear in the store. With the new version, paprika does appear, while ebony and coffee are still not in the store. Job done, I would say.
 

Attachments

  • StoreUtilite.c
    15.4 KB · Views: 121
Fixed. It's the bane of modders, a misplaced bracket on this line:
Code:
if (tradeType == TRADE_TYPE_CONTRABAND)) {// PW change to function to use island based tradeType
Job done, I would say.

Thanks for the work to find and sort it.
 
It's the bane of modders, a misplaced bracket on this line:
Code:
if (tradeType == TRADE_TYPE_CONTRABAND)) {// PW change to function to use island based tradeType
Huh; I thought I had seen same-line opening brackets before.
Maybe because the { is followed immediately by the // ?

Good catch and fix in any case. :cheers
 
The only reason I noticed it was that I don't like '{' at the end of a line and also initially wondered whether having it right next to the '//' was fouling it up. That's what drew my attention to that line, and that's when I noticed the '))'.

I've moved the '{' onto its own line, properly indented. It makes code easier to read if the opening '{' and closing '}' are on their own lines, equally indented, with the content of the block indented one tab further. Especially when there are nested blocks.
 
The only reason I noticed it was that I don't like '{' at the end of a line
[...]
It makes code easier to read if the opening '{' and closing '}' are on their own lines, equally indented, with the content of the block indented one tab further. Especially when there are nested blocks.
I definitely agree it reads much nicer that way. :onya
 
Back
Top