Add Sd0Conversion

Add brick by brick conversion commands with 2 parameters to tell the program what to do with the data.

Add zlib -> sd0 conversion.  Files look good at a glance but should be tested in game to ensure stability.  Tests to come.
This commit is contained in:
EmosewaMC
2022-08-19 01:58:50 -07:00
parent ece15934d3
commit 8cd7526dae
6 changed files with 147 additions and 5 deletions

View File

@@ -20,6 +20,7 @@
#include "CDClientManager.h"
#include "Database.h"
#include "MigrationRunner.h"
#include "BrickByBrickFix.h"
#include "Diagnostics.h"
#include "dCommonVars.h"
#include "dConfig.h"
@@ -203,6 +204,24 @@ int main(int argc, char** argv) {
return EXIT_SUCCESS;
}
// We were given a brick by brick command
if (argc == 3 && strcmp(argv[1], "--brick-by-brick") == 0) {
// Truncates invalid model lxfml from the database and
// removes their respective models from the database.
if (strcmp(argv[2], "TruncateBrokenModels") == 0) {
uint32_t numberOfTruncatedModels = BrickByBrickFix::TruncateBrokenBrickByBrickXml();
Game::logger->Log("MasterServer", "%i models were truncated from the database.", numberOfTruncatedModels);
}
// Updates old Brick-by-Brick models to use sd0 compression
// as opposed to zlib compression
if (strcmp(argv[2], "UpdateOldModels") == 0) {
uint32_t numberOfUpdatedModels = BrickByBrickFix::UpdateBrickByBrickModelsToSd0();
Game::logger->Log("MasterServer", "%i models were updated from zlib to sd0.", numberOfUpdatedModels);
}
FinalizeShutdown();
}
int maxClients = 999;
int ourPort = 1000;
if (config.GetValue("max_clients") != "") maxClients = std::stoi(config.GetValue("max_clients"));
@@ -825,9 +844,9 @@ void ShutdownSequence() {
int FinalizeShutdown() {
//Delete our objects here:
Database::Destroy("MasterServer");
delete Game::im;
delete Game::server;
delete Game::logger;
if (Game::im) delete Game::im;
if (Game::server) delete Game::server;
if (Game::logger) delete Game::logger;
exit(EXIT_SUCCESS);
return EXIT_SUCCESS;