• 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 Improve Performance in 3D Sailing Mode

Select everything that applies to you

  • -- WHERE DID YOU NOTICE ANY REDUCED PERFORMANCE? --

    Votes: 0 0.0%
  • -- WHAT IS THE MOST RECENT MODPACK VERSION WITH THE BEST PERFORMANCE? --

    Votes: 0 0.0%
  • Build 14 Beta 3.1/3.2

    Votes: 0 0.0%

  • Total voters
    17
Do you have Fraps installed? I ask because I use it to show the frame rate, and what it shows is a steady pulse in the fps every half second or so. Counting using the old "a thousand 1, a thousand 2" method I get "a thousand" between pulses.
 
Do you have Fraps installed? I ask because I use it to show the frame rate, and what it shows is a steady pulse in the fps every half second or so. Counting using the old "a thousand 1, a thousand 2" method I get "a thousand" between pulses.
This is also when I see the function I told being called, thats why I think thats the culprit. I'm going to look at that function this week. Hopefully I can rewrite it enough so it wont cause lag anymore.
 
This is also when I see the function I told being called, thats why I think thats the culprit. I'm going to look at that function this week. Hopefully I can rewrite it enough so it wont cause lag anymore.
I have used Shadowplay and find the performance very good . For the first time I have seen FPS go to 62 in
big sea battle,and it is stable between 59 to 62 FPS. I have been playing about 1 hour, and have 4 big battle
with 6 to 7 ships . So I think this is great!:D
 
Last edited:
At the moment I don't have anything to actually show the FPS.
@Levis: One thing you can try to very quickly see if you're on the right track with your performance work is to stick a return line at the top of that function.
That should stop everything in there from being executed. If performance doesn't get better after that, the culprit might still be somewhere else.
 
From what I can see I get about a 50 to 100% increase in FPS by disabling that function. but it's a bit hard to test because disabling that function makes sure you can't access the map anymore or hoist sails :p.
But even with my setting maxed out on a rainy foggy weather with an enemy ship in the bay I got about 25 to 30 fps where I'd normally get about 20 fps. on a clear day with a bit of rain and no enemy ship I got about 40 fps where I'd normally get about 25 fps.
 
@Pieter Boelen you have been working on the flag detection so I guess you know how the ship distance etc works.
This is called each second for each ship. I think we can improve this right, or maybe combine it with the flag detection.
Code:
// check forts for abordage
    int iFortsNum = GetAttributesNum(aForts);
    fBestDistance = 10000000.0;
    for (i=0; i<iFortsNum; i++)
    {
        aref aFort = GetAttributeN(aForts, i);
        iRelation = sti(aFort.relation);
        if (iRelation == RELATION_FRIEND) { continue; }
        ref rFortCharacter = GetCharacter(sti(aFort.idx));
        if (LAi_IsDead(rFortCharacter)) { continue; }
        aref aRLoc = FindIslandReloadLocator(sPlayerLocation, rFortCharacter.location.locator);
        float fRadius = stf(aRLoc.Radius);
        fDistance = stf(aFort.Distance);
        if(CheckAttribute(rCharacter, "ship.SubmergeDutchman")) fDistance = DIST_NOSHIP; //Levis no shooting at submerged dutchman
        int iFortMode = sti(rFortCharacter.Fort.Mode);

        switch (iFortMode)
        {
            case FORT_NORMAL:
                if (iRelation == RELATION_ENEMY)
                {
                    if (fMinEnemyDistance > fDistance) { fMinEnemyDistance = fDistance; }
                }
// KK -->
                if (sti(rFortCharacter.nation) == PERSONAL_NATION) {
                    if (!bMapEnter) continue;
                    if (fDistance > fRadius) continue;
                    //if (!Character_IsAbordageEnable(rFortCharacter)) { continue; }

                    if (fBestDistance > fDistance)
                    {
                        fBestDistance = fDistance;

                        bCanEnterToFort = true;
                        sAbordageLocator = rFortCharacter.location.locator;
                        iAbordageFortEnemyCharacter = sti(rFortCharacter.index);
                    }
                }
// <-- KK
            break;
            case FORT_DEAD:
                if (fDistance > fRadius) { continue; }
                if (fBestDistance > fDistance)
                {
                    fBestDistance = fDistance;

                    bCanEnterToLand = true;

                    sIslandID = rIsland.id;
                    makearef(arIslandReload, rIsland.reload);
                    sIslandLocator = aRLoc.GoAfterBoard.location;
                }
            break;
            case FORT_ABORDAGE:
                if (iRelation == RELATION_ENEMY)
                {
                    if (fMinEnemyDistance > fDistance) { fMinEnemyDistance = fDistance; }
                }
                if (fDistance > fRadius) { continue; }
                if (!Character_IsAbordageEnable(rFortCharacter)) { continue; }

                if (fBestDistance > fDistance)
                {
                    fBestDistance = fDistance;

                    bAbordageFortCanBe = true;
                    sAbordageLocator = rFortCharacter.location.locator;
                    iAbordageFortEnemyCharacter = sti(rFortCharacter.index);
                }
            break;
        }
    }

