Skip to content
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

Merged
merged 19 commits into from
Jul 15, 2015
Merged

Conversation

kevingranade
Copy link
Member

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.

@kevingranade
Copy link
Member Author

Fixed the issue BevapDin pointed out.

@BevapDin BevapDin self-assigned this Jul 6, 2015
json.member("npcs");
json.start_array();
for (auto &i : npcs) {
json.write( i->save_info() );
Copy link
Contributor

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.

@BevapDin BevapDin removed their assignment Jul 6, 2015
@Coolthulhu Coolthulhu assigned Coolthulhu and unassigned Coolthulhu Jul 7, 2015
@kevingranade
Copy link
Member Author

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.
Not done, I still need to read in some NPCs and some vehicles, but I wanted to push it in the current state for feedback. Also I'm planning on having it write the new version of the file, then read it back in and check the same values again to make sure nothing changed.

@kevingranade kevingranade changed the title Json overmap saves [WIP] Json overmap saves Jul 13, 2015
@kevingranade
Copy link
Member Author

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.

@kevingranade kevingranade force-pushed the json-overmap-saves branch 2 times, most recently from 980c7ed to 12918ea Compare July 13, 2015 15:20
@kevingranade kevingranade changed the title [WIP] Json overmap saves [RDY] Json overmap saves Jul 14, 2015
@kevingranade
Copy link
Member Author

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 },
Copy link
Contributor

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.

Copy link
Member Author

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.

@BevapDin
Copy link
Contributor

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.

@kevingranade
Copy link
Member Author

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.

@BevapDin BevapDin merged commit 6bc2bdf into CleverRaven:master Jul 15, 2015
@BevapDin
Copy link
Contributor

I needed to partially revert the last Lua changes, the build would fail otherwise.

The wrapper generates a setter function named mongroup_set_target (mongroup is the class type, set indicates a setter function, target is the member that is set).

An equally named function is generated for mongroup::set_target (in which set_target denotes the function name).

Those two function conflict as they have the very same signature. Ideally the Lua wrapper really unique names.

@narc0tiq
Copy link
Contributor

I hesitate to suggest "more name mangling" as the solution, but if the first were to translate to mongroup_setter_for_member_target and the second to mongroup_method_set_target, that would be unlikely to be made to conflict in the same way in future.

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.

@macrosblackd
Copy link
Contributor

This breaks Play Now! functionality

@BevapDin
Copy link
Contributor

There were changes in newcharacter.cpp that leave the WINDOW pointer with a nullptr when started via "Play now". It worked fine in curses. I looked up the version of delwin in cursesport.cpp and it has a check for nullptr, so I thought it would be fine.

However, the versions of werase and wrefresh in cursesport.cpp (which I did hadn't checked), and many functions more, don't have that check.

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?

@macrosblackd
Copy link
Contributor

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.

@kevingranade
Copy link
Member Author

kevingranade commented Jul 16, 2015 via email

@kevingranade kevingranade deleted the json-overmap-saves branch June 1, 2018 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants