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

Build 14 Alpha 8.5

This is what I find in my compile.log

InitSounds (English): created 62 entries.
InitSounds (common): total sounds - 191
InitMusic: created 42 entries.
InitGreetings: created 247 entries.
InitTalks: created 20 entries.

The Sound_GetName function searches through 900 possible entries. It should search a maximum of 458. This doesn't sound like much difference, but I've noticed better response in my game, and I wasn't even noticing lag before.

Look in the alias.c file near the bottom for the FindSounds, FindGreetings and FindTalks functions. In each there's a line that says something like

if (!CheckAttribute(Sounds_Alias, "id")) continue;

Change "continue" to "break" in all three cases. You can probably do FindMusic as well, but it shouldn't it shouldn't affect processing that much.

See if that doesn't help a lot.

Edit: I think I can figure out how to determine if a sound should use an alias or be played as is. If so, we can cut down the 458 entries searched and achieve close to the performance of what Captain Dan suggested.

Hook
 
I hope the two of you can look into this. Not being at home and not having much time until Friday, there's not much I can do except say random things.
Good luck and I sincerely hope you'll manage! <img src="style_emoticons/<#EMO_DIR#>/me.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="me.gif" />
I'd LOVE to have proper game performance again for Build 14 Alpha 9! <img src="style_emoticons/<#EMO_DIR#>/danse1.gif" style="vertical-align:middle" emoid=":dance" border="0" alt="danse1.gif" />
 
Maybe a solution: for the very start of the 'string Sound_GetName(string name)'

function whe need a check, that the 'name' is a legal PATH for a soundfile, or soemthing else.
WHich search for a wav file, and if wont find the EXACT path, it returns 0, and THEN the search continues,
otherwise: it exicts, returning the 'name', playing the legal path.

As the current FindSound arent do, as it searches through lots of entries, instead of deciding that the 'name' path refers to a file, and could instantly play, or not.

What do you think?
Can you tell me, with what function I can check simply if the path is valid?
 