// check ships for abordage
    int iShipsNum = GetAttributesNum(aShips);
    fBestDistance = 10000000.0;
    aref aShip; // KK
    ref rShipCharacter; // KK
    for (i=0; i<iShipsNum; i++)
    {
        aShip = GetAttributeN(aShips, i);

        rShipCharacter = GetCharacter(sti(aShip.idx));

        if (LAi_IsDead(rShipCharacter)) { continue; } // TIH moved up here for program speed Aug24'06
        if (!Character_IsAbordageEnable(rShipCharacter)) { continue; } // TIH moved up here for program speed Aug24'06
        if (IsCompanion(rShipCharacter)) { continue; } // TIH don't even do this stuff with companion ships Aug24'06

        fDistance = stf(aShip.Distance);        // distance between player ship and this ship
        if(CheckAttribute(rCharacter, "ship.SubmergeDutchman")) fDistance = DIST_NOSHIP; //Levis trying to get the Dutchman out of reach when submerged
        iRelation = sti(aShip.relation);

        // NK surrender 05-04-20 -->
        if (iRelation == RELATION_ENEMY && fMinEnemyDistance > fDistance) { fMinEnemyDistance = fDistance; }
        if (iRelation != RELATION_ENEMY && !CheckAttribute(rShipCharacter,"surrendered")) { continue; }
        //if (fMinEnemyDistance > fDistance) { fMinEnemyDistance = fDistance; }
        // NK <--

        float fAng = stf(aShip.d_ay);                        // it's dot.ay between ships
        float fRelativeSpeed = stf(aShip.RelativeSpeed);    // it's relative speed about player ship
        float fEnemyBoxSizeX = stf(rShipCharacter.Ship.BoxSize.x) / 2.0 * (1.0 + makefloat(CheckAttribute(rShipCharacter,"surrendered"))*BOARD_SURR_DISTANCE_MULT); //so you can board surrednered ships from afar. NK 05-04-23 //KB - corrected
        bool bAngleTest = abs(fAng) > fOurMaxAbordageAngle && fRelativeSpeed < fOurMaxAbordageSpeed;
        if(!USE_REAL_SAILING) bAngleTest = bAngleTest || bGrapplingProfessional; // KNB
        //if (abs(fAng) > fOurMaxAbordageAngle && fRelativeSpeed < fOurMaxAbordageSpeed)
        float fAbordageDistance = fDistance - fEnemyBoxSizeX - fOurBoxSizeX;
        // NK check for surrender 05-04-21 (reorganize this so dist checked first, angle second)
        if (fAbordageDistance < fOurMaxAbordageDistance && fBestDistance > fDistance)
        {
            if(CheckAttribute(rShipCharacter,"surrendered"))
            {
                /*string sGroupID = rShipCharacter.surrendered.oldgroup;
                bool alive = true;
                int gidx = Group_FindGroup(sGroupID);
                if(gidx == -1) alive = false;
                if(alive) alive = Group_isDead(sGroupID);
                if(alive)
                {
                    ref gcmdr = Group_GetGroupCommander(sGroupID);
                    if(SeaAI_GetRelation(sti(gcmdr.index), GetMainCharacterIndex()) != RELATION_ENEMY) { continue; }
                }
                else { */
                    // TIH --> use a better function for relation checking to determine if you can board a surrendered ship Aug24'06
                    //Trace("BDCHK: surrendered ship boarding check: " + rShipCharacter.id + " oldnation: " + rShipCharacter.oldnation + " curnation: " + rShipCharacter.nation );

                    // attempt 7: (couldn't seem to board ANYONE who surrendered)
                    //int tmpNation = sti(rShipCharacter.nation);
                    //rShipCharacter.nation = rShipCharacter.oldnation;
                    //int tmpRelation = SeaAI_GetRelation(sti(rShipCharacter.index), GetMainCharacterIndex());
                    //rShipCharacter.nation = tmpNation;
                    //if (tmpRelation != RELATION_ENEMY) continue;

                    // LDH unable to board surrendered ship test
                    // Relations 0=friend, 1=neutral, 2=enemy
                    // Flags 0=England, 1=France, 5=Portugal
                    // 5, 1, 0,
                    //logit("Surrendered ship: flag = " + GetCurrentFlag() + ", oldnation = " + rShipCharacter.oldnation);
                    // 0 with English (Portugese!!) flag, 1 with personal flag
                    //logit("NationRelation = " + GetNationRelation(GetCurrentFlag(),sti(rShipCharacter.oldnation)));
                    // 2
                    //logit("ActualRelation = " + GetNationRelation2MainCharacter(sti(rShipCharacter.oldnation)));

                    // attempt 6: (seems to work except for one damned french ship - but he is set to never surrender now, so who cares?)

                /*    int tmpRelation = "";
                    if ( GetCurrentFlag() != PERSONAL_NATION )
                    {
                        tmpRelation = GetNationRelation(GetCurrentFlag(),sti(rShipCharacter.oldnation));
                    //    Trace("BDCHK: GetNationRelation: " + tmpRelation + "  (" + RELATION_ENEMY + ")" );
                    }
                    else
                    {
                        tmpRelation = GetNationRelation2MainCharacter(sti(rShipCharacter.oldnation));
                    //    Trace("BDCHK: GetNationRelation2MainCharacter: " + tmpRelation + "  (" + RELATION_ENEMY + ")" );
                    }
                */
                    int tmpRelation = GetNationRelation(GetCurrentFlag(), sti(rShipCharacter.oldnation)); // PB
                    if (tmpRelation != RELATION_ENEMY) continue;

                    // attempt 5:
                    //int tmpnation = sti(rShipCharacter.nation);
                    //rShipCharacter.nation = rShipCharacter.oldnation;
                    //if(GetRelation(rCharacter.index,rShipCharacter.index) != RELATION_ENEMY) { rShipCharacter.nation = tmpnation; continue; }
                    //rShipCharacter.nation = tmpnation;
                    // attempt 4:
                    //if(SeaAI_GetRelation(sti(rShipCharacter.index), GetMainCharacterIndex()) != RELATION_ENEMY) { continue; }
                    // attempt 3:
                    //if(GetRMRelationType(GetRMRelation(rCharacter, sti(rShipCharacter.oldnation))) != RELATION_ENEMY) { continue; }
                    // attempt 2:
                    //if(GetNationRelation2MainCharacter(sti(rShipCharacter.oldnation)) != RELATION_ENEMY) { continue; }
                    // attempt 1:
                    //if(GetNationRelation2MainCharacter(sti(rShipCharacter.oldnation)) != RELATION_ENEMY) { continue; }
                    // TIH <--
                //}
                //HKE -->
                if (!CheckAttribute(rCharacter, "PlayedAbordageSound"))
                {
                    PlayStereoSound("INTERFACE\prepare_for_boarding.wav");
                    rCharacter.PlayedAbordageSound = true;
                }
                //<-- HKE
                bAbordageShipCanBe = true;
                iAbordageShipEnemyCharacter = sti(rShipCharacter.index);
                fBestDistance = fDistance;
                continue;
            }
            if (bAngleTest)
            {
                // NK surrender 05-04-20 <--
                //HKE -->
                if (!CheckAttribute(rCharacter, "PlayedAbordageSound"))
                {
                    PlayStereoSound("INTERFACE\prepare_for_boarding.wav");
                    rCharacter.PlayedAbordageSound = true;
                }
                //<-- HKE
                // abordage enable
                fBestDistance = fDistance;
                bAbordageShipCanBe = true;
                iAbordageShipEnemyCharacter = sti(rShipCharacter.index);

                // maybe other character want abordage us?
                float fEnemyFencing = pow2(stf(rShipCharacter.TmpSkill.Fencing),FENCING_BOARD_PWR); // NK scale by fencingpwr 05-04-20
                float fEnemyCrewFencing = (0.1 + fEnemyFencing * stf(rShipCharacter.Ship.Crew.Quantity) * (1.0 - ((1.0 - fclamp(0.1, 10.0, stf(rShipCharacter.ship.crew.morale)/(MORALE_MAX-MORALE_MIN) * 2))/2.0))); // NK add morale 05-04-20
                float fRatio = fEnemyCrewFencing / fOurCrewFencing;
                if (sti(rShipCharacter.nation) == PIRATE) { fRatio = fRatio * 1.4; }
                if (fRatio > 1.2)
                {
                    bAbordageStartNow = true;
                    break;
                }
            }
            continue;
        }
    }
