From 0d16361a4001ac3252702abacc17ac144987be6c Mon Sep 17 00:00:00 2001 From: KimLS Date: Mon, 18 Feb 2013 19:00:07 -0800 Subject: [PATCH] Working on shared memory stuff - removed some stuff dealing with older code and loading spells from the non-database --- CMakeLists.txt | 1 + EMuShareMem/MMF.cpp | 13 +- common/EmuTCPConnection.cpp | 2 - common/Mutex.cpp | 10 - common/TCPConnection.cpp | 10 - common/TCPServer.cpp | 1 - common/debug.h | 9 - shared_memory/CMakeLists.txt | 34 +++ shared_memory/main.cpp | 26 ++ shared_memory/spells.cpp | 17 ++ shared_memory/spells.h | 17 ++ world/console.cpp | 1 + world/zonelist.cpp | 3 +- world/zoneserver.cpp | 1 + zone/AA.cpp | 3 - zone/MobAI.cpp | 4 - zone/attack.cpp | 4 - zone/client.cpp | 3 - zone/client_packet.cpp | 3 - zone/client_process.cpp | 3 - zone/command.cpp | 1 + zone/embperl.h | 6 +- zone/entity.cpp | 9 - zone/mob.cpp | 3 - zone/net.cpp | 524 ++++------------------------------- zone/npc.cpp | 3 - zone/spdat.cpp | 3 - zone/spdat.h | 17 +- zone/spell_effects.cpp | 3 - zone/spells.cpp | 3 - 30 files changed, 162 insertions(+), 575 deletions(-) create mode 100644 shared_memory/CMakeLists.txt create mode 100644 shared_memory/main.cpp create mode 100644 shared_memory/spells.cpp create mode 100644 shared_memory/spells.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 4267e63be..ac3cc41f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) IF(EQEMU_BUILD_SERVER) ADD_SUBDIRECTORY(EMuShareMem) + ADD_SUBDIRECTORY(shared_memory) ADD_SUBDIRECTORY(world) ADD_SUBDIRECTORY(zone) ADD_SUBDIRECTORY(ucs) diff --git a/EMuShareMem/MMF.cpp b/EMuShareMem/MMF.cpp index 1975604f0..3070a260b 100644 --- a/EMuShareMem/MMF.cpp +++ b/EMuShareMem/MMF.cpp @@ -158,15 +158,10 @@ bool MMF::Open(const char* iName, uint32 iSize) { case 'O': load_share = 7; break; case 'Z': load_share = 8; break; case 'K': load_share = 9; break; -#ifdef CATCH_CRASH - default: - cerr<<"Failed to load shared memory segment="<= 5 - cout << "Free on TCP# " << GetID() << endl; -#endif Disconnect(); pFree = true; } @@ -362,7 +356,6 @@ void TCPConnection::AsyncConnect(uint32 irIP, uint16 irPort) { if (ConnectionType != Outgoing) { // If this code runs, we got serious problems // Crash and burn. - ThrowError("TCPConnection::AsyncConnect() call on a Incomming connection object!"); return; } if(!ConnectReady()) { @@ -423,7 +416,6 @@ bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) { if (ConnectionType != Outgoing) { // If this code runs, we got serious problems // Crash and burn. - ThrowError("TCPConnection::Connect() call on a Incomming connection object!"); return false; } MState.lock(); @@ -862,7 +854,6 @@ bool TCPConnection::SendData(bool &sent_something, char* errbuf) { ServerSendQueuePushFront(&data[status], size - status); } else if (status > (signed)size) { - ThrowError("TCPConnection::SendData(): WTF! status > size"); return false; } // else if (status == size) {} @@ -905,7 +896,6 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) { SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); #endif if (tmp == 0) { - ThrowError("TCPConnectionLoop(): tmp = 0!"); THREAD_RETURN(NULL); } TCPConnection* tcpc = (TCPConnection*) tmp; diff --git a/common/TCPServer.cpp b/common/TCPServer.cpp index 6bd714d44..d7056dc05 100644 --- a/common/TCPServer.cpp +++ b/common/TCPServer.cpp @@ -67,7 +67,6 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) { SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); #endif if (tmp == 0) { -// ThrowError("BaseTCPServerLoop(): tmp = 0!"); THREAD_RETURN(NULL); } BaseTCPServer* tcps = (BaseTCPServer*) tmp; diff --git a/common/debug.h b/common/debug.h index ca5173897..62641f53a 100644 --- a/common/debug.h +++ b/common/debug.h @@ -55,15 +55,6 @@ #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 // VS6 doesn't like the length of STL generated names: disabling #pragma warning(disable:4786) diff --git a/shared_memory/CMakeLists.txt b/shared_memory/CMakeLists.txt new file mode 100644 index 000000000..6373d8ffd --- /dev/null +++ b/shared_memory/CMakeLists.txt @@ -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) diff --git a/shared_memory/main.cpp b/shared_memory/main.cpp new file mode 100644 index 000000000..fcc5a09e9 --- /dev/null +++ b/shared_memory/main.cpp @@ -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 +#include "spells.h" + +int main(int argc, char **argv) { + bool load_spells = true; + + return 0; +} \ No newline at end of file diff --git a/shared_memory/spells.cpp b/shared_memory/spells.cpp new file mode 100644 index 000000000..a9aadda19 --- /dev/null +++ b/shared_memory/spells.cpp @@ -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 +*/ diff --git a/shared_memory/spells.h b/shared_memory/spells.h new file mode 100644 index 000000000..a9aadda19 --- /dev/null +++ b/shared_memory/spells.h @@ -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 +*/ diff --git a/world/console.cpp b/world/console.cpp index a1b12aec6..93250d87e 100644 --- a/world/console.cpp +++ b/world/console.cpp @@ -66,6 +66,7 @@ extern QueryServConnection QSLink; extern volatile bool RunLoops; ConsoleList console_list; +void CatchSignal(int sig_num); Console::Console(EmuTCPConnection* itcpc) : WorldTCPConnection(), diff --git a/world/zonelist.cpp b/world/zonelist.cpp index 03b6567de..c19a55c4d 100644 --- a/world/zonelist.cpp +++ b/world/zonelist.cpp @@ -28,8 +28,7 @@ extern uint32 numzones; extern bool holdzones; extern ConsoleList console_list; - - +void CatchSignal(int sig_num); ZSList::ZSList() { diff --git a/world/zoneserver.cpp b/world/zoneserver.cpp index bab704fb3..402427cb3 100644 --- a/world/zoneserver.cpp +++ b/world/zoneserver.cpp @@ -46,6 +46,7 @@ extern volatile bool RunLoops; extern AdventureManager adventure_manager; extern UCSConnection UCSLink; extern QueryServConnection QSLink; +void CatchSignal(int sig_num); ZoneServer::ZoneServer(EmuTCPConnection* itcpc) : WorldTCPConnection(), tcpc(itcpc), ls_zboot(5000) { diff --git a/zone/AA.cpp b/zone/AA.cpp index f3fb7cfad..afc7f199c 100644 --- a/zone/AA.cpp +++ b/zone/AA.cpp @@ -38,9 +38,6 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemulator.net) #include "../common/logsys.h" #include "zonedb.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. AA_DBAction AA_Actions[aaHighestID][MAX_AA_ACTION_RANKS]; //[aaid][rank] diff --git a/zone/MobAI.cpp b/zone/MobAI.cpp index eeaad192a..79426a61f 100644 --- a/zone/MobAI.cpp +++ b/zone/MobAI.cpp @@ -36,10 +36,6 @@ using namespace std; #include "QuestParserCollection.h" #include "watermap.h" -#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat) - extern SPDat_Spell_Struct spells[SPDAT_RECORDS]; -#endif - extern EntityList entity_list; extern Zone *zone; diff --git a/zone/attack.cpp b/zone/attack.cpp index 20ca69426..7e647734d 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -52,10 +52,6 @@ extern WorldServer worldserver; #endif extern EntityList entity_list; -#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat) - extern SPDat_Spell_Struct spells[SPDAT_RECORDS]; -#endif - extern Zone* zone; bool Mob::AttackAnimation(SkillType &skillinuse, int Hand, const ItemInst* weapon) diff --git a/zone/client.cpp b/zone/client.cpp index 403916c8f..5b7303fef 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -76,9 +76,6 @@ extern EntityList entity_list; extern Zone* zone; extern volatile bool ZoneLoaded; extern WorldServer worldserver; -#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat) - extern SPDat_Spell_Struct spells[SPDAT_RECORDS]; -#endif extern uint32 numclients; extern PetitionList petition_list; bool commandlogged; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 947721ab5..3d1edc2a9 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -79,9 +79,6 @@ using namespace std; extern Zone* zone; extern volatile bool ZoneLoaded; extern WorldServer worldserver; -#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat) - extern SPDat_Spell_Struct spells[SPDAT_RECORDS]; -#endif extern bool spells_loaded; extern PetitionList petition_list; extern EntityList entity_list; diff --git a/zone/client_process.cpp b/zone/client_process.cpp index d0f5249cf..0080e117e 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -73,9 +73,6 @@ using namespace std; extern Zone* zone; extern volatile bool ZoneLoaded; extern WorldServer worldserver; -#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat) - extern SPDat_Spell_Struct spells[SPDAT_RECORDS]; -#endif extern bool spells_loaded; extern PetitionList petition_list; extern EntityList entity_list; diff --git a/zone/command.cpp b/zone/command.cpp index aa07c28d1..0299a7449 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -67,6 +67,7 @@ extern WorldServer worldserver; extern bool spells_loaded; extern TaskManager *taskmanager; +void CatchSignal(int sig_num); #include "QuestParserCollection.h" diff --git a/zone/embperl.h b/zone/embperl.h index 8e402590c..77c8dab2f 100644 --- a/zone/embperl.h +++ b/zone/embperl.h @@ -96,9 +96,9 @@ public: //Access to perl variables //all varnames here should be of the form package::name //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(SvIV(my_get_sv(varname))); }; //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(SvNV(my_get_sv(varname)));}; //returns the contents of the perl variable named in varname as a string std::string getstr(const char * varname) { SV * temp = my_get_sv(varname); @@ -133,7 +133,7 @@ public: // Iterate through key-value pairs, storing them in hash for (it = vals.begin(); it != vals.end(); it++) { - int keylen = it->first.length(); + int keylen = static_cast(it->first.length()); SV *val = newSVpv(it->second.c_str(), it->second.length()); diff --git a/zone/entity.cpp b/zone/entity.cpp index 1789f95de..8da28b8da 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -62,9 +62,6 @@ extern volatile bool ZoneLoaded; extern WorldServer worldserver; extern NetConnection net; extern uint32 numclients; -#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat) - extern SPDat_Spell_Struct spells[SPDAT_RECORDS]; -#endif extern bool spells_loaded; extern PetitionList petition_list; extern DBAsync *dbasync; @@ -3259,12 +3256,6 @@ BulkZoneSpawnPacket::BulkZoneSpawnPacket(Client* iSendTo, uint32 iMaxSpawnsPerPa data = 0; pSendTo = iSendTo; 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() { diff --git a/zone/mob.cpp b/zone/mob.cpp index 410285e63..e48ad1f1a 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -27,9 +27,6 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) #include extern EntityList entity_list; -#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat) - extern SPDat_Spell_Struct spells[SPDAT_RECORDS]; -#endif extern bool spells_loaded; extern Zone* zone; diff --git a/zone/net.cpp b/zone/net.cpp index b1832f48b..65cf7c290 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -109,9 +109,6 @@ NetConnection net; EntityList entity_list; WorldServer worldserver; uint32 numclients = 0; -#ifdef CATCH_CRASH -uint8 error = 0; -#endif char errorname[32]; uint16 adverrornum = 0; extern Zone* zone; @@ -126,23 +123,13 @@ QuestParserCollection *parse = 0; bool zoneprocess; -#if defined(NEW_LoadSPDat) || defined(DB_LoadSPDat) - // For NewLoadSPDat function - const SPDat_Spell_Struct* spells; - SPDat_Spell_Struct* spells_delete; - int32 GetMaxSpellID(); - - void LoadSPDat(); - bool FileLoadSPDat(SPDat_Spell_Struct* sp, int32 iMaxSpellID); - int32 SPDAT_RECORDS = -1; -#else - #define SPDat_Location "spdat.eff" - SPDat_Spell_Struct spells[SPDAT_RECORDS]; - void LoadSPDat(SPDat_Spell_Struct** SpellsPointer = 0); - - -#endif +const SPDat_Spell_Struct* spells; +SPDat_Spell_Struct* spells_delete; +int32 GetMaxSpellID(); +void LoadSPDat(); +bool FileLoadSPDat(SPDat_Spell_Struct* sp, int32 iMaxSpellID); +int32 SPDAT_RECORDS = -1; #ifdef _WINDOWS #include @@ -396,18 +383,8 @@ int main(int argc, char** argv) { Timer::SetCurrentTime(); //process stuff from world -#ifdef CATCH_CRASH - try{ -#endif - worldserver.Process(); -#ifdef CATCH_CRASH - } - catch(...){ - error = 1; - worldserver.Disconnect(); - worldwasconnected = false; - } -#endif + worldserver.Process(); + if (!eqsf.IsOpen() && Config->ZonePort!=0) { _log(ZONE__INIT, "Starting EQ Network server on port %d",Config->ZonePort); if (!eqsf.Open(Config->ZonePort)) { @@ -457,103 +434,54 @@ int main(int argc, char** argv) { if (ZoneLoaded && temp_timer.Check()) { { uint8 error2 = 4; -#ifdef CATCH_CRASH - try{ -#endif - 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; -#ifdef CATCH_CRASH - try{ - entity_list.MobProcess(); + 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) { + Zone::Shutdown(); } - catch(...){ - printf("Catching Mob Crash...\n"); - } -#else - entity_list.MobProcess(); -#endif - error2 = 94; - entity_list.BeaconProcess(); -#ifdef CATCH_CRASH } - catch(...){ - error=error2; - } - try{ -#endif - if (zone) { - zoneprocess= zone->Process(); - if (!zoneprocess) { - Zone::Shutdown(); - } - } -#ifdef CATCH_CRASH - } - catch(...){ - error = 2; - } - try{ -#endif - if(quest_timers.Check()) - quest_manager.Process(); -#ifdef CATCH_CRASH - } - catch(...){ - error = 77777; - } -#endif + + if(quest_timers.Check()) + quest_manager.Process(); + } } DBAsyncWork* dbaw = 0; while ((dbaw = MTdbafq.Pop())) { DispatchFinishedDBAsync(dbaw); } - if (InterserverTimer.Check() -#ifdef CATCH_CRASH - && !error -#endif - ) { -#ifdef CATCH_CRASH - try{ -#endif - InterserverTimer.Start(); - database.ping(); - AsyncLoadVariables(dbasync, &database); -// NPC::GetAILevel(true); - entity_list.UpdateWho(); - if (worldserver.TryReconnect() && (!worldserver.Connected())) - worldserver.AsyncConnect(); -#ifdef CATCH_CRASH - } - catch(...) - { - error = 16; - RunLoops = false; - } -#endif + if (InterserverTimer.Check()) { + InterserverTimer.Start(); + database.ping(); + AsyncLoadVariables(dbasync, &database); + entity_list.UpdateWho(); + if (worldserver.TryReconnect() && (!worldserver.Connected())) + worldserver.AsyncConnect(); } -#ifdef CATCH_CRASH - if (error){ - RunLoops = false; - } -#endif + #if defined(_EQDEBUG) && defined(DEBUG_PC) QueryPerformanceCounter(&tmp3); mainloop_time += tmp3.QuadPart - tmp2.QuadPart; @@ -588,38 +516,14 @@ int main(int argc, char** argv) { safe_delete(pxs); 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(); - safe_delete(zone); -#endif - } -#endif - entity_list.Clear(); - if (zone != 0 -#ifdef CATCH_CRASH - & !error -#endif - ) + if (zone != 0) Zone::Shutdown(true); //Fix for Linux world server problem. eqsf.Close(); worldserver.Disconnect(); dbasync->CommitWrites(); dbasync->StopThread(); -#if defined(NEW_LoadSPDat) || defined(DB_LoadSPDat) - safe_delete(spells_delete); -#endif safe_delete(taskmanager); command_deinit(); @@ -726,73 +630,7 @@ bool chrcmpI(const char* a, const char* b) { return true; } -#if defined(NEW_LoadSPDat) || defined(DB_LoadSPDat) 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 char errbuf[MYSQL_ERRMSG_SIZE]; @@ -813,8 +651,8 @@ int32 GetMaxSpellID() { ret = -1; } return ret; -#endif } + #ifdef SHAREMEM extern "C" bool extFileLoadSPDat(void* sp, int32 iMaxSpellID) { return FileLoadSPDat((SPDat_Spell_Struct*) sp, iMaxSpellID); } #endif @@ -860,242 +698,7 @@ void LoadSPDat() { } 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 - char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; 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)); // Numeric fields (everything else) - sp[tempid].range=atof(row[9]); - sp[tempid].aoerange=atof(row[10]); - sp[tempid].pushback=atof(row[11]); - sp[tempid].pushup=atof(row[12]); + sp[tempid].range=static_cast(atof(row[9])); + sp[tempid].aoerange=static_cast(atof(row[10])); + sp[tempid].pushback=static_cast(atof(row[11])); + sp[tempid].pushup=static_cast(atof(row[12])); sp[tempid].cast_time=atoi(row[13]); sp[tempid].recovery_time=atoi(row[14]); 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].field209=atoi(row[209]); sp[tempid].CastRestriction = atoi(row[211]); - sp[tempid].AllowRest = atoi(row[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].AllowRest = atoi(row[212]) != 0; sp[tempid].DamageShieldType = 0; } @@ -1295,12 +883,8 @@ This is hanging on freebsd for me, not sure why... safe_delete_array(query); return false; } -#endif - } -#endif //from just above GetMaxSpellID(): #if defined(NEW_LoadSPDat) || defined(DB_LoadSPDat) - void UpdateWindowTitle(char* iNewTitle) { #ifdef _WINDOWS char tmp[500]; diff --git a/zone/npc.cpp b/zone/npc.cpp index c78680c4f..bdf219dbe 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -51,9 +51,6 @@ using namespace std; extern Zone* zone; extern volatile bool ZoneLoaded; extern EntityList entity_list; -#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat) - extern SPDat_Spell_Struct spells[SPDAT_RECORDS]; -#endif #include "QuestParserCollection.h" diff --git a/zone/spdat.cpp b/zone/spdat.cpp index d3a9997ca..db71d88fa 100644 --- a/zone/spdat.cpp +++ b/zone/spdat.cpp @@ -87,9 +87,6 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) #include #include "../common/unix.h" #endif -#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat) - extern SPDat_Spell_Struct spells[SPDAT_RECORDS]; -#endif extern bool spells_loaded; /////////////////////////////////////////////////////////////////////////////// diff --git a/zone/spdat.h b/zone/spdat.h index 7222b6bd7..f7d2613f5 100644 --- a/zone/spdat.h +++ b/zone/spdat.h @@ -33,15 +33,6 @@ #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 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. @@ -722,12 +713,8 @@ struct SPDat_Spell_Struct 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 int32 SPDAT_RECORDS; -#else - #define SPDAT_RECORDS 3602 -#endif +extern const SPDat_Spell_Struct* spells; +extern int32 SPDAT_RECORDS; bool IsTargetableAESpell(uint16 spell_id); bool IsSacrificeSpell(uint16 spell_id); diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index de8fd27e1..5db1eed33 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -38,9 +38,6 @@ Copyright (C) 2001-2004 EQEMu Development Team (http://eqemu.org) extern Zone* zone; extern volatile bool ZoneLoaded; -#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat) - extern SPDat_Spell_Struct spells[SPDAT_RECORDS]; -#endif extern bool spells_loaded; extern WorldServer worldserver; //uchar blah[]={0x0D,0x00,0x00,0x00,0x01,0x00,0x00,0x00}; diff --git a/zone/spells.cpp b/zone/spells.cpp index 41fe4d191..c18687239 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -99,9 +99,6 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) extern Zone* zone; extern volatile bool ZoneLoaded; -#if !defined(NEW_LoadSPDat) && !defined(DB_LoadSPDat) - extern SPDat_Spell_Struct spells[SPDAT_RECORDS]; -#endif extern bool spells_loaded; extern WorldServer worldserver; uchar blah[]={0x0D,0x00,0x00,0x00,0x01,0x00,0x00,0x00};