• 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 Empty officer appearing in Passengers

I just boarded two ships (wanted to get rid of those pesky French attacking Speightstown) and I ended up with an empty officer. (noticed when I wanted to assign a captain to the frigate I captured). I first boarded a French ship who was getting close to the port as I hit the sea, next I fast traveled to the closest Frigate.
Got a save before I went off to fight em and when I got back in port. Log files are there also.
 

Attachments

  • Pirates of the Caribbean.rar
    1.4 MB · Views: 109
Last edited:
I'll see if there is anything there that gives a clue, but I'm not counting on it.

Just to remind you, until this question of mine is answered, there is nothing much I could do:
What I mostly need to know is: When I start a new game, what exact actions do I need to take to trigger this bug?
It seems very odd that you would get this bug several times, but nobody else has reported it by now.

Could any of your non-default settings have anything to do with it?
Would you consider playing the mod on default settings to see if that makes a difference?
 
I did not change anything about the mod. I just installed it and started playing. Maybe I should try a total clean install if it is only me having this problem.
As for what to do when you start a new game...I got no clue. I started using the standard storyline, changed the character to Morris Williams and set my nationality to Dutch. It seems to happen when im doing normal stuff like hauling cargo, boarding ships etc.
 
Do you still have the code change I suggested in post #12 in place?
Are you still getting those on-screen messages all the time?

We need to narrow down specific acts that trigger it.
For now, it sounds like it is completely random, but there is virtually nothing that can be done about 100% random issues. :facepalm
 
I understand :)
Yes I still have that implemented, just when going into battle I tend to watch the enemy and not the messages :rolleyes:
I'll try to do the exact same steps with the 1st save file somewhere today and see if I can reproduce the event.
 
Yes I still have that implemented, just when going into battle I tend to watch the enemy and not the messages :rolleyes:
Because it Traces as well, you can also temporarily Alt+Tab out of the game and check the contents of compile.log to see if it happened.
 
More debug code to add. In all cases, the "Trace("ClearCharacter called from *somewhere*");" line is to be added.
Then when it executes on a real officer of yours, we can see in compile.log which of these three was responsible.

PROGRAM\Dialog_func.c:
Code:
int FindFreeCabinCaptain()
{
   for(int tempnum=0; tempnum<=CABINCAPTAINS_MAX; tempnum++)
   {
     string tempid = "Enc_CabinCaptain_" + tempnum;
     int tempidx = GetCharacterIndex(tempid);
     if(tempidx==-1) break;
     ref tempChar = GetCharacter(tempidx);

     if(bAllies(tempChar)) { continue; }

     Trace("ClearCharacter called from FindFreeCabinCaptain");
     ClearCharacter(tempChar); // PB: Completely erase the unused character

     return tempidx;
   }

   return -1;
}

PROGRAM\Characters\characters_login.c:
Code:
// PB -->
void LogoffCharactersFromLocation(ref loc)
{
   int i;
   ref chr;
   string locID = loc.id;
   for(i = 0; i < LAi_numloginedcharacters; i++) //Levis: only use logged in characters
   {
     chr = &Characters[LAi_loginedcharacters[i]]; //Levis: only use logged in characters
   //   if (!CheckAttribute(chr, "location"))   continue; // PB: Then we don't need this anymore, do we?
   //   if (chr.location != locID)         continue; // PB: Same here
     if (HasSubStr(chr.id, "Enc_Officer_") && !bAllies(chr))
     {
       Trace("ClearCharacter called from FindFreeCabinCaptain");
       ClearCharacter(chr); // PB: Completely erase the unused character
     }
   }
}
// PB <--

