From 7b0de551e1a28bee263ac3acc5db83d355bf07c1 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 20 May 2013 22:13:19 -0700 Subject: [PATCH 01/16] removed char buffer in 'UpdateWindowTitle" --- zone/net.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/zone/net.cpp b/zone/net.cpp index 60e891b23..cca1eb59f 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -20,7 +20,7 @@ #include "../common/features.h" #include using namespace std; -#include +#include #include #include #include @@ -62,6 +62,7 @@ extern volatile bool ZoneLoaded; #include "../common/patches/patches.h" #include "../common/rulesys.h" #include "../common/MiscFunctions.h" +#include "../common/StringUtil.h" #include "../common/platform.h" #include "../common/crash.h" #include "../common/ipc_mutex.h" @@ -608,27 +609,27 @@ void LoadSpells(EQEmu::MemoryMappedFile **mmf) { void UpdateWindowTitle(char* iNewTitle) { #ifdef _WINDOWS - char tmp[500]; + std::string newTitle; if (iNewTitle) { - snprintf(tmp, sizeof(tmp), "%i: %s", ZoneConfig::get()->ZonePort, iNewTitle); + StringFormat(&newTitle, "%i: %s", ZoneConfig::get()->ZonePort, iNewTitle); } else { if (zone) { #if defined(GOTFRAGS) || defined(_EQDEBUG) - snprintf(tmp, sizeof(tmp), "%i: %s, %i clients, %i", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients, getpid()); + StringFormat(&newTitle, "%i: %s, %i clients, %i", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients, getpid()); #else - snprintf(tmp, sizeof(tmp), "%i: %s, %i clients", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients); + StringFormat(&newTitle, "%i: %s, %i clients", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients); #endif } else { #if defined(GOTFRAGS) || defined(_EQDEBUG) - snprintf(tmp, sizeof(tmp), "%i: sleeping, %i", ZoneConfig::get()->ZonePort, getpid()); + StringFormat(&newTitle, "%i: sleeping, %i", ZoneConfig::get()->ZonePort, getpid()); #else - snprintf(tmp, sizeof(tmp), "%i: sleeping", ZoneConfig::get()->ZonePort); + StringFormat(&newTitle, "%i: sleeping", ZoneConfig::get()->ZonePort); #endif } } - SetConsoleTitle(tmp); + SetConsoleTitle(newTitle.c_str()); #endif } From dcec112b91bb63d1aa91d92568b710eb16fd9def Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 20 May 2013 22:17:56 -0700 Subject: [PATCH 02/16] reordering includes to make it easier to simplify. --- zone/net.cpp | 81 +++++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/zone/net.cpp b/zone/net.cpp index cca1eb59f..c42242801 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -18,34 +18,6 @@ */ #include "../common/debug.h" #include "../common/features.h" -#include -using namespace std; -#include -#include -#include -#include -#include - #ifdef _CRTDBG_MAP_ALLOC - #undef new - #endif -#include - #ifdef _CRTDBG_MAP_ALLOC - #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) - #endif -using namespace std; -#ifdef _WINDOWS -#include -#define snprintf _snprintf -#if (_MSC_VER < 1500) - #define vsnprintf _vsnprintf -#endif -#define strncasecmp _strnicmp -#define strcasecmp _stricmp -#endif - -volatile bool RunLoops = true; -extern volatile bool ZoneLoaded; - #include "../common/queue.h" #include "../common/timer.h" #include "../common/EQStream.h" @@ -54,7 +26,6 @@ extern volatile bool ZoneLoaded; #include "../common/Mutex.h" #include "../common/version.h" #include "../common/EQEMuError.h" -#include "ZoneConfig.h" #include "../common/packet_dump_file.h" #include "../common/opcodemgr.h" #include "../common/guilds.h" @@ -68,11 +39,12 @@ extern volatile bool ZoneLoaded; #include "../common/ipc_mutex.h" #include "../common/memory_mapped_file.h" #include "../common/eqemu_exception.h" +#include "../common/spdat.h" +#include "ZoneConfig.h" #include "masterentity.h" #include "worldserver.h" #include "net.h" -#include "../common/spdat.h" #include "zone.h" #include "command.h" #include "parser.h" @@ -85,6 +57,48 @@ extern volatile bool ZoneLoaded; #include "tasks.h" #include "QuestParserCollection.h" +#include +#include +#include + +#include +#include +#include +#include + +#ifdef _CRTDBG_MAP_ALLOC + #undef new +#endif + +#ifdef _CRTDBG_MAP_ALLOC + #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif + +#ifdef _WINDOWS + #include + + #if (_MSC_VER < 1500) + #define vsnprintf _vsnprintf + #endif + + #define snprintf _snprintf + #define strncasecmp _strnicmp + #define strcasecmp _stricmp +#endif + +#ifdef _WINDOWS + #include +#else + #include + #include "../common/unix.h" +#endif + +volatile bool RunLoops = true; +extern volatile bool ZoneLoaded; + + + + TimeoutManager timeout_manager; NetConnection net; EntityList entity_list; @@ -105,12 +119,7 @@ const SPDat_Spell_Struct* spells; void LoadSpells(EQEmu::MemoryMappedFile **mmf); int32 SPDAT_RECORDS = -1; -#ifdef _WINDOWS -#include -#else -#include -#include "../common/unix.h" -#endif + void Shutdown(); extern void MapOpcodes(); From 3c11f8f26b5f465c3b46e7eae7afd3149ed65cf0 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 20 May 2013 22:20:01 -0700 Subject: [PATCH 03/16] simplified the includes to be a bit clearer. --- zone/net.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/zone/net.cpp b/zone/net.cpp index c42242801..896adb49f 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -1,4 +1,3 @@ -#define DONT_SHARED_OPCODES /* EQEMu: Everquest Server Emulator Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) @@ -16,6 +15,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#define DONT_SHARED_OPCODES + #include "../common/debug.h" #include "../common/features.h" #include "../common/queue.h" @@ -68,15 +70,12 @@ #ifdef _CRTDBG_MAP_ALLOC #undef new -#endif - -#ifdef _CRTDBG_MAP_ALLOC #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) #endif #ifdef _WINDOWS #include - + #include #if (_MSC_VER < 1500) #define vsnprintf _vsnprintf #endif @@ -84,10 +83,6 @@ #define snprintf _snprintf #define strncasecmp _strnicmp #define strcasecmp _stricmp -#endif - -#ifdef _WINDOWS - #include #else #include #include "../common/unix.h" From 26143750f336e2ada89eb03e3f24e50d7c3e5765 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 20 May 2013 22:40:10 -0700 Subject: [PATCH 04/16] removed visual studio 5,6,7 specific code except in tinyxml and StackWalker. --- common/debug.h | 13 ------------- zone/PlayerCorpse.cpp | 8 +++----- zone/beacon.cpp | 11 +++++------ zone/client.cpp | 20 +++++++++----------- zone/net.cpp | 4 +--- zone/tribute.cpp | 23 ++++++++++------------- 6 files changed, 28 insertions(+), 51 deletions(-) diff --git a/common/debug.h b/common/debug.h index 3961598a6..de04fe0ff 100644 --- a/common/debug.h +++ b/common/debug.h @@ -45,22 +45,9 @@ #ifndef _CRTDBG_MAP_ALLOC #include #include - #if (_MSC_VER < 1300) - #include - #include - #define _CRTDBG_MAP_ALLOC - #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) - #define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) - #endif #endif #endif -#ifdef _WINDOWS - // VS6 doesn't like the length of STL generated names: disabling - #pragma warning(disable:4786) - #pragma warning(disable:4996) -#endif - #ifndef EQDEBUG_H #define EQDEBUG_H diff --git a/zone/PlayerCorpse.cpp b/zone/PlayerCorpse.cpp index 1011e9804..eeb6fd5c9 100644 --- a/zone/PlayerCorpse.cpp +++ b/zone/PlayerCorpse.cpp @@ -28,12 +28,10 @@ Child of the Mob class. #include using namespace std; #ifdef _WINDOWS -#define snprintf _snprintf -#if (_MSC_VER < 1500) + #define snprintf _snprintf #define vsnprintf _vsnprintf -#endif -#define strncasecmp _strnicmp -#define strcasecmp _stricmp + #define strncasecmp _strnicmp + #define strcasecmp _stricmp #endif #include "masterentity.h" diff --git a/zone/beacon.cpp b/zone/beacon.cpp index 2d2d9a942..9b88dd524 100644 --- a/zone/beacon.cpp +++ b/zone/beacon.cpp @@ -24,13 +24,12 @@ target to center around. */ #include "../common/debug.h" + #ifdef _WINDOWS -#define snprintf _snprintf -#if (_MSC_VER < 1500) - #define vsnprintf _vsnprintf -#endif -#define strncasecmp _strnicmp -#define strcasecmp _stricmp + #define snprintf _snprintf + #define vsnprintf _vsnprintf + #define strncasecmp _strnicmp + #define strcasecmp _stricmp #endif #include "masterentity.h" diff --git a/zone/client.cpp b/zone/client.cpp index 5b021b715..3730c1b4d 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -28,19 +28,17 @@ using namespace std; // for windows compile #ifdef _WINDOWS -#define abs64 _abs64 -#define snprintf _snprintf -#if (_MSC_VER < 1500) + #define abs64 _abs64 + #define snprintf _snprintf #define vsnprintf _vsnprintf -#endif -#define strncasecmp _strnicmp -#define strcasecmp _stricmp + #define strncasecmp _strnicmp + #define strcasecmp _stricmp #else -#include -#include -#include -#include "../common/unix.h" -#define abs64 abs + #include + #include + #include + #include "../common/unix.h" + #define abs64 abs #endif extern volatile bool RunLoops; diff --git a/zone/net.cpp b/zone/net.cpp index 896adb49f..b408c8a7f 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -76,10 +76,8 @@ #ifdef _WINDOWS #include #include - #if (_MSC_VER < 1500) - #define vsnprintf _vsnprintf - #endif + #define vsnprintf _vsnprintf #define snprintf _snprintf #define strncasecmp _strnicmp #define strcasecmp _stricmp diff --git a/zone/tribute.cpp b/zone/tribute.cpp index 9d864a72d..1e6bd0a31 100644 --- a/zone/tribute.cpp +++ b/zone/tribute.cpp @@ -27,21 +27,18 @@ using namespace std; #ifdef _WINDOWS -#include -#include -#include - -#define snprintf _snprintf -#if (_MSC_VER < 1500) + #include + #include + #include + #define snprintf _snprintf #define vsnprintf _vsnprintf -#endif -#define strncasecmp _strnicmp -#define strcasecmp _stricmp + #define strncasecmp _strnicmp + #define strcasecmp _stricmp #else -#include -#include -#include -#include "../common/unix.h" + #include + #include + #include + #include "../common/unix.h" #endif /* From 9002bfb9a03f0197cd14d165cee487754fb0a413 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 20 May 2013 23:16:02 -0700 Subject: [PATCH 05/16] corrected incorrect use of StringFormat and did basic indenting fix. --- zone/client.cpp | 4 ---- zone/net.cpp | 28 ++++++++++++++-------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index 3730c1b4d..7b2460879 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -29,10 +29,6 @@ using namespace std; // for windows compile #ifdef _WINDOWS #define abs64 _abs64 - #define snprintf _snprintf - #define vsnprintf _vsnprintf - #define strncasecmp _strnicmp - #define strcasecmp _stricmp #else #include #include diff --git a/zone/net.cpp b/zone/net.cpp index b408c8a7f..30b0eb614 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -74,16 +74,16 @@ #endif #ifdef _WINDOWS - #include - #include - - #define vsnprintf _vsnprintf - #define snprintf _snprintf - #define strncasecmp _strnicmp - #define strcasecmp _stricmp + #include + #include + + #define vsnprintf _vsnprintf + #define snprintf _snprintf + #define strncasecmp _strnicmp + #define strcasecmp _stricmp #else - #include - #include "../common/unix.h" + #include + #include "../common/unix.h" #endif volatile bool RunLoops = true; @@ -613,21 +613,21 @@ void UpdateWindowTitle(char* iNewTitle) { #ifdef _WINDOWS std::string newTitle; if (iNewTitle) { - StringFormat(&newTitle, "%i: %s", ZoneConfig::get()->ZonePort, iNewTitle); + StringFormat(newTitle, "%i: %s", ZoneConfig::get()->ZonePort, iNewTitle); } else { if (zone) { #if defined(GOTFRAGS) || defined(_EQDEBUG) - StringFormat(&newTitle, "%i: %s, %i clients, %i", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients, getpid()); + StringFormat(newTitle, "%i: %s, %i clients, %i", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients, getpid()); #else - StringFormat(&newTitle, "%i: %s, %i clients", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients); + StringFormat(newTitle, "%i: %s, %i clients", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients); #endif } else { #if defined(GOTFRAGS) || defined(_EQDEBUG) - StringFormat(&newTitle, "%i: sleeping, %i", ZoneConfig::get()->ZonePort, getpid()); + StringFormat(newTitle, "%i: sleeping, %i", ZoneConfig::get()->ZonePort, getpid()); #else - StringFormat(&newTitle, "%i: sleeping", ZoneConfig::get()->ZonePort); + StringFormat(newTitle, "%i: sleeping", ZoneConfig::get()->ZonePort); #endif } } From c18d868d0326c5b8189a3f81432656bbbc47b344 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 20 May 2013 23:25:08 -0700 Subject: [PATCH 06/16] set many pointers to nullptr instead of 0. --- zone/net.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/zone/net.cpp b/zone/net.cpp index 30b0eb614..f2b059656 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -76,11 +76,6 @@ #ifdef _WINDOWS #include #include - - #define vsnprintf _vsnprintf - #define snprintf _snprintf - #define strncasecmp _strnicmp - #define strcasecmp _stricmp #else #include #include "../common/unix.h" From 70eb226fea5f177da91404657e6e332f5033faf2 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 20 May 2013 23:59:41 -0700 Subject: [PATCH 07/16] changed from using a preset char buffer to string. --- common/logsys_eqemu.cpp | 15 +++++++++------ world/world_logsys.cpp | 26 ++++++++++++++------------ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/common/logsys_eqemu.cpp b/common/logsys_eqemu.cpp index 79ea82ec0..5086114f5 100644 --- a/common/logsys_eqemu.cpp +++ b/common/logsys_eqemu.cpp @@ -18,9 +18,12 @@ #include "debug.h" #include "logsys.h" +#include "StringUtil.h" + #include #include -#include + +#include void log_message(LogType type, const char *fmt, ...) { va_list args; @@ -30,10 +33,10 @@ void log_message(LogType type, const char *fmt, ...) { } void log_messageVA(LogType type, const char *fmt, va_list args) { - char prefix_buffer[256]; - snprintf(prefix_buffer, 255, "[%s] ", log_type_info[type].name); - prefix_buffer[255] = '\0'; - - LogFile->writePVA(EQEMuLog::Debug, prefix_buffer, fmt, args); + std::string prefix_buffer; + + StringFormat(prefix_buffer, "[%s] ", log_type_info[type].name); + + LogFile->writePVA(EQEMuLog::Debug, prefix_buffer.c_str(), fmt, args); } diff --git a/world/world_logsys.cpp b/world/world_logsys.cpp index 2d94a4042..f60186a86 100644 --- a/world/world_logsys.cpp +++ b/world/world_logsys.cpp @@ -1,18 +1,21 @@ #include "../common/debug.h" #include "../common/logsys.h" +#include "../common/StringUtil.h" + #include "zoneserver.h" #include "client.h" + #include #include void log_message_clientVA(LogType type, Client *who, const char *fmt, va_list args) { - char prefix_buffer[256]; - snprintf(prefix_buffer, 255, "[%s] %s: ", log_type_info[type].name, who->GetAccountName()); - prefix_buffer[255] = '\0'; - LogFile->writePVA(EQEMuLog::Debug, prefix_buffer, fmt, args); + std::string prefix_buffer; + StringFormat(prefix_buffer,"[%s] %s: ", log_type_info[type].name, who->GetAccountName()); + + LogFile->writePVA(EQEMuLog::Debug, prefix_buffer.c_str(), fmt, args); } void log_message_client(LogType type, Client *who, const char *fmt, ...) { @@ -24,18 +27,17 @@ void log_message_client(LogType type, Client *who, const char *fmt, ...) { void log_message_zoneVA(LogType type, ZoneServer *who, const char *fmt, va_list args) { - char prefix_buffer[256]; - char zone_tag[65]; + std::string prefix_buffer, zone_tag; const char *zone_name=who->GetZoneName(); - if (*zone_name==0) - snprintf(zone_tag,64,"[%d]", who->GetID()); + + if (zone_name == nullptr) + StringFormat(zone_tag,"[%d]", who->GetID()); else - snprintf(zone_tag,64,"[%d] [%s]",who->GetID(),zone_name); + StringFormat(zone_tag,"[%d] [%s]",who->GetID(),zone_name); - snprintf(prefix_buffer, 255, "[%s] %s ", log_type_info[type].name, zone_tag); - prefix_buffer[255] = '\0'; + StringFormat(prefix_buffer, "[%s] %s ", log_type_info[type].name, zone_tag.c_str()); - LogFile->writePVA(EQEMuLog::Debug, prefix_buffer, fmt, args); + LogFile->writePVA(EQEMuLog::Debug, prefix_buffer.c_str(), fmt, args); } void log_message_zone(LogType type, ZoneServer *who, const char *fmt, ...) { From 64212176ec91e59c64e28a3c682293866f13ff01 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 21 May 2013 00:04:45 -0700 Subject: [PATCH 08/16] removed unneeded defines. snprintf and friends are used within StringUtil.h --- world/client.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/world/client.cpp b/world/client.cpp index 46c11bcc8..30e6b31c4 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -19,9 +19,6 @@ using namespace std; #ifdef _WINDOWS #include #include - #define snprintf _snprintf - #define strncasecmp _strnicmp - #define strcasecmp _stricmp #else #include #ifdef FREEBSD //Timothy Whitman - January 7, 2003 From a7084b4d6c04a0cb2e214600d29e647a766a104b Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 21 May 2013 00:12:28 -0700 Subject: [PATCH 09/16] reorganized includes to allow for consolidation and cleanup. --- world/client.cpp | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/world/client.cpp b/world/client.cpp index 30e6b31c4..e153aa6c0 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -2,10 +2,24 @@ #include "../common/EQPacket.h" #include "../common/EQStreamIntf.h" #include "../common/misc.h" +#include "../common/rulesys.h" +#include "../common/emu_opcodes.h" +#include "../common/eq_packet_structs.h" +#include "../common/packet_dump.h" +#include "../common/EQStreamIntf.h" +#include "../common/Item.h" +#include "../common/races.h" +#include "../common/classes.h" +#include "../common/languages.h" +#include "../common/skills.h" +#include "../common/extprofile.h" +#include "../common/StringUtil.h" +#include "../common/clientversions.h" + #include -using namespace std; #include using namespace std; + #include #include #include @@ -20,29 +34,19 @@ using namespace std; #include #include #else + + #ifdef FREEBSD //Timothy Whitman - January 7, 2003 + #include + #endif + #include -#ifdef FREEBSD //Timothy Whitman - January 7, 2003 - #include -#endif #include #include #include #endif - #include "client.h" -#include "../common/emu_opcodes.h" -#include "../common/eq_packet_structs.h" -#include "../common/packet_dump.h" -#include "../common/EQStreamIntf.h" #include "worlddb.h" -#include "../common/Item.h" -#include "../common/races.h" -#include "../common/classes.h" -#include "../common/languages.h" -#include "../common/skills.h" -#include "../common/extprofile.h" -#include "../common/StringUtil.h" #include "WorldConfig.h" #include "LoginServer.h" #include "LoginServerList.h" @@ -50,9 +54,8 @@ using namespace std; #include "zonelist.h" #include "clientlist.h" #include "wguild_mgr.h" -#include "../common/rulesys.h" #include "SoFCharCreateData.h" -#include "../common/clientversions.h" + std::vector character_create_allocations; std::vector character_create_race_class_combos; From cdc7b2a00071d801beaaa71fcbb3d6f539b277d4 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 21 May 2013 00:25:12 -0700 Subject: [PATCH 10/16] weird #ifdef pattern, reorganized and cleaned it up. easier to understand now. --- common/Condition.cpp | 251 +++++++++++++++++++++---------------------- 1 file changed, 123 insertions(+), 128 deletions(-) diff --git a/common/Condition.cpp b/common/Condition.cpp index bb4dba96e..7d99d0a43 100644 --- a/common/Condition.cpp +++ b/common/Condition.cpp @@ -20,134 +20,129 @@ #include "Condition.h" #ifdef _WINDOWS + + Condition::Condition() + { + m_events[SignalEvent] = CreateEvent (nullptr, // security + FALSE, // is auto-reset event? + FALSE, // is signaled initially? + nullptr); // name + m_events[BroadcastEvent] = CreateEvent (nullptr, // security + TRUE, // is auto-reset event? + FALSE, // is signaled initially? + nullptr); // name + m_waiters = 0; + InitializeCriticalSection(&CSMutex); + } + + Condition::~Condition() + { + DeleteCriticalSection(&CSMutex); + CloseHandle(m_events[SignalEvent]); + CloseHandle(m_events[BroadcastEvent]); + } + + void Condition::Signal() + { + EnterCriticalSection(&CSMutex); + if(m_waiters > 0) + SetEvent(m_events[SignalEvent]); + LeaveCriticalSection(&CSMutex); + } + + void Condition::SignalAll() + { + EnterCriticalSection(&CSMutex); + if(m_waiters > 0) + SetEvent(m_events[BroadcastEvent]); + LeaveCriticalSection(&CSMutex); + } + + void Condition::Wait() + { + EnterCriticalSection(&CSMutex); + + m_waiters++; + + + LeaveCriticalSection(&CSMutex); + int result = WaitForMultipleObjects (_eventCount, m_events, FALSE, INFINITE); + EnterCriticalSection(&CSMutex); + + m_waiters--; + + //see if we are the last person waiting on the condition, and there was a broadcast + //if so, we need to reset the broadcast event. + if(m_waiters == 0 && result == (WAIT_OBJECT_0+BroadcastEvent)) + ResetEvent(m_events[BroadcastEvent]); + + LeaveCriticalSection(&CSMutex); + } + #else -#include -#include -#include + #include + #include + #include + + Condition::Condition() + { + pthread_cond_init(&cond,nullptr); + pthread_mutex_init(&mutex,nullptr); + } + + void Condition::Signal() + { + pthread_mutex_lock(&mutex); + pthread_cond_signal(&cond); + pthread_mutex_unlock(&mutex); + } + + void Condition::SignalAll() + { + pthread_mutex_lock(&mutex); + pthread_cond_broadcast(&cond); + pthread_mutex_unlock(&mutex); + } + + void Condition::Wait() + { + pthread_mutex_lock(&mutex); + pthread_cond_wait(&cond,&mutex); + pthread_mutex_unlock(&mutex); + } + + /* + I commented this specifically because I think it might be very + difficult to write a windows counterpart to it, so I would like + to discourage its use until we can confirm that it can be reasonably + implemented on windows. + + bool Condition::TimedWait(unsigned long usec) + { + struct timeval now; + struct timespec timeout; + int retcode=0; + pthread_mutex_lock(&mutex); + gettimeofday(&now,nullptr); + now.tv_usec+=usec; + timeout.tv_sec = now.tv_sec + (now.tv_usec/1000000); + timeout.tv_nsec = (now.tv_usec%1000000) *1000; + //cout << "now=" << now.tv_sec << "."< 0) - SetEvent(m_events[SignalEvent]); - LeaveCriticalSection(&CSMutex); -} - -void Condition::SignalAll() -{ - EnterCriticalSection(&CSMutex); - if(m_waiters > 0) - SetEvent(m_events[BroadcastEvent]); - LeaveCriticalSection(&CSMutex); -} - -void Condition::Wait() -{ - EnterCriticalSection(&CSMutex); - - m_waiters++; - - - LeaveCriticalSection(&CSMutex); - int result = WaitForMultipleObjects (_eventCount, m_events, FALSE, INFINITE); - EnterCriticalSection(&CSMutex); - - m_waiters--; - - //see if we are the last person waiting on the condition, and there was a broadcast - //if so, we need to reset the broadcast event. - if(m_waiters == 0 && result == (WAIT_OBJECT_0+BroadcastEvent)) - ResetEvent(m_events[BroadcastEvent]); - - LeaveCriticalSection(&CSMutex); -} - - -#else //!WIN32 - -Condition::Condition() -{ - pthread_cond_init(&cond,nullptr); - pthread_mutex_init(&mutex,nullptr); -} - -void Condition::Signal() -{ - pthread_mutex_lock(&mutex); - pthread_cond_signal(&cond); - pthread_mutex_unlock(&mutex); -} - -void Condition::SignalAll() -{ - pthread_mutex_lock(&mutex); - pthread_cond_broadcast(&cond); - pthread_mutex_unlock(&mutex); -} - -void Condition::Wait() -{ - pthread_mutex_lock(&mutex); - pthread_cond_wait(&cond,&mutex); - pthread_mutex_unlock(&mutex); -} - -/* -I commented this specifically because I think it might be very -difficult to write a windows counterpart to it, so I would like -to discourage its use until we can confirm that it can be reasonably -implemented on windows. - -bool Condition::TimedWait(unsigned long usec) -{ -struct timeval now; -struct timespec timeout; -int retcode=0; - pthread_mutex_lock(&mutex); - gettimeofday(&now,nullptr); - now.tv_usec+=usec; - timeout.tv_sec = now.tv_sec + (now.tv_usec/1000000); - timeout.tv_nsec = (now.tv_usec%1000000) *1000; - //cout << "now=" << now.tv_sec << "."< Date: Tue, 21 May 2013 18:08:21 -0700 Subject: [PATCH 11/16] removed DBMemLeak.cpp and DBMemLeak.h, unused. --- common/CMakeLists.txt | 2 -- common/DBMemLeak.cpp | 62 ------------------------------------------- common/DBMemLeak.h | 25 ----------------- common/dbcore.h | 1 - common/shareddb.cpp | 4 ++- 5 files changed, 3 insertions(+), 91 deletions(-) delete mode 100644 common/DBMemLeak.cpp delete mode 100644 common/DBMemLeak.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 9d97b1eca..ed1a1e808 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -10,7 +10,6 @@ SET(common_sources database.cpp dbasync.cpp dbcore.cpp - DBMemLeak.cpp debug.cpp emu_opcodes.cpp EmuTCPConnection.cpp @@ -103,7 +102,6 @@ SET(common_headers database.h dbasync.h dbcore.h - DBMemLeak.h debug.h deity.h emu_opcodes.h diff --git a/common/DBMemLeak.cpp b/common/DBMemLeak.cpp deleted file mode 100644 index 2b457b1ad..000000000 --- a/common/DBMemLeak.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#ifdef _EQDEBUG -#include "../common/debug.h" -#include -#include -#include -#include "../common/Mutex.h" -#include "DBMemLeak.h" - -#include - -#ifdef _WINDOWS -#define snprintf _snprintf -#define strncasecmp _strnicmp -#define strcasecmp _stricmp -#endif - -DBMemLeak dbmemleak; -LinkedList* list = 0; -Mutex MDBMemLeak; - -DBMemLeak::DBMemLeak() { - list = new LinkedList; -} - -DBMemLeak::~DBMemLeak() { - LinkedListIterator iterator(*list); - iterator.Reset(); - while (iterator.MoreElements()) { - char tmp[200]; - snprintf(tmp, sizeof(tmp) - 3, "DB Mem Leak: Block=%6d, Query=%s", iterator.GetData()->memblock, iterator.GetData()->query); - snprintf(tmp, sizeof(tmp), "%s\n", tmp); - OutputDebugString(tmp); - iterator.Advance(); - } - safe_delete(list); -} - -void DBMemLeak::Alloc(const void* result, const char* query) { - LockMutex lock(&MDBMemLeak); - long requestNumber; - uint8* tmp2 = new uint8; - _CrtIsMemoryBlock( tmp2, 1, &requestNumber, 0, 0 ); - safe_delete(tmp2); - DBMemLeakStruct* tmp = (DBMemLeakStruct*) new uchar[sizeof(DBMemLeakStruct) + strlen(query) + 1]; - tmp->result = result; - tmp->memblock = requestNumber; - strcpy(tmp->query, query); - list->Append(tmp); -} - -void DBMemLeak::Free(const void* result) { - LockMutex lock(&MDBMemLeak); - LinkedListIterator iterator(*list); - iterator.Reset(); - while (iterator.MoreElements()) { - if (result == iterator.GetData()->result) - iterator.RemoveCurrent(); - else - iterator.Advance(); - } -} -#endif diff --git a/common/DBMemLeak.h b/common/DBMemLeak.h deleted file mode 100644 index 48f3f7374..000000000 --- a/common/DBMemLeak.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifdef _EQDEBUG -#ifndef DBMemLeak_H -#define DBMemLeak_H -#include "../common/types.h" -#include "../common/linked_list.h" - -#define mysql_free_result(r) { DBMemLeak::Free(r); mysql_free_result(r); } - -struct DBMemLeakStruct { - const void* result; - uint32 memblock; - char query[0]; -}; - -class DBMemLeak { -public: - DBMemLeak(); - ~DBMemLeak(); - - static void Alloc(const void* result, const char* query); - static void Free(const void* result); -}; - -#endif -#endif diff --git a/common/dbcore.h b/common/dbcore.h index b43752c1f..ed5e62133 100644 --- a/common/dbcore.h +++ b/common/dbcore.h @@ -7,7 +7,6 @@ //#include #endif #include -#include "../common/DBMemLeak.h" #include "../common/types.h" #include "../common/Mutex.h" #include "../common/linked_list.h" diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 98699fd99..b78218b8b 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -1,7 +1,9 @@ -#include "shareddb.h" #include #include #include + +#include "shareddb.h" +#include "mysql.h" #include "Item.h" #include "classes.h" #include "rulesys.h" From d7546e09ee86d40a05bd573c5cdd1e9f0d6b4932 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 21 May 2013 22:51:35 -0700 Subject: [PATCH 12/16] broke up dumpInventory into methods, changed it to dumpEntireInventory (dumpInventory now only dumps a small peice) --- common/Item.cpp | 152 ++++++++++++++++------------------------- common/Item.h | 6 ++ zone/client.cpp | 2 +- zone/client_packet.cpp | 2 +- 4 files changed, 67 insertions(+), 95 deletions(-) diff --git a/common/Item.cpp b/common/Item.cpp index 0a05d8bff..b8e3c4298 100644 --- a/common/Item.cpp +++ b/common/Item.cpp @@ -15,20 +15,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifdef _WINDOWS - // VS6 doesn't like the length of STL generated names: disabling - #pragma warning(disable:4786) - // Quagmire: Dont know why the one in debug.h doesnt work, but it doesnt. -#endif #include "../common/debug.h" -/*#ifdef _CRTDBG_MAP_ALLOC - #undef new - #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) -#endif -*/ +#include "../common/StringUtil.h" + #include #include + #include #include "Item.h" #include "database.h" @@ -36,6 +28,7 @@ #include "races.h" #include "shareddb.h" #include "classes.h" + using namespace std; int32 NextItemInstSerialNumber = 1; @@ -1060,103 +1053,76 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo return SLOT_INVALID; } -void Inventory::dumpInventory() { +void Inventory::dumpBagContents(ItemInst *inst) { + iter_inst it; + iter_contents itb; + + if (!inst || !inst->IsType(ItemClassContainer)) + return; + + // Go through bag, if bag + for (itb=inst->_begin(); itb!=inst->_end(); itb++) { + ItemInst* baginst = itb->second; + if(!baginst || !baginst->GetItem()) + continue; + + std::string subSlot; + StringFormat(subSlot," Slot %d: %s (%d)", Inventory::CalcSlotId(it->first, itb->first), + baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); + std::cout << subSlot << std::endl; + } + +} + +void Inventory::dumpItemCollection(const map &collection) { iter_inst it; iter_contents itb; ItemInst* inst = nullptr; - - // Check item: After failed checks, check bag contents (if bag) - printf("Worn items:\n"); - for (it=m_worn.begin(); it!=m_worn.end(); it++) { + + for (it=collection.begin(); it!=collection.end(); it++) { inst = it->second; it->first; if(!inst || !inst->GetItem()) continue; + + std:string slot; + StringFormat(slot, "Slot %d: %s (%d)",it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); + std::cout << slot << std::endl; - printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); - - // Go through bag, if bag - if (inst && inst->IsType(ItemClassContainer)) { - for (itb=inst->_begin(); itb!=inst->_end(); itb++) { - ItemInst* baginst = itb->second; - if(!baginst || !baginst->GetItem()) - continue; - printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first), - baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); - } - } + dumpBagContents(inst); } +} - printf("Inventory items:\n"); - for (it=m_inv.begin(); it!=m_inv.end(); it++) { - inst = it->second; - it->first; - if(!inst || !inst->GetItem()) - continue; +void Inventory::dumpWornItems() { + std::cout << "Worn items:" << std::endl; + dumpItemCollection(m_worn); +} - printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); +void Inventory::dumpInventory() { + std::cout << "Inventory items:" << std::endl; + dumpItemCollection(m_inv); +} - // Go through bag, if bag - if (inst && inst->IsType(ItemClassContainer)) { - for (itb=inst->_begin(); itb!=inst->_end(); itb++) { - ItemInst* baginst = itb->second; - if(!baginst || !baginst->GetItem()) - continue; - printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first), - baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); +void Inventory::dumpBankItems() { + + std::cout << "Bank items:" << std::endl; + dumpItemCollection(m_bank); +} - } - } - } +void Inventory::dumpSharedBankItems() { + + std::cout << "Shared Bank items:" << std::endl; + dumpItemCollection(m_shbank); +} - printf("Bank items:\n"); - for (it=m_bank.begin(); it!=m_bank.end(); it++) { - inst = it->second; - it->first; - if(!inst || !inst->GetItem()) - continue; +void Inventory::dumpEntireInventory() { - printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); - - // Go through bag, if bag - if (inst && inst->IsType(ItemClassContainer)) { - - for (itb=inst->_begin(); itb!=inst->_end(); itb++) { - ItemInst* baginst = itb->second; - if(!baginst || !baginst->GetItem()) - continue; - printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first), - baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); - - } - } - } - - printf("Shared Bank items:\n"); - for (it=m_shbank.begin(); it!=m_shbank.end(); it++) { - inst = it->second; - it->first; - if(!inst || !inst->GetItem()) - continue; - - printf("Slot %d: %s (%d)\n", it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); - - // Go through bag, if bag - if (inst && inst->IsType(ItemClassContainer)) { - - for (itb=inst->_begin(); itb!=inst->_end(); itb++) { - ItemInst* baginst = itb->second; - if(!baginst || !baginst->GetItem()) - continue; - printf(" Slot %d: %s (%d)\n", Inventory::CalcSlotId(it->first, itb->first), - baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); - - } - } - } - - printf("\n"); - fflush(stdout); + dumpWornItems(); + dumpInventory(); + dumpBankItems(); + dumpSharedBankItems(); + + std::cout << std::endl; } // Internal Method: Retrieves item within an inventory bucket diff --git a/common/Item.h b/common/Item.h index c5d43f25e..0c0ea81b9 100644 --- a/common/Item.h +++ b/common/Item.h @@ -196,7 +196,13 @@ public: // Test whether a given slot can support a container item static bool SupportsContainers(int16 slot_id); + void dumpItemCollection(const map &collection); + void dumpBagContents(ItemInst *inst); + void dumpEntireInventory(); + void dumpWornItems(); void dumpInventory(); + void dumpBankItems(); + void dumpSharedBankItems(); void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, std::string value); void SetCustomItemData(uint32 character_id, int16 slot_id, std::string identifier, int value); diff --git a/zone/client.cpp b/zone/client.cpp index 7b2460879..58219b697 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -597,7 +597,7 @@ bool Client::Save(uint8 iCommitNow) { p_timers.Store(&database); // printf("Dumping inventory on save:\n"); -// m_inv.dumpInventory(); +// m_inv.dumpEntireInventory(); SaveTaskState(); if (iCommitNow <= 1) { diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 11525537d..348ec7be2 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -9195,7 +9195,7 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) { #ifdef _EQDEBUG printf("Dumping inventory on load:\n"); - m_inv.dumpInventory(); + m_inv.dumpEntireInventory(); #endif //lost in current PP From 41dcd5bc2930e1568b162b18a4c440ed816ebcf8 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Tue, 21 May 2013 23:02:15 -0700 Subject: [PATCH 13/16] Should only need dumpItemCollection and dumpBagContents internally so made them protected. --- common/Item.cpp | 7 +++---- common/Item.h | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/Item.cpp b/common/Item.cpp index b8e3c4298..e93dd5202 100644 --- a/common/Item.cpp +++ b/common/Item.cpp @@ -1053,8 +1053,7 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo return SLOT_INVALID; } -void Inventory::dumpBagContents(ItemInst *inst) { - iter_inst it; +void Inventory::dumpBagContents(ItemInst *inst, iter_inst *it) { iter_contents itb; if (!inst || !inst->IsType(ItemClassContainer)) @@ -1067,7 +1066,7 @@ void Inventory::dumpBagContents(ItemInst *inst) { continue; std::string subSlot; - StringFormat(subSlot," Slot %d: %s (%d)", Inventory::CalcSlotId(it->first, itb->first), + StringFormat(subSlot," Slot %d: %s (%d)", Inventory::CalcSlotId((*it)->first, itb->first), baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); std::cout << subSlot << std::endl; } @@ -1089,7 +1088,7 @@ void Inventory::dumpItemCollection(const map &collection) { StringFormat(slot, "Slot %d: %s (%d)",it->first, it->second->GetItem()->Name, (inst->GetCharges()<=0) ? 1 : inst->GetCharges()); std::cout << slot << std::endl; - dumpBagContents(inst); + dumpBagContents(inst, &it); } } diff --git a/common/Item.h b/common/Item.h index 0c0ea81b9..b6703d81d 100644 --- a/common/Item.h +++ b/common/Item.h @@ -196,8 +196,6 @@ public: // Test whether a given slot can support a container item static bool SupportsContainers(int16 slot_id); - void dumpItemCollection(const map &collection); - void dumpBagContents(ItemInst *inst); void dumpEntireInventory(); void dumpWornItems(); void dumpInventory(); @@ -214,6 +212,9 @@ protected: // Protected Methods /////////////////////////////// + void dumpItemCollection(const map &collection); + void dumpBagContents(ItemInst *inst, iter_inst *it); + // Retrieves item within an inventory bucket ItemInst* _GetItem(const map& bucket, int16 slot_id) const; From ac78841e55957c765a75f95769d3446cd7635c8e Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 22 May 2013 19:41:16 -0700 Subject: [PATCH 14/16] Removed MakeUpperString since it's not used anywhere. --- common/StringUtil.cpp | 21 --------------------- common/StringUtil.h | 14 ++------------ 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/common/StringUtil.cpp b/common/StringUtil.cpp index b1269bf46..bba3433fb 100644 --- a/common/StringUtil.cpp +++ b/common/StringUtil.cpp @@ -126,27 +126,6 @@ bool strn0cpyt(char* dest, const char* source, uint32 size) { return (bool) (source[strlen(dest)] == 0); } -const char *MakeUpperString(const char *source) { - static char str[128]; - if (!source) - return nullptr; - MakeUpperString(source, str); - return str; -} - -void MakeUpperString(const char *source, char *target) { - if (!source || !target) { - *target=0; - return; - } - while (*source) - { - *target = toupper(*source); - target++;source++; - } - *target = 0; -} - const char *MakeLowerString(const char *source) { static char str[128]; if (!source) diff --git a/common/StringUtil.h b/common/StringUtil.h index 423201247..bbd9d43ba 100644 --- a/common/StringUtil.h +++ b/common/StringUtil.h @@ -23,19 +23,9 @@ void vStringFormat(std::string& output, const char* format, va_list args); void StringFormat(std::string& output, const char* format, ...); -////////////////////////////////////////////////////////////////////// -// -// MakeUpperString -// i : source - allocated null-terminated string -// return: pointer to static buffer with the target string -const char *MakeUpperString(const char *source); + const char *MakeLowerString(const char *source); -////////////////////////////////////////////////////////////////////// -// -// MakeUpperString -// i : source - allocated null-terminated string -// io: target - allocated buffer, at least of size strlen(source)+1 -void MakeUpperString(const char *source, char *target); + void MakeLowerString(const char *source, char *target); From b4e65a8840b37db943cbdeb2ec4f816054cea326 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 22 May 2013 19:52:48 -0700 Subject: [PATCH 15/16] tabbify and cleaned up std issues and min/max problems. --- common/EQStream.cpp | 40 ++++++++++++--------- common/Item.cpp | 31 +++++++++++++--- common/ProcLauncher.cpp | 30 +++++++++------- loginserver/Encryption.cpp | 4 ++- zone/attack.cpp | 12 +++---- zone/bot.cpp | 74 +++++++++++++++++++------------------- zone/botspellsai.cpp | 8 ++--- zone/client.h | 39 ++++++++++++-------- zone/client_mods.cpp | 10 +++--- zone/entity.h | 11 +++--- 10 files changed, 153 insertions(+), 106 deletions(-) diff --git a/common/EQStream.cpp b/common/EQStream.cpp index 1aaf39527..3f68d2d69 100644 --- a/common/EQStream.cpp +++ b/common/EQStream.cpp @@ -15,16 +15,36 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "debug.h" +#include "EQPacket.h" +#include "EQStream.h" +#include "misc.h" +#include "Mutex.h" +#include "op_codes.h" +#include "CRC16.h" + #include #include #include #include -#include -#include +#include + +#if defined(ZONE) || defined(WORLD) + #define RETRANSMITS +#endif +#ifdef RETRANSMITS + #include "rulesys.h" +#endif + #ifdef _WINDOWS #include + // have to undefine these since a macro version + // is defined in windef.h (which windows includes) + #undef min + #undef max #else + #include #include #include #include @@ -33,20 +53,6 @@ #include #include #endif -#include "EQPacket.h" -#include "EQStream.h" -//#include "EQStreamFactory.h" -#include "misc.h" -#include "Mutex.h" -#include "op_codes.h" -#include "CRC16.h" - -#if defined(ZONE) || defined(WORLD) - #define RETRANSMITS -#endif -#ifdef RETRANSMITS - #include "rulesys.h" -#endif //for logsys #define _L "%s:%d: " @@ -567,7 +573,7 @@ uint32 length; while (usedpBuffer+2,tmpbuff+used,chunksize); out->size=chunksize+2; SequencedPush(out); diff --git a/common/Item.cpp b/common/Item.cpp index 8ac1e21dc..3e798363e 100644 --- a/common/Item.cpp +++ b/common/Item.cpp @@ -16,10 +16,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include - #include "debug.h" #include "StringUtil.h" #include "Item.h" @@ -29,6 +25,11 @@ #include "shareddb.h" #include "classes.h" +#include + +#include +#include + int32 NextItemInstSerialNumber = 1; static inline int32 GetNextItemInstSerialNumber() { @@ -43,7 +44,7 @@ static inline int32 GetNextItemInstSerialNumber() { // NextItemInstSerialNumber is the next one to hand out. // // It is very unlikely to reach 2,147,483,647. Maybe we should call abort(), rather than wrapping back to 1. - if(NextItemInstSerialNumber >= std::numeric_limits::max()) + if(NextItemInstSerialNumber >= INT_MAX) NextItemInstSerialNumber = 1; else NextItemInstSerialNumber++; @@ -1051,6 +1052,26 @@ int16 Inventory::FindFreeSlot(bool for_bag, bool try_cursor, uint8 min_size, boo return SLOT_INVALID; } +void Inventory::dumpBagContents(ItemInst *inst, iter_inst *it) { + iter_contents itb; + + if (!inst || !inst->IsType(ItemClassContainer)) + return; + + // Go through bag, if bag + for (itb=inst->_begin(); itb!=inst->_end(); itb++) { + ItemInst* baginst = itb->second; + if(!baginst || !baginst->GetItem()) + continue; + + std::string subSlot; + StringFormat(subSlot," Slot %d: %s (%d)", Inventory::CalcSlotId((*it)->first, itb->first), + baginst->GetItem()->Name, (baginst->GetCharges()<=0) ? 1 : baginst->GetCharges()); + std::cout << subSlot << std::endl; + } + +} + void Inventory::dumpItemCollection(const std::map &collection) { iter_inst it; iter_contents itb; diff --git a/common/ProcLauncher.cpp b/common/ProcLauncher.cpp index d2db2f6d4..da0cd81e9 100644 --- a/common/ProcLauncher.cpp +++ b/common/ProcLauncher.cpp @@ -15,21 +15,25 @@ 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 + #include "debug.h" #include "ProcLauncher.h" #ifdef _WINDOWS -#include + #include #else -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include #endif ProcLauncher ProcLauncher::s_launcher; @@ -165,8 +169,8 @@ ProcLauncher::ProcRef ProcLauncher::Launch(Spec *&to_launch) { // Create the child process. //glue together all the nice command line arguments - string args(it->program); - vector::iterator cur, end; + std::string args(it->program); + std::vector::iterator cur, end; cur = it->args.begin(); end = it->args.end(); for(; cur != end; cur++) { diff --git a/loginserver/Encryption.cpp b/loginserver/Encryption.cpp index 129ab18e3..290325ffe 100644 --- a/loginserver/Encryption.cpp +++ b/loginserver/Encryption.cpp @@ -19,9 +19,11 @@ #include "Encryption.h" #include "ErrorLog.h" +#include + extern ErrorLog *server_log; -bool Encryption::LoadCrypto(string name) +bool Encryption::LoadCrypto(std::string name) { if(!Load(name.c_str())) { diff --git a/zone/attack.cpp b/zone/attack.cpp index e8c009efd..7d428d6f8 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -1476,7 +1476,7 @@ void Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ if (killerMob != nullptr) { if (killerMob->IsNPC()) { - parse->EventNPC(EVENT_SLAY, killerMob->CastToNPC(), this, "", 0); + parse->EventNPC(EVENT_SLAY, killerMob->CastToNPC(), this, "", 0); mod_client_death_npc(killerMob); @@ -2124,7 +2124,7 @@ void NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski /* Send the EVENT_KILLED_MERIT event for all raid members */ for (int i = 0; i < MAX_RAID_MEMBERS; i++) { if (kr->members[i].member != nullptr) { // If Group Member is Client - parse->EventNPC(EVENT_KILLED_MERIT, this, kr->members[i].member, "killed", 0); + parse->EventNPC(EVENT_KILLED_MERIT, this, kr->members[i].member, "killed", 0); mod_npc_killed_merit(kr->members[i].member); @@ -2167,7 +2167,7 @@ void NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski for (int i = 0; i < MAX_GROUP_MEMBERS; i++) { if (kg->members[i] != nullptr && kg->members[i]->IsClient()) { // If Group Member is Client Client *c = kg->members[i]->CastToClient(); - parse->EventNPC(EVENT_KILLED_MERIT, this, c, "killed", 0); + parse->EventNPC(EVENT_KILLED_MERIT, this, c, "killed", 0); mod_npc_killed_merit(c); @@ -2214,7 +2214,7 @@ void NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski } } /* Send the EVENT_KILLED_MERIT event */ - parse->EventNPC(EVENT_KILLED_MERIT, this, give_exp_client, "killed", 0); + parse->EventNPC(EVENT_KILLED_MERIT, this, give_exp_client, "killed", 0); mod_npc_killed_merit(give_exp_client); @@ -2347,7 +2347,7 @@ void NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski // Parse quests even if we're killed by an NPC if(killerMob) { Mob *oos = killerMob->GetOwnerOrSelf(); - parse->EventNPC(EVENT_DEATH, this, oos, "", 0); + parse->EventNPC(EVENT_DEATH, this, oos, "", 0); mod_npc_killed(oos); @@ -4234,7 +4234,7 @@ void Mob::ApplyMeleeDamageBonus(uint16 skill, int32 &damage){ if(!RuleB(Combat, UseIntervalAC)){ if(IsNPC()){ //across the board NPC damage bonuses. - //only account for STR here, assume their base STR was factored into their DB damages + //only account for STR here, assume their base STR was factored into their DB damages int dmgbonusmod = 0; dmgbonusmod += (100*(itembonuses.STR + spellbonuses.STR))/3; dmgbonusmod += (100*(spellbonuses.ATK + itembonuses.ATK))/5; diff --git a/zone/bot.cpp b/zone/bot.cpp index 2de1796eb..c88ad72b7 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -1576,7 +1576,7 @@ void Bot::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) return; } - for (map::const_iterator iter = aa_effects[aaid].begin(); iter != aa_effects[aaid].end(); ++iter) { + for (std::map::const_iterator iter = aa_effects[aaid].begin(); iter != aa_effects[aaid].end(); ++iter) { effect = iter->second.skill_id; base1 = iter->second.base1; base2 = iter->second.base2; @@ -4779,7 +4779,7 @@ void Bot::LoadAndSpawnAllZonedBots(Client* botOwner) { std::list ActiveBots = Bot::GetGroupedBotsByGroupId(botOwner->GetGroup()->GetID(), &errorMessage); if(errorMessage.empty() && !ActiveBots.empty()) { - for(list::iterator itr = ActiveBots.begin(); itr != ActiveBots.end(); itr++) { + for(std::list::iterator itr = ActiveBots.begin(); itr != ActiveBots.end(); itr++) { Bot* activeBot = Bot::LoadBot(*itr, &errorMessage); if(!errorMessage.empty()) { @@ -6701,7 +6701,7 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) return 0; } - for (map::const_iterator iter = aa_effects[aa_ID].begin(); iter != aa_effects[aa_ID].end(); ++iter) + for (std::map::const_iterator iter = aa_effects[aa_ID].begin(); iter != aa_effects[aa_ID].end(); ++iter) { effect = iter->second.skill_id; base1 = iter->second.base1; @@ -11136,7 +11136,7 @@ int32 Bot::CalcBaseEndurance() int BonusUpto800 = int( at_most_800 / 4 ) ; if(Stats > 400) { Bonus400to800 = int( (at_most_800 - 400) / 4 ); - HalfBonus400to800 = int( max( ( at_most_800 - 400 ), 0 ) / 8 ); + HalfBonus400to800 = int( std::max( ( at_most_800 - 400 ), 0 ) / 8 ); if(Stats > 800) { Bonus800plus = int( (Stats - 800) / 8 ) * 2; @@ -11598,7 +11598,7 @@ void Bot::ProcessClientZoneChange(Client* botOwner) { if(botOwner) { std::list BotList = entity_list.GetBotsByBotOwnerCharacterID(botOwner->CharacterID()); - for(list::iterator itr = BotList.begin(); itr != BotList.end(); itr++) { + for(std::list::iterator itr = BotList.begin(); itr != BotList.end(); itr++) { Bot* tempBot = *itr; if(tempBot) { @@ -12322,7 +12322,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(std::string(sep->arg[2]).compare("all") == 0) listAll = true; else { - string botName = std::string(sep->arg[2]); + std::string botName = std::string(sep->arg[2]); Bot* tempBot = entity_list.GetBotByBotName(botName); @@ -15981,12 +15981,12 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Bot* leaderBot = *botListItr; if(leaderBot->GetInHealRotation() && leaderBot->GetHealRotationLeader() == leaderBot) { //start all heal rotations - list rotationMemberList; + std::list rotationMemberList; int index = 0; rotationMemberList = GetBotsInHealRotation(leaderBot); - for(list::iterator rotationMemberItr = rotationMemberList.begin(); rotationMemberItr != rotationMemberList.end(); rotationMemberItr++) { + for(std::list::iterator rotationMemberItr = rotationMemberList.begin(); rotationMemberItr != rotationMemberList.end(); rotationMemberItr++) { Bot* tempBot = *rotationMemberItr; if(tempBot) { @@ -16014,7 +16014,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } if(leaderBot) { - list botList; + std::list botList; int index = 0; if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); @@ -16023,7 +16023,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { botList = GetBotsInHealRotation(leaderBot); - for(list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { + for(std::list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { Bot* tempBot = *botListItr; if(tempBot) { @@ -16058,11 +16058,11 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Bot* leaderBot = *botListItr; if(leaderBot->GetInHealRotation() && leaderBot->GetHealRotationLeader() == leaderBot) { //start all heal rotations - list rotationMemberList; + std::list rotationMemberList; rotationMemberList = GetBotsInHealRotation(leaderBot); - for(list::iterator rotationMemberItr = rotationMemberList.begin(); rotationMemberItr != rotationMemberList.end(); rotationMemberItr++) { + for(std::list::iterator rotationMemberItr = rotationMemberList.begin(); rotationMemberItr != rotationMemberList.end(); rotationMemberItr++) { Bot* tempBot = *rotationMemberItr; if(tempBot) { @@ -16087,7 +16087,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } if(leaderBot) { - list botList; + std::list botList; if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; @@ -16095,7 +16095,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { botList = GetBotsInHealRotation(leaderBot); - for(list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { + for(std::list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { Bot* tempBot = *botListItr; if(tempBot && tempBot->GetBotOwnerCharacterID() == c->CharacterID()) { @@ -16146,7 +16146,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } if(leaderBot) { - list botList; + std::list botList; if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; @@ -16158,7 +16158,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { c->Message(0, "Bot Heal Rotation- Leader: %s", leaderBot->GetCleanName()); c->Message(0, "Bot Heal Rotation- Timer: %1.1f", ((float)leaderBot->GetHealRotationTimer()/1000.0f)); - for(list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { + for(std::list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { Bot* tempBot = *botListItr; if(tempBot && tempBot->GetBotOwnerCharacterID() == c->CharacterID()) { @@ -16208,7 +16208,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } if(leaderBot) { - list botList; + std::list botList; if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; @@ -16216,7 +16216,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { botList = GetBotsInHealRotation(leaderBot); - for(list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { + for(std::list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { Bot* tempBot = *botListItr; if(tempBot && tempBot->GetBotOwnerCharacterID() == c->CharacterID()) @@ -16248,7 +16248,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(leaderBot) { bool fastHeals = false; - list botList; + std::list botList; if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; @@ -16264,7 +16264,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { botList = GetBotsInHealRotation(leaderBot); - for(list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { + for(std::list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { Bot* tempBot = *botListItr; if(tempBot && tempBot->GetBotOwnerCharacterID() == c->CharacterID()) @@ -16548,7 +16548,7 @@ Bot* EntityList::GetBotByBotID(uint32 botID) { Bot* Result = 0; if(botID > 0) { - for(list::iterator botListItr = bot_list.begin(); botListItr != bot_list.end(); botListItr++) { + for(std::list::iterator botListItr = bot_list.begin(); botListItr != bot_list.end(); botListItr++) { Bot* tempBot = *botListItr; if(tempBot && tempBot->GetBotID() == botID) { @@ -16565,7 +16565,7 @@ Bot* EntityList::GetBotByBotName(std::string botName) { Bot* Result = 0; if(!botName.empty()) { - for(list::iterator botListItr = bot_list.begin(); botListItr != bot_list.end(); botListItr++) { + for(std::list::iterator botListItr = bot_list.begin(); botListItr != bot_list.end(); botListItr++) { Bot* tempBot = *botListItr; if(tempBot && std::string(tempBot->GetName()) == botName) { @@ -16609,11 +16609,11 @@ void EntityList::AddBot(Bot *newBot, bool SendSpawnPacket, bool dontqueue) { } } -list EntityList::GetBotsByBotOwnerCharacterID(uint32 botOwnerCharacterID) { - list Result; +std::list EntityList::GetBotsByBotOwnerCharacterID(uint32 botOwnerCharacterID) { + std::list Result; if(botOwnerCharacterID > 0) { - for(list::iterator botListItr = bot_list.begin(); botListItr != bot_list.end(); botListItr++) { + for(std::list::iterator botListItr = bot_list.begin(); botListItr != bot_list.end(); botListItr++) { Bot* tempBot = *botListItr; if(tempBot && tempBot->GetBotOwnerCharacterID() == botOwnerCharacterID) @@ -16676,7 +16676,7 @@ bool EntityList::RemoveBot(uint16 entityID) { bool Result = false; if(entityID > 0) { - for(list::iterator botListItr = bot_list.begin(); botListItr != bot_list.end(); botListItr++) + for(std::list::iterator botListItr = bot_list.begin(); botListItr != bot_list.end(); botListItr++) { Bot* tempBot = *botListItr; @@ -16695,7 +16695,7 @@ void EntityList::ShowSpawnWindow(Client* client, int Distance, bool NamedOnly) { const char *WindowTitle = "Bot Tracking Window"; - string WindowText; + std::string WindowText; int LastCon = -1; int CurrentCon = 0; @@ -17228,9 +17228,9 @@ bool Bot::AddHealRotationMember( Bot* healer ) { //update leader's previous member (end of list) to new member and update rotation data SetPrevHealRotationMember(healer); - list botList = GetBotsInHealRotation(this); + std::list botList = GetBotsInHealRotation(this); - for(list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { + for(std::list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { Bot* tempBot = *botListItr; if(tempBot) @@ -17276,9 +17276,9 @@ bool Bot::RemoveHealRotationMember( Bot* healer ) { } //update rotation data - list botList = GetBotsInHealRotation(leader); + std::list botList = GetBotsInHealRotation(leader); - for(list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { + for(std::list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { Bot* tempBot = *botListItr; if(tempBot) { @@ -17349,11 +17349,11 @@ bool Bot::AddHealRotationTarget( Mob* target ) { if (_healRotationTargets[i] == 0) { - list botList = GetBotsInHealRotation(this); + std::list botList = GetBotsInHealRotation(this); _healRotationTargets[i] = target->GetID(); - for(list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { + for(std::list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { Bot* tempBot = *botListItr; if(tempBot && tempBot != this) { @@ -17386,12 +17386,12 @@ bool Bot::RemoveHealRotationTarget( Mob* target ) { //notify all heal rotation members to remove target for(int i=0; iGetID()) { - list botList = GetBotsInHealRotation(this); + std::list botList = GetBotsInHealRotation(this); _healRotationTargets[i] = 0; index = i; removed = true; - for(list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { + for(std::list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { Bot* tempBot = *botListItr; if(tempBot) @@ -17499,8 +17499,8 @@ Mob* Bot::GetHealRotationTarget( uint8 index ) { return target; } -list Bot::GetBotsInHealRotation(Bot* rotationLeader) { - list Result; +std::list Bot::GetBotsInHealRotation(Bot* rotationLeader) { + std::list Result; if(rotationLeader != nullptr) { Result.push_back(rotationLeader); diff --git a/zone/botspellsai.cpp b/zone/botspellsai.cpp index 58d94d03b..10d3fa7af 100644 --- a/zone/botspellsai.cpp +++ b/zone/botspellsai.cpp @@ -559,7 +559,7 @@ bool Bot::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) { std::list inCombatBuffList = GetBotSpellsBySpellType(this, SpellType_InCombatBuff); - for(list::iterator itr = inCombatBuffList.begin(); itr != inCombatBuffList.end(); itr++) { + for(std::list::iterator itr = inCombatBuffList.begin(); itr != inCombatBuffList.end(); itr++) { BotSpell selectedBotSpell = *itr; if(selectedBotSpell.SpellId == 0) @@ -646,7 +646,7 @@ bool Bot::AICastSpell(Mob* tar, uint8 iChance, uint16 iSpellTypes) { const int maxDotSelect = 5; int dotSelectCounter = 0; - for(list::iterator itr = dotList.begin(); itr != dotList.end(); itr++) { + for(std::list::iterator itr = dotList.begin(); itr != dotList.end(); itr++) { BotSpell selectedBotSpell = *itr; if(selectedBotSpell.SpellId == 0) @@ -2049,7 +2049,7 @@ BotSpell Bot::GetBestBotSpellForCure(Bot* botCaster, Mob *tar) { //Check for group cure first if(countNeedsCured > 2) { - for(list::iterator itr = cureList.begin(); itr != cureList.end(); itr++) { + for(std::list::iterator itr = cureList.begin(); itr != cureList.end(); itr++) { BotSpell selectedBotSpell = *itr; if(IsGroupSpell(itr->SpellId) && CheckSpellRecastTimers(botCaster, itr->SpellIndex)) { @@ -2086,7 +2086,7 @@ BotSpell Bot::GetBestBotSpellForCure(Bot* botCaster, Mob *tar) { //no group cure for target- try to find single target spell if(!spellSelected) { - for(list::iterator itr = cureList.begin(); itr != cureList.end(); itr++) { + for(std::list::iterator itr = cureList.begin(); itr != cureList.end(); itr++) { BotSpell selectedBotSpell = *itr; if(CheckSpellRecastTimers(botCaster, itr->SpellIndex)) { diff --git a/zone/client.h b/zone/client.h index 21005949c..2a51bdca2 100644 --- a/zone/client.h +++ b/zone/client.h @@ -28,27 +28,38 @@ class Client; #include "../common/EQPacket.h" #include "../common/linked_list.h" #include "../common/extprofile.h" -#include "zonedb.h" -#include "errno.h" #include "../common/classes.h" #include "../common/races.h" #include "../common/deity.h" +#include "../common/seperator.h" +#include "../common/Item.h" +#include "../common/guilds.h" +#include "../common/item_struct.h" +#include "../common/clientversions.h" + +#include "zonedb.h" +#include "errno.h" #include "mob.h" #include "npc.h" #include "merc.h" #include "zone.h" #include "AA.h" -#include "../common/seperator.h" -#include "../common/Item.h" #include "updatemgr.h" -#include "../common/guilds.h" #include "questmgr.h" +#include "QGlobals.h" + +#ifdef _WINDOWS + // since windows defines these within windef.h (which windows.h include) + // we are required to undefine these to use min and max from + #undef min + #undef max +#endif + #include #include #include -#include "../common/item_struct.h" -#include "../common/clientversions.h" -#include "QGlobals.h" +#include + #define CLIENT_TIMEOUT 90000 #define CLIENT_LD_TIMEOUT 30000 // length of time client stays in zone after LDing @@ -1101,7 +1112,7 @@ public: void DuplicateLoreMessage(uint32 ItemID); void GarbleMessage(char *, uint8); - void TickItemCheck(); + void TickItemCheck(); void TryItemTick(int slot); int16 GetActSTR() { return( std::min(GetMaxSTR(), GetSTR()) ); } int16 GetActSTA() { return( std::min(GetMaxSTA(), GetSTA()) ); } @@ -1110,9 +1121,9 @@ public: int16 GetActINT() { return( std::min(GetMaxINT(), GetINT()) ); } int16 GetActWIS() { return( std::min(GetMaxWIS(), GetWIS()) ); } int16 GetActCHA() { return( std::min(GetMaxCHA(), GetCHA()) ); } - void LoadAccountFlags(); - void SetAccountFlag(std::string flag, std::string val); - std::string GetAccountFlag(std::string flag); float GetDamageMultiplier(SkillType); + void LoadAccountFlags(); + void SetAccountFlag(std::string flag, std::string val); + std::string GetAccountFlag(std::string flag); float GetDamageMultiplier(SkillType); int mod_client_damage(int damage, SkillType skillinuse, int hand, ItemInst* weapon, Mob* other); bool mod_client_message(char* message, uint8 chan_num); bool mod_can_increase_skill(SkillType skillid, Mob* against_who); @@ -1431,9 +1442,9 @@ private: uint8 MaxXTargets; bool XTargetAutoAddHaters; - struct XTarget_Struct XTargets[XTARGET_HARDCAP]; + struct XTarget_Struct XTargets[XTARGET_HARDCAP]; - Timer ItemTickTimer; + Timer ItemTickTimer; std::map accountflags; }; diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index 5ed426789..73774ca6b 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -15,19 +15,21 @@ 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 "../common/debug.h" -#include "masterentity.h" -#include "worldserver.h" -#include "zonedb.h" #include "../common/spdat.h" #include "../common/packet_dump.h" #include "../common/packet_functions.h" -#include "petitions.h" #include "../common/serverinfo.h" #include "../common/ZoneNumbers.h" #include "../common/moremath.h" #include "../common/guilds.h" #include "../common/logsys.h" +#include "masterentity.h" +#include "worldserver.h" +#include "zonedb.h" +#include "petitions.h" #include "StringIDs.h" #include "NpcAI.h" diff --git a/zone/entity.h b/zone/entity.h index 812d229bb..9d25ceeeb 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -20,12 +20,13 @@ #include "../common/types.h" #include "../common/linked_list.h" -#include "zonedb.h" -#include "../common/eq_constants.h" -#include "zonedump.h" -#include "zonedbasync.h" #include "../common/servertalk.h" #include "../common/bodytypes.h" +#include "../common/eq_constants.h" + +#include "zonedb.h" +#include "zonedump.h" +#include "zonedbasync.h" #include "QGlobals.h" // max number of newspawns to send per bulk packet @@ -441,7 +442,7 @@ private: Mob* GetMobByBotID(uint32 botID); Bot* GetBotByBotID(uint32 botID); Bot* GetBotByBotName(std::string botName); - list GetBotsByBotOwnerCharacterID(uint32 botOwnerCharacterID); + std::list GetBotsByBotOwnerCharacterID(uint32 botOwnerCharacterID); bool Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, float iRange, uint16 iSpellTypes); // TODO: Evaluate this closesly in hopes to eliminate void ShowSpawnWindow(Client* client, int Distance, bool NamedOnly); // TODO: Implement ShowSpawnWindow in the bot class but it needs entity list stuff From e5d4b35a323fc951abc54cc28bedc03037f3b419 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Wed, 22 May 2013 22:21:28 -0700 Subject: [PATCH 16/16] Spelling fix in a comment. Nothing else. --- common/database.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/database.h b/common/database.h index 22474a807..b194476b8 100644 --- a/common/database.h +++ b/common/database.h @@ -216,7 +216,7 @@ public: const char *GetRaidLeaderName(uint32 rid); /* - * Database Varaibles + * Database Variables */ bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len); bool SetVariable(const char* varname, const char* varvalue);