• 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 Crash from Cargo Quest: Martinho Guterres in Sao Jorge

Redbeard

Sailor
The shopkeeper in Sao Jorge regularly crashes my game 50% of the time. It happens when asking for a charter mission. Before he can respond it just freezes up. :\ This has never happened in another conversation for any reason.

I save before every time talking to him. Can anyone else confirm?

28 July build Beta 4.1 wip.
 
Last edited:
When asking for a mission, eh?
Please post a savegame and also a screenshot of your Nations Relations interface.
I assume the town is Portuguese?
 
The shopkeeper in Sao Jorge regularly crashes my game 50% of the time. It happens when asking for a charter mission. Before he can respond it just freezes up. :\ This has never happened in another conversation for any reason.

I save before every time talking to him. Can anyone else confirm?

28 July build Beta 4.1 wip.
Could you check for me if its only this specific character?
Btw don't you mean the tavern keeper? Shop keepers don't give escort missions right?
 
No, Martinho Guterres is the storekeeper. Storekeepers don't offer escort missions but they can offer charter cargo delivery missions. ;) That's probably what is crashing @Redbeard's game.
 
No, Martinho Guterres is the storekeeper. Storekeepers don't offer escort missions but they can offer charter cargo delivery missions. ;) That's probably what is crashing @Redbeard's game.
Oh wait I read it wrong :read.

The same question though. Please check if the problem is with other shopkeepers too.
 
Before I head off to work real fast. No it isn't only this guy and only when I ask for a mission. Yes Portuguese. Relations are Nathanial hawk relations. His standard allied status with them
 
Before I head off to work real fast. No it isn't only this guy and only when I ask for a mission. Yes Portuguese. Relations are Nathanial hawk relations. His standard allied status with them
Please post a savegame when you can. Doesn't have to be right now though.

My suspicion is that the code gets into an endless loop, which eventually crashes the game.
We've had that before. Just need to trace why it is happening this time, which requires a savegame to test from.
 
Problem should be in this piece of code from his dialog file then:
Code:
case "quests":
            iTest = 0;
            Dialog.text = DLG_TEXT[19];
            int iQuantityShipGoods;
            int iQuestTradeGoods;
            if (CheckAttribute(pchar, "quest.generate_trade_quest_progress.iQuantityGoods"))    // LDH was quest.quest.generate, fixed 01Jan09
            {
                iQuantityShipGoods = pchar.quest.generate_trade_quest_progress.iQuantityGoods;
                iQuestTradeGoods = pchar.quest.generate_trade_quest_progress.iTradeGoods;
            }
            if (CheckQuestAttribute("generate_trade_quest_progress", "begin") || CheckQuestAttribute("generate_trade_quest_progress",  "failed"))
            {
                if (GetSquadronGoods(pchar, iQuestTradeGoods) >= iQuantityShipGoods && pchar.quest.generate_trade_quest_progress.iTradeColony == GetCurrentTownID() && CheckAttribute(PChar, "quest.generate_trade_quest_progress.iTradeExp"))
                {
                    dialog.text = DLG_TEXT[20];
                    link.l1 = DLG_TEXT[21];
                    link.l1.go = "generate_quest_2";
                }
            }
            else
            {
                if (!CheckQuestAttribute("generate_trade_quest_progress", "begin"))
                {
                    link.l1 = DLG_TEXT[22];
                    link.l1.go = "generate_quest";
                }
            }
            link.l99 = DLG_TEXT[23];
            Link.l99.go = "no_quests";
        break;

here is the code from James Griffith. If it's only with this specific shopkeeper we should see a difference:
Code:
case "quests":
            iTest = 0;
            Dialog.text = DLG_TEXT[19];
            if (CheckAttribute(pchar, "quest.generate_trade_quest_progress.iQuantityGoods"))
            {
                int iQuantityShipGoods = pchar.quest.generate_trade_quest_progress.iQuantityGoods;
                int iQuestTradeGoods = pchar.quest.generate_trade_quest_progress.iTradeGoods;
            }
            if (CheckQuestAttribute("generate_trade_quest_progress", "begin") || CheckQuestAttribute("generate_trade_quest_progress",  "failed"))
            {
                if (GetSquadronGoods(pchar, iQuestTradeGoods) >= iQuantityShipGoods && pchar.quest.generate_trade_quest_progress.iTradeColony == GetCurrentTownID() && CheckAttribute(PChar, "quest.generate_trade_quest_progress.iTradeExp"))
                {
                    dialog.text = DLG_TEXT[20];
                    link.l1 = DLG_TEXT[21];
                    link.l1.go = "generate_quest_2";
                }
            }
            else
            {
                if (!CheckQuestAttribute("generate_trade_quest_progress", "begin"))
                {
                    link.l1 = DLG_TEXT[22];
                    link.l1.go = "generate_quest";
                }
            }
            link.l99 = DLG_TEXT[23];
            Link.l99.go = "exit";
        break;
 
