Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Database::CheckDatabaseVersion(const std::string& database)
- {
- uint32 expected_version, expected_structure, expected_content;
- if (database == "World")
- {
- expected_version = WORLD_DB_VERSION_NR;
- expected_structure = WORLD_DB_STRUCTURE_NR;
- expected_content = WORLD_DB_CONTENT_NR;
- }
- else if (database == "Character")
- {
- expected_version = CHAR_DB_VERSION_NR;
- expected_structure = CHAR_DB_STRUCTURE_NR;
- expected_content = CHAR_DB_CONTENT_NR;
- }
- else if (database == "Realmd")
- {
- expected_version = REALMD_DB_VERSION_NR;
- expected_structure = REALMD_DB_STRUCTURE_NR;
- expected_content = REALMD_DB_CONTENT_NR;
- }
- // 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", expected_version, expected_structure, 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 == 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", expected_version, expected_structure, 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 == expected_version && content == 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", expected_version, expected_structure, 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