mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
NPC Faction lists to new shared memory scheme
This commit is contained in:
@@ -4,6 +4,7 @@ SET(shared_memory_sources
|
||||
items.cpp
|
||||
loot.cpp
|
||||
main.cpp
|
||||
npc_faction.cpp
|
||||
spells.cpp
|
||||
skill_caps.cpp
|
||||
)
|
||||
@@ -11,6 +12,7 @@ SET(shared_memory_sources
|
||||
SET(shared_memory_headers
|
||||
items.h
|
||||
loot.h
|
||||
npc_faction.h
|
||||
spells.h
|
||||
skill_caps.h
|
||||
)
|
||||
|
||||
@@ -28,8 +28,9 @@ void LoadItems(SharedDatabase *database) {
|
||||
EQEmu::IPCMutex mutex("items");
|
||||
mutex.Lock();
|
||||
|
||||
int32 items = -1;
|
||||
uint32 max_item = 0;
|
||||
int32 items = database->GetItemsCount(&max_item);
|
||||
database->GetItemsCount(items, max_item);
|
||||
if(items == -1) {
|
||||
EQ_EXCEPT("Shared Memory", "Unable to get any items from the database.");
|
||||
}
|
||||
@@ -39,8 +40,6 @@ void LoadItems(SharedDatabase *database) {
|
||||
mmf.ZeroFile();
|
||||
|
||||
void *ptr = mmf.Get();
|
||||
database->LoadItems(ptr, size, items, max_item);
|
||||
mmf.SetLoaded();
|
||||
|
||||
database->LoadItems(ptr, size, items, max_item);
|
||||
mutex.Unlock();
|
||||
}
|
||||
|
||||
@@ -57,8 +57,5 @@ void LoadLoot(SharedDatabase *database) {
|
||||
|
||||
database->LoadLootTables(mmf_loot_table.Get(), loot_table_max);
|
||||
database->LoadLootDrops(mmf_loot_drop.Get(), loot_drop_max);
|
||||
|
||||
mmf_loot_table.SetLoaded();
|
||||
mmf_loot_drop.SetLoaded();
|
||||
mutex.Unlock();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "../common/rulesys.h"
|
||||
#include "../common/eqemu_exception.h"
|
||||
#include "items.h"
|
||||
#include "npc_faction.h"
|
||||
#include "loot.h"
|
||||
#include "skill_caps.h"
|
||||
#include "spells.h"
|
||||
@@ -55,6 +56,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
bool load_all = true;
|
||||
bool load_items = true;
|
||||
bool load_factions = true;
|
||||
bool load_loot = true;
|
||||
bool load_skill_caps = true;
|
||||
bool load_spells = true;
|
||||
@@ -68,6 +70,16 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if(load_all || load_factions) {
|
||||
LogFile->write(EQEMuLog::Status, "Loading factions...");
|
||||
try {
|
||||
LoadFactions(&database);
|
||||
} catch(std::exception &ex) {
|
||||
LogFile->write(EQEMuLog::Error, "%s", ex.what());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(load_all || load_loot) {
|
||||
LogFile->write(EQEMuLog::Status, "Loading loot...");
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "npc_faction.h"
|
||||
#include "../common/debug.h"
|
||||
#include "../common/shareddb.h"
|
||||
#include "../common/ipc_mutex.h"
|
||||
#include "../common/memory_mapped_file.h"
|
||||
#include "../common/eqemu_exception.h"
|
||||
#include "../common/faction.h"
|
||||
|
||||
void LoadFactions(SharedDatabase *database) {
|
||||
EQEmu::IPCMutex mutex("faction");
|
||||
mutex.Lock();
|
||||
|
||||
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<uint32>(EQEmu::FixedMemoryHashSet<NPCFactionList>::estimated_size(lists, max_list));
|
||||
EQEmu::MemoryMappedFile mmf("shared/faction", size);
|
||||
mmf.ZeroFile();
|
||||
|
||||
void *ptr = mmf.Get();
|
||||
database->LoadNPCFactionLists(ptr, size, lists, max_list);
|
||||
mutex.Unlock();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __EQEMU_SHARED_MEMORY_NPC_FACTION_H
|
||||
#define __EQEMU_SHARED_MEMORY_NPC_FACTION_H
|
||||
|
||||
class SharedDatabase;
|
||||
void LoadFactions(SharedDatabase *database);
|
||||
|
||||
#endif
|
||||
@@ -37,8 +37,6 @@ void LoadSkillCaps(SharedDatabase *database) {
|
||||
mmf.ZeroFile();
|
||||
|
||||
void *ptr = mmf.Get();
|
||||
database->LoadSkillCaps(ptr);
|
||||
mmf.SetLoaded();
|
||||
|
||||
database->LoadSkillCaps(ptr);
|
||||
mutex.Unlock();
|
||||
}
|
||||
@@ -38,8 +38,5 @@ void LoadSpells(SharedDatabase *database) {
|
||||
|
||||
void *ptr = mmf.Get();
|
||||
database->LoadSpells(ptr, records);
|
||||
mmf.SetLoaded();
|
||||
|
||||
//Mutex will unlock on destruction because it's RAII but still.
|
||||
mutex.Unlock();
|
||||
}
|
||||
Reference in New Issue
Block a user