mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
Initial work on shared memory hotfixes
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
#include "../common/memory_mapped_file.h"
|
||||
#include "../common/eqemu_exception.h"
|
||||
|
||||
void LoadBaseData(SharedDatabase *database) {
|
||||
void LoadBaseData(SharedDatabase *database, const std::string &prefix) {
|
||||
EQEmu::IPCMutex mutex("base_data");
|
||||
mutex.Lock();
|
||||
int records = (database->GetMaxBaseDataLevel() + 1);
|
||||
@@ -32,11 +32,12 @@ void LoadBaseData(SharedDatabase *database) {
|
||||
}
|
||||
|
||||
uint32 size = records * 16 * sizeof(BaseDataStruct);
|
||||
EQEmu::MemoryMappedFile mmf("shared/base_data", size);
|
||||
|
||||
std::string file_name = std::string("shared/") + prefix + std::string("base_data");
|
||||
EQEmu::MemoryMappedFile mmf(file_name, size);
|
||||
mmf.ZeroFile();
|
||||
|
||||
void *ptr = mmf.Get();
|
||||
database->LoadBaseData(ptr, records);
|
||||
mutex.Unlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
#ifndef __EQEMU_SHARED_MEMORY_BASE_DATA_H
|
||||
#define __EQEMU_SHARED_MEMORY_BASE_DATA_H
|
||||
|
||||
#include <string>
|
||||
class SharedDatabase;
|
||||
void LoadBaseData(SharedDatabase *database);
|
||||
void LoadBaseData(SharedDatabase *database, const std::string &prefix);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "../common/eqemu_exception.h"
|
||||
#include "../common/item_struct.h"
|
||||
|
||||
void LoadItems(SharedDatabase *database) {
|
||||
void LoadItems(SharedDatabase *database, const std::string &prefix) {
|
||||
EQEmu::IPCMutex mutex("items");
|
||||
mutex.Lock();
|
||||
|
||||
@@ -36,7 +36,9 @@ void LoadItems(SharedDatabase *database) {
|
||||
}
|
||||
|
||||
uint32 size = static_cast<uint32>(EQEmu::FixedMemoryHashSet<Item_Struct>::estimated_size(items, max_item));
|
||||
EQEmu::MemoryMappedFile mmf("shared/items", size);
|
||||
|
||||
std::string file_name = std::string("shared/") + prefix + std::string("items");
|
||||
EQEmu::MemoryMappedFile mmf(file_name, size);
|
||||
mmf.ZeroFile();
|
||||
|
||||
void *ptr = mmf.Get();
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
#ifndef __EQEMU_SHARED_MEMORY_ITEMS_H
|
||||
#define __EQEMU_SHARED_MEMORY_ITEMS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class SharedDatabase;
|
||||
void LoadItems(SharedDatabase *database);
|
||||
void LoadItems(SharedDatabase *database, const std::string &prefix);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "../common/fixed_memory_variable_hash_set.h"
|
||||
#include "../common/loottable.h"
|
||||
|
||||
void LoadLoot(SharedDatabase *database) {
|
||||
void LoadLoot(SharedDatabase *database, const std::string &prefix) {
|
||||
EQEmu::IPCMutex mutex("loot");
|
||||
mutex.Lock();
|
||||
|
||||
@@ -44,8 +44,11 @@ void LoadLoot(SharedDatabase *database) {
|
||||
(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);
|
||||
std::string file_name_lt = std::string("shared/") + prefix + std::string("loot_table");
|
||||
std::string file_name_ld = std::string("shared/") + prefix + std::string("loot_drop");
|
||||
|
||||
EQEmu::MemoryMappedFile mmf_loot_table(file_name_lt, loot_table_size);
|
||||
EQEmu::MemoryMappedFile mmf_loot_drop(file_name_ld, loot_drop_size);
|
||||
mmf_loot_table.ZeroFile();
|
||||
mmf_loot_drop.ZeroFile();
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
#ifndef __EQEMU_SHARED_MEMORY_LOOT_H
|
||||
#define __EQEMU_SHARED_MEMORY_LOOT_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class SharedDatabase;
|
||||
void LoadLoot(SharedDatabase *database);
|
||||
void LoadLoot(SharedDatabase *database, const std::string &prefix);
|
||||
|
||||
#endif
|
||||
|
||||
+41
-26
@@ -26,6 +26,7 @@
|
||||
#include "../common/crash.h"
|
||||
#include "../common/rulesys.h"
|
||||
#include "../common/eqemu_exception.h"
|
||||
#include "../common/string_util.h"
|
||||
#include "items.h"
|
||||
#include "npc_faction.h"
|
||||
#include "loot.h"
|
||||
@@ -61,6 +62,7 @@ int main(int argc, char **argv) {
|
||||
database.LoadLogSettings(Log.log_settings);
|
||||
Log.StartFileLogs();
|
||||
|
||||
std::string hotfix_name = "";
|
||||
bool load_all = true;
|
||||
bool load_items = false;
|
||||
bool load_factions = false;
|
||||
@@ -69,112 +71,125 @@ int main(int argc, char **argv) {
|
||||
bool load_spells = false;
|
||||
bool load_bd = false;
|
||||
if(argc > 1) {
|
||||
load_all = false;
|
||||
|
||||
for(int i = 1; i < argc; ++i) {
|
||||
switch(argv[i][0]) {
|
||||
case 'a':
|
||||
if(strcasecmp("all", argv[i]) == 0) {
|
||||
load_all = true;
|
||||
}
|
||||
break;
|
||||
|
||||
switch(argv[i][0]) {
|
||||
case 'b':
|
||||
if(strcasecmp("base_data", argv[i]) == 0) {
|
||||
load_bd = true;
|
||||
load_all = false;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'i':
|
||||
if(strcasecmp("items", argv[i]) == 0) {
|
||||
load_items = true;
|
||||
load_all = false;
|
||||
}
|
||||
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;
|
||||
load_all = false;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 's':
|
||||
if(strcasecmp("skill_caps", argv[i]) == 0) {
|
||||
load_skill_caps = true;
|
||||
load_all = false;
|
||||
} else if(strcasecmp("spells", argv[i]) == 0) {
|
||||
load_spells = true;
|
||||
load_all = false;
|
||||
}
|
||||
break;
|
||||
case '-': {
|
||||
auto split = SplitString(argv[i], '=');
|
||||
if(split.size() >= 2) {
|
||||
auto command = split[0];
|
||||
auto argument = split[1];
|
||||
if(strcasecmp("-hotfix", command.c_str()) == 0) {
|
||||
hotfix_name = argument;
|
||||
load_all = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(hotfix_name.length() > 0) {
|
||||
Log.Out(Logs::General, Logs::Status, "Writing data for hotfix '%s'", hotfix_name.c_str());
|
||||
}
|
||||
|
||||
if(load_all || load_items) {
|
||||
Log.Out(Logs::General, Logs::Status, "Loading items...");
|
||||
try {
|
||||
LoadItems(&database);
|
||||
LoadItems(&database, hotfix_name);
|
||||
} catch(std::exception &ex) {
|
||||
Log.Out(Logs::General, Logs::Error, "%s", ex.what());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(load_all || load_factions) {
|
||||
Log.Out(Logs::General, Logs::Status, "Loading factions...");
|
||||
try {
|
||||
LoadFactions(&database);
|
||||
LoadFactions(&database, hotfix_name);
|
||||
} catch(std::exception &ex) {
|
||||
Log.Out(Logs::General, Logs::Error, "%s", ex.what());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(load_all || load_loot) {
|
||||
Log.Out(Logs::General, Logs::Status, "Loading loot...");
|
||||
try {
|
||||
LoadLoot(&database);
|
||||
LoadLoot(&database, hotfix_name);
|
||||
} catch(std::exception &ex) {
|
||||
Log.Out(Logs::General, Logs::Error, "%s", ex.what());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(load_all || load_skill_caps) {
|
||||
Log.Out(Logs::General, Logs::Status, "Loading skill caps...");
|
||||
try {
|
||||
LoadSkillCaps(&database);
|
||||
LoadSkillCaps(&database, hotfix_name);
|
||||
} catch(std::exception &ex) {
|
||||
Log.Out(Logs::General, Logs::Error, "%s", ex.what());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(load_all || load_spells) {
|
||||
Log.Out(Logs::General, Logs::Status, "Loading spells...");
|
||||
try {
|
||||
LoadSpells(&database);
|
||||
LoadSpells(&database, hotfix_name);
|
||||
} catch(std::exception &ex) {
|
||||
Log.Out(Logs::General, Logs::Error, "%s", ex.what());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(load_all || load_bd) {
|
||||
Log.Out(Logs::General, Logs::Status, "Loading base data...");
|
||||
try {
|
||||
LoadBaseData(&database);
|
||||
LoadBaseData(&database, hotfix_name);
|
||||
} catch(std::exception &ex) {
|
||||
Log.Out(Logs::General, Logs::Error, "%s", ex.what());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Log.CloseFileLogs();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "../common/eqemu_exception.h"
|
||||
#include "../common/faction.h"
|
||||
|
||||
void LoadFactions(SharedDatabase *database) {
|
||||
void LoadFactions(SharedDatabase *database, const std::string &prefix) {
|
||||
EQEmu::IPCMutex mutex("faction");
|
||||
mutex.Lock();
|
||||
|
||||
@@ -33,7 +33,9 @@ void LoadFactions(SharedDatabase *database) {
|
||||
database->GetFactionListInfo(lists, max_list);
|
||||
|
||||
uint32 size = static_cast<uint32>(EQEmu::FixedMemoryHashSet<NPCFactionList>::estimated_size(lists, max_list));
|
||||
EQEmu::MemoryMappedFile mmf("shared/faction", size);
|
||||
|
||||
std::string file_name = std::string("shared/") + prefix + std::string("faction");
|
||||
EQEmu::MemoryMappedFile mmf(file_name, size);
|
||||
mmf.ZeroFile();
|
||||
|
||||
void *ptr = mmf.Get();
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
#ifndef __EQEMU_SHARED_MEMORY_NPC_FACTION_H
|
||||
#define __EQEMU_SHARED_MEMORY_NPC_FACTION_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class SharedDatabase;
|
||||
void LoadFactions(SharedDatabase *database);
|
||||
void LoadFactions(SharedDatabase *database, const std::string &prefix);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "../common/classes.h"
|
||||
#include "../common/features.h"
|
||||
|
||||
void LoadSkillCaps(SharedDatabase *database) {
|
||||
void LoadSkillCaps(SharedDatabase *database, const std::string &prefix) {
|
||||
EQEmu::IPCMutex mutex("skill_caps");
|
||||
mutex.Lock();
|
||||
|
||||
@@ -33,7 +33,9 @@ void LoadSkillCaps(SharedDatabase *database) {
|
||||
uint32 skill_count = HIGHEST_SKILL + 1;
|
||||
uint32 level_count = HARD_LEVEL_CAP + 1;
|
||||
uint32 size = (class_count * skill_count * level_count * sizeof(uint16));
|
||||
EQEmu::MemoryMappedFile mmf("shared/skill_caps", size);
|
||||
|
||||
std::string file_name = std::string("shared/") + prefix + std::string("skill_caps");
|
||||
EQEmu::MemoryMappedFile mmf(file_name, size);
|
||||
mmf.ZeroFile();
|
||||
|
||||
void *ptr = mmf.Get();
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
#ifndef __EQEMU_SHARED_MEMORY_SKILL_CAPS_H
|
||||
#define __EQEMU_SHARED_MEMORY_SKILL_CAPS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class SharedDatabase;
|
||||
void LoadSkillCaps(SharedDatabase *database);
|
||||
void LoadSkillCaps(SharedDatabase *database, const std::string &prefix);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "../common/eqemu_exception.h"
|
||||
#include "../common/spdat.h"
|
||||
|
||||
void LoadSpells(SharedDatabase *database) {
|
||||
void LoadSpells(SharedDatabase *database, const std::string &prefix) {
|
||||
EQEmu::IPCMutex mutex("spells");
|
||||
mutex.Lock();
|
||||
int records = database->GetMaxSpellID() + 1;
|
||||
@@ -32,8 +32,10 @@ void LoadSpells(SharedDatabase *database) {
|
||||
EQ_EXCEPT("Shared Memory", "Unable to get any spells from the database.");
|
||||
}
|
||||
|
||||
uint32 size = records * sizeof(SPDat_Spell_Struct);
|
||||
EQEmu::MemoryMappedFile mmf("shared/spells", size);
|
||||
uint32 size = records * sizeof(SPDat_Spell_Struct) + sizeof(uint32);
|
||||
|
||||
std::string file_name = std::string("shared/") + prefix + std::string("spells");
|
||||
EQEmu::MemoryMappedFile mmf(file_name, size);
|
||||
mmf.ZeroFile();
|
||||
|
||||
void *ptr = mmf.Get();
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
#ifndef __EQEMU_SHARED_MEMORY_SPELLS_H
|
||||
#define __EQEMU_SHARED_MEMORY_SPELLS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class SharedDatabase;
|
||||
void LoadSpells(SharedDatabase *database);
|
||||
void LoadSpells(SharedDatabase *database, const std::string &prefix);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user