Air Pumps, Backups, and Save Files

Hey Folks! More clean-up and prep today, plus a bit of investigation into what will probably be the next big task: saving game state.

After yesterday's performance housekeeping, the game was a bit more usable with large ships loaded. And one of the finishing touches to that change was to fix the camera panning to be independent of frame rate. A large part of what alerted me to the low framerate was the hitching camera panning. Now, the camera feels much smoother regardless (which will be a big deal in scenes where cpu/gpu usage spikes).

I fixed a few minor issues that crept in when optimizing crew animation calls, so they update at more appropriate times. There's still a weird glitch when tasking an AI with an interaction beyond closed doors (they'll start the interaction anim as they walk), but otherwise, it's behaving almost normally again (minus the performance hit).

In preparation for my first cross-system journey, I checked how the air pumps and canisters were working. It turns out: not.

There were a few bugs in the system causing the pumps to basically blast all the gas in the tanks instantly into the room. First of all, the tank data was a bit off, with a pressure assuming room temperature, but an actual temperature of near 0K. This meant the pressure in the tank was way lower than intended.

Secondly, the air pump calculations sort of break at such low temperatures. At near-0K, the numerator of PV/RT skyrockets, causing the pump to pull massive amounts of gas per cycle. And due to a bug in the pump code, it wasn't checking for supply before pulling, so it actually pulled 3x what was in the tank. And that was for each of the 6 tanks :)

Needless to say, we had some fixing to do.

I did a bit of research into NASA air tanks and airlocks, and found some better numbers. And when I adjusted the gas tank stats for room temperature, the air pump started to behave much more reasonably. Finally, I added a new nitrogen tank type to complete the atmo pumping system (an 80/20 N2/O2 mix). It's still a really basic system, and currently pumps constantly (even after room is full), but at least nobody suffocates :)

I might have to add a switching feature to the pump to turn off when the room pressure stabilizes, but before that, I wanted to look into a more critical system.

Actually, before even that, I backed-up the project source files and uploaded them to an off-site server ;)

Right, so save systems. I actually already have the game saving ship data out to files, and I can load that back in when needed. It's how I save and load ship designs to files, and between building/flying scenes.

However, there's one important thing missing from that data: current status. The ship data file works well as a template. It even stores things like UI settings (e.g. UI console X is connected to ship equipment Y). But it doesn't record info like current room pressures, damaged items, or battery charge. It's basically just a ship design file.

What I need is the actual ship data. The base design plus all the current stats on things. Also, the crew on the ship, other ships in the System, and the positions of celestial bodies.

Unfortunately, that's a lot of data. And even if saving that data isn't too hard, loading it back again in a way that meshes with current data structures is tricky. For example, the ship auto-generates tiles and rooms when it's loaded, but this save game file would need to at least store room data like pressure. So I'd need some way to bypass/supplement the auto-room code to use this data. And the rooms, tiles, and ship all have related data that needs to be tied together.

The good news is that a lot of the data can already be saved without too much work. I think it's just combining the data once loaded that's the hard part.

Once I can get that working, I should be able to spawn a ship, spawn crew into it, then save that data so I have a persistent universe/ship to follow around for more long-term testing!

Tags: Ostranauts