[Loot] Remove from shared memory, simplification (#3988)

* First pass of pulling loot out of shared memory, functional

* More code cleanup

* More cleanup

* More cleanup

* More cleanup

* Add loot reload type

* Reload, logging

* Update npc.h

* Cleanup

* Logging, don't load attempt to load loottable id 0

* Update worldserver.cpp

* Update client.cpp

* Update zone_loot.cpp

* PR feedback

* Update zone.cpp

* Memory leak suggestion

* Update CMakeLists.txt

* Post rebase issues
This commit is contained in:
Chris Miles
2024-02-05 15:17:53 -06:00
committed by GitHub
parent fcbf5cae47
commit c654c1d674
55 changed files with 1595 additions and 1890 deletions
-2
View File
@@ -3,7 +3,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
SET(shared_memory_sources
base_data.cpp
items.cpp
loot.cpp
main.cpp
spells.cpp
skill_caps.cpp
@@ -12,7 +11,6 @@ SET(shared_memory_sources
SET(shared_memory_headers
base_data.h
items.h
loot.h
spells.h
skill_caps.h
)
-65
View File
@@ -1,65 +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 "loot.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/fixed_memory_variable_hash_set.h"
#include "../common/loottable.h"
void LoadLoot(SharedDatabase *database, const std::string &prefix) {
EQ::IPCMutex mutex("loot");
mutex.Lock();
uint32 loot_table_count, loot_table_max, loot_table_entries_count;
uint32 loot_drop_count, loot_drop_max, loot_drop_entries_count;
database->GetLootTableInfo(loot_table_count, loot_table_max, loot_table_entries_count);
database->GetLootDropInfo(loot_drop_count, loot_drop_max, loot_drop_entries_count);
uint32 loot_table_size = (3 * sizeof(uint32)) + //header
((loot_table_max + 1) * sizeof(uint32)) + //offset list
(loot_table_count * sizeof(LootTable_Struct)) + //loot table headers
(loot_table_entries_count * sizeof(LootTableEntries_Struct)); //number of loot table entries
uint32 loot_drop_size = (3 * sizeof(uint32)) + //header
((loot_drop_max + 1) * sizeof(uint32)) + //offset list
(loot_drop_count * sizeof(LootDrop_Struct)) + //loot table headers
(loot_drop_entries_count * sizeof(LootDropEntries_Struct)); //number of loot table entries
auto Config = EQEmuConfig::get();
std::string file_name_lt = Config->SharedMemDir + prefix + std::string("loot_table");
std::string file_name_ld = Config->SharedMemDir + prefix + std::string("loot_drop");
EQ::MemoryMappedFile mmf_loot_table(file_name_lt, loot_table_size);
EQ::MemoryMappedFile mmf_loot_drop(file_name_ld, loot_drop_size);
mmf_loot_table.ZeroFile();
mmf_loot_drop.ZeroFile();
EQ::FixedMemoryVariableHashSet<LootTable_Struct> loot_table_hash(reinterpret_cast<byte*>(mmf_loot_table.Get()),
loot_table_size, loot_table_max);
EQ::FixedMemoryVariableHashSet<LootDrop_Struct> loot_drop_hash(reinterpret_cast<byte*>(mmf_loot_drop.Get()),
loot_drop_size, loot_drop_max);
database->LoadLootTables(mmf_loot_table.Get(), loot_table_max);
database->LoadLootDrops(mmf_loot_drop.Get(), loot_drop_max);
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_LOOT_H
#define __EQEMU_SHARED_MEMORY_LOOT_H
#include <string>
#include "../common/eqemu_config.h"
class SharedDatabase;
void LoadLoot(SharedDatabase *database, const std::string &prefix);
#endif
-19
View File
@@ -28,7 +28,6 @@
#include "../common/eqemu_exception.h"
#include "../common/strings.h"
#include "items.h"
#include "loot.h"
#include "skill_caps.h"
#include "spells.h"
#include "base_data.h"
@@ -183,7 +182,6 @@ int main(int argc, char **argv)
bool load_all = true;
bool load_items = false;
bool load_loot = false;
bool load_skill_caps = false;
bool load_spells = false;
bool load_bd = false;
@@ -205,13 +203,6 @@ int main(int argc, char **argv)
}
break;
case 'l':
if (strcasecmp("loot", argv[i]) == 0) {
load_loot = true;
load_all = false;
}
break;
case 's':
if (strcasecmp("skill_caps", argv[i]) == 0) {
load_skill_caps = true;
@@ -252,16 +243,6 @@ int main(int argc, char **argv)
}
}
if (load_all || load_loot) {
LogInfo("Loading loot");
try {
LoadLoot(&content_db, hotfix_name);
} catch (std::exception &ex) {
LogError("{}", ex.what());
return 1;
}
}
if (load_all || load_skill_caps) {
LogInfo("Loading skill caps");
try {