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

Solved Fixing the Different Flags Mod

I just tested your method ashore and it seems to work as well as mine, but since your uses per-frame updates,
rather than millisecond updates like mine, it's not system-related and would certainly be better. <img src="style_emoticons/<#EMO_DIR#>/yes.gif" style="vertical-align:middle" emoid=":yes" border="0" alt="yes.gif" />

However, it still doesn't fix the inventory problem.
What if we REALLY limit the updating of flags to sea only? That'd solve the problem for sure: <img src="style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->            if( bSeaActive && !bAbordageStarted )
            {
                LayerFreeze("sea_realize",false);
                LayerFreeze("sea_execute",false);
                if(CheckAttribute(GetMainCharacter(),"setcolours")) // PB: Only update flags if needed
                {
                    DeleteAttribute(GetMainCharacter(),"setcolours");
                    RefreshMc_n_companionsFlags(); // Screwface: Just refresh the player and companion flag
                /*    PB Method
                    SetShipFlag(GetMainCharacterIndex()); // Screwface: Just refresh the player flag
                    // PB: Refresh companion flags too -->
                    for(int i = 1; i <= 3; i++)
                    {
                        int iCharacterIndex = GetCompanionIndex(GetMainCharacter(),i);
                        PostEvent("RefreshCharFlag", i*50, "l", iCharacterIndex);
                    }
                    // PB: Refresh companion flags too <--
                */
                }
            }
            else
            {
                LayerFreeze("realize",false);
                LayerFreeze("execute",false);
            }<!--c2--></div><!--ec2-->
 
<!--quoteo(post=336654:date=Jul 11 2009, 11:31 PM:name=Screwface)--><div class='quotetop'>QUOTE (Screwface @ Jul 11 2009, 11:31 PM) <a href="index.php?act=findpost&pid=336654"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->That sounds quite impossible to me unless you have a 486 DX computer <img src="style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" />
Take a look in compile.log you posted previously, i'm sure that the first refreshflags was finished when the second call appeared !<!--QuoteEnd--></div><!--QuoteEEnd-->Then why DID my game crash upon that? Remember the Assassin storyline dialog crash too;
the game actually had time to start the dialog before the RefreshFlags call was finished. <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" />

<!--quoteo(post=336654:date=Jul 11 2009, 11:31 PM:name=Screwface)--><div class='quotetop'>QUOTE (Screwface @ Jul 11 2009, 11:31 PM) <a href="index.php?act=findpost&pid=336654"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Problem because the AI sea updates has toggle and can be turned off <img src="style_emoticons/<#EMO_DIR#>/dunno.gif" style="vertical-align:middle" emoid=":shrug" border="0" alt="dunno.gif" /> Plus if the AI sea update appears at the same time of surrender event, the problem could probably be the same<!--QuoteEnd--></div><!--QuoteEEnd-->True; but it'd still decrease the risk, wouldn't it?
And maybe the flag code could be moved outside the toggle? Or on second thought...
Maybe the on-sea flag updates should have a toggle too, considering the risk of crashes with it, despite our hard efforts on fixing it.
 
I just did some sailing at sea and noticed that indeed now surrendered ships DO get white flags.
However, after capturing the surrendered ship, the flags didn't automatically turn to my own.
After manually hoisting different flags, it still didn't update. A reload to worldmap was needed.

Also: Why doesn't the Amsterdam have pennants anymore? I'm sure she had them before! <img src="style_emoticons/<#EMO_DIR#>/piratesing.gif" style="vertical-align:middle" emoid=":shock" border="0" alt="piratesing.gif" />
 
<!--quoteo(post=336658:date=Jul 11 2009, 11:43 PM:name=Pieter Boelen)--><div class='quotetop'>QUOTE (Pieter Boelen @ Jul 11 2009, 11:43 PM) <a href="index.php?act=findpost&pid=336658"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->True; but it'd still decrease the risk, wouldn't it?
And maybe the flag code could be moved outside the toggle? Or on second thought...
Maybe the on-sea flag updates should have a toggle too, considering the risk of crashes with it, despite our hard efforts on fixing it.<!--QuoteEnd--></div><!--QuoteEEnd-->
I think your idea of adding a delay after the first refreshflags sounds the best one to me. It could be the best protection to avoid crashes. Nothing couldn't be refresh until the delay was finished. Perhaps we could try to applicate the delay in frame to be non-system related too but actually i've no clue of the way to do that <img src="style_emoticons/<#EMO_DIR#>/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" /> If we wouldn't succeed to do that, mix the refresh flags with the AI sea update could be a solution to envisage too.

