• 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 in shipyard after town capture

Jason

Buccaneer
Storm Modder
ctd in Port Royal Ship yard (4 in a row) after I took the city and installed my own governor
 

Attachments

  • error.log
    298 bytes · Views: 71
@pedrwyth I think this problem is the same as with the shop, could you look at this one too?
 
I suppose it could be something similar -although I see that in this case there IS an error log so perhaps not, I'll take a look but it won't be for a few days.
 
Took a look at the CTD in shipyard interface but setting captured town as for the store doesn't produce anything. The error codes relate to the character's ship -and may not be related to the reported crash anyway. So in the absence of a saved game I can't confirm or progress this.

That's not to say everything in the shipyard is rosy. The ransack title underlays the other interface titles (see screenshots) -so that needs looking at in any shipyard interface re-write.

I did try to see what happened in the shipyard from @Grey Roger 's saved game in 3.4. Although he had a full compliment of ships I was able to berth some (for 0 per month for the ship but with crew costs) and get replacements for nothing - some upgrades were free but others (notably copper plating and bronze cannons cost money) - so some inconsistencies in treatment there (whatever the decision on what town capture should allow). It also allows an exploit of stealing/looting and berthing ships to sell later when on your return when the town has returned to normal which perhaps wants blocking?
 

Attachments

  • seadogs2_0000.tga
    1.8 MB · Views: 103
  • seadogs2_0001.tga
    1.8 MB · Views: 101
  • seadogs2_0002.tga
    1.8 MB · Views: 104
Standard storyline: I have the same problem at ending of the Main storyline.
Game crash when you use the shipyard, and it only crash at the shipyard,not
at the Store or any other locations. There is no error message.
Savegame: At the Store.
 

Attachments

  • -=Player=- Barbados. Bridgetown store March 19th, 1751.zip
    864.5 KB · Views: 72
Looked at this a bit more but it isn't one I can see how to fix. Ansel's is nothing to do with town capture just a crash on trying to open the shipyard interface. It did generate an error log for me. Both Jason and Ansel's crashes look similar from the similar error logs

Jason's error log
RUNTIME ERROR - file: characters\characterUtilite.c; line: 562
invalid index -1 [size:514]
RUNTIME ERROR - file: characters\characterUtilite.c; line: 562
function 'GetCharacterShipValue' stack error
RUNTIME ERROR - file: KB_routines.c; line: 555
Using reference variable without initializing

Ansels's error log (produced when I ran the saved game to the crash)
RUNTIME ERROR - file: characters\characterUtilite.c; line: 562
invalid index -1 [size:514]
RUNTIME ERROR - file: characters\characterUtilite.c; line: 562
function 'GetCharacterShipValue' stack error
RUNTIME ERROR - file: KB_routines.c; line: 484
Using reference variable without initializing

Both error logs stop on similar lines in KB_routines in code that @Pieter Boelen appears to have looked at before. So for now this one is beyond me.
 
Pedrwyth says: Ansel's is nothing to do with town capture just a crash on trying to open the shipyard interface.
I went to the Shipyard just after I capture the town, so what are you saying whit that?
 
I think he's saying that the crash itself may not be related to the town capture.

Invalid index means the game is looking for something that isn't there.
 
Sorry that's my mistake but the saved game showed a normal store interface with buy and sell - not ransack and take and leave so not the town capture I was expecting - but I can see from the questbook it is after the standard storyline capture the colony to free the researcher. It's just not the type of town capture I mistakenly thought I was looking for. So perhaps that element is relevant for both Jason and @ANSEL examples. So once again my mistake:sick:sick:sick
 
Doing some error checking:
Code:
int GetCharacterShipValue(ref chr, string attribute)
{
   int nShipType = GetCharacterShipType(chr);
   if (nShipType == SHIP_NOTUSED) return 0;
   aref ship; makearef(ship, chr.ship);
   trace("GetCharacterShipValue: " + GetMySimpleName(chr) + ", nShipType = " + nShipType); // <---------- THAT LINE ---------
   if (CheckShipAttribute(ship, &ShipsTypes[nShipType], attribute))
     return sti(GetLocalShipAttrib(ship, &ShipsTypes[nShipType], attribute));
   else
     return 0;
}
Returns:
Code:
GetCharacterShipValue: David Fairweather, nShipType = -1
Yep, that would cause a problem. But WHY is the game looking for a ship apparently owned by the SHIPYARD OWNER? I don't think that's how it is supposed work. o_O
 
Doing some error checking:
Code:
int GetCharacterShipValue(ref chr, string attribute)
{
   int nShipType = GetCharacterShipType(chr);
   if (nShipType == SHIP_NOTUSED) return 0;
   aref ship; makearef(ship, chr.ship);
   trace("GetCharacterShipValue: " + GetMySimpleName(chr) + ", nShipType = " + nShipType); // <---------- THAT LINE ---------
   if (CheckShipAttribute(ship, &ShipsTypes[nShipType], attribute))
     return sti(GetLocalShipAttrib(ship, &ShipsTypes[nShipType], attribute));
   else
     return 0;
}
Returns:
Code:
GetCharacterShipValue: David Fairweather, nShipType = -1
Yep, that would cause a problem. But WHY is the game looking for a ship apparently owned by the SHIPYARD OWNER? I don't think that's how it is supposed work. o_O

Could be its called for the upgrades.
In order to apply upgrades to ships still in market I had to first give the ship to the shipyard owner and apply then and then remove the ship from him again because the functions are written like that.
 
Attached copy of the file contains a lot more error-handling lines to prevent functions being called for non-existent ships.
Extract to PROGRAM\Characters to apply.

I'm still not sure WHY this happens, but I suspect the large amount of "Personal design" ships might have something to do with it.
You normally never do get those in the shipyards or much of anywhere else.

In any case, this DOES get past the CTD. But I cannot guarantee there are no weird side-effects lurking about.
Still.... worth a try, no? Can't be worse than it was. ;)
 

Attachments

  • CharacterUtilite.zip
    35.4 KB · Views: 68
If you're wondering why some of the SHIP_NOTUSED checks are gone, that is because the new check looks between 0 and SHIP_TYPES_QUANTITY.
This is currently 243 and is coded so it cannot exceed SHIP_TYPES_QUANTITY_WITH_FORT which is set at 514.
SHIP_NOTUSED is 1000 and therefore automatically falls outside the range.
That is what I figured anyway.... Hopefully I'm right..... :oops:
 
Anyone had problems with this recently?
 
I know the game didn't crash anymore on that savegame that was posted earlier after I made the fixes.
Whether any other weirdness arises from those fixes though, I do not know.

But I suppose we can call the CTD itself fixed for the time being.
 
Back
Top