LandSandBoat / server

:sailboat: LandSandBoat - a server emulator for Final Fantasy XI
https://landsandboat.github.io/server/
GNU General Public License v3.0
294 stars 593 forks source link

🔨 How should we load, store, and modify static entity data? #6268

Open zach2good opened 3 weeks ago

zach2good commented 3 weeks ago

I affirm:

What problem are we trying to solve?

Capturing points from a discussion we're having:

What caveats do we need to keep in mind about a possible solution?

What options do we have?

Open to all suggestions (if you have a valid opinion. Not interested in non-developer-types weighing in here)

zach2good commented 3 weeks ago

One option that's being floated is to store a lot, if not all, of this static data in Lua files.

Benefits:

Drawbacks:

KnowOne134 commented 3 weeks ago

Edens yaml approach also allows hand editing the database and export with dbtool to fill in the yaml data changes. Makes editing many blocks with a statement very easy instead of searching and changing 1 by 1

jmcmorris commented 3 weeks ago

Lua can actually be made multithreaded. The main challenge with Lua multithreading is that each Lua state is sandboxed so you have to synchronize data between the states in C++. However, since we're really just wanting it to be one way (Lua data to C++) we don't need to worry about this.

It should be entirely possible to spin up a bunch of threads with each one given a Lua state and list of mob files and they can each load up their files and store that data in C++. I probably would store the data in C++ and then join all of the thread data together at the end to avoid constantly checking a mutex for safely writing to the final data container.

cocosolos commented 3 weeks ago

Recently had a discussion about this and one thing I do like about Eden's yaml approach (not directly related to entities) is that they seem to maintain some enums like mods and effects as yaml then have tooling to generate the C++ and Lua tables, whereas we maintain each of those separately which can cause issues.

I do also like the idea of a GUI mob editor, which could exist alongside of and export to whatever system is decided on. Not really a fan of moving exclusively to Lua though as I think that while it may be easy to read and edit, it may be harder to search in ways that SQL allows. Plus having stuff available in the DB makes it very easy to integrate with basically any external/custom tooling.

claywar commented 3 weeks ago

I think one of the suggestions I'd like to float is us rethinking how mobs and other static data is structured in the first place. Mobs are a convoluted mess to navigate and implement at this time, and if we're going to move to another interpreted format, its time to take a step back and evaluate how this can better be done.

zach2good commented 3 weeks ago

it may be harder to search in ways that SQL allows

This is actually a very good point, thanks @cocosolos!

I think startup (and obviously our entity classes etc.) should stay as they are, where we load from SQL. I know I haven't measured anything yet, but I can't imagine loading large Lua tables from files and then building entities our of them could be anything but slower than loading from SQL.

So then the other data layout (Lua or otherwise) gets pooped back into the database, or back into SQL files for consumption as part of dbtool's regular running.

zach2good commented 3 weeks ago

Also yes @claywar, we should be inspecting how we build and lay out mobs before we start making changes, they're a nightmare