PROGRAM\Characters\officers.c:
Code:
int FindFreeRandomOfficer()
{
   // this function rewritten by KAM so new officers don't keep overwriting captains on shore leave [changes made by MAXIMUS 07.10.2007]

   for(int tempnum=0; tempnum<=NUM_RANDOM_OFFICERS; tempnum++) // NK 05-03-30 we now use char not exist to stop loop, so we can have any number of enc_off.
   {
     string tempid = "Enc_Officer_" + tempnum;
     int tempidx = GetCharacterIndex(tempid);
     if(tempidx==-1) break; // NK 05-03-30 ditto
     ref tempChar = GetCharacter(tempidx);

     if(bAllies(tempChar)) { continue; }
     if(tempChar.location == loadedLocation.id) { continue; } // PB: To prevent prospective officers from disappearing when you're talking to them

     Trace("ClearCharacter called from FindFreeRandomOfficer");
     ClearCharacter(tempChar); // PB: Completely erase the unused character

     return tempidx;
   }

   return -1;
}


The crazy part is that all three call 'bAllies' first to check if this is a USED officer or not.
That function is defined as:
Code:
bool bAllies(ref refCharacter)
{
   if(!CheckAttribute(refCharacter,"index"))       return false;
   if(sti(refCharacter.index)==-1)             return false;

   if(IsMainCharacter(refCharacter))           return true;
   if(IsCompanion(refCharacter))             return true;
   if(IsOfficer(refCharacter))               return true;
   if(IsOfficerCompanion(refCharacter))         return true;
   if(IsPassenger(refCharacter))             return true;
   if(IsOnShoreLeave(refCharacter))           return true;
   if(IsOfficerOnShoreLeave(refCharacter))         return true;
   if(CheckAttribute(refCharacter, "StoredFellow"))   return true; // PB: Prevent these characters being overwritten
   return false;
}
In other words, it basically covers all real officers and therefore those shouldn't ever be cleared! :shock
 
Thanks to details in the Confirmed Bug - Game crash when recruiting captured ship captain/exit captured ship | PiratesAhoy! thread, I have been able to come up with an attempted fix for this one.

In PROGRAM\Characters\CharacterUtilite.c find:
Code:
// KK -->
bool IsPassenger(ref akCaptainChar)
{
   if(!CheckAttribute(akCaptainChar,"index")) return false;// MAXIMUS
   if (CheckAttribute(akCaptainChar, "passenger")) return sti(akCaptainChar.passenger);
   return false;
}
// <-- KK
Replace with:
Code:
// KK -->
bool IsPassenger(ref _refCharacter)
{
   if(!CheckAttribute(_refCharacter,"index"))      return false;                 // MAXIMUS
   if (CheckAttribute(_refCharacter, "passenger"))   return sti(_refCharacter.passenger);

   // PB -->
   int cn;
   ref chr;
   ref pchar = GetMainCharacter();
   for(int i=0; i < GetPassengersQuantity(pchar); i++)
   {
     cn = GetPassenger(pchar, i);
     if (cn < 0)                           continue;           // Skip invalid characters
     chr = GetCharacter(cn);                                   // Reference to the character
     if(!CheckAttribute(chr,"index"))               continue;           // Skip invalid characters
     if(sti(_refCharacter.index) == sti(chr.index))         return true;         // This character is in the captain's passenger list
   }
   // PB <--

   return false;
}
// KK <--

Apparently it is possible for characters to be REAL passengers without actually having the "passenger" attribute.
I don't know how that can happen, but this catches those ones so that they're STILL recognized as passengers.

That should prevent them from being erased and causing the error described in this thread.
 
Ok I added the code you posted in #28 (I removed the Trace codes from #27 since they caused the game to delete me/crash somehow).
When I wanted to recruit an enemy Capt the game crashed again. Results in attachment.
Seems it now wants to erase officer entry 11 (so at least it leaves nr 7 alone)

Also I found a loop to ''fix'' it for now: Assign that officer who gets deleted to a companion ship as officer and he wont get deleted. Also the game wont crash then when I recruit an enemy. (testing is still being done with that one save game)
 

Attachments

  • compile.log
    76.8 KB · Views: 109
  • system.log
    2.3 KB · Views: 110
