[Request] Have "DumpBlock" group every 64 bytes of AutoMapData on same line

Discuss Daggerfall Unity and Daggerfall Tools for Unity.
User avatar
XJDHDR
Posts: 60
Joined: Thu Jan 10, 2019 5:15 pm
Location: New Zealand

[Request] Have "DumpBlock" group every 64 bytes of AutoMapData on same line

Post by XJDHDR » Sat May 02, 2020 11:44 pm

Just have a small request to improve the DumpBlock command.
Currently, every byte in the AutoMapData section of a RMB is given it's own line in the JSON, resulting in 4096 lines of one number each. I just noticed that Hazelnut groups every 64 lines together here: https://github.com/ajrb/dfunity-mods/bl ... .json#L769
This reduces it down to just 64 lines of text each representing 64 bytes. This also makes it easier to edit this section as the numbers are now arranged in the same positions as they are used to construct the Automap's image. It's also easier to scroll past if you are looking for something else. And DFU is perfectly fine with the data arranged this way.

My question is whether it is possible to make the command dump it's JSON in the same arrangement as the file above? Mainly the 64 bytes per line but if the values could also be evenly spaced, that would be a bonus.
My mods (mainly for Oblivion but also a few for other games):
https://www.nexusmods.com/users/625820?tab=user+files

User avatar
BadLuckBurt
Posts: 535
Joined: Sun Nov 05, 2017 8:30 pm

Re: [Request] Have "DumpBlock" group every 64 bytes of AutoMapData on same line

Post by BadLuckBurt » Sun May 03, 2020 5:42 am

I made a very simple automap editor a while back that is part of https://github.com/BadLuckBurt/dfu-worlddata-editor. This way you can edit it visually. It also exports the array in the way you describe.

As for scrolling past it, use an editor that supports collapsing in JSON and you can fold in that entire section.
Daggerfall Unity on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
Daggerfall Unity on Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

User avatar
XJDHDR
Posts: 60
Joined: Thu Jan 10, 2019 5:15 pm
Location: New Zealand

Re: [Request] Have "DumpBlock" group every 64 bytes of AutoMapData on same line

Post by XJDHDR » Sun May 03, 2020 9:49 am

BadLuckBurt wrote:
Sun May 03, 2020 5:42 am
I made a very simple automap editor a while back that is part of https://github.com/BadLuckBurt/dfu-worlddata-editor. This way you can edit it visually. It also exports the array in the way you describe.
Thanks for this but I couldn't get the automap editor to work. For all of the web browsers I tried (Firefox, Chrome, Opera and Edge), clicking on "Load JSON" after selecting an RMB didn't do anything. Maybe I'm doing something wrong though.
That said, arranging the data the way I described gives me probably around 90% of what a visual editor would.
BadLuckBurt wrote:
Sun May 03, 2020 5:42 am
As for scrolling past it, use an editor that supports collapsing in JSON and you can fold in that entire section.
Notepad++ does support this.
My mods (mainly for Oblivion but also a few for other games):
https://www.nexusmods.com/users/625820?tab=user+files

User avatar
BadLuckBurt
Posts: 535
Joined: Sun Nov 05, 2017 8:30 pm

Re: [Request] Have "DumpBlock" group every 64 bytes of AutoMapData on same line

Post by BadLuckBurt » Sun May 03, 2020 9:54 am

Hit F12 in Chrome or Firefox and check the console when you try to load in the JSON, its probably blocking the upload and may say something about same origin policy. Been a while since I made these tools but I think it needs to be enabled in the about:config settings of your browser.

- edit

I had a look and you have two options atm:

1. Move the JSON file into the folder where dfu-automap-editor.html is located or into a subfolder of that folder
2. Disable security.fileuri.strict_origin_policy in about:config (Firefox) https://developer.mozilla.org/en-US/doc ... file:_URIs

I'd try the first one and only if that doesn't work, try the second solution. I made these tools so they can be run without a web server but browser security by default doesn't allow local files to be read unless they are determined to be part of the same path.

Alternatively, if you are familiar enough with web servers, you could install WAMP and run it from localhost, that should eliminate the problem all together.

I'll see if I can find another solution later but for now this will have to do.
Daggerfall Unity on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
Daggerfall Unity on Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