<!--quoteo(post=336661:date=Jul 12 2009, 12:04 AM:name=Pieter Boelen)--><div class='quotetop'>QUOTE (Pieter Boelen @ Jul 12 2009, 12:04 AM) <a href="index.php?act=findpost&pid=336661"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I just did some sailing at sea and noticed that indeed now surrendered ships DO get white flags.
However, after capturing the surrendered ship, the flags didn't automatically turn to my own.
After manually hoisting different flags, it still didn't update. A reload to worldmap was needed.

Also: Why doesn't the Amsterdam have pennants anymore? I'm sure she had them before! <img src="style_emoticons/<#EMO_DIR#>/piratesing.gif" style="vertical-align:middle" emoid=":shock" border="0" alt="piratesing.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->
Really strange because the surrended attribute is set to the character, not the ship so as soon as you capture the ship, the set flag functions should rework normally !
For the Amsterdam, i see no reasons in the last code modifications which could be culprit of those pennants disappearance <img src="style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" />
 
<!--quoteo(post=336674:date=Jul 12 2009, 01:20 AM:name=Screwface)--><div class='quotetop'>QUOTE (Screwface @ Jul 12 2009, 01:20 AM) <a href="index.php?act=findpost&pid=336674"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I think your idea of adding a delay after the first refreshflags sounds the best one to me. It could be the best protection to avoid crashes. Nothing couldn't be refresh until the delay was finished. Perhaps we could try to applicate the delay in frame to be non-system related too but actually i've no clue of the way to do that <img src="style_emoticons/<#EMO_DIR#>/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" /> If we wouldn't succeed to do that, mix the refresh flags with the AI sea update could be a solution to envisage too.<!--QuoteEnd--></div><!--QuoteEEnd-->What if we were to make a, say, ten-second delay in which no second flag update can be performed?
10 seconds should be enough for all flags on ANY computer (I hope) and is short enough to wait.
Of course if a flag update would be called within those ten seconds after the previous update,
it would be nice if the update were to be performed automatically later anyway, possibly at the time of a Sea AI update.

<!--quoteo(post=336674:date=Jul 12 2009, 01:20 AM:name=Screwface)--><div class='quotetop'>QUOTE (Screwface @ Jul 12 2009, 01:20 AM) <a href="index.php?act=findpost&pid=336674"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Really strange because the surrended attribute is set to the character, not the ship so as soon as you capture the ship, the set flag functions should rework normally !<!--QuoteEnd--></div><!--QuoteEEnd-->Really strange indeed; all I know is that the crash happened right after the reload to sea and by that time
apparently the ship had already managed to get a mast shot off by the fort.
That's really quite quick, but that's the only explanation I can think of.

<!--quoteo(post=336674:date=Jul 12 2009, 01:20 AM:name=Screwface)--><div class='quotetop'>QUOTE (Screwface @ Jul 12 2009, 01:20 AM) <a href="index.php?act=findpost&pid=336674"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->For the Amsterdam, i see no reasons in the last code modifications which could be culprit of those pennants disappearance <img src="style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->Neither do I. It might be that Fast Caravel problem again that I <a href="http://forum.piratesahoy.net//index.php?s=&showtopic=13298&view=findpost&p=332665" target="_blank">mentioned before</a>.
Can you confirm/deny that the Amsterdam has no pennants for you as well? I'd like to know if it's just me. <img src="style_emoticons/<#EMO_DIR#>/modding.gif" style="vertical-align:middle" emoid=":modding" border="0" alt="modding.gif" />
In any case, it appears that something really weird is going on with pennants refusing to appear
even though locators and code are both correct. But only in <i>some</i> cases on <i>some</i> ships. <img src="style_emoticons/<#EMO_DIR#>/wacko.gif" style="vertical-align:middle" emoid=":wacko:" border="0" alt="wacko.gif" />
 
<!--quoteo(post=336681:date=Jul 12 2009, 02:07 AM:name=Pieter Boelen)--><div class='quotetop'>QUOTE (Pieter Boelen @ Jul 12 2009, 02:07 AM) <a href="index.php?act=findpost&pid=336681"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->What if we were to make a, say, ten-second delay in which no second flag update can be performed?
10 seconds should be enough for all flags on ANY computer (I hope) and is short enough to wait.
Of course if a flag update would be called within those ten seconds after the previous update,
it would be nice if the update were to be performed automatically later anyway, possibly at the time of a Sea AI update.<!--QuoteEnd--></div><!--QuoteEEnd-->
I've found a way to avoid flags update during a number of frames after a refreshflags has begun. I think it's better to use frames instead of time because as we know that the flags update use a frame per ship, we can be sure that if we wait more frames that the number of ships, we could be sure that the refreshflags will be finished at the end of the frame delay, no matter the computer speed !

For example, if there are 6 coastraiders + you and 3 companions at sea, the flags update use 10 frames to refresh all the ships. You can forbid a new refreshflags during 20 frames (10 frames more for security). Of course this number must be increase to foresee the encounters ! As the MAX_SHIPS_ON_SEA value is 32, i think 40 or 50 frames could be enough. Plus in case where you only refresh flags of you and companions or surrended ship, this value could be less !

Now, if you want to perform the canceled flags update later, at the time of a Sea AI update for example, i suggest that the sea AI update frequency should be permanently set to 1 minute instead of the actual 5 minutes

I have pennants on the amsterdam <img src="style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />
 
I think frames is the way to go as well <img src="style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" />
 
Oh, frames is CERTAINLY the way to go about it. <img src="style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" />
Indeed I think it's a good idea to somehow ensure that no second RefreshFlags or SetFlag can be executed while one is already going.
And setting the Sea AI update frequency to 1 minute sounds good to me too; I don't think anyone encountered any real performance hits from that mod.
 
<!--quoteo(post=336948:date=Jul 13 2009, 03:34 PM:name=Screwface)--><div class='quotetop'>QUOTE (Screwface @ Jul 13 2009, 03:34 PM) <a href="index.php?act=findpost&pid=336948"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I have pennants on the amsterdam <img src="style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->Oh crap; NOW I get it. In the Devlin storyline she doesn't have pennants, but in Assassin she does. Reason being:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->#define PENNANTS_MIN_YEAR                        1600    // INT - year at which ships will use pennants
#define MERCHANT_FLAGS_MIN_YEAR                    1600    // INT - year at which merchant ships will use separate flags<!--c2--></div><!--ec2-->The Devlin storyline starts in 1550. <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" />

The Early Explorers period starts in 1500 and ends in 1599. As such, no pennants and merchant flags are used at any time during that period.
Does anyone else think that pennants and seperate merchant flags should always be used...? <img src="style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" />
 
Here are my last code modifications. I've introduced a security delay after a flags update. During this time, no new flags update can be done and is done at the following Ai Sea update after it end.
I was forced to put a big delay after a mast fall. The mast fall processus seems to pass during a relatively long time so if a flags update is called during this time, it causes a crash. With a long delay, there is no crash anymore and the good news is that after, you can also refresh the flags of the ship if she surrender, even if she has a fallen mast <img src="style_emoticons/<#EMO_DIR#>/piratesing.gif" style="vertical-align:middle" emoid=":shock" border="0" alt="piratesing.gif" />

Edit :
This patch is made for the last version of experimental mod !
 

Attachments

  • Period_Flags_mod_update_07_14_09.rar
    149.8 KB · Views: 86
That sounds really really good <img src="style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" />

Well done Screwface <img src="style_emoticons/<#EMO_DIR#>/bow.gif" style="vertical-align:middle" emoid=":bow" border="0" alt="bow.gif" />
 
YOU ARE DA MASTER!

Very good, screwface. Now you have fixed this wonderful mod, you can make some own <img src="style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" />
 
That sounds great, Screwface! One question though... if you use <i>Characters[GetMainCharacterIndex()].Delayrefresh</i>,
what happens if two different characters request an update call before the Sea AI update during a delay?
Of course that wouldn't happen often, but what if...? <img src="style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" />
 
<!--quoteo(post=337175:date=Jul 14 2009, 03:10 PM:name=Pieter Boelen)--><div class='quotetop'>QUOTE (Pieter Boelen @ Jul 14 2009, 03:10 PM) <a href="index.php?act=findpost&pid=337175"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->That sounds great, Screwface! One question though... if you use <i>Characters[GetMainCharacterIndex()].Delayrefresh</i>,
what happens if two different characters request an update call before the Sea AI update during a delay?
Of course that wouldn't happen often, but what if...? <img src="style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" /><!--QuoteEnd--></div><!--QuoteEEnd-->
Good point pieter ! I didn't think about that ! Actually that would be the last one who would be updated ! If you want to change that, the only way is to refresh all the ships instead of one !
In LogInterface.c, replace this section of code :
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->                        if(sti(mchr.Delayrefresh) == GetMainCharacterIndex())
                        {
                            // Refresh player and companions
                            RefreshMc_n_companionsFlags();
                            waitdelay();
                        }
                        else
                        {
                            // a surrended ship or captured and assigned to officer
                            mchr.waitdelay = 10;
                            SetShipFlag(sti(mchr.Delayrefresh));
                            waitdelay();
                        }<!--c2--></div><!--ec2-->
