Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum DatabaseTypes
- {
- DATABASE_WORLD,
- DATABASE_AUTH,
- DATABASE_CHARACTER,
- COUNT_DATABASES,
- };
- struct DBVersion
- {
- uint32 expected_version;
- uint32 expected_structure;
- uint32 expected_content;
- };
- static const DBVersion databaseVersions[COUNT_DATABASES] = {
- {123, 123, 123}, // DATABASE_WORLD
- {123, 123, 123}, // DATABASE_AUTH
- {123, 123, 123}, // DATABASE_CHARACTER
- };
- bool Database::CheckDatabaseVersion(DatabaseTypes database)
- {
- const DBVersion& dbversion = databaseVersions[database];
- // Fetch the world database version table information
- QueryResult* result = PQuery("SELECT * FROM db_version LIMIT 1");
- if (!result)
- {
- // db_version table does not exist
- sLog.outErrorDb("The table `db_version` in your [%s] database is missing or corrupt.", database);
- sLog.outErrorDb();
- sLog.outErrorDb(" [A] You have database version: --> Version: MaNGOS can not verify your database version or its existence.");
- sLog.outErrorDb();
- sLog.outErrorDb(" [B] You need database version: --> Version: %u Structure: %u Content: %u", dbversion.expected_version, dbversion.expected_structure, dbversion.expected_content);
- sLog.outErrorDb();
- sLog.outErrorDb("Please verify your database location or your database integrity.");
- return false;
- }
- Field* fields = result->Fetch();
- uint32 version = fields[0].GetUInt32();
- uint32 structure = fields[1].GetUInt32();
- uint32 content = fields[2].GetUInt32();
- std::string name = fields[3].GetCppString();
- delete result;
- // Check if the world database version matches the required core version
- if (structure == dbversion.expected_structure)
- {
- sLog.outErrorDb("The table `db_version` indicates that your [%s] database does not match the expected version!", database);
- sLog.outErrorDb();
- sLog.outErrorDb(" [A] You have database version: --> Version: %u Structure: %u Content: %u", version, structure, content);
- sLog.outErrorDb();
- sLog.outErrorDb(" [B] You need database version: --> Version: %u Structure: %u Content: %u", dbversion.expected_version, dbversion.expected_structure, dbversion.expected_content);
- sLog.outErrorDb();
- sLog.outErrorDb("You must apply all updates after [A] to [B] to use mangos with this database.");
- sLog.outErrorDb("These updates are included in the database/%s/Updates folder.", database);
- return false;
- }
- // World DB is not up to date, but structure is correct. Send warning but start core
- if (version != dbversion.expected_version || content != dbversion.expected_content)
- {
- sLog.outErrorDb("The table `db_version` indicates that your [%s] database does not match the expected version!", database);
- sLog.outErrorDb();
- sLog.outErrorDb(" [A] You have database version: --> Version: %u Structure: %u Content: %u", version, structure, content);
- sLog.outErrorDb();
- sLog.outErrorDb(" [B] You need database version: --> Version: %u Structure: %u Content: %u", dbversion.expected_version, dbversion.expected_structure, dbversion.expected_content);
- sLog.outErrorDb();
- sLog.outErrorDb("You are missing content updates or you have content updates beyond the expected core version.");
- sLog.outErrorDb("It is recommended to run ALL database updates up to the required core version.");
- sLog.outErrorDb("These updates are included in the database/%s/Updates folder.", database);
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement