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

Cannot Confirm Performance in LoginCharacter

Levis

Find(Rum) = false;
Staff member
Administrator
Creative Support
Programmer
Storm Modder
The function LoginCharacter (in character_login.c) has a weird stutter in it. It is probably caused by this part

Code:
if (isSoldier(chr) != UNKNOWN_NATION) GiveSoldierWeapon(chr, makeint(GetAttribute(chr, "nation")));    // PB: Re-Update Soldier Weapons
// KK -->
    if (CheckAttribute(chr, "old.blade")) {
        if (GetCharacterItem(chr, chr.old.blade) == 0) GiveItem2Character(chr, chr.old.blade);
        DeleteAttribute(chr, "old.blade");
    }
    if (CheckAttribute(chr, "old.gun")) {
        if (GetCharacterItem(chr, chr.old.gun) == 0) GiveItem2Character(chr, chr.old.gun);
        DeleteAttribute(chr, "old.gun");
    }

Need to look at this further cause this function is called for almost all monsters and fantoms and we are talking about almost a second of lag for running it once. So When a location with 10 fantoms needs to be loaded this one causes a lot of loading time.
 
I could imagine the soldier weapon part takes some time, but that is only called for soldiers.

The other part doesn't seem like it should be much of a performance issue.
Also not sure what it's for. I wonder if we can get rid of most of that .old code.

At what stage in the game do you notice this stutter?

Actually, is this part of a loop that goes through ALL characters in the game?
Perhaps it is worth only doing this for characters in the player location and skip the others.
Maybe add it to the new function that is run for logging out characters instead which has a similar check already included.
 
I noticed it for the smuggling. Its the reason why when the coastguard appears the game lags for a few seconds.
I fixed it in an other way now but it's worth looking into probably.

If you wanna test take one of the generate fantom functions from the coastguard generation and run it trough console.
 
Does the game cycle through all characters when one character is added to the scene then?
 
as far as I know it doesn't. But it does make fantoms I think cause there is a max amount of those.
 
The function LoginCharacter (in character_login.c) has a weird stutter in it. It is probably caused by this part

Code:
if (isSoldier(chr) != UNKNOWN_NATION) GiveSoldierWeapon(chr, makeint(GetAttribute(chr, "nation")));    // PB: Re-Update Soldier Weapons
// KK -->
    if (CheckAttribute(chr, "old.blade")) {
        if (GetCharacterItem(chr, chr.old.blade) == 0) GiveItem2Character(chr, chr.old.blade);
        DeleteAttribute(chr, "old.blade");
    }
    if (CheckAttribute(chr, "old.gun")) {
        if (GetCharacterItem(chr, chr.old.gun) == 0) GiveItem2Character(chr, chr.old.gun);
        DeleteAttribute(chr, "old.gun");
    }

Need to look at this further cause this function is called for almost all monsters and fantoms and we are talking about almost a second of lag for running it once. So When a location with 10 fantoms needs to be loaded this one causes a lot of loading time.
How did you discover it is that section of code that seems to be responsible for the lag?
Have you tried commenting out that whole section of code? Does that improve things?
 
For the smugglers I now generate the guards first and hide them. I then had to bring the back when needed whitout the lag so I copied the whole function and started to comment things out and see if the soldiers where still alright. And when this part was commented out it still worked without lag. Check smuggle.c for the coastguard function to see more.
 
Do you know if it was the GiveSoldierWeapon section or the other part?
Also, did you do this before or after the new guns were added into the game? I completely rewrote the GiveSoldierWeapon function a few days ago.

Code:
GetCharacterItem(chr, chr.old.blade) == 0
Can probably be replaced with:
Code:
!CheckCharacterItem(chr, chr.old.blade)
Not sure if that would help, but it does seem more sensible to me at least.
 
Not entirely sure if it's that, but could check tonight.
it was with the new guns. The delay has always been there.
 
The delay has always been there.
Even before last week? Then at least the new guns apparently didn't make it worse than it was.
Also, do you know if it applied ONLY to soldiers or also to other characters? GiveSoldierWeapon is executed specifically for soldiers only.
 
I should give this one a test; would admittedly be nice to prevent lag when NPCs are generated in mid-scene.
 
I tried to test this by attacking some town guards. After all, when you kill them, two more show up.
There is indeed a delay for each character added to the scene then, but even with the code from the opening post commented out, that still happens.
So I can't seem to relate the stutter to that section of code at all. :(
 
@Pieter Boelen I believe because of some of the changes I made in the last month the delay has become less. Could you confirm this?
 
Back
Top