User avatar
XJDHDR
Posts: 60
Joined: Thu Jan 10, 2019 5:15 pm
Location: New Zealand

Re: [Request] Have "DumpBlock" group every 64 bytes of AutoMapData on same line

Post by XJDHDR » Sun May 03, 2020 7:02 pm

:facepalm:
Yeah, I myself have had problems with that origin policy and completely forgot about it. The easiest solution I can think of for you would be to use Github Pages to turn your repository into a website. I personally went with the "User site" option but you could give "Project site" a try.

That said, I just tried again and this time, the "Load JSON" button worked for 3 of the files I tried. And this is without any attempt to mitigate the strict origin policy. I don't know what changed since last night. I did get a different error for one RMB file:

Code: Select all

SyntaxError: JSON.parse: bad escaped character at line 2853 column 25 of the JSON data
Line 2853 column 25 refers to the backslash in this section of TVRNAM03.RMB:

Code: Select all

            "Name": "TVRNAM03.RMB",
            "OtherNames": [
                "T3.HS2\01.HS2",
                "TAVERN1.HS2",
                "DHAUS034.HS2",
I didn't make any changes to this line. This is the output of the DumpBlock command.
My mods (mainly for Oblivion but also a few for other games):
https://www.nexusmods.com/users/625820?tab=user+files

User avatar
BadLuckBurt
Posts: 535
Joined: Sun Nov 05, 2017 8:30 pm

Re: [Request] Have "DumpBlock" group every 64 bytes of AutoMapData on same line

Post by BadLuckBurt » Sun May 03, 2020 7:23 pm

XJDHDR wrote:
Sun May 03, 2020 7:02 pm
:facepalm:
Yeah, I myself have had problems with that origin policy and completely forgot about it. The easiest solution I can think of for you would be to use Github Pages to turn your repository into a website. I personally went with the "User site" option but you could give "Project site" a try.

That said, I just tried again and this time, the "Load JSON" button worked for 3 of the files I tried. And this is without any attempt to mitigate the strict origin policy. I don't know what changed since last night. I did get a different error for one RMB file:

Code: Select all

SyntaxError: JSON.parse: bad escaped character at line 2853 column 25 of the JSON data
Line 2853 column 25 refers to the backslash in this section of TVRNAM03.RMB:

Code: Select all

            "Name": "TVRNAM03.RMB",
            "OtherNames": [
                "T3.HS2\01.HS2",
                "TAVERN1.HS2",
                "DHAUS034.HS2",
I didn't make any changes to this line. This is the output of the DumpBlock command.
I'm deliberately trying to avoid having to host it tbh but I will have a look at the Github Pages stuff, it should run fine from there. Thanks for the tip :)

After posting about the cross policy, I checked my own browser configuration and noticed my strict policy check was still set to true as well. Is it possible you happened to try that file with the backslash the first time?

Good to hear it is working for you now though.

And yeah, that backslash is a problem in the Serializer class that's used to dump these RMB JSONs. I just did a global search through my dumps at 1 point and removed the \ from those entries. I can't do anything from my end except handle the error more gracefully which I will look into as well.

OtherNames isn't ever used by DFU and is just a remnant from the original DF, they probably should be removed from the dump command but so very few people have used this extensively. At some point I dumped all locations, dungeon blocks, RMB blocks and the interior data as well so I hardly ever need the command again.
Daggerfall Unity on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
Daggerfall Unity on Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

User avatar
Hazelnut
Posts: 2190
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: [Request] Have "DumpBlock" group every 64 bytes of AutoMapData on same line

Post by Hazelnut » Tue May 05, 2020 9:52 am

XJDHDR wrote:
Sat May 02, 2020 11:44 pm
Just have a small request to improve the DumpBlock command.
Currently, every byte in the AutoMapData section of a RMB is given it's own line in the JSON, resulting in 4096 lines of one number each. I just noticed that Hazelnut groups every 64 lines together here: https://github.com/ajrb/dfunity-mods/bl ... .json#L769
This reduces it down to just 64 lines of text each representing 64 bytes. This also makes it easier to edit this section as the numbers are now arranged in the same positions as they are used to construct the Automap's image. It's also easier to scroll past if you are looking for something else. And DFU is perfectly fine with the data arranged this way.

My question is whether it is possible to make the command dump it's JSON in the same arrangement as the file above? Mainly the 64 bytes per line but if the values could also be evenly spaced, that would be a bonus.
If it were easy, I would have done it. :) My knowledge of the serializer is insufficient and I did that formatting by hand just so I could edit the map data by hand.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
XJDHDR
Posts: 60
Joined: Thu Jan 10, 2019 5:15 pm
Location: New Zealand

Re: [Request] Have "DumpBlock" group every 64 bytes of AutoMapData on same line

Post by XJDHDR » Tue May 05, 2020 6:51 pm

Hazelnut wrote:
Tue May 05, 2020 9:52 am
If it were easy, I would have done it. :) My knowledge of the serializer is insufficient and I did that formatting by hand just so I could edit the map data by hand.
BadLuckBurt's automap editor exports that data in the arrangement I requested. Perhaps you could try see how he did it.
BadLuckBurt wrote:
Sun May 03, 2020 7:23 pm
Is it possible you happened to try that file with the backslash the first time?