Problem should be in this piece of code from his dialog file then:
You should follow the "generate_quest" line. That should eventually call some sort of "Generate Cargo Quest" function that is in quests_common.c .
I'd suspect the problem to lie there somewhere.
 
If we have a savegame we can easily trace where it goes wrong. so let's wait till we got that
 
Here is a save, confirmed crash follows on my computer. It only happens when asking for a charter mission. It also only happens when you don't already have a charter mission.

As soon as you select the "I have a ship and a loyal crew" Or what not, asking for the charter mission, you should freeze up. The game hard shuts down for me. Forcing a ctrl alt del
 

Attachments

  • -=Campaign=- La Grenade.zip
    850 KB · Views: 169
I also forgot to mention, this happens across different profiles and characters. It happens with a freeplay save set during the Golden Age of Piracy in 1680, Hence why I didn't post a screenshot of relations. Every time it has happened the town has been portuguese. If that helps.
 
@Redbeard: Just to confirm, you have the 28 July 2016 EXE version and did NOT install any ZIP updates afterwards?
Or did you? By accident, the previous ZIP did not update the date, so the game would still show the same date, but actually be quite different.

Reason being that I tried to replicate the issue on my own game version (which is virtually identical to the actual 28 Jul 2016 version as I didn't install the ZIPs yet myself).
This is what happened:
upload_2016-9-14_22-56-47.png


And then no crash, but a valid quest:
upload_2016-9-14_22-57-9.png

This was my second try. First time he wanted to send me to Kingston, Jamaica, which is also fine.
In other words: As far as I can tell, this is working fine in my own game version.

Maybe @Levis could also try to replicate it on his end since he's got a somewhat different game version?
 
I had expected the problem to be due to 'GenerateNationTrade', but turns out it is not.
Instead, that one returns a valid number. But that number is 5, which equals Portugal.

But I think I understand the real problem now and it is actually in the 'GenerateTradeQuest' function in MAXIMUS_functions.c, specifically here:
Code:
  if (friendlyTowns != "") {
     sTown = GetRandSubString(friendlyTowns);
     while (sTown == "" || HasSubStr(sTown, ",") || GetIslandIDFromTown(sTown) == GetIslandIDFromTown(GetCurrentTownId()))
     {
       sTown = GetRandSubString(friendlyTowns);
     }
   } else {
     sTown = "Quebradas Costillas"; //MAXIMUS: Quebradas Costillas - why some trader can't trade with pirates?
   }
If you're at the ONLY Portuguese island, then the only friendly town is the one you're already at.
And that one is on your current island, is therefore no valid destination, and that 'while' keeps going for all eternity.
Until the game has had enough and decides to crash instead.
 
so adding some kind of counter there to escape the while loop and then just pick
Quebradas Costillas would fix it right?
 
so adding some kind of counter there to escape the while loop and then just pick
Quebradas Costillas would fix it right?
I think so, yes. Trying to think of the best way to solve that now.
 
what about this?
Code:
int numFtowns = 0;
    for(i = 0; i < TOWNS_QUANTITY; i++)
    {
        if(!CheckAttribute(&Towns[i],"id")) continue;
        if(!CheckAttribute(&Towns[i],"nation")) continue;
        if(GetAttribute(&Towns[i],"skiptrade") == true) continue;//MAXIMUS: added for some towns (such as St. John's on Antigua)
        if(sti(Towns[i].nation) != iTradeNation) continue;
        friendlyTowns = StoreString(friendlyTowns,Towns[i].id);
        numFtowns++;
    }
    if (friendlyTowns != "" && numFtowns>0) {
        sTown = GetRandSubString(friendlyTowns);
        while (sTown == "" || HasSubStr(sTown, ",") || GetIslandIDFromTown(sTown) == GetIslandIDFromTown(GetCurrentTownId()))
        {
            sTown = GetRandSubString(friendlyTowns);
        }
    } else {
        sTown = "Quebradas Costillas"; //MAXIMUS: Quebradas Costillas - why some trader can't trade with pirates?
    }
 
Or wait even better. In the forloop above you should just check if the town is equal to your current town ... if that is the case you should continue too. Now it will generate a empty friendlyTowns if there is only 1 friendly town for portugal
 
'numFtowns' would be 1 though, since Sao Jorge itself would be included.
I think I've thought of a good way to fix it, basically by moving the 'GetIslandIDFromTown(sTown) == GetIslandIDFromTown(GetCurrentTownId())' check into that for-loop instead.
That makes a lot of sense to me; testing now how that works.

EDIT: Looks like @Levis pretty much had the same thought at the same time. :cheeky
 
Back
Top