-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RDY] Json overmap saves #12790
[RDY] Json overmap saves #12790
Conversation
603d541
to
2674de7
Compare
Fixed the issue BevapDin pointed out. |
json.member("npcs"); | ||
json.start_array(); | ||
for (auto &i : npcs) { | ||
json.write( i->save_info() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work correctly. save_info
returns a JSON string, it is written here as a single string to JSON, but the deserialize code expects a normal JsonObject.
Example (that's what is written):
"npcs":["{\"str_cur\":1,\"str_max\":6,\"dex_cur\":5,\"dex_max\":8,\"int_cur\":3,\"int_max\":6,\"per_cur\":7,\"per_max\":
This is what is expected:
"npcs":[
{ "str_cur":1,"str_max":6,"dex_cur":5,"dex_max":8,"int_cur":3,"int_max":6,"per_cur":7,
Edit: changing it to write( *i )
should do the trick.
2674de7
to
cf9540a
Compare
Ok, this is what I should have done in the first place, big fat integration test where I load an overmap save and then test the overmap for having the expected contents. |
Side note, init_global_state() in savegame_test.cpp is how to stand up an instance of the game in a unit test, that's what took me the longest time to sort out, but now you should be able to just do that and write whatever unit tests. |
980c7ed
to
12918ea
Compare
And there we go, spot-checks a whole bunch of overmap entities, and we can repeat the same process for future savegame migrations. |
writable = true | ||
} | ||
pos = { type = "tripoint", writable = true }, | ||
target = { type = "tripoint", writable = false }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the target read-only, but the position is writable? Shouldn't it be the other way, the position is also used as key in the map of groups, so it should always match the value in the object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No good reason, I just restyled it while I was changing it from a 3-tuple to a tripoint and left how it works alone.
The savegame_test binary must be run from the main folder, but when started from the Makefile it is (like all test binaries) run from within the tests folder. Therefor it won't find the game data and consequently crashes. It works fine from the main folder. Old maps and converted maps load fine. |
Addressed everything but the last point, path configuration quickly turned into a can of worms I don't want to deal with right now, unless there's a simple way to handle it I'm missing. |
I needed to partially revert the last Lua changes, the build would fail otherwise. The wrapper generates a setter function named An equally named function is generated for Those two function conflict as they have the very same signature. Ideally the Lua wrapper really unique names. |
I hesitate to suggest "more name mangling" as the solution, but if the first were to translate to I'm assuming length of the generated name doesn't matter, as they should never be explicitly used by a human except through the translation layer. |
This breaks Play Now! functionality |
There were changes in newcharacter.cpp that leave the However, the versions of Should I add the check (and thereby make the functions more compatible with curses) or should I revert the changes in newcharacter.cpp, which would avoid using the nullptr in the first place? |
I would think that the changes need to be reverted, or the logic changed. Right now it says only create a window when you're not using play now. |
I'd prefer making cursesport compatible, not least because that is keeping
the unit test from crashing. Alternately you (or I for that matter) could
protect the calls to wrefresh etc from the nullptr, but I'm leaning toward
the former.
|
Turns out overmap save format was blocking my work on hordes 2.0, so I took care of this first so I can have more flexibility when saving/loading the new horde data structures without backwards compatibility being a problem.