It's the Modster Mash
Today was my first day digging into mod-merging, and it was pretty hardcore. Just about everything in the game relies on data IDs, so making it possible to load IDs from different sets of data means touching code in a lot of places. And one of the big places was the DataHandler class.
My plan at the moment is to see if I can take the list of all data in the game, and separate it from the singleton DataHandler class. Previously, this class was the go-to place to store and get all game data. It, unsurprisingly, "handled" all things data. Reading from files, parsing strings into usable formats, storing into lists and hash tables, you name it.
Now, all of those lists and tables are in a separate DataSet class, of which there can now be more than one. I'm thinking that the base data will be in DataSet 0, and mods will fill subsequent DataSets. (E.g. 1, 2, 3, etc.) When requesting data from the DataHandler, the game will now have to specify which DataSet to get the data from. If nothing is specified, it'll assume DataSet 0 (base game data), otherwise, it'll get data from the desired mod.
Most of the day was spent ripping these data properties out of DataHandler and putting them into DataSet. It also meant rewriting any references to data so that they go through special data request methods in DataHandler. And some of the loading/parsing code had to be rewired to straddle the DataHandler and DataSet classes.
More than a few times today, I stepped back and asked myself, "whoa, this seems messy. Is this the right way to approach it?" However, every time I reexamined the problem, this solution was the only one that seemed to cover all the requirements. And eventually, I finished refactoring.
Surprisingly, there were only a few hiccups when it came to compiling. I made a mistake with the way images were stored after loading, and in one place I loaded an ItemInstance instead of the Item (definition). However, once those were sorted out, the base game seemed to work again, this time with all data in DataSet 0!
Tomorrow, I'm going to tackle the next major issue: loading and storing a second DataSet (mod). This'll require some test data files, and probably a lot of changes in all the places data gets requested (so that it specifies the base or mod, accordingly).
Hopefully, I'll have a better idea of whether this system is going to do what I want then. That's all for today, however. Have a good one, all!