Registration Notice

Due to increased spam, forum registration must be manually approved by a moderator! Please see this post for instructions.

*

Offline LukeZ

  • 1241
    • View Profile
  • France
Re: Squeak settings
« Reply #15 on: July 01, 2021, 10:49:58 PM »
Thank you very much for taking the time to do the test! I appreciate your help.

I have a few more updates that I am working on, completely unrelated to the sounds, and when I am done with those I will post a new official firmware version that includes this squeak fix. But until then you can use this testing firmware, it will be essentially the same thing as what I post later.

Good luck with finding the right sounds!
NO SUPPORT THROUGH PM - Read why
Need a forum account? Read here
Open Panzer FAQs

*

Offline osika

  • 53
    • View Profile
Re: Squeak settings
« Reply #16 on: July 01, 2021, 11:35:13 PM »
No problem and thanks for the solution!  Curious was it hard to figure out and execute? Seems like it would be.

*

Offline LukeZ

  • 1241
    • View Profile
  • France
Re: Squeak settings
« Reply #17 on: July 04, 2021, 09:28:02 PM »
Curious was it hard to figure out and execute? Seems like it would be.
It took a little effort but by process of elimination I finally discovered the issue. As you noticed, the problem was that in some cases the squeaks were not turning on when the vehicle reached the minimum speed.

The simple way of turning on the squeaks would be something like this:
IF vehicle speed > minimum speed THEN turn on squeaks

This would work but is not what I had done, because it would turn on the squeaks every single time through the main loop as long as the speed exceeded the minimum. That doesn't hurt anything but it's unnecessary work since once the squeaks are on we don't need to turn them on again, unless we later drop below the minimum speed. I try to avoid this kind of activity because even though in this single case it doesn't really take much time, if I have hundreds of things that run like that it all ads up and we take time away from other tasks.

Instead what I had originally was something like this:
IF squeaks = off AND IF vehicle speed > minimum speed AND IF prior speed < minimum speed THEN turn on squeaks

This is a better approach because we only turn on the squeaks once when we need to, the rest of the time we skip this step. (There was a similar command in reverse for turning off the squeaks.)

The problem was that sometimes the prior speed was not getting updated correctly, or anyway, unusual states could be created when changing between forward and reverse quickly, for complicated reasons. The prior speed is only used in a few situations and back when I included it I didn't think through every situation since it was only important at certain times, and I made sure it worked at those times. Later I added the squeaks and just assumed I could always count on them to behave as I wanted for this purpose too. Most of the time that assumption was correct, which is why I never noticed a problem, but you found the case where it wasn't.

This is a very typical example of the kinds of issues that arise over time when new features are added. With 30,000 lines of code I can't remember everything so I often make assumptions about what ancient Luke did in the past. However that assumes ancient Luke was as smart as present Luke, or that ancient Luke thought ahead to what present Luke might wish he had done in the past, and that usually ends badly.  :D
NO SUPPORT THROUGH PM - Read why
Need a forum account? Read here
Open Panzer FAQs

 

bomber-explosion