• 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!

WIP Increasing Companion Limit

So this code here in LogInterface.c...
Code:
void BI_GetMsgIconRoot()
{
   aref arTmp;
   aref pARef[4]; // <---- specifically this
   int i,idx,cn;
   ref mchr = GetMainCharacter();

   idx = 0;
   // This was being triggered during boarding, clause added to fix it...
   if(bSeaActive && !bAbordageStarted && !LAi_IsBoardingProcess())
   {
     for (i = 0; i < COMPANION_MAX; i++)
     {
       cn = GetCompanionIndex(mchr, i);
       if(cn<0) {continue;}
       Characters[cn].MessageIcons = true;
       makearef(arTmp,Characters[cn].MessageIcons);
       pARef[idx] = arTmp;
       idx++;
     }
     SendMessage(&BattleInterface,"le", BI_MSG_SET_MSG_ICONS, &pARef);
   }
   else
   {
     for (i = 0; i < OFFICER_MAX; i++)
     {
       cn = GetOfficersIndex(mchr, i);
       if(cn<0) {continue;}
       Characters[cn].MessageIcons = true;
       makearef(arTmp,Characters[cn].MessageIcons);
       pARef[idx] = arTmp;
       idx++;
     }
     SendMessage(&objLandInterface,"le", MSG_BATTLE_LAND_SET_MSGICONS, &pARef);
   }
}
This seems to be rather important. The bit I pointed out, should that be matching the companion limit? I changed this to 5 and the game didn’t care until I got a fifth companion... that’s when it crashed on launching to sea. Funnily enough, by changing that number and so long as it wasn’t crashing, this ceases to be a problem...
Error.log is pretty much constantly throwing this up...

RUNTIME ERROR - file: battle_interface\loginterface.c; line: 533
invalid index 4 [size:4]
RUNTIME ERROR - file: battle_interface\loginterface.c; line: 533
process event stack error
So the companion and officer icons are intrinsically linked, probably somewhere else as well other than the above code. I’m assuming that if there are more than 4 player icons to be shown then the battle interface needs to be able to do this correctly. In fact, it quite happily loads the icons and they can be appropriately interacted with, but that code above seems to have other ideas.

Whatever is going on here, it should also be considered in respect of the loot crash fix because I think that is what is causing those errors to show up anyway, not that they seem to be causing a problem but no errors is better. The crash I got when getting a fifth companion left no entry in the error log, so I’m guessing that it is directly related to why the loot crash happens.

It’s all about the icons when the battle or sea interface is loaded, it’s really finicky about it.
 
Last edited:
Now that I see that full section, it isn't a big surprise.
That [4] is the size of the array. 5 is higher than 4 so it doesn't fit in there and causes trouble.
The game won't resize arrays if you add more to it than its size allows.

You could try to replace that 4 with the maximum between the officer and companion maxima.
Alternatively, use a different variable for officers and companions.
Or initialize that value based on whether you're working with officers or companions at that time.
 
It doesn’t change anything. If that value is 5 and I have 5 ships, it doesn’t care... it will crash.

Still, I’m going to leave the two different variables in place as a precaution, I like it that way.

Maybe if I start a new game I might see different results, it’d be a good idea.
 
It’s an array, it starts at zero anyhow (though that doesn’t explain why it is 4 rather than 3).

Either way, it systematically crashes if both that and the number of companions are greater than 4.

Wait... you know what? Screw that nonsense. What exactly does this even do?
Code:
   if(bSeaActive && !bAbordageStarted && !LAi_Boarding_Process && !LAi_IsBoardingProcess()) {
     for (i=0; i<COMPANION_MAX; i++) {
       cn = GetCompanionIndex(mchr, i);
       if(cn<0) {continue;}
       Characters[cn].MessageIcons = true;
       makearef(arTmp,Characters[cn].MessageIcons);
       //C_pARef[idx] = arTmp; // <-------- commented out
       //idx++; // <-------- commented out
     }
     //SendMessage(&BattleInterface,"le", BI_MSG_SET_MSG_ICONS, &C_pARef); // <---- commented out
   }
Enough of that, this works just fine and now I’m not even getting any errors. :woot

Time to see if this affects the loot bug! It definitely does not. Oh well.
 
Last edited:
Those lines are to send something to the game engine.
But what that does and why, I haven't the foggiest.
 
So.... Uhm..... That engine stuff must have served *some* purpose, right...?
 
Last edited:
I suppose so.

Did you still get any related error logs the last time you had it in?
I think as long as you do, the error is still in the visible code.
 
Yes, it was always throwing those errors because the index was invalid. Now I have no error log at all. I set Horatio Nelson’s ID back to what it originally which fixes that problem, although it could prop up again if I happen to run into HMS Victory since she’s probably still floating around Jamaica some place. That was littering my error log as well but now I’m completely free of any apparent problems.
 
Looking at this a bit more I have a few comments:

- First of all the size of the arrays could be a problem if you dont make a new game.
At lot of these arrays are stored in the savegame and are only genereated on a new game from what I've seen. Dunno if that's the problem here.

- In potc if the array size is set to 4 you have 4 slots avaible in it being; 0,1,2 and 3.

- I believe the message icons is used to show if a character went level up etc. This is shown with a icon above the ships/character icon.

now some questsion:

- how much of this is implemented in the current build?
- Has anyone has problems with seeing these new ships on the compass?
- what is the limit now?
- Does this mean you can add more ships to you fleet or can they only be added by other stuff?
 
First of all the size of the arrays could be a problem if you dont make a new game.
At lot of these arrays are stored in the savegame and are only genereated on a new game from what I've seen. Dunno if that's the problem here.
Array? What array?

how much of this is implemented in the current build?
It is technically operational, but the default value is still 4 so it isn't actually active.
But that number can be changed now and that should make it work.

Any and all actual interface changes to make this easier to work with have NOT been added to the main mod.
This is mainly because I didn't want to risk breaking stuff that isn't broken...
Anyway, those files are still available here: Brainstorming - Personal Modifications for Feedback and Testing | PiratesAhoy!

One of the good ideas in there are "arrow keys" to make the "four images" swap between the "first four" and "second four".

Has anyone has problems with seeing these new ships on the compass?
Apart from @Mere_Mortal himself, I don't think anyone tested this at all.

what is the limit now?
Still 4.

Does this mean you can add more ships to you fleet or can they only be added by other stuff?
You indeed can add more than 4 IF that number is increased.
 
Back
Top