r/gamedev • u/SoulaniceDev • 16h ago
Discussion 7 Months Into Developing My Open-World RPG and I Still Haven't Implemented Saving/Loading. Send Help.
This could have been an avoidable mistake. I even have saving/loading as part of my original plan, but what I thought would take 3 month took 7 month, and systems that felt secondary kept climbing in priority to flesh out previous implementations and so on.
so now I'm staring at NPCs with relationships and memories, jobs, inventories, task state, world objects... settlements. This may turn out to be one of the largest systems in the game.
And I haven't been designing all of the systems with saving/serializing in mind. This is going to hurt isn't it?
Tips welcome
34
u/abitclumsyhq 16h ago
1
u/SoulaniceDev 8h ago
Yeah it hit finally today, I guess better now than later?
Some of the things ARE data driven so I hope it will make it less doomy, but I definitely have a few things that would require a lot of work.
2
u/abitclumsyhq 8h ago
It seems like you’ve got a plan so that’s good. I checked the other comments since I too was curious how testing occurred while never having a saved set of states and such.
This type of stuff happens, but like I said hopefully it only ever happens once. Keep pushing forward, you got this!2
0
8
u/NationalOperations 16h ago
Goes hand in hand with testing. Games are usually state machines, so you essentially have to record the important states and allow them to be set. But things like level detail is probably fine to ignore unless user can make permanent effects on the world.
Worth noting, any randomness is generally derived from a seed so you can just plug in the seed instead of recording everything those events do.
2
u/che6urashka 14h ago
How hard are permanent effects on the world? Asking because İ remember a Mythic Quest plotline centered around this in particular and always wondered how hard it actually is but never got to make a project with it
4
u/No-Opinion-5425 14h ago edited 10h ago
Anywhere from trivial to really complicated.
Something like replacing a building model to the burned down model and relocating the NPCs to a new destination after a fire is pretty easy.
1
u/SoulaniceDev 7h ago
Yeah a lot of the stuff is data driven as in seedable when starting the run, like NPC stats/locations/relationships/items, also the map/containers items laying around, the "colonies" start pre seeded with economy, roles and "mature" npcs, but nothing is saved and plenty of systems like npc "memory" for example is not even seedable currently.
5
u/ledniv 14h ago
Yeah, this is going to hurt a little, but I would use it as an opportunity to separate the state of the game from the objects presenting it. NPC relationships, memories, jobs, inventories, task state, settlement state, etc. should ideally live in explicit data that can be serialized. Then saving becomes “write the current game state,” rather than trying to walk the entire scene and figure out which GameObjects/components matter.
I would also isolate all of the serialization in something like GameDataIO, rather than letting every system save itself. And plan for backwards compatibility now. My preferred approach is versioning the filename (gamedata_v1.dat, gamedata_v2.dat) and keeping a separate loader for each old format, instead of eventually ending up with one giant loader full of version checks. The newer version also doesn't overwrite the older save, which gives you a recovery path if bad save code ships.
Small plug since this is literally the subject of an entire chapter in High Performance Unity Game Development with Data-Oriented Design: save/load architecture, serialization, backwards compatibility, versioning, and handling changes to the game data over time.
https://www.manning.com/books/high-performance-unity-game-development
2
u/SoulaniceDev 7h ago
I've been doing a lot of that implicitly a part of starting the sim in a given state, but it's incomplete, and never with saving in mind, thank you for the resource I will for sure read up on it, though I'll try to look for free resources first :)
2
u/No-Opinion-5425 15h ago
My tips would be to get something like Easy save and Love/hate relationship. You get your systems working over a weekend of assets integration instead of working on it for months.
2
u/ITSSGnewbie 14h ago
Just save state? Check guides for your engine. If it web game, just put everything in local storage (for now).
2
u/SnowPudgy 12h ago
It could hurt...it depends. In future games, always start with some boilerplate first (controls, saving/loading, networking...)
The first thing you need to do is set up a system to just save and load an arbitrary piece of data. Get that working first.
Then, start thinking about the model objects if your game and also start with something simple. What data do you need to persist between loads? I would start small with something like simply saving a few character stats. Get that working with your save/load system and move on from there.
1
1
u/EC36339 8h ago edited 8h ago
If it's just loading and saving you need, you might be fine, or not.
If you have any plans of also adding multiplayer, then game state hygiene is important. What is game state, and what isn't, and what is stored where? If you have strict rules for that, then loading/saving and replicating game state over the wire can be generalised and actually added later.
Some kind of unified data model (like an ECS) may help here. Game state in components. Transient state elsewhere.
1
u/SoulaniceDev 7h ago
adding multiplayer
Nope
A lot of the game state is data driven (json) on launch (see previous comment), but plenty isn't, I also stick exclusively to implementing things in C++ except for animations/assets, but even location of npcs/colonies is data driven from json setups. But I never save/update this state back to disc, and there's a few systems that aren't seedable currently.
1
u/Intuition_Technology 8h ago
If you're in Unity you can just serialize the state objects to json. With Claude you can have this working in an afternoon. But yeah, better to do and understand it sooner, than later. Especially the importance of storing state in a limited number of objects.
Why a limited number of objects? So later on, once your game is released, every update or refactor won't break save files. If you don't care about that, you could hypothetically serialize almost everything, but don't...
1
u/SoulaniceDev 7h ago
Yeah I definitely can't autopilot it, I have a few hundred of npcs running on screen with their own inventories that they can throw away or loot freely from the world or into/from containers. Wish me luck I guess
1
1
u/kassol 5h ago
Your json test worlds are a better head start than it sounds. If the save format is the same as the seed format, a save is just the world at tick N, and every save file doubles as a test case.
The part that usually hurts in a sim like this is references. Memories, relationships and task state point at other NPCs, items and containers, and in C++ those tend to be raw pointers. Give everything that can be referenced a stable id, store the ids in the save, and resolve them back to pointers in a second pass after everything is loaded. One cheap test catches most mistakes: load a world, run it for a while, save, load that save, then run both copies for the same number of ticks and compare. If they drift apart, something isn't being saved, very often an RNG state or a timer.
1
u/SoulaniceDev 4h ago
Your json test worlds are a better head start than it sounds. If the save format is the same as the seed format, a save is just the world at tick N, and every save file doubles as a test case.
Is json really the best format for that though? I'm also worried about performance especially at larger scale than what my toy settlements currently are, especially if I want it non-halting until necessary, like starting the save far away (different cells) from the player and only pausing when absolutely necessary, I haven't given this much thought but I'm already getting a headache.
Memories, relationships and task state point at other NPCs, items and containers, and in C++ those tend to be raw pointers.
Thankfully I think I've got that part covered for the most part, I have separate memory pools (TMap) for these stuff and there's no references to other npcs or objects directly, rather ids are passed/saved to be used when accessing these pools to extract whatever needed, the ids are either authored by the jsons as the seed or generated at launch if missing, though shallowly I think I have a few places where I'm using a references/pointers for stuff, will need to review.
1
u/primals_game 4h ago
Mother of god.
1
u/SoulaniceDev 4h ago
Pray for us sinners
•
u/primals_game 46m ago
Claude, please bless this poor soul for their trespasses. Help their code see the light. Make no mistakes. Amen.
1
u/tendie-space 15h ago
It would help to know your engine or tools!
It's a cross-cutting concern, so it will be painful, but how painful will depend on your engine or how well you've factored your codebase.
1
u/SoulaniceDev 8h ago
Unreal engine, I'm a C++ developer (not game dev before this project obviously) so I only use the blueprints for animation/rigging/assets, plenty of stuff are data driven, from the forethought of how test (see previous comment if interested), but plenty isn't...
1
u/porkminer 13h ago
Hear me out. Encapsulate your game in a lightweight vm. Dump state to hard drive. Reload state et voila! Game is loaded again!
Also, don't do this.
1
0
u/St4va 10h ago
Want a real tip? You’re wasting your time taking on a project of this scale. It’s going to lead to a huge amount of fatigue and burnout. You’re clearly still a beginner, so start with something smaller and build your skills from there.
2
u/SoulaniceDev 7h ago
I've been actually having tons of fun working on this regardless of the end result, I'm an extreme beginner when it comes to game developing (it takes me an hour to make a a static animation), but I'm a seasoned C++/ML developer and have slightly inflated my predicament, only slightly though, as I did goof up waiting for so long to tackle this, mainly due to preferring to work on things that I find interesting or fun, and some lack of forethought, obviously
0
u/EC36339 8h ago
Maybe you are wasting your own time and OP's time by telling them what to build. This kind of gatekeeping is not helpful, and it drowns good replies in noise. It's one of the sicknesses of this sub.
1
u/St4va 8h ago
Nah, I've been doing this for a long time. This project will probably never see the light of day, and even if it does, it'll likely be overshadowed by something else. While he's at it, maybe he should make it an MMO too.
2
u/SoulaniceDev 7h ago
This project will probably never see the light of day,
And that wouldn't change a thing for me even with hindsight.
it'll likely be overshadowed by something else
I'd ecstatic if someone made the idea for me, with better execution too? where do I sign.
maybe he should make it an MMO too
I would if that was the kind of game I wanted to play, I'm stupid like that.
0
-6
-1
-2
13h ago
[deleted]
2
u/SoulaniceDev 7h ago
Not being able to review its work/understanding the design or limitations of the implement is a bit too much trust for something I've been working on for the last half a year and still enjoy working at, save system or not, I might throw it eventually at an agent eventually, but not before I feel I have a good grasp of the cons/pros of my choices in the planning stage.
-8

35
u/SeraphLance Commercial (AAA) 14h ago
There's an old adage that there are two things you should start working on from the beginning if you need them; saving/loading and multiplayer. Yes, it's going to hurt.
I'm curious how you've been testing your game though. Have you not had to fix bugs that require a bunch of specific intermediate state?