[NOT A BUG] Custom books can only be loaded from loose files

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

[NOT A BUG] Custom books can only be loaded from loose files

Post by Hazelnut »

I suspect that to load binary files via unity textAsset it now needs to have the .bytes extension and DFU currently requires that books have a .txt extension, as books usually do. Doesn't affect vanilla books as they are loaded from files in arena2 folder, and doesn't affect loose files as they're also loaded from the files. Only files that load into text assets and they are extracted via textAsset.bytes on line 178 of BookReplacement.cs - I'm only guessing it's the extension because the binary files I use in the roads mod work fine that way.

This image shows the difference in values of the byte array that gets returned from File.ReadAllBytes(path) on the left and textAsset.bytes on the right.
TextAsset-bytes.png
TextAsset-bytes.png (8.5 KiB) Viewed 1303 times
This causes the number of pages to be read as far too high rather than the 6 it should be. (bytes 234 & 235)

@TheLacus, any ideas how this could be fixed? Can we change the extension required for custom books or is there a reason not to?

@Interkarma, is this some kind of localisation running before the text asset converts to byte array in unity - anything that could be disabled? Looks to me like the byte 210 is being replaced by 239,191,189 for some reason.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: [0.10.26] Custom books can only be loaded from loose files

Post by TheLacus »

Nothing changed as far as i know. Books must have .bytes extension (and always had to), for example BOK00000.TXT.bytes. Isn't this working?

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

Re: [0.10.26] Custom books can only be loaded from loose files

Post by Hazelnut »

I have always had my books with just the .TXT extension since I did them originally, not changed it since.

The mod docs at https://www.dfworkshop.net/projects/dag ... ing/books/ doesn't say this either.

EDIT: it does say at the top actually, I was looking at the file list at the bottom. Let me test this works. I thought it had to be just .TXT from the param

Code: Select all

<param name="name">Name of book including .TXT extension</param>
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

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

Re: [NOT A BUG] Custom books can only be loaded from loose files

Post by Hazelnut »

Oh if only everything were that simple. Apologies, I had never noticed that .bytes before and it worked fine in unity 2018.

Thanks TheLacus, note to self check documentation before spending an hour debugging the byte differences.... :lol:
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: [NOT A BUG] Custom books can only be loaded from loose files

Post by TheLacus »

I fixed the misleading example, thanks for pointing that out. :)

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

Re: [NOT A BUG] Custom books can only be loaded from loose files

Post by Hazelnut »

Great stuff. I still feel :oops: but that's the gig I guess.. :lol:
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

Locked