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

Another question about flags

Not for ships but I tested pirate flags for forts and could only use those from the current period texture file.
I'll make a few more attempts then I'll leave it as it is.
That probably means the game needs to be educated to load the correct file somewhere else in the code.
 
Not for ships but I tested pirate flags for forts and could only use those from the current period texture file.
I'll make a few more attempts then I'll leave it as it is.
That doesn't make sense. There are no period files for pirate flags. Each file contains the flags of one row of the array from which you choose your flag. Besides, there are six periods and only five pirate flag texture files. If something is associating pirate texture files with periods, it's going to get stuck in either "Early Explorers" (if it's counting from 0 and looking for "pirflg0.tga.tx") or "Napoleonic" (if it wants "pirflg6.tga.tx"). Neither file exists.

Your red flag with the right-facing skull is the fifth flag in "pirflg3.tga.tx". That appeared on Port Royale fort when you set the commander to have 'cmdr.Flags.Pirate = 4; cmdr.Flags.Pirate.texture = 2;'. So I'm guessing that "Flags.Pirate.texture" is the texture file number, but counting from 0 whereas file numbers start at 1; and "Flags.Pirate" is the flag number within that file, again starting at 0. What happens if you run the same experiment but set 'cmdr.Flags.Pirate.texture = 3;'?
 
Last edited:
Your red flag with the right-facing skull is the fifth flag in "pirflg3.tga.tx". That appeared on Port Royale fort when you set the commander to have 'cmdr.Flags.Pirate = 4; cmdr.Flags.Pirate.texture = 2;'. So I'm guessing that "Flags.Pirate.texture" is the texture file number, but counting from 0 whereas file numbers start at 1; and "Flags.Pirate" is the flag number within that file, again starting at 0.
Yes.
What happens if you run the same experiment but set 'cmdr.Flags.Pirate.texture = 3;'?
Any other number than 2 gives an empty flagpole.

I'll give it up now and try my workaround for the red pirate flag only at one shore in WoodesRogers and only temporary there.
 
Do I understand correctly that you CAN get a custom pirate flag to show up on a fort, like you wanted?
With the only limitation being that it must be in the flag file with the period number in it?

If so, admittedly that isn't perfect, but it does provide some leeway to fix your problem, doesn't it?
What if you swap some of the existing pirate flags so that the one you need is in the file that does work?

If that could be made to work, then your purpose would be served. Right?
Or am I completely misunderstanding something here...? :unsure
 
Yes.

Any other number than 2 gives an empty flagpole.
Could you try again with a different number, and then post "system.log"? Perhaps that will give a clue as to why other custom flags are not showing up. Presumably something is still trying to find a period-correct flag for a situation in which periods should not be a consideration.
 
Do I understand correctly that you CAN get a custom pirate flag to show up on a fort, like you wanted?
With the only limitation being that it must be in the flag file with the period number in it?
Yes. That was the case yesterday. Now I'm testing a 'switch' to temporary turn your fix off/on. Not got it to work properly yet.
Either my custom flag doesn't show up (in my case) OR the standard (Rackham) flag doesn't show up (normal Pirate fort).

The problem seems to be with this code (in SetFortFlag and SetTownFlag):
Code:
if(CheckAttribute(Pchar,"special_flag") && Pchar.special_flag == "on")
        {
            case PIRATE:
                GetPirateFlag(chr, &i);
                SendMessage(&PirateFlag[i], "lil", MSG_FLAG_INIT, &rModel, idx);
            break;
        }

You had this part outcommented and I need to keep it that way for the normal pirate towns/forts but need it working for my custom flag case.

What if you swap some of the existing pirate flags so that the one you need is in the file that does work?
I don't even have to do that as the red one with a head already is in there.

Could you try again with a different number, and then post "system.log"?
I'll do that as soon as I get it to work again.
 
The problem seems to be with this code (in SetFortFlag and SetTownFlag):
You're putting an 'if'-statement around a 'case' in a 'switch'. That isn't correct syntax.
You have to either move the 'if'-statement inside the 'case' or make two alternate 'switch'es.

You had this part outcommented and I need to keep it that way for the normal pirate towns/forts but need it working for my custom flag case.
My suggestion would be to first change it the way you need it yourself without adding a toggle. Then if that works correctly, we can check the side-effects in all other uses.
The biggest check is hoisting the flag in your "Woodes Rogers dozens of pirate ships at anchor at lighthouse" scene.
If the game doesn't crash there with your changed code, then that would be VERY promising!
 
You have to either move the 'if'-statement inside the 'case'
Yes I tried that but forgot to add the else at end. (Which is the same as the default)

Code:
case PIRATE:
            if(CheckAttribute(Pchar,"special_flag") && Pchar.special_flag == "on")
            {
                GetPirateFlag(chr, &i);
                SendMessage(&PirateFlag[i], "lil", MSG_FLAG_INIT, &rModel, idx);
            }
            else SendMessage(&FortFlag, "lil", MSG_FLAG_INIT, &rModel, idx);
        break;

So now I've got it to work. Showing Howard Pyle's red custom flag whith my toggle on in a pirate fort.
And showing the standard Rackham one with my toggle off in a pirate fort.

Here are the files for cmdr.Flags.Pirate = 4; cmdr.Flags.Pirate.texture = 3; (flag 5 in the next period)
It's in the errorlog.
 

Attachments

  • error.log
    358 bytes · Views: 73
  • system.log
    2.7 KB · Views: 83
  • Flags.c
    14.6 KB · Views: 72
The biggest check is hoisting the flag in your "Woodes Rogers dozens of pirate ships at anchor at lighthouse" scene.
If the game doesn't crash there with your changed code, then that would be VERY promising!
I played through that scene and it didn't crash. I used my changed Flags.c but with my toggle off to be sure
everything behaved like earlier. That is: your fix is on.

The shore where I want to use my toggle on (red pirate flag) is another shore without ships. Just a flagpole.
 
So... Problem solved for you? Or at least... workaround found?

This does sound pretty good. If something can be figured out to make the game load the correct texture regardless of period, then a toggle may not even be necessary.
 
Here are the files for cmdr.Flags.Pirate = 4; cmdr.Flags.Pirate.texture = 3; (flag 5 in the next period)
It's in the errorlog.
From "error.log":
Code:
RUNTIME ERROR - file: battle_interface\flags.c; line: 316
invalid index 6 [size:5]
Line 316 is in function "SetTownFlag", the one modified to check your "special_flag" attribute:
Code:
   idx = GetTownGovernorIndex(town);
   if (idx < 0) idx = GetTownFortCommanderIndex(town, 0);
   if (idx < 0) idx = GetMainCharacterIndex();
   chr = GetCharacter(idx); // PB
   switch (iNation) {
       
       //ok for red, ok for standard
       case PIRATE:
           if(CheckAttribute(Pchar,"special_flag") && Pchar.special_flag == "on")
           {
               GetPirateFlag(chr, &i);
               SendMessage(&PirateFlag[i], "lil", MSG_FLAG_INIT, &mdl, idx); // <--- This is line 316
           }
           else SendMessage(&FortFlag, "lil", MSG_FLAG_INIT, &mdl, idx);
       break;
The first thing which puzzles me is why "GetPirateFlag" seems to have set "i" to 6. The second thing which puzzles me is why this works at all, if you're setting the "Flags.Pirate" attributes on the fort commander, because the first character this function appears to check is the colony governor, then it checks the fort commander if it can't find a governor.
 
From "error.log":
Code:
RUNTIME ERROR - file: battle_interface\flags.c; line: 316
invalid index 6 [size:5]
[...]
The first thing which puzzles me is why "GetPirateFlag" seems to have set "i" to 6.
Oh dear; we've had array errors from pirate flags before. This sounds uncomfortably familiar...
 
I've been playing around with this. No error message but the same effect; the flag appears only if the texture file number matches the period. This is consistent; if I use a savegame from"Spanish Main", for example, the flag only appears if "Flags.pirate.texture" is 1.

Personal flags do something even weirder. If I modify "console.c" to conquer Port Royale for PERSONAL_NATION, and use custom Personal flag attributes for the fort commander, the flag only appears if "Flags.personal.texture" does not match the period!
 
Personal flag attributes for the fort commander, the flag only appears if "Flags.personal.texture" does not match the period!
I used a lot of personal flags but didn't notice that effect. Very strange.
 
I've been playing around with this. No error message but the same effect; the flag appears only if the texture file number matches the period. This is consistent; if I use a savegame from"Spanish Main", for example, the flag only appears if "Flags.pirate.texture" is 1.
Maybe add a hack so the fort commander always gets the needed attribute set for the present period?

Personal flags do something even weirder. If I modify "console.c" to conquer Port Royale for PERSONAL_NATION, and use custom Personal flag attributes for the fort commander, the flag only appears if "Flags.personal.texture" does not match the period!
Wow, that IS strange! I've got absolutely no explanation for that one... o_O
 
Here are the versions of "Flags.c" and "console.c" which I used for my tests. "Flags.c" is pretty much what @Jack Rackham posted but with a load of 'trace' statements added. In particular:
Code:
trace("procGetRiggingData: starting");
   string datName = GetEventData();
   if (datName == "GetFlagTexNum") {
       n = GetEventData();
       n = GetEventData();
switch(n)
{
case SHIP_FLAG: trace("procGetRiggingData: Ship flag"); break;
case SHIP_PENNANT: trace("procGetRiggingData: Ship pennant"); break;
trace("procGetRiggingData: not ship flag or pennant");
}

"console.c" contains a duplicate of the code to set Port Royale to Pirate and to use the custom flag, but the new block sets it to Personal instead, setting "Flags.Personal" and "Flags.Personal.texture" attributes.
 

Attachments

  • Flags.c
    15.8 KB · Views: 68
  • console.c
    35.9 KB · Views: 83
And here are the results, renamed to distinguish whether they're using Pirate or Personal flags, and in which period. All of them show the traces from function "SetFortFlag":
Code:
SetFortFlag: starting
SetFortFlag: Found commander 'Rauf Mallard'
SetFortFlag: checking for nation 3
The ones for Personal check for nation -1, of course. But then come the traces from "progGetRiggingData". In "compile_pirate_goldenage.log", "compile_personal_spmain.log" and "compile_personal_colpowers.log", there is this:
Code:
procGetRiggingData: starting
procGetRiggingData: not ship flag or pennant
That's the function being called for the fort flag. And indeed, if the fort is taken for Pirate in "Golden Age of Piracy", or for Personal in "Spanish Main" or "Colonial Powers", the flag appears on the fort.

No such entry for "not ship flag or pennant" appears in "compile_pirate_spmain.log", "compile_pirate_colpowers.log" or "compile_personal_goldenage.log". If "cmdr.Flags.Pirate.texture" does not match the period number (actually the period number -1), no pirate flag appears because "procGetRiggingData" has not been called. If "cmdr.Flags.Personal.texture" does match, again "procGetRiggingData" is not called, so no flag appears.

"procGetRiggingData" is an event handler for event "GetRiggingData". And I can't find where that event is triggered.
 

Attachments

  • compile_personal_colpowers.log
    10.5 KB · Views: 102
  • compile_personal_goldenage.log
    11.7 KB · Views: 114
  • compile_personal_spmain.log
    10.4 KB · Views: 97
  • compile_pirate_colpowers.log
    7.4 KB · Views: 108
  • compile_pirate_goldenage.log
    10.4 KB · Views: 112
  • compile_pirate_spmain.log
    10.2 KB · Views: 87
"procGetRiggingData" is an event handler for event "GetRiggingData". And I can't find where that event is triggered.
In that case, it might be in the game ENGINE itself. That's usually the case if no trace can be found in the PROGRAM folder.
 
Is the current version of ENGINE.exe linked to the mod? The original game had no custom flags or different periods, so unless the current one does something with custom flags, it has to be something in the mod failing to trigger event "GetRiggingData".
 
Back
Top