mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
More shared memory work + moved spdat from zone to common
This commit is contained in:
+44
-1
@@ -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;
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user