Closed brandonm4 closed 6 years ago
DB/Savegame management will be an important part of the project as a whole as it evolves. Mods should be able to be installed and uninstalled without much impact to the end user. Thanks for the information and the link to your project.
Regarding licensing, ModTek is licensed under the UNLICENSE, which means it's released to the public domain. That also means that any included code will have to licensed like that, so I'll probably use your project as a jumping off platform to how the DB works and what needs to be done, and write separate code that actually does it or you'll have to 'release' the code to me in a pull request that acknowledges that you're agreeing to the license.
Also, as an observation, I don't think it's a very good idea to write raw SQL into your code -- instead, I would look up documentation on how to use a library (preferably the one that the game uses to write to the DB) that does it for me. Again, I haven't worked on this particular problem at all, so it might ultimately be needed.
They are using Mono.Data.Sqlite, I'm using Microsoft.Data.Sqlite. Either will work similarly. If you check out the BattleTech.Data classes in Assembly_CSharp you'll see they are using SQL right in the code as well. As far as I know that's the only way to work with sqlite in .Net but there could be a wrapper out there that I'm not aware of. (Although even entity and such when you get to the lower layers you're still seeing sql, it's just a lot of it is autogenerated by the library for you).
I'm pretty open to licensing, I figured by putting it on GitHub it's open to the world anyway but I can look into setting a specific license for it.
Definitely have some kind of wrapper to escape data and mitigate SQL injection attacks. You definitely wouldn't want a mod to become a malware vector because BT assumes the database is safe to ingest naively.
ModTek will end up using the game MDD extension methods, as provided by the game's assembly.
An idea on how you could utilize the MetadataDatabase library I'm working on to autoload mechdefs, vehicledefs (and in the future pilots,events,etc) with BTML. Link to BMIT GitHub. You only need the BMIT.DataLibrary project from my repo. This is just a quick/dirty example, I'm sure there are better ways to incorporate but I hope you can get the basic idea of functionality from this example.
Potential Issues: Once the MetadataDatabase.db has been updated with a def, that def must exist in the VersionManifest.CSV list (or get loaded by BTML someway). If that def is removed, the MetadataDatabse.db must also have it's associated entries removed. Failure to do this will cause infinite/hanging loading screens. I will add def deletion functionality to the library, but it means the mod manager must be used to 'Uninstall' a mod, and not simply just delete it. Alternatively, some sanity check could be run on inititalization that cleans the db of any def that isn't found in the associated json files. Obviously removing a def from an active campaign will break it, if the player has the mech or the parts in his inventory or it's saved during a contract with one in play.