It's in AIShip.c starting at 3783
 
Looks like that code actually uses the same engine-based distances that I use for the false flag detection.
I see no calls there to the 2D distance calculation so I figure that section of code should be relatively fast.

The "lag" at sea is only every few seconds, so I'd be surprised if that code was the culprit.
It is also code that was in the game also back when it was still smooth. :confused:
 
The game is running better than it used to for me now. It is still very inconsistent with no stutter at all at times, very little stutter, and heavy stutter at other times.

Frame rates are up a bit, but that is not the issue for me. It is the stopstartstopstartstopstart stutters that bother me. It happens when walking the deck, looking in the spyglass, and when trying to aim the cannons.
 
I've noticed it too in my short bits of testing. But I need a break from hard modding for a while now so won't be looking into it just yet.
 
Okay I will look into this more when I'm back.
Untill then all information you can provide would be nice.
For example:
- Does it only happen in battle, or also normally
- Does it happen with all spyglasses or only some
- Does it become worse with a higher spyglass
- Does it happen on each type of ship
- Is it worse when a fort is around

And all other things you can notice :).
 
It happens all the time everywhere.

With a single small ship like a Polacca it ranges from mild to "can't see it". With large ships and especially lots of large ships it can make the game unplayable. Forts don't seem to make a difference.
 