In the file sound.c

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->string Sound_GetName(string name)
{
    if (strRight(name,4) == ".wav") return name;    // LDH 10Mar09

    aref SoundsRef;<!--c2--></div><!--ec2-->

Add the line marked with the LDH comment. As far as I can tell, all sounds intended to be played directly have ".wav" on them, and no aliases should have this. This should bypass the alias processing if you've given a specific sound.

Edit: looks like we came up with similar ideas at the same time. <img src="style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I even had time to test it.

Hook
 
I sent a PM to Pirate_KK to inform him of your findings. Since he originally rewrote the sound system, hopefully he can provide some useful input too. <img src="style_emoticons/<#EMO_DIR#>/doff.gif" style="vertical-align:middle" emoid=":doff" border="0" alt="doff.gif" />
 
You currently answered my last question, AND found the solution. <img src="style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Im amazed, we thinked totally together XD
But you know functions, im not <img src="style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" />

A question for you:

WHAT language POTC uses??? C ? C++?
Does it have its stock language functions, or just POTC fucntions?

Where can I find, search, and learn its main functions?

<img src="style_emoticons/<#EMO_DIR#>/keith.gif" style="vertical-align:middle" emoid=":keith" border="0" alt="keith.gif" />

Im amazed, nice to meet you Hook!
 
The PotC language is close to C, but not exactly the same, if I recall correctly. There should be a keywords file in the buildinfo subfolder that might be useful.
 
Ok, the result of Hook's amazing code:

Stutter WONT present at all with clicking sounds, and flapping sounds anymore, but gunfire remain the same... Its isnt appear to directplay.

The solution works,

But Where can I where can I chaneg the gunfire sounds, to make them contain .wav??? XDXDXD
 
The gunfire sounds use the INI option at the moment. Find their INI entries in RESOURCE\INI\sounds, then search for that code in the PROGRAM folder.
(I'm not at home, otherwise I would've done it for you <img src="style_emoticons/<#EMO_DIR#>/mybad.gif" style="vertical-align:middle" emoid=":facepalm" border="0" alt="mybad.gif" /> )
 
In the AIBalls.c file:

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->if(JRH_GUNSOUNDS && CheckAttribute(rCannon,"sound")) // NK 05-05-03 add toggle and check.
{
    //sounds per type JRH
    //    ref    rCannon = GetCannonByType(sti(aCharacter.Ship.Cannons.Type)); // not needed
    Play3DSound( rCannon.sound , fX, fY, fZ);

    //gunner cough JRH
    if(sti(aCharacter.index) == GetMainCharacterIndex())
    {
        Play3DSound("gunner_cough", fX, fY, fZ);
    }
}

else { Play3DSound("cannon_fire", fX, fY, fZ); }<!--c2--></div><!--ec2-->

This is the code that plays the cannon sounds.

Neither gunner_cough nor cannon_fire is in the new alias code, so the code is searched then the alias name passed to the sound system. I hate special cases, but we could add those two to the check that bypasses the alias search the same way we bypass ".wav" files.

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->string Sound_GetName(string name)
{
    if (strRight(name,4) == ".wav") return name;    // LDH 10Mar09
    if (name == "cannon_fire" || name == "gunner_cough") return name;  // LDH 10Mar09

    aref SoundsRef;<!--c2--></div><!--ec2-->

Let me go test that. You test it too, see if it helps any.

Edit: DANG! That makes quite a difference. Go with that code change I posted.

This isn't something to chastise the original programmers for. Usually optimization issues like this come up after the code has been released.

Hook
 
If you make an exception, you also need to do it for all the possible rCannon.sound options. Otherwise you're still going to get the lag if you have enabled JRH_GUNSOUNDS.
 
The second code posted is in the sound.c. Appears universal for me <img src="style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" />

I HOOOOPE it works!!!

SPinned up my nerves with adrenaline about the joy that he found a solution, and with Cherry tobacco Egyptian waterpipe,
It feels like heaven... XD going inject and test the latest code-

jkdnmfkg Jippeeeee!

(a tad unstable soul mood currently)
 
Serves 'em right for using those sounds.

Perhaps a test for strLeft(name,11) == "cannon_fire" instead of testing the whole string would work.

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->if (strLeft(name,11) == "cannon_fire" || name == "gunner_cough") return name;  // LDH 10Mar09<!--c2--></div><!--ec2-->

The strLeft function is smart enough to return the proper string even if it's not long enough.

Hook
 
What's wrong with cannon-specific sounds??? <img src="style_emoticons/<#EMO_DIR#>/piratesing.gif" style="vertical-align:middle" emoid=":shock" border="0" alt="piratesing.gif" />

[ <img src="style_emoticons/<#EMO_DIR#>/razz.gif" style="vertical-align:middle" emoid=":razz" border="0" alt="razz.gif" /> ]
 
that they not contains ".wav" in the path, thats why they lagged still. But Hook made an if which still excludes from them from further search, and innstantly play them. Works fine yet
 
<!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->What's wrong with cannon-specific sounds???<!--QuoteEnd--></div><!--QuoteEEnd-->
Nothing at all, as long as they sound like cannons.

I was a tank crewman for a while in the army. I can tell you from personal experience that the only difference between a shotgun, a hand grenade and a tank main gun is the volume. I also spent time at American Civil War reenactments (got some good pics somewhere) and the cannons they used had the same sound.

Of course, the guns need to sound like a player expects a cannon to sound, no matter what they sound like in real life. For me, the stock sounds are correct.

Pirate_KK recommends using native find functions, but I'm not sure if they're optimized to work with sparse arrays like we have with the sounds. Perhaps on the larger ones, but the ones with only a few entries may actually take longer with those functions.

I'm still missing a lot of sounds. Whatever the new code was supposed to do to fix that didn't help.

Hook
 
What sounds do you miss?

I have dialog sounds, NPC comments, all sailing sounds-

Youre right about the find functions, if you open them in notepad, it seems they are scanning through all aliases.. Or if not, still not as memory, and cpu friendly, as find 3-5 characters in a short string....
 
Back
Top