Initial work on shared memory hotfixes

This commit is contained in:
KimLS
2015-06-23 17:39:06 -07:00
parent 32e880f571
commit 67143f1b8a
23 changed files with 266 additions and 185 deletions
+14
View File
@@ -361,6 +361,7 @@ int command_init(void) {
command_add("setlsinfo", "[email] [password] - Set login server email address and password (if supported by login server)", 10, command_setlsinfo) ||
command_add("setpass", "[accountname] [password] - Set local password for accountname", 150, command_setpass) ||
command_add("setpvppoints", "[value] - Set your or your player target's PVP points", 100, command_setpvppoints) ||
command_add("setsharedmem", "[hotfix_name] - Set your shared memory mapping to a specific hotfix", 250, command_set_shared_memory) ||
command_add("setskill", "[skillnum] [value] - Set your target's skill skillnum to value", 50, command_setskill) ||
command_add("setskillall", "[value] - Set all of your target's skills to value", 50, command_setskillall) ||
command_add("setstartzone", "[zoneid] - Set target's starting zone. Set to zero to allow the player to use /setstartcity", 80, command_setstartzone) ||
@@ -10655,3 +10656,16 @@ void command_mysqltest(Client *c, const Seperator *sep)
}
Log.Out(Logs::General, Logs::Debug, "MySQL Test... Took %f seconds", ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
}
void command_set_shared_memory(Client *c, const Seperator *sep) {
std::string hotfix_name = sep->arg[1];
c->Message(0, "Setting shared memory hotfix mapping to '%s'", hotfix_name.c_str());
database.SetVariable("hotfix_name", hotfix_name.c_str());
ServerPacket pack(ServerOP_ChangeSharedMem, hotfix_name.length() + 1);
if(hotfix_name.length() > 0) {
strcpy((char*)pack.pBuffer, hotfix_name.c_str());
}
worldserver.SendPacket(&pack);
}
+2 -1
View File
@@ -325,7 +325,8 @@ void command_tune(Client *c, const Seperator *sep);
void command_logtest(Client *c, const Seperator *sep);
void command_mysqltest(Client *c, const Seperator *sep);
void command_logs(Client *c, const Seperator *sep);
void command_set_shared_memory(Client *c, const Seperator *sep);
#ifdef EQPROFILE
void command_profiledump(Client *c, const Seperator *sep);
void command_profilereset(Client *c, const Seperator *sep);
+14 -31
View File
@@ -107,7 +107,6 @@ QuestParserCollection *parse = 0;
EQEmuLogSys Log;
const SPDat_Spell_Struct* spells;
void LoadSpells(EQEmu::MemoryMappedFile **mmf);
int32 SPDAT_RECORDS = -1;
void Shutdown();
@@ -205,37 +204,44 @@ int main(int argc, char** argv) {
Log.Out(Logs::General, Logs::Zone_Server, "Loading Variables");
database.LoadVariables();
char hotfix_name[256] = { 0 };
if(database.GetVariable("hotfix_name", hotfix_name, 256)) {
Log.Out(Logs::General, Logs::Zone_Server, "Current hotfix in use: %s", hotfix_name);
}
Log.Out(Logs::General, Logs::Zone_Server, "Loading zone names");
database.LoadZoneNames();
Log.Out(Logs::General, Logs::Zone_Server, "Loading items");
if (!database.LoadItems()) {
if(!database.LoadItems(hotfix_name)) {
Log.Out(Logs::General, Logs::Error, "Loading items FAILED!");
Log.Out(Logs::General, Logs::Error, "Failed. But ignoring error and going on...");
}
Log.Out(Logs::General, Logs::Zone_Server, "Loading npc faction lists");
if (!database.LoadNPCFactionLists()) {
if(!database.LoadNPCFactionLists(hotfix_name)) {
Log.Out(Logs::General, Logs::Error, "Loading npcs faction lists FAILED!");
return 1;
}
Log.Out(Logs::General, Logs::Zone_Server, "Loading loot tables");
if (!database.LoadLoot()) {
if(!database.LoadLoot(hotfix_name)) {
Log.Out(Logs::General, Logs::Error, "Loading loot FAILED!");
return 1;
}
Log.Out(Logs::General, Logs::Zone_Server, "Loading skill caps");
if (!database.LoadSkillCaps()) {
if(!database.LoadSkillCaps(std::string(hotfix_name))) {
Log.Out(Logs::General, Logs::Error, "Loading skill caps FAILED!");
return 1;
}
Log.Out(Logs::General, Logs::Zone_Server, "Loading spells");
EQEmu::MemoryMappedFile *mmf = nullptr;
LoadSpells(&mmf);
if(!database.LoadSpells(hotfix_name, &SPDAT_RECORDS, &spells)) {
Log.Out(Logs::General, Logs::Error, "Loading spells FAILED!");
return 1;
}
Log.Out(Logs::General, Logs::Zone_Server, "Loading base data");
if (!database.LoadBaseData()) {
if(!database.LoadBaseData(hotfix_name)) {
Log.Out(Logs::General, Logs::Error, "Loading base data FAILED!");
return 1;
}
@@ -468,7 +474,6 @@ int main(int argc, char** argv) {
safe_delete(lua_parser);
#endif
safe_delete(mmf);
safe_delete(Config);
if (zone != 0)
@@ -571,28 +576,6 @@ NetConnection::~NetConnection() {
safe_delete_array(WorldAddress);
}
void LoadSpells(EQEmu::MemoryMappedFile **mmf) {
int records = database.GetMaxSpellID() + 1;
try {
EQEmu::IPCMutex mutex("spells");
mutex.Lock();
*mmf = new EQEmu::MemoryMappedFile("shared/spells");
uint32 size = (*mmf)->Size();
if(size != (records * sizeof(SPDat_Spell_Struct))) {
EQ_EXCEPT("Zone", "Unable to load spells: (*mmf)->Size() != records * sizeof(SPDat_Spell_Struct)");
}
spells = reinterpret_cast<SPDat_Spell_Struct*>((*mmf)->Get());
mutex.Unlock();
} catch(std::exception &ex) {
Log.Out(Logs::General, Logs::Error, "Error loading spells: %s", ex.what());
return;
}
SPDAT_RECORDS = records;
}
/* Update Window Title with relevant information */
void UpdateWindowTitle(char* iNewTitle) {
#ifdef _WINDOWS
+35
View File
@@ -1841,6 +1841,41 @@ void WorldServer::Process() {
}
break;
}
case ServerOP_ChangeSharedMem:
{
std::string hotfix_name = std::string((char*)pack->pBuffer);
Log.Out(Logs::General, Logs::Zone_Server, "Loading items");
if(!database.LoadItems(hotfix_name)) {
Log.Out(Logs::General, Logs::Error, "Loading items FAILED!");
}
Log.Out(Logs::General, Logs::Zone_Server, "Loading npc faction lists");
if(!database.LoadNPCFactionLists(hotfix_name)) {
Log.Out(Logs::General, Logs::Error, "Loading npcs faction lists FAILED!");
}
Log.Out(Logs::General, Logs::Zone_Server, "Loading loot tables");
if(!database.LoadLoot(hotfix_name)) {
Log.Out(Logs::General, Logs::Error, "Loading loot FAILED!");
}
Log.Out(Logs::General, Logs::Zone_Server, "Loading skill caps");
if(!database.LoadSkillCaps(std::string(hotfix_name))) {
Log.Out(Logs::General, Logs::Error, "Loading skill caps FAILED!");
}
Log.Out(Logs::General, Logs::Zone_Server, "Loading spells");
if(!database.LoadSpells(hotfix_name, &SPDAT_RECORDS, &spells)) {
Log.Out(Logs::General, Logs::Error, "Loading spells FAILED!");
}
Log.Out(Logs::General, Logs::Zone_Server, "Loading base data");
if(!database.LoadBaseData(hotfix_name)) {
Log.Out(Logs::General, Logs::Error, "Loading base data FAILED!");
}
break;
}
default: {
std::cout << " Unknown ZSopcode:" << (int)pack->opcode;
std::cout << " size:" << pack->size << std::endl;