Good to hear it is working for you now though.
I looked into this a bit more and I think I figured out why your automap editor wasn't working the first time. I was wondering because I distinctly remember trying a number of my RMBs and none of them worked. I found that if I try to give your editor a file with a backslash in it, it doesn't just give me an error and not process the file. It completely freezes your script so that any subsequent files you try won't work either. Once this happens, you have to refresh the page to get things working again. That file with the backslash in it must have been the first file I tried.

That said, thanks for creating that editor. It is much better than editing the original text.
My mods (mainly for Oblivion but also a few for other games):
https://www.nexusmods.com/users/625820?tab=user+files

User avatar
BadLuckBurt
Posts: 535
Joined: Sun Nov 05, 2017 8:30 pm

Re: [Request] Have "DumpBlock" group every 64 bytes of AutoMapData on same line

Post by BadLuckBurt » Tue May 05, 2020 7:38 pm

XJDHDR wrote:
Tue May 05, 2020 6:51 pm
Hazelnut wrote:
Tue May 05, 2020 9:52 am
If it were easy, I would have done it. :) My knowledge of the serializer is insufficient and I did that formatting by hand just so I could edit the map data by hand.
BadLuckBurt's automap editor exports that data in the arrangement I requested. Perhaps you could try see how he did it.
BadLuckBurt wrote:
Sun May 03, 2020 7:23 pm
Is it possible you happened to try that file with the backslash the first time?

Good to hear it is working for you now though.
I looked into this a bit more and I think I figured out why your automap editor wasn't working the first time. I was wondering because I distinctly remember trying a number of my RMBs and none of them worked. I found that if I try to give your editor a file with a backslash in it, it doesn't just give me an error and not process the file. It completely freezes your script so that any subsequent files you try won't work either. Once this happens, you have to refresh the page to get things working again. That file with the backslash in it must have been the first file I tried.

That said, thanks for creating that editor. It is much better than editing the original text.
Hazelnut actually contributed that 64x64 export to the automap editor: https://github.com/BadLuckBurt/dfu-worl ... 494182a9e5

And thanks for the feedback on that bug. I can probably reproduce it with that info, I'll fix it later this week. Loading a broken JSON definitely shouldn't break the whole thing.

And you're welcome, I slapped it together when Hazelnut was working on the FG Master quest I think.
Daggerfall Unity on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
Daggerfall Unity on Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

User avatar
XJDHDR
Posts: 60
Joined: Thu Jan 10, 2019 5:15 pm
Location: New Zealand

Re: [Request] Have "DumpBlock" group every 64 bytes of AutoMapData on same line

Post by XJDHDR » Tue May 05, 2020 9:21 pm

BadLuckBurt wrote:
Tue May 05, 2020 7:38 pm
Hazelnut actually contributed that 64x64 export to the automap editor: https://github.com/BadLuckBurt/dfu-worl ... 494182a9e5
Okay, I'm wondering what is the reason this is difficult to implement. Is it something inherent to the Unity engine?
My mods (mainly for Oblivion but also a few for other games):
https://www.nexusmods.com/users/625820?tab=user+files

Post Reply