• 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 Boarding: Inconsistent Crashes Related to Looting

The boarding fix we did yesterday should not have affected this problem at all; it is a long-standing one and I see no reason why it should be better now than it was before.
So @Levis: Will you be looking into fixing this one for real then?
 
After all other stuff is Done, this one is high on my list yes.
I hope to add some logging code at least somewhere soonish so we can see where it goes wrong.
 
I'm marking this back as "Low Priority" since I don't think we'll see this fully fixed prior to Beta 4 and it is relatively easy to avoid.
 
while looking into misterious repairing of ship I found this:
Code:
void procActionRepair()
{
    int chrIdx = GetEventData();
    int eRepType = GetEventData();
    if(chrIdx<0) return;
    if(!bSeaActive)    return;
    ref chref = GetCharacter(chrIdx);
    if( LAi_IsDead(chref) ) return;

    if(eRepType!=0)
    {
        float fMaterialH = GetEventData();
        float fMaterialS = GetEventData();
    }

    if(bAbordageStarted)
    {
        if(eRepType==0)
        {
            PostEvent("evntActionRepair",BI_FAST_REPAIR_PERIOD,"ll", chrIdx, 0);
        }
        else
        {
            PostEvent("evntActionRepair",BI_FAST_REPAIR_PERIOD,"llff", chrIdx, eRepType, fMaterialH,fMaterialS);
        }
        return;
    }

the evntActionRepair goes to the function procActionRepair. So if this is called with eRepType != 0 when abordagestarted == true it will cause a infinite loop which will cause a CTD without error.log files.
Maybe this is the cause of the ctd's during boarding?
 
Why are there repairs going on during boarding???
beats me. I'm trying to make sensse of this code too.
I'm tempted on just commenting the event calls and make it return during boarding.
 
Also, if it is because of "being repaired", why would that in any way seem to be triggered by looting?
 
Also, if it is because of "being repaired", why would that in any way seem to be triggered by looting?
I don't know.
Maybe because when you are looting your longer in the location so the time spend is longer so more repairs can be done or something like that?
I found it and it does seems to be weird. might not be the whole cause....
 
Currently while playing build 14.3 every time I try to capture a ship bigger than a Frigate the game crashes after the second deck, I checked the error log and it says this, I'm running a i7-4790K with 16gig ram and GTX980 graphics card

RUNTIME ERROR - file: Loc_ai\LAi_equip.c; line: 141
missed attribute: firstperiod
RUNTIME ERROR - file: Loc_ai\LAi_equip.c; line: 141
no rAP data
RUNTIME ERROR - file: Loc_ai\LAi_equip.c; line: 141
missed attribute: lastperiod
RUNTIME ERROR - file: Loc_ai\LAi_equip.c; line: 141
no rAP data
RUNTIME ERROR - file: Loc_ai\LAi_equip.c; line: 141
missed attribute: firstperiod
RUNTIME ERROR - file: Loc_ai\LAi_equip.c; line: 141
no rAP data
RUNTIME ERROR - file: Loc_ai\LAi_equip.c; line: 141
missed attribute: lastperiod
RUNTIME ERROR - file: Loc_ai\LAi_equip.c; line: 141
no rAP data
 
I think I made a fix for that error log in the Beta 4 versions, but that is unlikely to be the cause of the crash anyway.

Are you looting all your enemies?
Try to NOT loot any enemies and see if it works better then.
Looting has been known to trigger CTDs for unknown reasons. :facepalm
 
Looks like I’m typically not crashing so long as I have no sail cloths. ;)
Well... it seems that boarding is not saved per-se, I’m being booted back to the sea upon reloading. I don’t know yet, but I’m assuming that loot, crew status, etc, is saved, but the boarding must be done again. Therefore, I wonder what might happen if I kill the captain and then save/reload?

Anyway, I’ve found something. I have disabled ENABLE_EXTRA_SOUNDS and it seems now that the game is crashing not only every time I loot a body, but also chests. I haven’t checked it in a town. I also hit a buffer overflow when I returned to the main map.
compile.log said:
PauseAllSounds
SETTING MUSIC: music_map
ResumeAllSounds
Repair & Defence skill added in ProcessSailRepair: 1.5714 actual 2
system.log said:
Island Set
User Rised Exception
C:\PROJECTS\DRIVE_V2\ENGINE\SOURCES\s_stack.cpp line 47
stack overflaw
“A stack overflaw was rised”. Cool.

