Record Saving

Everything about development and the OpenMW source code.
Post Reply
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Record Saving

Post by Zini »

*Phew*
Anyway, should I create a set of save<whatever> classes or just add a save function to the load<whatever> ones that already exist?
And on that matter, is all the data that needs to be saved contained in those files, or are there any cases where I have to read the data from somewhere else?
The load name is misleading. Ignore it and pretend these files were called activatorrecord.hpp, weaponrecord.hpp and such. Just add sa save/write function to each of these.

There are a few special cases to consider. The actual cell content (the objects in the cell)) is stored outside of the ESM recrod structure, but loadcell.hpp offers a CellRef structure for it. This struct also needs a save function.

The land record file has an additional struct LandData. This data currently is stored in the main record (which is wrong; but we can fix that later). LandData will also need a save function.

And when this is all done, we also need a way to test the correctness of loading/saving (probably best implemented in the ESM tool, which will require a bit of clean up first). But we will get to that when you are done with the save functions.
User avatar
Ace (SWE)
Posts: 887
Joined: 15 Aug 2011, 14:56

Re: Record Saving

Post by Ace (SWE) »

Added basic save functions to all the records, right not they're basically inverted copies of the load functions. (If that makes any sense)
I was planning on either giving esmtool a clone function or writing a separate testing utility to see if I can load and save a .esm while keeping it readable.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Record Saving

Post by Zini »

I suggest to extend the esmtool. We have enough executables already and this clearly falls into the area of an esmtool anyway.

The easiest method would be to extend the tool in a git-like fashion, i.e. with sub commands. What the tool is currently doing could be invoked via ./esmtool dump. And for load/save testing ./esmtool test?
User avatar
Ace (SWE)
Posts: 887
Joined: 15 Aug 2011, 14:56

Re: Record Saving

Post by Ace (SWE) »

I've added simple modes to the esmtool; dump and clone.
Clone will take the first file specified and clone it to the second file through loading and saving the records.
The only record I'm having trouble with is the land record, so I've disabled loading the land data from it.
I'm hoping that once land records are saved properly, the resulting file should be fully usable in Morrowind.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: Record Saving

Post by Zini »

Okay. But we also need an automatic test mode, i.e. load -> save -> load again and compare with what was loaded before.
User avatar
Ace (SWE)
Posts: 887
Joined: 15 Aug 2011, 14:56

Re: Record Saving

Post by Ace (SWE) »

Got the clone functionality down to byte-perfect copies until it reaches a LAND record, still trying to figure out the best way to save them without adding lots of useless clutter.
Also added a few functions to the to_utf8 component so that I can (un?)encode the UTF-8 strings.
Post Reply