mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-27 14:42:25 +00:00
Fix for no factions in database crashing the server and shared memory
This commit is contained in:
parent
f613d12c61
commit
9daf572ea7
@ -1158,7 +1158,7 @@ void SharedDatabase::GetFactionListInfo(uint32 &list_count, uint32 &max_lists) {
|
|||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
|
|
||||||
list_count = static_cast<uint32>(atoul(row[0]));
|
list_count = static_cast<uint32>(atoul(row[0]));
|
||||||
max_lists = static_cast<uint32>(atoul(row[1]));
|
max_lists = static_cast<uint32>(atoul(row[1] ? row[1] : "0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const NPCFactionList* SharedDatabase::GetNPCFactionEntry(uint32 id) {
|
const NPCFactionList* SharedDatabase::GetNPCFactionEntry(uint32 id) {
|
||||||
@ -1235,9 +1235,6 @@ bool SharedDatabase::LoadNPCFactionLists() {
|
|||||||
uint32 list_count = 0;
|
uint32 list_count = 0;
|
||||||
uint32 max_lists = 0;
|
uint32 max_lists = 0;
|
||||||
GetFactionListInfo(list_count, max_lists);
|
GetFactionListInfo(list_count, max_lists);
|
||||||
if(list_count == 0) {
|
|
||||||
EQ_EXCEPT("SharedDatabase", "Database returned no result");
|
|
||||||
}
|
|
||||||
uint32 size = static_cast<uint32>(EQEmu::FixedMemoryHashSet<NPCFactionList>::estimated_size(
|
uint32 size = static_cast<uint32>(EQEmu::FixedMemoryHashSet<NPCFactionList>::estimated_size(
|
||||||
list_count, max_lists));
|
list_count, max_lists));
|
||||||
|
|
||||||
@ -1837,7 +1834,7 @@ void SharedDatabase::GetLootTableInfo(uint32 &loot_table_count, uint32 &max_loot
|
|||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
|
|
||||||
loot_table_count = static_cast<uint32>(atoul(row[0]));
|
loot_table_count = static_cast<uint32>(atoul(row[0]));
|
||||||
max_loot_table = static_cast<uint32>(atoul(row[1]));
|
max_loot_table = static_cast<uint32>(atoul(row[1] ? row[1] : "0"));
|
||||||
loot_table_entries = static_cast<uint32>(atoul(row[2]));
|
loot_table_entries = static_cast<uint32>(atoul(row[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1858,7 +1855,7 @@ void SharedDatabase::GetLootDropInfo(uint32 &loot_drop_count, uint32 &max_loot_d
|
|||||||
auto row =results.begin();
|
auto row =results.begin();
|
||||||
|
|
||||||
loot_drop_count = static_cast<uint32>(atoul(row[0]));
|
loot_drop_count = static_cast<uint32>(atoul(row[0]));
|
||||||
max_loot_drop = static_cast<uint32>(atoul(row[1]));
|
max_loot_drop = static_cast<uint32>(atoul(row[1] ? row[1] : "0"));
|
||||||
loot_drop_entries = static_cast<uint32>(atoul(row[2]));
|
loot_drop_entries = static_cast<uint32>(atoul(row[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,9 +31,6 @@ void LoadFactions(SharedDatabase *database) {
|
|||||||
uint32 lists = 0;
|
uint32 lists = 0;
|
||||||
uint32 max_list = 0;
|
uint32 max_list = 0;
|
||||||
database->GetFactionListInfo(lists, max_list);
|
database->GetFactionListInfo(lists, max_list);
|
||||||
if(lists == 0) {
|
|
||||||
EQ_EXCEPT("Shared Memory", "Unable to get any factions from the database.");
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 size = static_cast<uint32>(EQEmu::FixedMemoryHashSet<NPCFactionList>::estimated_size(lists, max_list));
|
uint32 size = static_cast<uint32>(EQEmu::FixedMemoryHashSet<NPCFactionList>::estimated_size(lists, max_list));
|
||||||
EQEmu::MemoryMappedFile mmf("shared/faction", size);
|
EQEmu::MemoryMappedFile mmf("shared/faction", size);
|
||||||
|
|||||||
@ -3256,7 +3256,7 @@ bool ZoneDatabase::LoadFactionData()
|
|||||||
|
|
||||||
auto row = results.begin();
|
auto row = results.begin();
|
||||||
|
|
||||||
max_faction = atoi(row[0]);
|
max_faction = row[0] ? atoi(row[0]) : 0;
|
||||||
faction_array = new Faction*[max_faction+1];
|
faction_array = new Faction*[max_faction+1];
|
||||||
for(unsigned int index=0; index<max_faction; index++)
|
for(unsigned int index=0; index<max_faction; index++)
|
||||||
faction_array[index] = nullptr;
|
faction_array[index] = nullptr;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user