Somebody mentioned something about repairs while looting, I’ve also already suspected an issue with the music and/or sound effects. I’ll have more of a look at it and if I can find anything useful then I’ll post it in the other thread.

UPDATE - It’s not crashing every time, I just boarded a Ketch and looted everything with a problem. Might this have been because I had no sail cloths?
 
Last edited:
See if you can find the ProcessSailRepair function and put a 'return' statement at the top. That will stop it from executing altogether.

Would be interesting to know if that helps against the crashes. If so, it should be simple enough to abort it during boarding.
 
I think I’ve already looked at it. What I have done, is this bit here...
Code:
bool CheckInstantRepairCondition(ref chref)
{
   if(!bMapEnter) return false;
   if(!GetOfficersPerkUsing(chref,"InstantRepair")) //ASVS - come on, we have a function for that, why not using it?
     return false;
   if(GetHullPercent(chref) < 90.0 && GetCargoGoods(chref, GOOD_PLANKS) > 0) return true;
   return GetSailPercent(chref) < 90.0 && GetCargoGoods(chref, GOOD_SAILCLOTH) > 0;
}
...I have enclosed it with...
Code:
 if(!LAi_IsBoardingProcess())
It makes no difference.

I’ve just tested it again with no sail cloths, I went through three decks looting everything without a problem.

I think I know what’s happening here - the system is trying to repair the player’s ship, but since he’s not technically on his ship it’s throwing a wobbler. So there are two potential problems; it is trying to repair every time a body is looted, which has already been suggested, and then it can’t do so for the above reason.

Ah, yes... the ProcessSailRepair is in another function and I did exactly as above for that one previously. Okay, I’ll do it for both to see if there’s a difference.
 
How come is it that when there are four British heavies together, all in top condition, and I roll up next to one, hoist the black flag and when I board it goes straight to the captain, with no crew fights? I wouldn’t complain normally but I actually need the melee!

Anyway...
See if you can find the ProcessSailRepair function and put a 'return' statement at the top. That will stop it from executing altogether.

Would be interesting to know if that helps against the crashes. If so, it should be simple enough to abort it during boarding.
It seems to have done it. I’m leaving that as it is for now, I’d actually rather have no automatic repair and be able to loot stuff. I obviously didn’t get the code right for catching the boarding location, but breaking the function let me get through the decks.
 
Last edited:
...I have enclosed it with...
Code:
if(!LAi_IsBoardingProcess())
It makes no difference.
I don't know what LAi_IsBoardingProcess() does. There is a different check that I normally use to check if there is a boarding going on.
Something like 'bDeckStarted' or so. Search PROGRAM\seadogs.c for 'bSeaActive' and you can probably find the variable I mean very close to that.

I also recommend putting the abort inside the ProcessSailRepair function itself instead of in CheckInstantRepairCondition.
That function you found doesn't look crash-worthy to me, so aborting it probably wouldn't make a difference.

I think I know what’s happening here - the system is trying to repair the player’s ship, but since he’s not technically on his ship it’s throwing a wobbler. So there are two potential problems; it is trying to repair every time a body is looted, which has already been suggested, and then it can’t do so for the above reason.
That does sound plausible. I'm not sure if repair is called every time you loot a body though.
Maybe it is that repair is called periodically, but it doesn't execute properly if the looting interface is open.

One way or another, I see no reason why repairing is needed during boarding.
So if that is indeed the reason, I'm quite happy to just skip it until the ship capture has been completed.

How come is it that when there are four British heavies together, all in top condition, and I roll up next to one, hoist the black flag and when I board it goes straight to the captain, with no crew fights? I wouldn’t complain normally but I actually need the melee!
Maybe they had a low morale and surrendered? But then you should have gotten the dialog.
Bit strange....
 
Code snipped, but this is what I’ve done. I don’t know whether both functions are relevant, or indeed the hull as well...
Code:
void ProcessDayRepair()
{
   if( GetHullPercent(chref)<100 ) return false;
   if( GetSailPercent(chref)<100 ) return false;
}
Code:
bool CheckInstantRepairCondition(ref chref)
{
   if(GetHullPercent(chref) < 90 && GetCargoGoods(chref, GOOD_PLANKS) > 0) return false;
   if(GetSailPercent(chref) < 90 && GetCargoGoods(chref, GOOD_SAILCLOTH) > 0) return false;
}

I grabbed LAi_IsBoardingProcess() from the function which controls saving whilst in combat, as we were discussing earlier. Presumably the right code would work, but this is probably not it.
 
Last edited:
Back
Top