OnlineCop / kq-fork

Fork of KQ r910. Just for fun.
GNU General Public License v2.0
15 stars 9 forks source link

res.cpp: Extract data into XML file #150

Open OnlineCop opened 2 years ago

OnlineCop commented 2 years ago

While (still) poring over eResistance and other recent changes, I've found quite a few bugs (yay!). Having a giant wall of data in res.cpp isn't ideal, however.

If I were to move these into the data folder as an XML, it should have an added advantage of allowing the stats to be hot-reloaded via Lua, so we can test that things like spells and elemental attacks are doing what they're supposed to.

If anyone sees disadvantages/cons to this, let's discuss. Otherwise, I think I'll start this migration process.

pedro-w commented 2 years ago

Just as a reminder, in the JB days, all the data written as C code was in res.c, then we extracted it into the csv data files (in other/) to edit with a spreadsheet, and generated code from the data, then we went onto editing the code directly, now we're back to data. I agree being able to 'hot reload' would be an advantage.

On XML - will a giant wall of XML be easier to edit? (maybe there is a graphical XML editor out there, I don't know) The only other alternative I can think of (short of adding in a dependency for a JSON parser) are to use Lua files as data (LSON, if you will) as Lua's literal object syntax is just as good as Javascript's.

z9484 commented 2 years ago

I think lua might be nice as specialitems and items are already in global.lua just not their stats.

OnlineCop commented 2 years ago

I usually haven't done much Lua programming (it warps my brain), but I'm happy to move everything to Lua-based.

Pros:

Cons:

If moved to a different data format (JSON, XML, csv, etc.) instead, we might still be able to write a Lua wrapper to ingest it, which should allow us to hot-reload the data (no recompile).