This is with walking on ship, aiming and using the telescope?
 
Okay I will look into this more when I'm back.
Untill then all information you can provide would be nice.
For example:
- Does it only happen in battle, or also normally
- Does it happen with all spyglasses or only some
- Does it become worse with a higher spyglass
- Does it happen on each type of ship
- Is it worse when a fort is around

And all other things you can notice :).
I have noticed worse stutters when enemy ships are around.
It was notably bad when I used the console switch (3) and went picking a fight with some Spanish ships around Hispaniola.
 
It is all the time everywhere doing anything and everything.
I'm sorry but these kind of posts dont help. I understand its annoying but this doesn't give me much information. If it's really exactly the same in all situations please specificly state it. else try to tell in which situation its worse or if some aspects make it worse. Those kind of small details can help me so much in finding where the problem lies....
 
I'm not going to repeat myself again. Figure it out for yourself.
The more details we've got, the more chance we've got of actually solving the problem.
While you've made a lot of posts on the subject, they're tremendously confusing.
Apparently sometimes everything is fine, except when it's not. And then it is crappy in situations with many ships. Except when it's not.
And then sometimes it is bad all the time.

When we did the Beta 3.3 > Beta 3.4 step-by-step hunt, nothing conclusive was proven either when really that would have been the only real way to get to the bottom of the problem.
All that gives us absolutely zero clue on what might be the cause, so to fix it we'd have to completely shoot in the dark.
The chance of actually finding the real culprit when rewriting stuff at random, hoping it will solve the problem, is very small indeed.
In fact, having to rewrite all sorts of stuff is very risky indeed as it might end up breaking stuff that never needed to be broken.
 
I suspect the issue has something related to the game time setting. At 1x I have no noticeable issues but changing to 3x or more I get the stutter and at 5x much worse. The music is stuttering as well at 3x and higher.
This is possibly just a symptom and not an indicator of the problem's source.

I don't get the stutter on land that I notice.

I do now get (latest 13 August with Levis officer level fix) a slight lag creeping in that I notice only when digging for jewels and minerals in the Crypt at Speightstown. This wasn't there in previous versions - only a minor issue though. I could dig as fast as I could hit the spacebar before- he he - and get lots of loot early in the game - provided I have plenty of potions, ( have to have lots of shovels as well as they break properly now) and run away a lot.

Hope this helps.
 
I'm not going to repeat myself again. Figure it out for yourself.
Wish i could but even with aa and everything to the max I have no fps below 30 on both my laptop and desktop...
 
What is the best (free!) way of displaying the PotC frame rate on the screen? It appears that I don't airways have very smooth performance with the latest modpack versions either, so it might be nice if we can quantify that.

Right now I can't really play the game due to the Leveling issues, so cannot proudly properly check the remaining quest issues.
And pretty much everything else is on hold pending player feedback. So perhaps I can give this issue one last shot.
 
Back
Top