• 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
Yes. I notice after installing Levis last work, the performance at sea drops down a lot.
Also there is a couple of thing that worry me (dont know if it is the place to mention this)
I tried to buy a trading license and the dialog is odd, see picture. And this master of arms
have a plenty lot of skills and perks.
 

Attachments

  • seadogs2_0020.jpg
    seadogs2_0020.jpg
    278 KB · Views: 181
  • seadogs2_0001a.jpg
    seadogs2_0001a.jpg
    437.6 KB · Views: 167
This is the 22 Sep 2015 version.
Please try this version and see what happens. At the very least, it shouldn't be worse.

Note that this isn't actually a fix; I'm just bypassing a lot of fancy code that may be slowing things down.
But this also means that items, skill modifiers, officer types, etc. are NOT taken into account anymore.
 

Attachments

  • officers.zip
    4.8 KB · Views: 169
I tried to buy a trading license and the dialog is odd, see picture. And this master of arms
have a plenty lot of skills and perks.
That dialog looks quite normal. Or do you mean that there isn't a second option in the dialog?
Check your Inventory; if it looks like that, you should already have the Trading License.
 
I've been playing a lot recently with the Sept 27th build and I was getting stuttering lag more and more the longer I would play a save. I think I have narrowed it down to being how many officers you have. I noticed the lag started right away when using the 'Brave Black Flag' start, and that you started with a bunch of officers there. So I went to one of my older saves and fired all my officers and indeed the stuttering was gone. Hopefully this helps you narrow it down.

Can't believe how far you all have come with the game over the years, it really is amazing work. :onya
 
That is it!!!!!:thumbs1:bow:monkeydance:monkeydance:monkeydance:monkeydance:monkeydance

Here are two screenies, one taken yesterday at Point a Pitre and the other just a few minutes ago at Orangestad. It was 30-36 fps and staggering and now it is 75 fps and smooth! :onya
POTC CAB 2015-09-29 10-51-47-45.jpg POTC CAB 2015-10-03 12-07-13-41.jpg
 
So performance is back to OK with that file?
Well, then at least we know where the problem lies!
Basically it is just too much stuff being called.
We really have to see about reducing that in such a way that we maintain the functionality.
Right now this was just a hack for testing purposes.

@ANSEL: The file I posted was for Hylie's version of the game which I think is the one from last week and wouldn't be compatible with yesterday's version.
I could make one for the new version, but I'd rather have an actual fix.
 
