mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 07:18:37 +00:00
[Validation] Add Size Validation to #hotfix. (#2304)
* [Validation] Add Size Validation to #hotfix. - Validates size of shared memory pool versus current count of database so people don't accidentally #hotfix and mess something up. * Typo. * Message change.
This commit is contained in:
@@ -932,6 +932,8 @@ bool SharedDatabase::LoadItems(const std::string &prefix) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_shared_items_count = GetItemsCount();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1782,6 +1784,9 @@ bool SharedDatabase::LoadSpells(const std::string &prefix, int32 *records, const
|
||||
LogError("Error Loading Spells: {}", ex.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
m_shared_spells_count = GetSpellsCount();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2367,3 +2372,35 @@ void SharedDatabase::SaveCharacterInspectMessage(uint32 character_id, const Insp
|
||||
const std::string query = StringFormat("REPLACE INTO `character_inspect_messages` (id, inspect_message) VALUES (%u, '%s')", character_id, Strings::Escape(message->text).c_str());
|
||||
auto results = QueryDatabase(query);
|
||||
}
|
||||
|
||||
uint32 SharedDatabase::GetSpellsCount()
|
||||
{
|
||||
auto results = QueryDatabase("SELECT count(*) FROM spells_new");
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto& row = results.begin();
|
||||
|
||||
if (row[0]) {
|
||||
return atoul(row[0]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 SharedDatabase::GetItemsCount()
|
||||
{
|
||||
auto results = QueryDatabase("SELECT count(*) FROM items");
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto& row = results.begin();
|
||||
|
||||
if (row[0]) {
|
||||
return atoul(row[0]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user