• 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
Holy crap, what is THIS?

Here's the #defines for skills:
Code:
#define SKILL_LEADERSHIP   "Leadership"
#define SKILL_FENCING     "Fencing"
#define SKILL_SAILING     "Sailing"
#define SKILL_ACCURACY     "Accuracy"
#define SKILL_CANNONS     "Cannons"
#define SKILL_GRAPPLING     "Grappling"
#define SKILL_REPAIR     "Repair"
#define SKILL_DEFENCE     "Defence"
#define SKILL_COMMERCE     "Commerce"
#define SKILL_SNEAK       "Sneak"
Now look at this line of code:
Code:
dmg *= (0.75 + fRand(GetSummonSkill(attack, SKILL_SNEAK))/(40.0/3.0));
Combined with this function that it uses:
Code:
int GetSummonSkill(ref chref,int _SkillType)
{
   return GetSummonSkillFromName(&chref,GetSkillName(_SkillType));
}
Anyone spot a problem there?

SKILL_SNEAK is "Sneak", in other words a string (=text) and NOT a number
But it enters that function as an integer number to be converted into a text afterwards.
That makes no sense and could throw those functions out of whack quite nicely. :facepalm
 
I made a start with the necessary rewrites for this and simplified the system quite a bit.
This is as far as I got:

- GetCharacterSkill returns a character's skill without modifiers
- CalcCharacterSkill returns a character's skill WITH stored modifiers from items
- CalcEffectiveSkill calculates and returns the character skills with officer type applied
- GetEffectiveSkill returns a previously stored value for the above (will calculate this if no stored value is present)
- CalcPartySkill calculates and returns the total skills for all contributing officers with "fleet mali" already substracted
- GetPartySkill returns a previously stored value for the above (will calculate this if no stored value is present)

This means there are now THREE versions of "stored skill numbers":
1. Total item modifiers, updated wherever UpdateSkillModifiers is called
2. Effective skill, currently NOT EVER updated
3. Party skill, currently NOT EVER updated

Depending on the situation, a different function may be called.
It should ALWAYS be possible to call a function that uses a previously stored variable so the game should not need to bother calculating it every time.

Important stuff still to be done:

- Determine when and how these numbers SHOULD be reset so they can be recalculated
I am hoping that @Levis can figure out appropriate points to do this so that we can do this ONLY when truly needed.
In fact, I would want even the INTERFACES to use the stored numbers so that we can actually SEE when they're wrong.
Otherwise we would only ever see the correctly updated values, which wouldn't allow us to check if they actually update correctly. :facepalm

- Determine which skill function is to be used where
Apart from the Character/Passenger interface and one specific instance, this is ALWAYS GetPartySkill.
Of course any personal fighting stuff should use CalcCharacterSkill instead. Possibly also some dialogs should consider only the player.
Excluding interfaces, I have no clue where any of the other functions would be appropriate.

In other words, it is pretty much either "CalcCharacterSkill" for individual skills OR "GetPartySkill" for combined skills, taking into account officer effects and the size of your ship.
Based on that reasoning, perhaps I don't even need to store the "effective" skill values at all.
But we'll see how that goes....


In any case, please have a think about all this and see what kind of scenarios you can think of where different skills should be used and/or updated.

As an added bonus, I restored some of my earlier changes to the Character Interface title.
Rather than showing the "officer type" in the title AND at the bottom, the title itself will show a "category" for the character you're looking at.
I always figured that would help to distinguish the status for different characters (and also allow us to notice any potential discrepancies...)
 
Last edited:
@Pieter Boelen could you upload your files ? I hope to start on this tomorrow afternoon.
 
@Pieter Boelen could you upload your files ? I hope to start on this tomorrow afternoon.
I was already working on it. ;)

My hope would be that you can build on my work on the skills tomorrow to make something that actually works again.
Right now performance is much better and there is a system that should hopefully be flexible enough to do everything we want.
However, once the numbers are stored, they're never updated again. So this probably won't be very awesome for gameplay just yet... :wp
 
My changes to this are now available from here: Mod Release - Build 14 Beta 4 Internal WIP For Testing | PiratesAhoy!

The "Get" functions call the "Calc" functions whenever a number isn't already already stored.
So removing the stored number will trigger it to be recalculated whenever it is needed next.
My hope is that will spread out the calculation load as this could only be done when needed.
And then hopefully not each character in a scene gets recalculated at the same time, so you wouldn't actually notice it anymore.
 
It also occurred to me that perhaps a rewrite for UpdateSkillModifiers is in order.
Then hopefully we can call that as part of TakeNItems so that we don't need to bother doing it manually anymore in various spots.
If it is called for only one character at a time and possibly only for a single item, it won't have much of an impact on that function.
That would allow us to NOT have that in any loops going through all characters; that should help.

Also, probably I'll need to write some "Reset" functions to go with the "Get" and "Calc" ones.
They'd probably have to be done a bit cleverly too, so that resetting the skill modifiers on an officer will reset the "party" attribute for that officer's captain as well.

Maybe that functionality can be included IN the "Calc" functions so that we won't need separate ones.
Then we can call "Calc" whenever we know the number is going to change and call "Get" when we just want to see what the last number was.
 
Here I was wrong to, a full installation brings the performance back again
to god FPS:shock
 
Or is it because of a new game and it gets worse again as the game progresses when you gain more officers for the game to loop through?

After my tests over the weekend, I do not believe there to be a magical fix to bring the performance back to normal.
It is plain inefficient coding that @Levis and me have to rewrite.
 
I have now all officers on board, the performance at sea is still god, loadingtime is going
down, but better than before. I still think a clean and full installation is doing a difference.
Its better than just a update.
 
This one seems to be well and truly fixed now, so I am taking great pleasure in marking this one as FIXED and archiving it hopefully for good! :dance

Of course fixing this required a substantial rewrite to the skills system, which is bound to bring with it all sorts of issues.
But that is a different problem for another day that will be continued here: Needs Testing - Skill System Rewrite to Improve Game Performance | PiratesAhoy!

In the meantime, enjoy the restored game performance! :cheers
 
Of course they'd crash! Have you go any clue how much else has been changed since then?
It's been a lot and the code isn't directly compatible anymore.

It may be possible to WinMerge only the need parts, but that would take substantial time and effort.
Best thing to do is to join the Beta 4 party soon.
 
  • First of all, the overall perfomance at sea is very high and excellent! I did one battle to a big fleet of merchants and the FPS didn't droped almost nothing and there weren't any lags of one second good and one second of freeze. This problem has persisted for a very long time and now it's fixed completely.
As per the above report, we really do seem to be good on this one!
Once we're done, Beta 4 should be really, really nice. :dance
 
Back
Top