More shared memory work + moved spdat from zone to common

This commit is contained in:
KimLS 2013-02-19 15:33:21 -08:00
parent 78b2385785
commit 7ce6f4de0d
37 changed files with 134 additions and 77 deletions

View File

@ -2,7 +2,7 @@
#define MEMSHARE_SPELLS_H
#include "../common/types.h"
#include "../zone/spdat.h"
#include "../common/spdat.h"
#include "../common/EMuShareMem.h"
struct MMFSpells_Struct {

View File

@ -55,6 +55,7 @@ SET(common_sources
serverinfo.cpp
shareddb.cpp
SharedLibrary.cpp
spdat.cpp
StructStrategy.cpp
TCPConnection.cpp
TCPServer.cpp
@ -168,6 +169,7 @@ SET(common_headers
shareddb.h
SharedLibrary.h
skills.h
spdat.h
StructStrategy.h
TCPBasicServer.h
TCPConnection.h

View File

@ -107,10 +107,6 @@ public:
bool Connect(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
~Database();
// void ExtraOptions();
/*
* General Character Related Stuff
*/
@ -256,7 +252,6 @@ public:
protected:
void HandleMysqlError(uint32 errnum);
//bool RunQuery(const char* query, uint32 querylen, char* errbuf = 0, MYSQL_RES** result = 0, uint32* affected_rows = 0, uint32* errnum = 0, bool retry = true);
private:
void DBInitVars();

View File

@ -100,6 +100,8 @@ bool EQEMuLog::open(LogIDs id) {
snprintf(exename, sizeof(exename), "_ucs");
} else if(platform == ExePlatformQueryServ) {
snprintf(exename, sizeof(exename), "_queryserv");
} else if(platform == ExePlatformSharedMemory) {
snprintf(exename, sizeof(exename), "_shared_memory");
}
char filename[200];

View File

@ -10,6 +10,7 @@ enum EQEmuExePlatform
ExePlatformQueryServ,
ExePlatformUCS,
ExePlatformLaunch,
ExePlatformSharedMemory
};
void RegisterExecutablePlatform(EQEmuExePlatform p);

View File

@ -5,7 +5,7 @@
#include "database.h"
#include "skills.h"
#include "../zone/spdat.h"
#include "spdat.h"
#include "Item.h"
#include <list>
@ -82,8 +82,6 @@ public:
const NPCFactionList* GetNPCFactionEntry(uint32 id);
uint16 GetSkillCap(uint8 Class_, SkillType Skill, uint8 Level);
uint8 GetTrainLevel(uint8 Class_, SkillType Skill, uint8 Level);
// const Door* GetDoor(uint8 door_id, const char* zone_name);
// const Door* GetDoorDBID(uint32 db_id);
const LootTable_Struct* GetLootTable(uint32 loottable_id);
const LootDrop_Struct* GetLootDrop(uint32 lootdrop_id);
bool LoadItems();

View File

@ -72,20 +72,18 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
#include "../common/debug.h"
#include "debug.h"
#include "spdat.h"
#include "masterentity.h"
#include "../common/packet_dump.h"
#include "../common/moremath.h"
#include "../common/Item.h"
#include "worldserver.h"
#include "../common/skills.h"
#include "../common/bodytypes.h"
#include "../common/classes.h"
#include "packet_dump.h"
#include "moremath.h"
#include "Item.h"
#include "skills.h"
#include "bodytypes.h"
#include "classes.h"
#include <math.h>
#ifndef WIN32
#include <stdlib.h>
#include "../common/unix.h"
#include "unix.h"
#endif
extern bool spells_loaded;

View File

@ -17,10 +17,53 @@
*/
#include <stdio.h>
#include "../common/debug.h"
#include "../common/shareddb.h"
#include "../common/EQEmuConfig.h"
#include "../common/platform.h"
#include "../common/crash.h"
#include "../common/rulesys.h"
#include "../common/eqemu_exception.h"
#include "spells.h"
//blah global variables =(
RuleManager *rules = new RuleManager();
int main(int argc, char **argv) {
bool load_spells = true;
RegisterExecutablePlatform(ExePlatformSharedMemory);
set_exception_handler();
LogFile->write(EQEMuLog::Status, "Shared Memory Loader Program");
if(!EQEmuConfig::LoadConfig()) {
LogFile->write(EQEMuLog::Error, "Unable to load configuration file.");
return 0;
}
const EQEmuConfig *config = EQEmuConfig::get();
if(!load_log_settings(config->LogSettingsFile.c_str())) {
LogFile->write(EQEMuLog::Error, "Warning: unable to read %s.", config->LogSettingsFile.c_str());
}
SharedDatabase database;
LogFile->write(EQEMuLog::Status, "Connecting to database...");
if(!database.Connect(config->DatabaseHost.c_str(), config->DatabaseUsername.c_str(),
config->DatabasePassword.c_str(), config->DatabaseDB.c_str(), config->DatabasePort)) {
LogFile->write(EQEMuLog::Error, "Unable to connect to the database, cannot continue without a "
"database connection");
return 0;
}
bool load_all = true;
bool load_spells = true;
if(load_all || load_spells) {
LogFile->write(EQEMuLog::Status, "Loading spells...");
try {
LoadSpells(&database);
} catch(std::exception &ex) {
LogFile->write(EQEMuLog::Error, "%s", ex.what());
return 0;
}
}
return 0;
}

View File

@ -15,3 +15,28 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "spells.h"
#include "../common/debug.h"
#include "../common/shareddb.h"
#include "../common/ipc_mutex.h"
#include "../common/memory_mapped_file.h"
#include "../common/eqemu_exception.h"
#include "../common/spdat.h"
void LoadSpells(SharedDatabase *database) {
EQEmu::IPCMutex mutex("spells");
mutex.Lock();
int max_spells = 0; //database->GetMaxSpellID();
if(max_spells == -1) {
EQ_EXCEPT("Shared Memory", "Unable to get maximum number of spells from the database.");
}
uint32 size = max_spells * sizeof(SPDat_Spell_Struct);
EQEmu::MemoryMappedFile mmf("shared/spells", size);
void *ptr = mmf.Get();
//database->LoadSpells(ptr, max_spells);
//Mutex will unlock on destruction because it's RAII but still.
mutex.Unlock();
}

View File

@ -15,3 +15,11 @@
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_SPELLS_H
#define __EQEMU_SHARED_MEMORY_SPELLS_H
class SharedDatabase;
void LoadSpells(SharedDatabase *database);
#endif

View File

@ -24,7 +24,7 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
#include "client.h"
#include "groups.h"
#include "raids.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "object.h"
#include "doors.h"
#include "beacon.h"

View File

@ -65,7 +65,6 @@ SET(zone_sources
spawn2.cpp
spawn2.h
spawngroup.cpp
spdat.cpp
special_attacks.cpp
spell_effects.cpp
spells.cpp
@ -142,7 +141,6 @@ SET(zone_headers
spawn2.cpp
spawn2.h
spawngroup.h
spdat.h
StringIDs.h
tasks.h
titles.h

View File

@ -21,7 +21,7 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
#include "masterentity.h"
#include "faction.h"
#include "map.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "../common/skills.h"
#include "../common/MiscFunctions.h"
#include "../common/rulesys.h"

View File

@ -35,7 +35,7 @@ using namespace std;
#include "../common/eq_packet_structs.h"
#include "../common/eq_constants.h"
#include "../common/skills.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "zone.h"
#include "StringIDs.h"
#include "../common/MiscFunctions.h"

View File

@ -34,7 +34,7 @@ target to center around.
#endif
#include "masterentity.h"
#include "spdat.h"
#include "../common/spdat.h"
extern EntityList entity_list;
extern Zone* zone;

View File

@ -16,7 +16,7 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemu.org)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "masterentity.h"
#include "../common/packet_dump.h"
#include "../common/moremath.h"
@ -595,7 +595,8 @@ void Client::CalcAABonuses(StatBonuses* newbon) {
}
//A lot of the normal spell functions (IsBlankSpellEffect, etc) are set for just spells (in zone/spdat.h). For now, we'll just put them directly into the code and comment with the corresponding normal function
//A lot of the normal spell functions (IsBlankSpellEffect, etc) are set for just spells (in common/spdat.h).
//For now, we'll just put them directly into the code and comment with the corresponding normal function
//Maybe we'll fix it later? :-D
void Client::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon)
{

View File

@ -51,7 +51,7 @@ extern bool spells_loaded;
#include "worldserver.h"
#include "../common/misc.h"
#include "zonedb.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "net.h"
#include "../common/packet_dump.h"
#include "../common/packet_functions.h"

View File

@ -19,7 +19,7 @@
#include "masterentity.h"
#include "worldserver.h"
#include "zonedb.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "../common/packet_dump.h"
#include "../common/packet_functions.h"
#include "petitions.h"

View File

@ -52,7 +52,7 @@
#include "../common/breakdowns.h"
#include "../common/guilds.h"
#include "../common/rulesys.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "petitions.h"
#include "NpcAI.h"
#include "../common/skills.h"

View File

@ -51,7 +51,7 @@
#include "worldserver.h"
#include "../common/packet_dump_file.h"
#include "../common/MiscFunctions.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "petitions.h"
#include "NpcAI.h"
#include "../common/skills.h"

View File

@ -2,7 +2,7 @@
#define __EQEMU_ZONE_COMMON_H
#include "../common/types.h"
#include "spdat.h"
#include "../common/spdat.h"
#define HIGHEST_RESIST 9 //Max resist type value

View File

@ -19,7 +19,7 @@
#include "masterentity.h"
#include "worldserver.h"
#include "zonedb.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "../common/packet_dump.h"
#include "../common/packet_functions.h"
#include "petitions.h"

View File

@ -39,7 +39,7 @@ using namespace std;
#include "../common/packet_dump.h"
#include "../common/packet_functions.h"
#include "petitions.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "features.h"
#include "StringIDs.h"
#include "parser.h"

View File

@ -20,7 +20,7 @@
#include "worldserver.h"
#include "net.h"
#include "../common/database.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "../common/packet_dump.h"
#include "../common/packet_functions.h"
#include "petitions.h"

View File

@ -20,7 +20,7 @@
#include "worldserver.h"
#include "net.h"
#include "zonedb.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "../common/packet_dump.h"
#include "../common/packet_functions.h"
#include "petitions.h"

View File

@ -5,7 +5,7 @@
#include "../common/eq_packet_structs.h"
#include "../common/eq_constants.h"
#include "../common/skills.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "zone.h"
#include "StringIDs.h"
#include "../common/MiscFunctions.h"

View File

@ -17,7 +17,7 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
*/
#include "../common/debug.h"
#include "masterentity.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "StringIDs.h"
#include "worldserver.h"
#include "QuestParserCollection.h"

View File

@ -67,8 +67,6 @@ extern volatile bool ZoneLoaded;
#endif
#include "../common/queue.h"
#include "../common/timer.h"
#include "../common/EQStream.h"
@ -91,7 +89,7 @@ extern volatile bool ZoneLoaded;
#include "masterentity.h"
#include "worldserver.h"
#include "net.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "zone.h"
#include "command.h"
#include "parser.h"
@ -104,11 +102,11 @@ extern volatile bool ZoneLoaded;
#include "tasks.h"
#include "QuestParserCollection.h"
TimeoutManager timeout_manager;
NetConnection net;
EntityList entity_list;
WorldServer worldserver;
uint32 numclients = 0;
TimeoutManager timeout_manager;
NetConnection net;
EntityList entity_list;
WorldServer worldserver;
uint32 numclients = 0;
char errorname[32];
uint16 adverrornum = 0;
extern Zone* zone;
@ -121,9 +119,6 @@ RuleManager *rules = new RuleManager();
TaskManager *taskmanager = 0;
QuestParserCollection *parse = 0;
bool zoneprocess;
const SPDat_Spell_Struct* spells;
SPDat_Spell_Struct* spells_delete;
int32 GetMaxSpellID();
@ -141,9 +136,6 @@ int32 SPDAT_RECORDS = -1;
void Shutdown();
extern void MapOpcodes();
//bool ZoneBootup(uint32 iZoneID, bool iStaticZone = false);
//char *strsep(char **stringp, const char *delim);
#ifdef ADDONCMD
#include "addoncmd.h"
extern AddonCmd addonCmd;
@ -213,7 +205,6 @@ int main(int argc, char** argv) {
#ifdef _EQDEBUG
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
// _crtBreakAlloc = 2025;
#endif
_log(ZONE__INIT, "CURRENT_ZONE_VERSION: %s", CURRENT_ZONE_VERSION);
@ -431,35 +422,35 @@ int main(int argc, char** argv) {
entity_list.ChannelMessageFromWorld(0, 0, 6, 0, 0, "WARNING: World server connection lost");
worldwasconnected = false;
}
if (ZoneLoaded && temp_timer.Check()) {
{
uint8 error2 = 4;
if(net.group_timer.Enabled() && net.group_timer.Check())
entity_list.GroupProcess();
error2 = 99;
if(net.door_timer.Enabled() && net.door_timer.Check())
entity_list.DoorProcess();
error2 = 98;
if(net.object_timer.Enabled() && net.object_timer.Check())
entity_list.ObjectProcess();
error2 = 97;
if(net.corpse_timer.Enabled() && net.corpse_timer.Check())
entity_list.CorpseProcess();
if(net.trap_timer.Enabled() && net.trap_timer.Check())
entity_list.TrapProcess();
if(net.raid_timer.Enabled() && net.raid_timer.Check())
entity_list.RaidProcess();
error2 = 98;
error2 = 96;
entity_list.Process();
error2 = 95;
entity_list.MobProcess();
error2 = 94;
entity_list.BeaconProcess();
if (zone) {
zoneprocess= zone->Process();
if (!zoneprocess) {
if(!zone->Process()) {
Zone::Shutdown();
}
}
@ -663,11 +654,7 @@ void LoadSPDat() {
}
int32 MaxSpellID = GetMaxSpellID();
if (MaxSpellID == -1) {
#ifdef NEW_LoadSPDat
_log(SPELLS__LOAD, "LoadSPDat() MaxSpellID == -1, %s missing?", ZoneConfig::get()->SpellsFile.c_str());
#else // defined(DB_LoadSPDat)
_log(SPELLS__LOAD, "LoadSPDat() MaxSpellID == -1, error in GetMaxSpellID()?");
#endif
return;
}
#ifdef SHAREMEM

View File

@ -38,7 +38,7 @@ using namespace std;
#include "map.h"
#include "entity.h"
#include "masterentity.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "../common/bodytypes.h"
#include "spawngroup.h"
#include "../common/MiscFunctions.h"

View File

@ -22,7 +22,7 @@ using namespace std;
#include "../common/classes.h"
#include "../common/races.h"
#include "zonedb.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "../common/packet_functions.h"
#include "spawn2.h"
#include "zone.h"

View File

@ -34,7 +34,7 @@ typedef const char Const_char;
#include "mob.h"
#include "client.h"
#include "spdat.h"
#include "../common/spdat.h"
#ifdef THIS /* this macro seems to leak out on some systems */
#undef THIS

View File

@ -16,7 +16,7 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemu.org)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "masterentity.h"
#include "../common/packet_dump.h"
#include "../common/moremath.h"

View File

@ -66,7 +66,7 @@ using namespace std;
#include "../common/classes.h"
#include "../common/races.h"
#include "zonedb.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "../common/packet_functions.h"
#include "../common/MiscFunctions.h"
#include "spawn2.h"
@ -76,7 +76,6 @@ using namespace std;
#include "guild_mgr.h"
#include "../common/rulesys.h"
#include "QGlobals.h"
#include "spdat.h"
#include "QuestParserCollection.h"
#ifdef BOTS

View File

@ -16,7 +16,7 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemu.org)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "masterentity.h"
#include "../common/packet_dump.h"
#include "../common/moremath.h"

View File

@ -73,7 +73,7 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
#include "../common/debug.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "masterentity.h"
#include "../common/packet_dump.h"
#include "../common/moremath.h"

View File

@ -19,7 +19,7 @@
#include "../common/types.h"
#include "entity.h"
#include "masterentity.h"
#include "spdat.h"
#include "../common/spdat.h"
#include "../common/MiscFunctions.h"
/*