-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
JSON Object unvisited member checking no longer works #64438
Comments
As Aivean commented on the original PR, the naming of the guard variables confused me and made me think it was tautologically disabled :( The relevant code is just ifdef'd out. It should be trivial to reenable. Unfortunately fixing the resulting shown issues might be harder, sorry :( |
Oh, it's just that easy? I'll handle it, thanks for the pointer. |
Yeah I made sure to implement and test it but left it (mistakenly) off because I thought it was already off. |
Curse past me for not renaming those variables :) |
@anothersimulacrum: Consider past you cursed. It can be noted that the curse has since expired. Sorry for the inconvenience during that period. |
Before I forget, the original code had two bools, one for 'should report unvisited' and one for 'did report unvisited'. I didn't implement the latter. We can reimplement the logic by putting at the end of the conditional here after Cataclysm-DDA/src/flexbuffer_json.cpp Lines 262 to 272 in 32774b3
|
I've got some sort of issue with deferred JSON reporting failing to visit members (like copy-from, proportional, ammo). I haven't had the time look enough into it. (Adding the line you recommend doesn't change that). |
Feel free to hit me up on discord anytime to take a look w/ repro steps. |
Figured it out! It looks like: diff --git a/src/init.cpp b/src/init.cpp
index fa7e2b7bbf..78cb2173dd 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -162,7 +162,7 @@ void DynamicDataLoader::load_deferred( deferred_json &data )
auto it = data.begin();
for( size_t idx = 0; idx != n; ++idx ) {
try {
- JsonObject jo = it->first;
+ const JsonObject &jo = it->first;
load_object( jo, it->second );
} catch( const JsonError &err ) {
debugmsg( "(json-error)\n%s", err.what() );
diff --git a/src/mapgen.cpp b/src/mapgen.cpp
index 3221abbf70..893bb87a94 100644
--- a/src/mapgen.cpp
+++ b/src/mapgen.cpp
@@ -4263,7 +4263,7 @@ void mapgen_function_json_base::setup_common()
if( is_ready ) {
return;
}
- JsonObject jo = jsobj;
+ const JsonObject &jo = jsobj;
mapgen_defer::defer = false;
if( !setup_common( jo ) ) {
jo.throw_error( "format: no terrain map" ); I do have a new issue, though. Because we're saving JsonObjects in game entities now, these unvisited member warnings trigger for some things when the game is saved. |
Change Line 810 in 32774b3
this->jsobj.allow_omitted_members(); to fix the mapgen error on save.
I'm not sold on the two changes you listed above but I trust you have verified they Do The Right Thing. I guess incrementally re-loading an object can only incrementally visit more members, so it's likely fine. But I think the original intent with those is to start fresh so that if an object passes load, we can properly assert all members were visited. But I don't remember if those objects are Edit: The DynamicDataLoader one is correct. The mapgen one can be reverted with my fix. |
Describe the bug
JSON unvisited member checking was introduced in #34735 and turned on outside of tests in #45635.
It provides an error on loading the game when a JSON object has data in it that the game makes no attempt to read, which is a significant help with debugging.
A bisect gives the first bad commit as any of
97d6a48
ec3f896
2833d7a
ca9428d
8987088
Clearly, the new flexbuffer
JsonObject
visited member reporting is not working.Attach save file
N/A
Steps to reproduce
Apply this patch
The game does not report that it fails to visit the
BAR
andBOB
members, when there is no code reading them.There's also existing unvisited JSON in the game source already: #64408
Cataclysm-DDA/data/json/items/book/driving.json
Lines 236 to 239 in 2d6713b
Expected behavior
Unvisited JSON members are reported.
Screenshots
No response
Versions and configuration
Any versions since #50143 was merged
#64408 shows it is not working on multiple platforms (tested on Linux).
Additional context
CC @akrieger , since you're the subject matter expert here.
The text was updated successfully, but these errors were encountered: