Working on shared memory stuff - removed some stuff dealing with older code and loading spells from the non-database

This commit is contained in:
KimLS 2013-02-18 19:00:07 -08:00
parent 70543c2b8a
commit 0d16361a40
30 changed files with 162 additions and 575 deletions

View File

@ -139,6 +139,7 @@ IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS) ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
IF(EQEMU_BUILD_SERVER) IF(EQEMU_BUILD_SERVER)
ADD_SUBDIRECTORY(EMuShareMem) ADD_SUBDIRECTORY(EMuShareMem)
ADD_SUBDIRECTORY(shared_memory)
ADD_SUBDIRECTORY(world) ADD_SUBDIRECTORY(world)
ADD_SUBDIRECTORY(zone) ADD_SUBDIRECTORY(zone)
ADD_SUBDIRECTORY(ucs) ADD_SUBDIRECTORY(ucs)

View File

@ -158,15 +158,10 @@ bool MMF::Open(const char* iName, uint32 iSize) {
case 'O': load_share = 7; break; case 'O': load_share = 7; break;
case 'Z': load_share = 8; break; case 'Z': load_share = 8; break;
case 'K': load_share = 9; break; case 'K': load_share = 9; break;
#ifdef CATCH_CRASH
default: default:
cerr<<"Failed to load shared memory segment="<<MMFname<<" ("<<MMFname[16]<<")"<<endl; cerr << "FATAL=" << (char)MMFname[16] << endl;
// malloc some memory here or something fancy return false;
return false; // and make this return true
break; break;
#else
default: cerr<<"FATAL="<<(char)MMFname[16]<<endl; return false; break;
#endif
} }
switch (load_share) { switch (load_share) {
// Item // Item

View File

@ -128,8 +128,6 @@ EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConne
RelayServer = true; RelayServer = true;
RelayCount = 0; RelayCount = 0;
RemoteID = iRemoteID; RemoteID = iRemoteID;
if (!RemoteID)
ThrowError("Error: TCPConnection: RemoteID == 0 on RelayLink constructor");
pOldFormat = false; pOldFormat = false;
ConnectionType = Incomming; ConnectionType = Incomming;
TCPMode = modePacket; TCPMode = modePacket;

View File

@ -214,11 +214,6 @@ bool MRMutex::TryReadLock() {
void MRMutex::UnReadLock() { void MRMutex::UnReadLock() {
MCounters.lock(); MCounters.lock();
rl--; rl--;
#ifdef _EQDEBUG
if (rl < 0) {
ThrowError("rl < 0 in MRMutex::UnReadLock()");
}
#endif
MCounters.unlock(); MCounters.unlock();
} }
@ -261,11 +256,6 @@ bool MRMutex::TryWriteLock() {
void MRMutex::UnWriteLock() { void MRMutex::UnWriteLock() {
MCounters.lock(); MCounters.lock();
wl--; wl--;
#ifdef _EQDEBUG
if (wl < 0) {
ThrowError("wl < 0 in MRMutex::UnWriteLock()");
}
#endif
MCounters.unlock(); MCounters.unlock();
} }

View File

@ -165,12 +165,6 @@ bool TCPConnection::GetSockName(char *host, uint16 *port)
} }
void TCPConnection::Free() { void TCPConnection::Free() {
if (ConnectionType == Outgoing) {
ThrowError("TCPConnection::Free() called on an Outgoing connection");
}
#if TCPN_DEBUG_Memory >= 5
cout << "Free on TCP# " << GetID() << endl;
#endif
Disconnect(); Disconnect();
pFree = true; pFree = true;
} }
@ -362,7 +356,6 @@ void TCPConnection::AsyncConnect(uint32 irIP, uint16 irPort) {
if (ConnectionType != Outgoing) { if (ConnectionType != Outgoing) {
// If this code runs, we got serious problems // If this code runs, we got serious problems
// Crash and burn. // Crash and burn.
ThrowError("TCPConnection::AsyncConnect() call on a Incomming connection object!");
return; return;
} }
if(!ConnectReady()) { if(!ConnectReady()) {
@ -423,7 +416,6 @@ bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) {
if (ConnectionType != Outgoing) { if (ConnectionType != Outgoing) {
// If this code runs, we got serious problems // If this code runs, we got serious problems
// Crash and burn. // Crash and burn.
ThrowError("TCPConnection::Connect() call on a Incomming connection object!");
return false; return false;
} }
MState.lock(); MState.lock();
@ -862,7 +854,6 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) {
ServerSendQueuePushFront(&data[status], size - status); ServerSendQueuePushFront(&data[status], size - status);
} }
else if (status > (signed)size) { else if (status > (signed)size) {
ThrowError("TCPConnection::SendData(): WTF! status > size");
return false; return false;
} }
// else if (status == size) {} // else if (status == size) {}
@ -905,7 +896,6 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
#endif #endif
if (tmp == 0) { if (tmp == 0) {
ThrowError("TCPConnectionLoop(): tmp = 0!");
THREAD_RETURN(NULL); THREAD_RETURN(NULL);
} }
TCPConnection* tcpc = (TCPConnection*) tmp; TCPConnection* tcpc = (TCPConnection*) tmp;

View File

@ -67,7 +67,6 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
#endif #endif
if (tmp == 0) { if (tmp == 0) {
// ThrowError("BaseTCPServerLoop(): tmp = 0!");
THREAD_RETURN(NULL); THREAD_RETURN(NULL);
} }
BaseTCPServer* tcps = (BaseTCPServer*) tmp; BaseTCPServer* tcps = (BaseTCPServer*) tmp;

View File

@ -55,15 +55,6 @@
#endif #endif
#endif #endif
#ifndef ThrowError
void CatchSignal(int);
#if defined(CATCH_CRASH) || defined(_EQDEBUG)
#define ThrowError(errstr) { cout << "Fatal error: " << errstr << " (" << __FILE__ << ", line " << __LINE__ << ")" << endl; LogFile->write(EQEMuLog::Error, "Thown Error: %s (%s:%i)", errstr, __FILE__, __LINE__); throw errstr; }
#else
#define ThrowError(errstr) { cout << "Fatal error: " << errstr << " (" << __FILE__ << ", line " << __LINE__ << ")" << endl; LogFile->write(EQEMuLog::Error, "Thown Error: %s (%s:%i)", errstr, __FILE__, __LINE__); CatchSignal(0); }
#endif
#endif
#ifdef _WINDOWS #ifdef _WINDOWS
// VS6 doesn't like the length of STL generated names: disabling // VS6 doesn't like the length of STL generated names: disabling
#pragma warning(disable:4786) #pragma warning(disable:4786)

View File

@ -0,0 +1,34 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET(shared_memory_sources
main.cpp
spells.cpp
)
SET(shared_memory_headers
spells.h
)
ADD_EXECUTABLE(shared_memory ${shared_memory_sources} ${shared_memory_headers})
TARGET_LINK_LIBRARIES(shared_memory Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE})
IF(MSVC)
SET_TARGET_PROPERTIES(shared_memory PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
TARGET_LINK_LIBRARIES(shared_memory "Ws2_32.lib")
ENDIF(MSVC)
IF(MINGW)
TARGET_LINK_LIBRARIES(shared_memory "WS2_32")
ENDIF(MINGW)
IF(UNIX)
TARGET_LINK_LIBRARIES(shared_memory "dl")
TARGET_LINK_LIBRARIES(shared_memory "z")
TARGET_LINK_LIBRARIES(shared_memory "m")
TARGET_LINK_LIBRARIES(shared_memory "rt")
TARGET_LINK_LIBRARIES(shared_memory "pthread")
ADD_DEFINITIONS(-fPIC)
ENDIF(UNIX)
SET(EXECUTABLE_OUTPUT_PATH ../Bin)

26
shared_memory/main.cpp Normal file
View File

@ -0,0 +1,26 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include "spells.h"
int main(int argc, char **argv) {
bool load_spells = true;
return 0;
}

17
shared_memory/spells.cpp Normal file
View File

@ -0,0 +1,17 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

17
shared_memory/spells.h Normal file
View File

@ -0,0 +1,17 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

View File

@ -66,6 +66,7 @@ extern QueryServConnection QSLink;
extern volatile bool RunLoops; extern volatile bool RunLoops;
ConsoleList console_list; ConsoleList console_list;
void CatchSignal(int sig_num);
Console::Console(EmuTCPConnection* itcpc) Console::Console(EmuTCPConnection* itcpc)
: WorldTCPConnection(), : WorldTCPConnection(),

View File

@ -28,8 +28,7 @@
extern uint32 numzones; extern uint32 numzones;
extern bool holdzones; extern bool holdzones;
extern ConsoleList console_list; extern ConsoleList console_list;
void CatchSignal(int sig_num);
ZSList::ZSList() ZSList::ZSList()
{ {

View File

@ -46,6 +46,7 @@ extern volatile bool RunLoops;
extern AdventureManager adventure_manager; extern AdventureManager adventure_manager;
extern UCSConnection UCSLink; extern UCSConnection UCSLink;
extern QueryServConnection QSLink; extern QueryServConnection QSLink;
void CatchSignal(int sig_num);
ZoneServer::ZoneServer(EmuTCPConnection* itcpc) ZoneServer::ZoneServer(EmuTCPConnection* itcpc)
: WorldTCPConnection(), tcpc(itcpc), ls_zboot(5000) { : WorldTCPConnection(), tcpc(itcpc), ls_zboot(5000) {

View File

@ -38,9 +38,6 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net)
#include "../common/logsys.h" #include "../common/logsys.h"
#include "zonedb.h" #include "zonedb.h"
#include "StringIDs.h" #include "StringIDs.h"
#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat)
extern SPDat_Spell_Struct spells[SPDAT_RECORDS];
#endif
//static data arrays, really not big enough to warrant shared mem. //static data arrays, really not big enough to warrant shared mem.
AA_DBAction AA_Actions[aaHighestID][MAX_AA_ACTION_RANKS]; //[aaid][rank] AA_DBAction AA_Actions[aaHighestID][MAX_AA_ACTION_RANKS]; //[aaid][rank]

View File

@ -36,10 +36,6 @@ using namespace std;
#include "QuestParserCollection.h" #include "QuestParserCollection.h"
#include "watermap.h" #include "watermap.h"
#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat)
extern SPDat_Spell_Struct spells[SPDAT_RECORDS];
#endif
extern EntityList entity_list; extern EntityList entity_list;
extern Zone *zone; extern Zone *zone;

View File

@ -52,10 +52,6 @@ extern WorldServer worldserver;
#endif #endif
extern EntityList entity_list; extern EntityList entity_list;
#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat)
extern SPDat_Spell_Struct spells[SPDAT_RECORDS];
#endif
extern Zone* zone; extern Zone* zone;
bool Mob::AttackAnimation(SkillType &skillinuse, int Hand, const ItemInst* weapon) bool Mob::AttackAnimation(SkillType &skillinuse, int Hand, const ItemInst* weapon)

View File

@ -76,9 +76,6 @@ extern EntityList entity_list;
extern Zone* zone; extern Zone* zone;
extern volatile bool ZoneLoaded; extern volatile bool ZoneLoaded;
extern WorldServer worldserver; extern WorldServer worldserver;
#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat)
extern SPDat_Spell_Struct spells[SPDAT_RECORDS];
#endif
extern uint32 numclients; extern uint32 numclients;
extern PetitionList petition_list; extern PetitionList petition_list;
bool commandlogged; bool commandlogged;

View File

@ -79,9 +79,6 @@ using namespace std;
extern Zone* zone; extern Zone* zone;
extern volatile bool ZoneLoaded; extern volatile bool ZoneLoaded;
extern WorldServer worldserver; extern WorldServer worldserver;
#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat)
extern SPDat_Spell_Struct spells[SPDAT_RECORDS];
#endif
extern bool spells_loaded; extern bool spells_loaded;
extern PetitionList petition_list; extern PetitionList petition_list;
extern EntityList entity_list; extern EntityList entity_list;

View File

@ -73,9 +73,6 @@ using namespace std;
extern Zone* zone; extern Zone* zone;
extern volatile bool ZoneLoaded; extern volatile bool ZoneLoaded;
extern WorldServer worldserver; extern WorldServer worldserver;
#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat)
extern SPDat_Spell_Struct spells[SPDAT_RECORDS];
#endif
extern bool spells_loaded; extern bool spells_loaded;
extern PetitionList petition_list; extern PetitionList petition_list;
extern EntityList entity_list; extern EntityList entity_list;

View File

@ -67,6 +67,7 @@
extern WorldServer worldserver; extern WorldServer worldserver;
extern bool spells_loaded; extern bool spells_loaded;
extern TaskManager *taskmanager; extern TaskManager *taskmanager;
void CatchSignal(int sig_num);
#include "QuestParserCollection.h" #include "QuestParserCollection.h"

View File

@ -96,9 +96,9 @@ public:
//Access to perl variables //Access to perl variables
//all varnames here should be of the form package::name //all varnames here should be of the form package::name
//returns the contents of the perl variable named in varname as a c int //returns the contents of the perl variable named in varname as a c int
int geti(const char * varname) { return SvIV(my_get_sv(varname)); }; int geti(const char * varname) { return static_cast<int>(SvIV(my_get_sv(varname))); };
//returns the contents of the perl variable named in varname as a c float //returns the contents of the perl variable named in varname as a c float
float getd(const char * varname) { return SvNV(my_get_sv(varname));}; float getd(const char * varname) { return static_cast<float>(SvNV(my_get_sv(varname)));};
//returns the contents of the perl variable named in varname as a string //returns the contents of the perl variable named in varname as a string
std::string getstr(const char * varname) { std::string getstr(const char * varname) {
SV * temp = my_get_sv(varname); SV * temp = my_get_sv(varname);
@ -133,7 +133,7 @@ public:
// Iterate through key-value pairs, storing them in hash // Iterate through key-value pairs, storing them in hash
for (it = vals.begin(); it != vals.end(); it++) for (it = vals.begin(); it != vals.end(); it++)
{ {
int keylen = it->first.length(); int keylen = static_cast<int>(it->first.length());
SV *val = newSVpv(it->second.c_str(), it->second.length()); SV *val = newSVpv(it->second.c_str(), it->second.length());

View File

@ -62,9 +62,6 @@ extern volatile bool ZoneLoaded;
extern WorldServer worldserver; extern WorldServer worldserver;
extern NetConnection net; extern NetConnection net;
extern uint32 numclients; extern uint32 numclients;
#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat)
extern SPDat_Spell_Struct spells[SPDAT_RECORDS];
#endif
extern bool spells_loaded; extern bool spells_loaded;
extern PetitionList petition_list; extern PetitionList petition_list;
extern DBAsync *dbasync; extern DBAsync *dbasync;
@ -3259,12 +3256,6 @@ BulkZoneSpawnPacket::BulkZoneSpawnPacket(Client* iSendTo, uint32 iMaxSpawnsPerPa
data = 0; data = 0;
pSendTo = iSendTo; pSendTo = iSendTo;
pMaxSpawnsPerPacket = iMaxSpawnsPerPacket; pMaxSpawnsPerPacket = iMaxSpawnsPerPacket;
#ifdef _EQDEBUG
if (pMaxSpawnsPerPacket <= 0 || pMaxSpawnsPerPacket > MAX_SPAWNS_PER_PACKET) {
// ok, this *cant* be right =p
ThrowError("Error in BulkZoneSpawnPacket::BulkZoneSpawnPacket(): pMaxSpawnsPerPacket outside range that makes sense");
}
#endif
} }
BulkZoneSpawnPacket::~BulkZoneSpawnPacket() { BulkZoneSpawnPacket::~BulkZoneSpawnPacket() {

View File

@ -27,9 +27,6 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
#include <limits.h> #include <limits.h>
extern EntityList entity_list; extern EntityList entity_list;
#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat)
extern SPDat_Spell_Struct spells[SPDAT_RECORDS];
#endif
extern bool spells_loaded; extern bool spells_loaded;
extern Zone* zone; extern Zone* zone;

View File

@ -109,9 +109,6 @@ NetConnection net;
EntityList entity_list; EntityList entity_list;
WorldServer worldserver; WorldServer worldserver;
uint32 numclients = 0; uint32 numclients = 0;
#ifdef CATCH_CRASH
uint8 error = 0;
#endif
char errorname[32]; char errorname[32];
uint16 adverrornum = 0; uint16 adverrornum = 0;
extern Zone* zone; extern Zone* zone;
@ -126,23 +123,13 @@ QuestParserCollection *parse = 0;
bool zoneprocess; bool zoneprocess;
#if defined(NEW_LoadSPDat) || defined(DB_LoadSPDat)
// For NewLoadSPDat function
const SPDat_Spell_Struct* spells; const SPDat_Spell_Struct* spells;
SPDat_Spell_Struct* spells_delete; SPDat_Spell_Struct* spells_delete;
int32 GetMaxSpellID(); int32 GetMaxSpellID();
void LoadSPDat(); void LoadSPDat();
bool FileLoadSPDat(SPDat_Spell_Struct* sp, int32 iMaxSpellID); bool FileLoadSPDat(SPDat_Spell_Struct* sp, int32 iMaxSpellID);
int32 SPDAT_RECORDS = -1; int32 SPDAT_RECORDS = -1;
#else
#define SPDat_Location "spdat.eff"
SPDat_Spell_Struct spells[SPDAT_RECORDS];
void LoadSPDat(SPDat_Spell_Struct** SpellsPointer = 0);
#endif
#ifdef _WINDOWS #ifdef _WINDOWS
#include <process.h> #include <process.h>
@ -396,18 +383,8 @@ int main(int argc, char** argv) {
Timer::SetCurrentTime(); Timer::SetCurrentTime();
//process stuff from world //process stuff from world
#ifdef CATCH_CRASH
try{
#endif
worldserver.Process(); worldserver.Process();
#ifdef CATCH_CRASH
}
catch(...){
error = 1;
worldserver.Disconnect();
worldwasconnected = false;
}
#endif
if (!eqsf.IsOpen() && Config->ZonePort!=0) { if (!eqsf.IsOpen() && Config->ZonePort!=0) {
_log(ZONE__INIT, "Starting EQ Network server on port %d",Config->ZonePort); _log(ZONE__INIT, "Starting EQ Network server on port %d",Config->ZonePort);
if (!eqsf.Open(Config->ZonePort)) { if (!eqsf.Open(Config->ZonePort)) {
@ -457,9 +434,6 @@ int main(int argc, char** argv) {
if (ZoneLoaded && temp_timer.Check()) { if (ZoneLoaded && temp_timer.Check()) {
{ {
uint8 error2 = 4; uint8 error2 = 4;
#ifdef CATCH_CRASH
try{
#endif
if(net.group_timer.Enabled() && net.group_timer.Check()) if(net.group_timer.Enabled() && net.group_timer.Check())
entity_list.GroupProcess(); entity_list.GroupProcess();
error2 = 99; error2 = 99;
@ -479,81 +453,35 @@ int main(int argc, char** argv) {
error2 = 96; error2 = 96;
entity_list.Process(); entity_list.Process();
error2 = 95; error2 = 95;
#ifdef CATCH_CRASH
try{
entity_list.MobProcess(); entity_list.MobProcess();
}
catch(...){
printf("Catching Mob Crash...\n");
}
#else
entity_list.MobProcess();
#endif
error2 = 94; error2 = 94;
entity_list.BeaconProcess(); entity_list.BeaconProcess();
#ifdef CATCH_CRASH
}
catch(...){
error=error2;
}
try{
#endif
if (zone) { if (zone) {
zoneprocess= zone->Process(); zoneprocess= zone->Process();
if (!zoneprocess) { if (!zoneprocess) {
Zone::Shutdown(); Zone::Shutdown();
} }
} }
#ifdef CATCH_CRASH
}
catch(...){
error = 2;
}
try{
#endif
if(quest_timers.Check()) if(quest_timers.Check())
quest_manager.Process(); quest_manager.Process();
#ifdef CATCH_CRASH
}
catch(...){
error = 77777;
}
#endif
} }
} }
DBAsyncWork* dbaw = 0; DBAsyncWork* dbaw = 0;
while ((dbaw = MTdbafq.Pop())) { while ((dbaw = MTdbafq.Pop())) {
DispatchFinishedDBAsync(dbaw); DispatchFinishedDBAsync(dbaw);
} }
if (InterserverTimer.Check() if (InterserverTimer.Check()) {
#ifdef CATCH_CRASH
&& !error
#endif
) {
#ifdef CATCH_CRASH
try{
#endif
InterserverTimer.Start(); InterserverTimer.Start();
database.ping(); database.ping();
AsyncLoadVariables(dbasync, &database); AsyncLoadVariables(dbasync, &database);
// NPC::GetAILevel(true);
entity_list.UpdateWho(); entity_list.UpdateWho();
if (worldserver.TryReconnect() && (!worldserver.Connected())) if (worldserver.TryReconnect() && (!worldserver.Connected()))
worldserver.AsyncConnect(); worldserver.AsyncConnect();
#ifdef CATCH_CRASH
} }
catch(...)
{
error = 16;
RunLoops = false;
}
#endif
}
#ifdef CATCH_CRASH
if (error){
RunLoops = false;
}
#endif
#if defined(_EQDEBUG) && defined(DEBUG_PC) #if defined(_EQDEBUG) && defined(DEBUG_PC)
QueryPerformanceCounter(&tmp3); QueryPerformanceCounter(&tmp3);
mainloop_time += tmp3.QuadPart - tmp2.QuadPart; mainloop_time += tmp3.QuadPart - tmp2.QuadPart;
@ -588,38 +516,14 @@ int main(int argc, char** argv) {
safe_delete(pxs); safe_delete(pxs);
safe_delete(ps); safe_delete(ps);
#ifdef CATCH_CRASH
if (error)
FilePrint("eqemudebug.log",true,true,"Zone %i crashed. Errorcode: %i/%i. Current zone loaded:%s. Current clients:%i. Caused by: %s",Config->ZonePort, error,adverrornum, zone->GetShortName(), numclients,errorname);
try{
entity_list.Message(0, 15, "ZONEWIDE_MESSAGE: This zone caused a fatal error and will shut down now. Your character will be restored to the last saved status. We are sorry for any inconvenience!");
}
catch(...){}
if (error){
#ifdef _WINDOWS
ExitProcess(error);
#else
entity_list.Clear(); entity_list.Clear();
safe_delete(zone); if (zone != 0)
#endif
}
#endif
entity_list.Clear();
if (zone != 0
#ifdef CATCH_CRASH
& !error
#endif
)
Zone::Shutdown(true); Zone::Shutdown(true);
//Fix for Linux world server problem. //Fix for Linux world server problem.
eqsf.Close(); eqsf.Close();
worldserver.Disconnect(); worldserver.Disconnect();
dbasync->CommitWrites(); dbasync->CommitWrites();
dbasync->StopThread(); dbasync->StopThread();
#if defined(NEW_LoadSPDat) || defined(DB_LoadSPDat)
safe_delete(spells_delete);
#endif
safe_delete(taskmanager); safe_delete(taskmanager);
command_deinit(); command_deinit();
@ -726,73 +630,7 @@ bool chrcmpI(const char* a, const char* b) {
return true; return true;
} }
#if defined(NEW_LoadSPDat) || defined(DB_LoadSPDat)
int32 GetMaxSpellID() { int32 GetMaxSpellID() {
#ifdef NEW_LoadSPDat
int tempid=0, oldid=-1;
char spell_line_start[2048];
char* spell_line = spell_line_start;
char token[64]="";
char seps[] = "^";
const char *spells_file=ZoneConfig::get()->SpellsFile.c_str();
//ifstream in(spells_file);
/*struct stat s;
if(stat(spells_file, &s) != 0) {
_log(SPELLS__LOAD_ERR, "File '%s' not found (stat failed), spell loading FAILED!", spells_file);
return(-1);
}
*/
FILE *sf = fopen(spells_file, "r");
if(sf == NULL) {
_log(SPELLS__LOAD_ERR, "File '%s' not found, spell loading FAILED!", spells_file);
return -1;
}
fgets(spell_line, sizeof(spell_line_start), sf);
while(!feof(sf)) {
strcpy(token,strtok(spell_line, seps));
if(token!=NULL);
{
tempid = atoi(token);
if(tempid>oldid)
oldid = tempid;
else
break;
}
fgets(spell_line, sizeof(spell_line_start), sf);
}
fclose(sf);
/*ifstream in(spells_file);
if(!in) {
_log(SPELLS__LOAD_ERR, "File '%s' not found, spell loading FAILED!", spells_file);
return -1;
}
in.getline(spell_line, sizeof(spell_line_start));
while(strlen(spell_line)>1)
{
strcpy(token,strtok(spell_line, seps));
if(token!=NULL);
{
tempid = atoi(token);
if(tempid>oldid)
oldid = tempid;
else
break;
}
in.getline(spell_line, sizeof(spell_line_start));
}*/
return oldid;
#else // defined(DB_LoadSPDat)
//load from DB //load from DB
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
@ -813,8 +651,8 @@ int32 GetMaxSpellID() {
ret = -1; ret = -1;
} }
return ret; return ret;
#endif
} }
#ifdef SHAREMEM #ifdef SHAREMEM
extern "C" bool extFileLoadSPDat(void* sp, int32 iMaxSpellID) { return FileLoadSPDat((SPDat_Spell_Struct*) sp, iMaxSpellID); } extern "C" bool extFileLoadSPDat(void* sp, int32 iMaxSpellID) { return FileLoadSPDat((SPDat_Spell_Struct*) sp, iMaxSpellID); }
#endif #endif
@ -860,242 +698,7 @@ void LoadSPDat() {
} }
bool FileLoadSPDat(SPDat_Spell_Struct* sp, int32 iMaxSpellID) { bool FileLoadSPDat(SPDat_Spell_Struct* sp, int32 iMaxSpellID) {
#ifdef NEW_LoadSPDat
int tempid=0;
uint16 counter=0;
char spell_line[2048];
const char *spells_file=ZoneConfig::get()->SpellsFile.c_str();
_log(SPELLS__LOAD,"FileLoadSPDat() Loading spells from %s", spells_file);
FILE *sf = fopen(spells_file, "r");
if(sf == NULL) {
_log(SPELLS__LOAD_ERR, "File '%s' not found, spell loading FAILED!", spells_file);
return false;
}
/* ifstream in(spells_file);
if(!in) {
_log(SPELLS__LOAD_ERR, "File '%s' not found, spell loading FAILED!", spells_file);
return false;
}
*/
if (iMaxSpellID < 0) {
_log(SPELLS__LOAD_ERR,"FileLoadSPDat() Loading spells FAILED! iMaxSpellID:%i < 0", iMaxSpellID);
return false;
}
/*
This is hanging on freebsd for me, not sure why...
//#if EQDEBUG >= 1
else {
_log(SPELLS__LOAD,"FileLoadSPDat() Highest spell ID:%i", iMaxSpellID);
}
//#endif
*/
/* in.close();
in.open(spells_file);
if(!in) {
_log(SPELLS__LOAD_ERR, "File '%s' not found, spell loading FAILED!", spells_file);
return false;
}
while(!in.eof()) {
in.getline(spell_line, sizeof(spell_line));
Seperator sep(spell_line, '^', 200, 100, false, 0, 0, false);
if(spell_line[0]=='\0')
break;
tempid = atoi(sep.arg[0]);
if (tempid > iMaxSpellID) {
_log(SPELLS__LOAD_ERR, "FATAL FileLoadSPDat() tempid:%i >= iMaxSpellID:%i", tempid, iMaxSpellID);
return false;
}
*/
while(!feof(sf)) {
if(fgets(spell_line, sizeof(spell_line), sf) == NULL)
break;
if(spell_line[0]=='\0')
continue;
Seperator sep(spell_line, '^', 220, 100, false, 0, 0, false);
tempid = atoi(sep.arg[0]);
if (tempid > iMaxSpellID) {
_log(SPELLS__LOAD_ERR, "FATAL FileLoadSPDat() tempid:%i >= iMaxSpellID:%i", tempid, iMaxSpellID);
return false;
}
counter++;
strcpy(sp[tempid].name, sep.arg[1]);
strcpy(sp[tempid].player_1, sep.arg[2]);
strcpy(sp[tempid].teleport_zone, sep.arg[3]);
strcpy(sp[tempid].you_cast, sep.arg[4]);
strcpy(sp[tempid].other_casts, sep.arg[5]);
strcpy(sp[tempid].cast_on_you, sep.arg[6]);
strcpy(sp[tempid].cast_on_other, sep.arg[7]);
strcpy(sp[tempid].spell_fades, sep.arg[8]);
sp[tempid].range=atof(sep.arg[9]);
sp[tempid].aoerange=atof(sep.arg[10]);
sp[tempid].pushback=atof(sep.arg[11]);
sp[tempid].pushup=atof(sep.arg[12]);
sp[tempid].cast_time=atoi(sep.arg[13]);
sp[tempid].recovery_time=atoi(sep.arg[14]);
sp[tempid].recast_time=atoi(sep.arg[15]);
sp[tempid].buffdurationformula=atoi(sep.arg[16]);
sp[tempid].buffduration=atoi(sep.arg[17]);
sp[tempid].AEDuration=atoi(sep.arg[18]);
sp[tempid].mana=atoi(sep.arg[19]);
int y=0;
for(y=0; y< EFFECT_COUNT;y++)
sp[tempid].base[y]=atoi(sep.arg[20+y]);
for(y=0; y < EFFECT_COUNT; y++)
sp[tempid].base2[y]=atoi(sep.arg[32+y]);
for(y=0; y< EFFECT_COUNT;y++)
sp[tempid].max[y]=atoi(sep.arg[44+y]);
sp[tempid].icon=atoi(sep.arg[56]);
sp[tempid].memicon=atoi(sep.arg[57]);
for(y=0; y< 4;y++)
sp[tempid].components[y]=atoi(sep.arg[58+y]);
for(y=0; y< 4;y++)
sp[tempid].component_counts[y]=atoi(sep.arg[62+y]);
for(y=0; y< 4;y++)
sp[tempid].NoexpendReagent[y]=atoi(sep.arg[66+y]);
for(y=0; y< EFFECT_COUNT;y++)
sp[tempid].formula[y]=atoi(sep.arg[70+y]);
sp[tempid].LightType=atoi(sep.arg[82]);
sp[tempid].goodEffect=atoi(sep.arg[83]);
sp[tempid].Activated=atoi(sep.arg[84]);
sp[tempid].resisttype=atoi(sep.arg[85]);
for(y=0; y< 12;y++)
sp[tempid].effectid[y]=atoi(sep.arg[86+y]);
sp[tempid].targettype = (SpellTargetType) atoi(sep.arg[98]);
sp[tempid].basediff=atoi(sep.arg[99]);
int tmp_skill = atoi(sep.arg[100]);;
if(tmp_skill < 0 || tmp_skill > HIGHEST_SKILL)
sp[tempid].skill = BEGGING; /* not much better we can do. */
else
sp[tempid].skill = (SkillType) tmp_skill;
sp[tempid].zonetype=atoi(sep.arg[101]);
sp[tempid].EnvironmentType=atoi(sep.arg[102]);
sp[tempid].TimeOfDay=atoi(sep.arg[103]);
for(y=0; y < PLAYER_CLASS_COUNT;y++)
sp[tempid].classes[y]=atoi(sep.arg[104+y]);
sp[tempid].CastingAnim=atoi(sep.arg[120]);
sp[tempid].TargetAnim=atoi(sep.arg[121]);
sp[tempid].TravelType=atoi(sep.arg[122]);
sp[tempid].SpellAffectIndex=atoi(sep.arg[123]);
sp[tempid].disallow_sit = atoi(sep.arg[124]);
sp[tempid].spacing125=atoi(sep.arg[125]);
for (y = 0; y < 16; y++)
sp[tempid].deities[y]=atoi(sep.arg[126+y]);
for (y = 0; y < 2; y++)
sp[tempid].spacing142[y]=atoi(sep.arg[142+y]);
sp[tempid].new_icon=atoi(sep.arg[144]);
sp[tempid].spellanim=atoi(sep.arg[145]);
sp[tempid].uninterruptable=atoi(sep.arg[146]);
sp[tempid].ResistDiff=atoi(sep.arg[147]);
sp[tempid].dot_stacking_exempt=atoi(sep.arg[148]);
sp[tempid].deletable=atoi(sep.arg[149]);
sp[tempid].RecourseLink = atoi(sep.arg[150]);
for(y = 0; y < 3;y++)
sp[tempid].spacing151[y]=atoi(sep.arg[151+y]);
sp[tempid].short_buff_box = atoi(sep.arg[154]);
sp[tempid].descnum = atoi(sep.arg[155]);
sp[tempid].typedescnum = atoi(sep.arg[156]);
sp[tempid].effectdescnum = atoi(sep.arg[157]);
for(y = 0; y < 4;y++)
sp[tempid].spacing158[y]=atoi(sep.arg[158+y]);
sp[tempid].bonushate=atoi(sep.arg[162]);
for(y = 0; y < 3;y++)
sp[tempid].spacing163[y]=atoi(sep.arg[163+y]);
sp[tempid].EndurCost=atoi(sep.arg[166]);
sp[tempid].EndurTimerIndex=atoi(sep.arg[167]);
sp[tempid].IsDisciplineBuff=atoi(sep.arg[168]);
for(y = 0; y < 4;y++)
sp[tempid].spacing169[y]=atoi(sep.arg[169+y]);
sp[tempid].HateAdded=atoi(sep.arg[173]);
sp[tempid].EndurUpkeep=atoi(sep.arg[174]);
sp[tempid].spacing175=atoi(sep.arg[175]);
sp[tempid].numhits = atoi(sep.arg[176]);
sp[tempid].pvpresistbase=atoi(sep.arg[177]);
sp[tempid].pvpresistcalc=atoi(sep.arg[178]);
sp[tempid].pvpresistcap=atoi(sep.arg[179]);
sp[tempid].spell_category=atoi(sep.arg[180]);
for(y = 0; y < 4;y++)
sp[tempid].spacing181[y]=atoi(sep.arg[181+y]);
sp[tempid].can_mgb=atoi(sep.arg[185]);
sp[tempid].dispel_flag = atoi(sep.arg[186]);
sp[tempid].MinResist = atoi(sep.arg[189]);
sp[tempid].MaxResist = atoi(sep.arg[190]);
sp[tempid].viral_targets = atoi(sep.arg[191]);
sp[tempid].viral_timer = atoi(sep.arg[192]);
sp[tempid].NimbusEffect = atoi(sep.arg[193]);
sp[tempid].directional_start = (float)atoi(sep.arg[194]);
sp[tempid].directional_end = (float)atoi(sep.arg[195]);
sp[tempid].spellgroup=atoi(row[207]);
sp[tempid].field209=atoi(row[209]);
sp[tempid].CastRestriction = atoi(sep.arg[211]);
sp[tempid].AllowRest = atoi(sep.arg[212]);
// May crash zone
/*
sp[tempid].nodispell=atoi(row[186]);
sp[tempid].npc_category=atoi(row[187]);
sp[tempid].npc_usefulness=atoi(row[188]);
for (y = 0; y < 18; y++)
sp[tempid].spacing189[y]=atoi(row[189+y]);
sp[tempid].spellgroup=atoi(row[207]);
for (y = 0; y < 18; y++)
sp[tempid].spacing208[y]=atoi(row[208+y]);
*/
sp[tempid].DamageShieldType = 0;
}
_log(SPELLS__LOAD, "FileLoadSPDat() spells loaded: %i", counter);
//in.close();
fclose(sf);
// Now fill in the DamageShieldType from the damageshieldtypes table, if it exists.
//
database.DBLoadDamageShieldTypes(sp, iMaxSpellID);
return true;
#else // defined(DB_LoadSPDat)
//load from db //load from db
char errbuf[MYSQL_ERRMSG_SIZE]; char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; char *query = 0;
MYSQL_RES *result; MYSQL_RES *result;
@ -1137,10 +740,10 @@ This is hanging on freebsd for me, not sure why...
strn0cpy(sp[tempid].spell_fades, row[8], sizeof(sp[tempid].spell_fades)); strn0cpy(sp[tempid].spell_fades, row[8], sizeof(sp[tempid].spell_fades));
// Numeric fields (everything else) // Numeric fields (everything else)
sp[tempid].range=atof(row[9]); sp[tempid].range=static_cast<float>(atof(row[9]));
sp[tempid].aoerange=atof(row[10]); sp[tempid].aoerange=static_cast<float>(atof(row[10]));
sp[tempid].pushback=atof(row[11]); sp[tempid].pushback=static_cast<float>(atof(row[11]));
sp[tempid].pushup=atof(row[12]); sp[tempid].pushup=static_cast<float>(atof(row[12]));
sp[tempid].cast_time=atoi(row[13]); sp[tempid].cast_time=atoi(row[13]);
sp[tempid].recovery_time=atoi(row[14]); sp[tempid].recovery_time=atoi(row[14]);
sp[tempid].recast_time=atoi(row[15]); sp[tempid].recast_time=atoi(row[15]);
@ -1264,22 +867,7 @@ This is hanging on freebsd for me, not sure why...
sp[tempid].spellgroup=atoi(row[207]); sp[tempid].spellgroup=atoi(row[207]);
sp[tempid].field209=atoi(row[209]); sp[tempid].field209=atoi(row[209]);
sp[tempid].CastRestriction = atoi(row[211]); sp[tempid].CastRestriction = atoi(row[211]);
sp[tempid].AllowRest = atoi(row[212]); sp[tempid].AllowRest = atoi(row[212]) != 0;
// May crash zone
/*
sp[tempid].nodispell=atoi(row[186]);
sp[tempid].npc_category=atoi(row[187]);
sp[tempid].npc_usefulness=atoi(row[188]);
for (y = 0; y < 18; y++)
sp[tempid].spacing189[y]=atoi(row[189+y]);
sp[tempid].spellgroup=atoi(row[207]);
for (y = 0; y < 18; y++)
sp[tempid].spacing208[y]=atoi(row[208+y]);
*/
sp[tempid].DamageShieldType = 0; sp[tempid].DamageShieldType = 0;
} }
@ -1295,12 +883,8 @@ This is hanging on freebsd for me, not sure why...
safe_delete_array(query); safe_delete_array(query);
return false; return false;
} }
#endif
} }
#endif //from just above GetMaxSpellID(): #if defined(NEW_LoadSPDat) || defined(DB_LoadSPDat)
void UpdateWindowTitle(char* iNewTitle) { void UpdateWindowTitle(char* iNewTitle) {
#ifdef _WINDOWS #ifdef _WINDOWS
char tmp[500]; char tmp[500];

View File

@ -51,9 +51,6 @@ using namespace std;
extern Zone* zone; extern Zone* zone;
extern volatile bool ZoneLoaded; extern volatile bool ZoneLoaded;
extern EntityList entity_list; extern EntityList entity_list;
#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat)
extern SPDat_Spell_Struct spells[SPDAT_RECORDS];
#endif
#include "QuestParserCollection.h" #include "QuestParserCollection.h"

View File

@ -87,9 +87,6 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
#include <stdlib.h> #include <stdlib.h>
#include "../common/unix.h" #include "../common/unix.h"
#endif #endif
#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat)
extern SPDat_Spell_Struct spells[SPDAT_RECORDS];
#endif
extern bool spells_loaded; extern bool spells_loaded;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -33,15 +33,6 @@
#define SPELL_NPC_HARM_TOUCH 929 #define SPELL_NPC_HARM_TOUCH 929
//#define SPDAT_SIZE 1824000
/*
solar: look at your spells_en.txt and find the id of the last spell.
this number has to be 1 more than that. if it's higher, your zone will
NOT start up. gonna autodetect this later..
*/
//#define NEW_LoadSPDat
#define DB_LoadSPDat //load from DB vs spells_us.txt. for now, we're piggybacking NEW_LoadSPDat, so it will take precedence
#define EFFECT_COUNT 12 #define EFFECT_COUNT 12
#define MAX_SPELL_TRIGGER 12 // One for each slot(only 6 for AA since AA use 2) #define MAX_SPELL_TRIGGER 12 // One for each slot(only 6 for AA since AA use 2)
#define MAX_RESISTABLE_EFFECTS 12 // Number of effects that are typcially checked agianst resists. #define MAX_RESISTABLE_EFFECTS 12 // Number of effects that are typcially checked agianst resists.
@ -722,12 +713,8 @@ struct SPDat_Spell_Struct
uint8 DamageShieldType; // This field does not exist in spells_us.txt uint8 DamageShieldType; // This field does not exist in spells_us.txt
}; };
#if defined(NEW_LoadSPDat) || defined(DB_LoadSPDat)
extern const SPDat_Spell_Struct* spells; extern const SPDat_Spell_Struct* spells;
extern int32 SPDAT_RECORDS; extern int32 SPDAT_RECORDS;
#else
#define SPDAT_RECORDS 3602
#endif
bool IsTargetableAESpell(uint16 spell_id); bool IsTargetableAESpell(uint16 spell_id);
bool IsSacrificeSpell(uint16 spell_id); bool IsSacrificeSpell(uint16 spell_id);

View File

@ -38,9 +38,6 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemu.org)
extern Zone* zone; extern Zone* zone;
extern volatile bool ZoneLoaded; extern volatile bool ZoneLoaded;
#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat)
extern SPDat_Spell_Struct spells[SPDAT_RECORDS];
#endif
extern bool spells_loaded; extern bool spells_loaded;
extern WorldServer worldserver; extern WorldServer worldserver;
//uchar blah[]={0x0D,0x00,0x00,0x00,0x01,0x00,0x00,0x00}; //uchar blah[]={0x0D,0x00,0x00,0x00,0x01,0x00,0x00,0x00};

View File

@ -99,9 +99,6 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
extern Zone* zone; extern Zone* zone;
extern volatile bool ZoneLoaded; extern volatile bool ZoneLoaded;
#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat)
extern SPDat_Spell_Struct spells[SPDAT_RECORDS];
#endif
extern bool spells_loaded; extern bool spells_loaded;
extern WorldServer worldserver; extern WorldServer worldserver;
uchar blah[]={0x0D,0x00,0x00,0x00,0x01,0x00,0x00,0x00}; uchar blah[]={0x0D,0x00,0x00,0x00,0x01,0x00,0x00,0x00};