by :

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->                        Refreshflags();
                        waitdelay();<!--c2--></div><!--ec2-->
 
Thanks, Screwface. Do you think it would be possible to make some sort of array of characters whose ships' flags need to be update?
Then each time a flag update is requested during a delay, the index of that character is added to this array.
Upon the next Sea AI update, all characters in the array would then get their flags update, one per frame.
Of course you'd also need to filter out any possible doubles. But then ships only surrender once, don't they?

Hmm... suddenly I'm wondering about a mod involving other ships ALSO usign false flags. Might get too complicated though, no? <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" />
 
The best way would be to add an attribute to ships who need to be updated at the ai sea update. So at the next Ai sea update we would call a refreshflags style function which also check the presence of this attribute. If it exists, the function would refresh the flags and delete it.

For the other ships using false flags, i also had this kind of brainstorming but i think we must be sure that the period flags mod works perfectly before to envisage a new add to it which could bring new conflicts <img src="style_emoticons/<#EMO_DIR#>/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" />
 
Absolutely agreed. At this point, I think it's better to finish what we have, rather that add new stuff. <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" />
Now that the Different Flags mod is nearing it's completion, have you got any idea what to do next?
It'd be great if we could continue the work on moving the Development Resources code part-by-part to the Build 14 Alpha.
For example the Save At Sea mod and updated Shipyard Interface would be great to have. <img src="style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" />
 
I just got this in error.log:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->RUNTIME ERROR - file: battle_interface\landinterface.c; line: 142
missed attribute: waitdelay
RUNTIME ERROR - file: battle_interface\landinterface.c; line: 142
no rAP data<!--c2--></div><!--ec2-->
<b>Edit:</b> And now this one too:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->RUNTIME ERROR - file: battle_interface\BattleInterface.c; line: 441
missed attribute: waitdelay
RUNTIME ERROR - file: battle_interface\BattleInterface.c; line: 441
no rAP data<!--c2--></div><!--ec2-->
 
Hmm did you have a processus anormaly interrupted before ?

<b>Edit :</b>
Probably you had 2 waitdelay() very close each other and at the end of the first one, the waitdelay attribute was deleted so the errors came when the second reached it end. Need to be fix !
 
The error occurs at these two lines. From battle_interface\landinterface.c:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// Screwface
void BLI_Waitdelay()
{
    int init = 0;
    if (CheckAttribute(&objLandInterface, "Waitrefreshflags")) init = sti(objLandInterface.Waitrefreshflags);
    //trace("waiting before refresh - Frame : "+init);
    init++;
    objLandInterface.Waitrefreshflags = init;
    if(init >= sti(Characters[GetMaincharacterIndex()].waitdelay)) { // THIS LINE
        DeleteAttribute(&objLandInterface, "Waitrefreshflags");
        DelEventHandler("frame", "BLI_Waitdelay");
        DeleteAttribute(&Characters[GetMaincharacterIndex()], "waitdelay");
    }
}<!--c2--></div><!--ec2-->
From battle_interface\BattleInterface.c:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// Screwface
void BI_Waitdelay()
{
    int init = 0;
    if (CheckAttribute(&BattleInterface, "Waitrefreshflags")) init = sti(BattleInterface.Waitrefreshflags);
    //trace("waiting before refresh - Frame : "+init);
    init++;
    BattleInterface.Waitrefreshflags = init;
    if (init >= sti(Characters[GetMaincharacterIndex()].waitdelay)) { // AND THIS LINE
        DeleteAttribute(&BattleInterface, "Waitrefreshflags");
        DelEventHandler("frame", "BI_Waitdelay");
        DeleteAttribute(&Characters[GetMaincharacterIndex()], "waitdelay");
    }
}<!--c2--></div><!--ec2-->
The reason seems simple; the main character doesn't HAVE the "waitdelay" attribute yet.
I imagine you'd only need to add some code to prevent the error message and abort the whole thing.
It's not a serious problem, but I don't like error.log files. <img src="style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" />
 
Back
Top