That does actually make sense based on the test @Hylie Pistof did earlier today.
Many officers means many characters whose skills need to be checked all the time.
Now that we finally know what we're up against, I think we can figure out ways to get the game performance back where we want it!
(It just probably won't be done overnight, but hopefully @Levis can figure out something clever too.)
 
Sounds like the contriblist isn't working....
 
Thread renamed for accuracy and several posts moved back and forth so that the ones dealing with performance IN the game are here and the ones dealing with the loading times are in the other thread.
Better split up the two as otherwise this could become real confusing.

Sounds like the contriblist isn't working....
As confirmed by @Hylie Pistof, this hack of mine did a lot to bring performance back to normal:
Confirmed Bug - Modpack Performance Issues | Page 14 | PiratesAhoy!
What I did there was to completely bypass every fancy code dealing with skills.

According to a quick look through the code, your "contriblist" applies exclusively to perks. So quite possibly that DOES work.
We just need to call something like that for skills too as that seems to be where the real problem lies.

Also, we could check what skills are being asked for in 3D sailing mode and why.
For example, I saw some calls to check characters' commerce skills in 3D sailing mode.
Not quite sure whatever that is needed for. o_O

EDIT: "Commerce" is called because ALL skills are called as part of Ship_UpdateTmpSkills . See below.
 
Last edited:
Let me see if I can figure out how the whole skill-calling system works:

- CalcCharacterSkill: Get character skill AND applies modifiers, then add a check to ensure the resulting number is between 1 and 10

- CalcSummOnSkillFromName: For the player, cycles through all passengers; for all other characters, call CalcEffectiveSkill

- ApplyFleetMali: Subtracts numbers from your skills if you have too large a ship; contains calls to CalcSummonSkillFromName for Leadership and Sailing.
Remember that this one checks all passengers too!

- GetCharacterSkill: Calls CalcCharacterSkill first, then applies "fleet mali"

- GetEffectiveSkill: Call GetCharacterSkill, then call GetEffectiveSkillByValue
Remember that GetCharacterSkill = CalcCharacterSkill + ApplyFleetMali

- CalcEffectiveSkill: Call CalcCharacterSkill, then call GetEffectiveSkillByValue
In other words, this is the same as GetEffectiveSkill, but skips the FleetMali

- GetEffectiveSkillByValue: Checks officer type to see what should be contributed and what not


The first thing that becomes immediately apparent is that all of this is CONFUSING AND CONVOLUTED!
Also, GetEffectiveSkill is the one that seems to get called a lot at sea.
(EDIT: Sorry, it is CalcEffectiveSkill that gets called so often, so the one EXCLUDING fleet mali.)

So that means:
1. Get character skill AND applies modifiers, then add a check to ensure the resulting number is between 1 and 10
2. Check if you can handle your large ship by looping through all your passengers apparently twice
3. For each passenger, get character skill AND applies modifiers, then add a check to ensure the resulting number is between 1 and 10
4. For each passenger, read officer type and apply whatever that type should be contributing
5. The number that results from here is then passed to GetEffectiveSkillByValue again, but probably this should be the player or a companion so no officer type checks are performed
However, that might be different for NPCs as they are NOT companions of the player.

While technically all this is all valid functionality, it becomes rather a pain when that is checked often for every character in a 3D sailing mode scene.
So clearly there is some substantial work to be done here.... :(
 
Last edited:
GetBasicSkill and GetSkillBool don't seem to be used anywhere.
GetAverageSkill is used in a few dialogs, but WHY? What is the point in doing this???

GetSummonSkillFromName is also a really fun function!
First it loops through all passengers by calling CalcSummOnSkillFromName,
then it will apply the "fleet mali", which ALSO loops through all passengers by calling that same function again, sometimes twice.
So you get a loop through all passengers three times for checking one skill number.
Anyone getting loopy yet? :razz
 
It gets better!
CalcEffectiveSkill gets called EVERY GAME SECOND for EVERY CHARACTER AT SEA for EVERY SKILL.
Simply leaving Barbados after the tutorial makes for 100 calls to that function per second.
This is probably because it gets called through GetSummonSkillFromName and/or CalcSummOnSkillFromName .

CalcSummonSkillFromName is mainly a part of ApplyFleetMali and should get used only for Leadership and Sailing.
However, GetSummonSkillFromName is indeed called for EACH skill as part of Ship_UpdateTmpSkills .
And THAT function is indeed part of Ship_UpdateParameters which gets called every second.

By the looks of it, the intention of Ship_UpdateTmpSkills is specifically to prevent issues like this.
Rather than using any of the fancy skill-checking functions I mentioned in my post above,
a lot of code in the SEA_AI folder checks the "TmpSkill" attributes.
So if that is set once, the game can just read straight from that rather than going through all sorts of fancy calculations.

Of course it defeats its purpose to then have those fancy calculation functions called every second anyway.
Ideally it should be called once when reloading to 3D sailing mode and afterwards ONLY for specific characters for whom the resulting number may have changed.
So that means it probably should be updated when:
- The player reassigns a character's officer type
- An officer gets killed during a sea battle (currently never happens as no such feature exists)
- After a successful boarding action (this may be considered "reloading to 3D sailing mode", in which case no separate call is needed)
- EDIT: Also when a character or an active officer of that character levels up, of course.
- Can't think of any other situations right now. Anyone else?
 
Last edited:
I will take a look at it. I think ill just make a sort of contriblist for skills too. I now know when someone levels up, so only then it should be made again. At other moments we could just pre calculate everything and make it look up.
So we just store the contributed skill for the character too the first time its called. After that we just look it up. When someone in the party levels at a certain skill this attribute will be removed so the next time it gets calculated again.
And also to be Sure on load its removed also, so if someone is moved to the location its recalculated again. And i think if an passenger is added or removed it should delete. Any more cases?
 
Also, GetEffectiveSkill is the one that seems to get called a lot at sea.
(EDIT: Sorry, it is CalcEffectiveSkill that gets called so often, so the one EXCLUDING fleet mali.)
Seems I misremembered from yesterday, so my post above has been updated for accuracy.
Odd though; now that I know where it is called and why, I would expect that fleet mali SHOULD be included here.
After all, these are the "effective skills" that are being used in 3D sailing mode so if anything should decrease from having too large a ship, that should.
Right? :confused:

I've been playing a lot recently with the Sept 27th build and I was getting stuttering lag more and more the longer I would play a save. I think I have narrowed it down to being how many officers you have. I noticed the lag started right away when using the 'Brave Black Flag' start, and that you started with a bunch of officers there. So I went to one of my older saves and fired all my officers and indeed the stuttering was gone. Hopefully this helps you narrow it down.
Also @Levis, I think Nate has a point here .
When I reloaded to 3D Sailing Mode after the tutorial, reload times were still somewhat reasonable.
It only got really bad when I had a fleet of four ships and a bunch of extra officers.
 
I will take a look at it. I think ill just make a sort of contriblist for skills too. I now know when someone levels up, so only then it should be made again. At other moments we could just pre calculate everything and make it look up.
You might have missed my post above. By the looks of it, something like that is already in place in 3D sailing mode where performance is the most important.
It just doesn't serve its purpose right now.

And also to be Sure on load its removed also, so if someone is moved to the location its recalculated again. And i think if an passenger is added or removed it should delete. Any more cases?
Might want to be careful with adding all sorts of resets upon location reloads. I'd really rather do those resets ONLY if something actually changes!
Recalculating too much on a reload may be a likely cause for the reload times now being so much slower than they used to be.
 
By the looks of it, the intention of Ship_UpdateTmpSkills is specifically to prevent issues like this.
Rather than using any of the fancy skill-checking functions I mentioned in my post above,
a lot of code in the SEA_AI folder checks the "TmpSkill" attributes.
So if that is set once, the game can just read straight from that rather than going through all sorts of fancy calculations.
I checked all the way back to the stock game code and it has ALWAYS been in that "once per second" function call.
Figures! Probably time to do something about that now.

TWO things we should be trying:
- Simplifying the whole "getting skill numbers" system so it doesn't loop more than it needs to
- Convincing that Ship_UpdateTmpSkills function to be called ONLY when the numbers actually change, rather than continuously

Actually, perhaps we don't even NEED that function in the first place.
What if the normal "getting skill numbers" functions automatically write to the "TmpSkill" attributes when needed?
Then we can have two versions of the functions:
One that goes through the trouble of calculating everything and another that just reads its previously stored number and calculates only if there is no previously stored number.
Then whenever something happens to change the numbers, we just delete the "TmpSkill" and it'll automatically be recalculated the next time it is needed.

Worth noting though that the "TmpSkill" numbers are reduced to a fraction, so a number between 0 and 1 rather than 1-10.
 
It turns out that me measuring FPS to determine performance here is basically completely pointless.
I bypassed and skipped ALL the skill coding and the game performance was really nicely smooth!
But framerate was 30 FPS at best. Went down to about 11 at 20x time compression.
No stuttering though!

Also, @Levis about Ship_UpdatePerks: Should we perhaps deliberately NOT check all perks?
After all, these are uses ONLY at sea and probably continuously updated too.
Many perks just don't have any meaning in 3D sailing mode, so those might as well be skipped, no?
 
Back
Top