Last edited:
Seems it now wants to erase officer entry 11 (so at least it leaves nr 7 alone)
Assuming you're testing from the same savegame you posted last time, then that is not a problem.
Officer #11 isn't actually an officer of yours and therefore it is perfectly fine for that one to be cleared.
Note that there is no name shown at all:
Code:
ClearCharacter erases Enc_Officer_11(*name would have gone here*)

Also I found a loop to ''fix'' it for now: Assign that officer who gets deleted to a companion ship as officer and he wont get deleted. Also the game wont crash then when I recruit an enemy. (testing is still being done with that one save game)
But that should not be necessary anymore.
And if it does happen, I want to know about it AND why.

In this case, DID you actually notice an actual officer of yours vanishing?
 
For reference, attached files are my copies where I made my changes. Those work fine for me.

They go to PROGRAM for Dialog_func.c and PROGRAM\Characters for the rest.
 

Attachments

  • characters_login.zip
    3.3 KB · Views: 103
  • CharacterUtilite.zip
    33.6 KB · Views: 112
  • Dialog_func.zip
    24.6 KB · Views: 105
  • officers.zip
    2.5 KB · Views: 104
No with that code of yours it didnt delete an officer of mine, but it still ended up crashing for some reason.
I'll add those to my game now and test again.
 
Ok I've boarded about 30 ships I guess and succesfully recruited 5 captains (they just wont surrender lol), and the 6th caused a crash again. I'm starting to think that it is a certain type of officer that causes the crash. And indeed you are making some progress :) awesome! Also I noticed there is no cooldown on the instant boarding skill (not that I mind now, makes for fast testing). I guess that counts as a bug too?
Logfiles in attachment
 

Attachments

  • logfiles.rar
    47.9 KB · Views: 104
That is my suspicion too.

Better continue in the other thread though. I posted a file there to hopefully allow us to test that "officer type theory".
 
I had this issue in my first campaign which I finished up last week, a blank portrait with the name "Citizen", could not remove them, this happened twice.
The only annoying part of it was that when scrolling through the officers it would not go past these "phantoms" I would have to click on the next real officers to continue though the roster.
I had figured it may have been a captain that was with a berthed ship, as I did that on two occasions, and had two of these citizens.
 
I had this issue in my first campaign which I finished up last week, a blank portrait with the name "Citizen", could not remove them, this happened twice.
The only annoying part of it was that when scrolling through the officers it would not go past these "phantoms" I would have to click on the next real officers to continue though the roster.
I had figured it may have been a captain that was with a berthed ship, as I did that on two occasions, and had two of these citizens.
Please extract CharacterUtilite.c from post #31 above to your PROGRAM\Characters folder.
This will not fix existing such characters, but should hopefully prevent new ones.
 
I don't know if this is related...

I was organising my officers in my cabin, well organising them for another ship actually, giving them trinkets to boost their stats. When I was ready, I removed them as officers but when I went to transfer them to my other ship, they were gone. I looked at my passenger page and there were two "empty" slots, with them showing some kind of error in the text. Afterwards, the most recent quick save was corrupted (even though I did not save it at that point, and thankfully I had another recent save to fall back on). This is as much as I know and can recall of the matter, but if the problem happens again then I'll try to make better note of the circumstances.
 
I don't know if this is related...

I was organising my officers in my cabin, well organising them for another ship actually, giving them trinkets to boost their stats. When I was ready, I removed them as officers but when I went to transfer them to my other ship, they were gone. I looked at my passenger page and there were two "empty" slots, with them showing some kind of error in the text. Afterwards, the most recent quick save was corrupted (even though I did not save it at that point, and thankfully I had another recent save to fall back on). This is as much as I know and can recall of the matter, but if the problem happens again then I'll try to make better note of the circumstances.
I recommend installing the files from post #31 above.
That contains a fix that should prevent that along with some extra debug code so we get more information if it does happen again.
 
Okay, and what about characters.c from post #7? I've grabbed that one as well.

It has only happened the one time but I will probably be tweaking my officers a lot as I find new ones and new trinkets as well. I'll update if it recurs or if I see any peculiar log entries.
 
Back
Top