Shared Memory Loot works

This commit is contained in:
KimLS
2013-02-22 18:25:17 -08:00
parent 6f13d0cfbc
commit 9eaa98675b
6 changed files with 236 additions and 348 deletions
+31 -17
View File
@@ -22,29 +22,43 @@
#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) {
EQEmu::IPCMutex mutex("loot");
mutex.Lock();
uint32 loottable_count, loottable_max, loottable_entries_count, lootdrop_count, lootdrop_max, lootdrop_entries_count;
database->GetLootTableInfo(loottable_max, loottable_entries_count,
lootdrop_max, lootdrop_entries_count);
uint32 size = (sizeof(uint32) *3) +
(sizeof(uint32) * (loottable_max + 1)) +
(sizeof(LootTable_Struct) * loottable_count) +
(sizeof(LootTableEntries_Struct) * loottable_entries_count) +
(sizeof(uint32) * (lootdrop_max + 1)) +
(sizeof(LootDrop_Struct) * lootdrop_count) +
(sizeof(LootDropEntries_Struct) * lootdrop_entries_count);
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);
EQEmu::MemoryMappedFile mmf("shared/loot", size);
mmf.ZeroFile();
void *ptr = mmf.Get();
database->LoadLoot(ptr, loottable_count, loottable_max, loottable_entries_count, lootdrop_count,
lootdrop_max, lootdrop_entries_count);
mmf.SetLoaded();
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
EQEmu::MemoryMappedFile mmf_loot_table("shared/loot_table", loot_table_size);
EQEmu::MemoryMappedFile mmf_loot_drop("shared/loot_drop", loot_drop_size);
mmf_loot_table.ZeroFile();
mmf_loot_drop.ZeroFile();
EQEmu::FixedMemoryVariableHashSet<LootTable_Struct> loot_table_hash(reinterpret_cast<byte*>(mmf_loot_table.Get()),
loot_table_size, loot_table_max);
EQEmu::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);
mmf_loot_table.SetLoaded();
mmf_loot_drop.SetLoaded();
mutex.Unlock();
}
+4 -4
View File
@@ -53,11 +53,11 @@ int main(int argc, char **argv) {
return 0;
}
bool load_all = false;
bool load_items = false;
bool load_all = true;
bool load_items = true;
bool load_loot = true;
bool load_skill_caps = false;
bool load_spells = false;
bool load_skill_caps = true;
bool load_spells = true;
if(load_all || load_items) {
LogFile->write(EQEMuLog::Status, "Loading items...");
try {