[Factions] Remove from shared memory and simplify (#3999)

* [Factions] Remove from shared memory and simplify

- Removes factions from shared memory and moves to zone based storage of repositories and changes the NPC `faction_list` to also use repositories.
- This affects NPC Factions and Faction Associations.

* Bug fixes.

* Update client.cpp

* Update client.cpp

* Update client.cpp

* Cleanup

* Update client.cpp

* Update client.cpp

* Update client.cpp

* Final push

* Update CMakeLists.txt

* Consolidate reloading.

* [Cleanup] PR # 3999 (#4039)

* [Fixes for PR # 3999

* [Reload actual in game factions, not just the umbrella data.

* syntax

* Fix typo

* Foix bug where primary_faction not filled in when no hits

* Fix typos

* Fix splash factions for kills.

* Fix typo

* Fix more variable names to be accurate

* Fix Loads to load new ones as they come in.

* Load npc_factions without primary (tasks) and support old task faction

* Rename to make way for new LoadFactionAssocition (by faction_id)

* Fix some review comments

* Add code to load factions for splash tasks and quests.

* Fix issue with sign and RewardFaction, fix Log Message

---------

Co-authored-by: Paul Coene <noudess@gmail.com>
This commit is contained in:
Alex King
2024-02-04 10:38:38 -05:00
committed by GitHub
parent 029581772d
commit 297e358c02
31 changed files with 568 additions and 597 deletions
-4
View File
@@ -2,21 +2,17 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
SET(shared_memory_sources
base_data.cpp
faction_association.cpp
items.cpp
loot.cpp
main.cpp
npc_faction.cpp
spells.cpp
skill_caps.cpp
)
SET(shared_memory_headers
base_data.h
faction_association.h
items.h
loot.h
npc_faction.h
spells.h
skill_caps.h
)
-45
View File
@@ -1,45 +0,0 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2022 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 "faction_association.h"
#include "../common/global_define.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 LoadFactionAssociation(SharedDatabase *database, const std::string &prefix) {
EQ::IPCMutex mutex("factionassociations");
mutex.Lock();
uint32 lists = 0;
uint32 max_list = 0;
database->GetFactionAssociationInfo(lists, max_list);
uint32 size = static_cast<uint32>(EQ::FixedMemoryHashSet<FactionAssociations>::estimated_size(lists, max_list));
auto Config = EQEmuConfig::get();
std::string file_name = Config->SharedMemDir + prefix + std::string("factionassociations");
EQ::MemoryMappedFile mmf(file_name, size);
mmf.ZeroFile();
void *ptr = mmf.Get();
database->LoadFactionAssociation(ptr, size, lists, max_list);
mutex.Unlock();
}
-28
View File
@@ -1,28 +0,0 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2022 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_FACTION_ASSOCIATION_H
#define __EQEMU_SHARED_MEMORY_FACTION_ASSOCIATION_H
#include <string>
#include "../common/eqemu_config.h"
class SharedDatabase;
void LoadFactionAssociation(SharedDatabase *database, const std::string &prefix);
#endif
-34
View File
@@ -27,9 +27,7 @@
#include "../common/rulesys.h"
#include "../common/eqemu_exception.h"
#include "../common/strings.h"
#include "faction_association.h"
#include "items.h"
#include "npc_faction.h"
#include "loot.h"
#include "skill_caps.h"
#include "spells.h"
@@ -185,8 +183,6 @@ int main(int argc, char **argv)
bool load_all = true;
bool load_items = false;
bool load_factions = false;
bool load_faction_assoc = false;
bool load_loot = false;
bool load_skill_caps = false;
bool load_spells = false;
@@ -209,13 +205,6 @@ int main(int argc, char **argv)
}
break;
case 'f':
if (strcasecmp("factions", argv[i]) == 0) {
load_factions = true;
load_all = false;
}
break;
case 'l':
if (strcasecmp("loot", argv[i]) == 0) {
load_loot = true;
@@ -232,10 +221,6 @@ int main(int argc, char **argv)
load_spells = true;
load_all = false;
}
else if (strcasecmp("faction_assoc", argv[i]) == 0) {
load_faction_assoc = true;
load_all = false;
}
break;
case '-': {
auto split = Strings::Split(argv[i], '=');
@@ -267,15 +252,6 @@ int main(int argc, char **argv)
}
}
if (load_all || load_factions) {
try {
LoadFactions(&content_db, hotfix_name);
} catch (std::exception &ex) {
LogError("{}", ex.what());
return 1;
}
}
if (load_all || load_loot) {
LogInfo("Loading loot");
try {
@@ -306,16 +282,6 @@ int main(int argc, char **argv)
}
}
if (load_all || load_faction_assoc) {
LogInfo("Loading faction associations");
try {
LoadFactionAssociation(&content_db, hotfix_name);
} catch(std::exception &ex) {
LogError("{}", ex.what());
return 1;
}
}
if (load_all || load_bd) {
LogInfo("Loading base data");
try {
-45
View File
@@ -1,45 +0,0 @@
/* 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/global_define.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, const std::string &prefix) {
EQ::IPCMutex mutex("faction");
mutex.Lock();
uint32 lists = 0;
uint32 max_list = 0;
database->GetFactionListInfo(lists, max_list);
uint32 size = static_cast<uint32>(EQ::FixedMemoryHashSet<NPCFactionList>::estimated_size(lists, max_list));
auto Config = EQEmuConfig::get();
std::string file_name = Config->SharedMemDir + prefix + std::string("faction");
EQ::MemoryMappedFile mmf(file_name, size);
mmf.ZeroFile();
void *ptr = mmf.Get();
database->LoadNPCFactionLists(ptr, size, lists, max_list);
mutex.Unlock();
}
-28
View File
@@ -1,28 +0,0 @@
/* 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
#include <string>
#include "../common/eqemu_config.h"
class SharedDatabase;
void LoadFactions(SharedDatabase *database, const std::string &prefix);
#endif