Tickers Ticking, Optimizations Continue

Hey Folks! Better dev day, today. I managed to solve yesterday's bug in a matter of minutes this morning. Sometimes walking away for a bit really does help!

Turns out the problem I was having was a bad timer calculation. I was decrementing the head ticker by the wrong variable each frame. Instead of the amount of time since the last frame, it was the amount of time since the last game object update. So it was deducting seconds worth of time per millisecond of real time. And this caused weird accounting issues and mismatches, breaking the timer system. Oops!

Fixing that magically made everything normal again. In fact, better than normal! Now that stuff is updating exactly when it needs it, certain in-game actions were a lot more snappy. Previously, nothing could happen faster than 1 second, which meant 1 second delays everywhere. Now, we can have near-instant feedback on certain actions, which is a big improvement. (And was actually a task I had on my to do list for a while. Done now for free!)

As I was testing, I noticed a few discomforts on AI that were hard to decipher. So I changed their text to be a bit clearer. I also noticed a bug that caused AI to try and open doors twice each time. The first time was normal, but the second was their impatient try again while it was opening. (The down-side of the new instant-response fix.) While it's cute to think of AI impatiently hitting the button, it's not as cute when it happens exactly twice for each door.

Once this was done, I began work on the next phase of this optimization: turning off auto updates for every object in the game that never needs updates. And adding/removing objects to that manual update list when needed.

This took a few running starts before it worked. I ended up having to add code in a few places to make sure sleeping objects didn't update until they awoke. E.g. characters on stations that were not currently loaded. Before I fixed this, my entire system of people and ship equipment was updating in a test run, and it was about 20-30fps. Which is about the same performance I saw before I optimized, except that version was only updating the ships on screen.

During testing, I also noticed a bug in my fusion power code that was running the power grid each frame, instead of it's slower schedule. It still could use some optimizing to make each run faster, but at least it's not happening 30-70 times per second now.

Finally, while using a save game file to test two rather large, docked ships, I ran into a bug in the AI memory. It had extra spaces in the names of interactions it remembered, which made those memories useless. And it was introduced by the save game system. Fixing that was trivial, once I figured out where it was happening.

All told, a successful day! Game's running a bit faster now. Things seem to be reliable again. I noticed some save/load instability and bugs which might need fixing, plus the aforementioned (days ago) extra scavenging options, to make my "derelict-scavenger without debug commands" goal possible. But it feels good to be back on track!

Tags: Ostranauts