• 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 Levelling: Runtime error while talking to random officers

Jason

Buccaneer
Storm Modder
Walking around the port in San Juan a random officer approached. When I asked how good, I got the runtime error. This happened twice curiously there was no error log. Here is save from when I landed in the port.
 

Attachments

  • -=Player=- Puerto Rico. San Juan port.rar
    518.1 KB · Views: 103
@Levis: Game crashes on this line:
Code:
void LAi_Create_Officer(int rankch, ref Npchar)
{
   DeleteAttribute(Npchar,"skillsetup");
   Npchar.rank = GetRandomRank(CharacterIsFriend(Npchar), GetAttribute(Npchar,"quest.officertype"), rankch);
   bool realfantom = FALSE;
   //Let's make it fantom for now so it's rank is remembered
   if(CheckAttribute(Npchar,"isfantom")) realfantom = TRUE;
   else Npchar.isfantom = true;
   //Now lets set it to the right level
   InitCharacterSkills(Npchar); // <-------- THIS ONE --------------
 
The game crashes because it gets into a infinite loop.
As a preliminary fix, I did the following in PROGRAM\Leveling.c . Find:
Code:
bool AddXPtoChar(ref chref, string expName, int _exp)
{
   bool LevelUp = false;
   
   //In case the officertype is changed, we should apply the importances again
   if(!CheckAttribute(chref,"skillsetup")) InitCharacterSkills(chref); //shouldn't happen but does seem to happen sometimes
   if(chref.skillsetup != chref.quest.officerType)
   {
     if(DEBUG_EXPERIENCE>1) Trace("XP LOG: Offictype for "+GetMySimpleName(chref)+" is changed so reapply the importances.");
     SetCharSkillImportance(chref,1);
   }
Replace with:
Code:
bool AddXPtoChar(ref chref, string expName, int _exp)
{
   bool LevelUp = false;
   
   //In case the officertype is changed, we should apply the importances again
//   if(!CheckAttribute(chref,"skillsetup")) InitCharacterSkills(chref); //shouldn't happen but does seem to happen sometimes
   if(!CheckAttribute(chref,"skillsetup") || chref.skillsetup != chref.quest.officerType) // PB: This function can be called FROM InitCharacterSkills, so the above line could trigger an infinite loop
   {
     if(DEBUG_EXPERIENCE>1) Trace("XP LOG: Offictype for "+GetMySimpleName(chref)+" is set or changed so (re)apply the importances.");
     SetCharSkillImportance(chref,1);
   }
 
the fix seems to be okay to me. Think I made a little logic flaw there.
The dialog error I need to look into more. But doesn't have high priority for me atm.
 
The dialog error I need to look into more. But doesn't have high priority for me atm.
Agreed. As far as I can tell, there are no adverse effects from that one to be noticed within the game.
So it's just another pointless "error.log" entry. :shrug
 
Back
Top