From 9daf572ea78394e6f909031030c159dd628508cb Mon Sep 17 00:00:00 2001 From: KimLS Date: Tue, 10 Feb 2015 11:53:16 -0800 Subject: [PATCH] Fix for no factions in database crashing the server and shared memory --- common/shareddb.cpp | 9 +++------ shared_memory/npc_faction.cpp | 3 --- zone/zonedb.cpp | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 13ae065be..0e057812d 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -1158,7 +1158,7 @@ void SharedDatabase::GetFactionListInfo(uint32 &list_count, uint32 &max_lists) { auto row = results.begin(); list_count = static_cast(atoul(row[0])); - max_lists = static_cast(atoul(row[1])); + max_lists = static_cast(atoul(row[1] ? row[1] : "0")); } const NPCFactionList* SharedDatabase::GetNPCFactionEntry(uint32 id) { @@ -1235,9 +1235,6 @@ bool SharedDatabase::LoadNPCFactionLists() { uint32 list_count = 0; uint32 max_lists = 0; GetFactionListInfo(list_count, max_lists); - if(list_count == 0) { - EQ_EXCEPT("SharedDatabase", "Database returned no result"); - } uint32 size = static_cast(EQEmu::FixedMemoryHashSet::estimated_size( list_count, max_lists)); @@ -1837,7 +1834,7 @@ void SharedDatabase::GetLootTableInfo(uint32 &loot_table_count, uint32 &max_loot auto row = results.begin(); loot_table_count = static_cast(atoul(row[0])); - max_loot_table = static_cast(atoul(row[1])); + max_loot_table = static_cast(atoul(row[1] ? row[1] : "0")); loot_table_entries = static_cast(atoul(row[2])); } @@ -1858,7 +1855,7 @@ void SharedDatabase::GetLootDropInfo(uint32 &loot_drop_count, uint32 &max_loot_d auto row =results.begin(); loot_drop_count = static_cast(atoul(row[0])); - max_loot_drop = static_cast(atoul(row[1])); + max_loot_drop = static_cast(atoul(row[1] ? row[1] : "0")); loot_drop_entries = static_cast(atoul(row[2])); } diff --git a/shared_memory/npc_faction.cpp b/shared_memory/npc_faction.cpp index df33b7368..ebaeb3457 100644 --- a/shared_memory/npc_faction.cpp +++ b/shared_memory/npc_faction.cpp @@ -31,9 +31,6 @@ void LoadFactions(SharedDatabase *database) { uint32 lists = 0; uint32 max_list = 0; database->GetFactionListInfo(lists, max_list); - if(lists == 0) { - EQ_EXCEPT("Shared Memory", "Unable to get any factions from the database."); - } uint32 size = static_cast(EQEmu::FixedMemoryHashSet::estimated_size(lists, max_list)); EQEmu::MemoryMappedFile mmf("shared/faction", size); diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 165282f3d..6cb15d16e 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -3256,7 +3256,7 @@ bool ZoneDatabase::LoadFactionData() auto row = results.begin(); - max_faction = atoi(row[0]); + max_faction = row[0] ? atoi(row[0]) : 0; faction_array = new Faction*[max_faction+1]; for(unsigned int index=0; index