From f51f6e00c4de23859c4e1ec5bfb468d847ff8254 Mon Sep 17 00:00:00 2001 From: j883376 Date: Wed, 15 May 2013 17:04:08 -0400 Subject: [PATCH 01/20] Add install paths to CMakeLists --- eqlaunch/CMakeLists.txt | 2 ++ loginserver/CMakeLists.txt | 2 ++ queryserv/CMakeLists.txt | 2 ++ shared_memory/CMakeLists.txt | 2 ++ ucs/CMakeLists.txt | 2 ++ world/CMakeLists.txt | 2 ++ zone/CMakeLists.txt | 2 ++ 7 files changed, 14 insertions(+) diff --git a/eqlaunch/CMakeLists.txt b/eqlaunch/CMakeLists.txt index 6097279d2..097662b03 100644 --- a/eqlaunch/CMakeLists.txt +++ b/eqlaunch/CMakeLists.txt @@ -13,6 +13,8 @@ SET(eqlaunch_headers ADD_EXECUTABLE(eqlaunch ${eqlaunch_sources} ${eqlaunch_headers}) +INSTALL(TARGETS eqlaunch RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) + TARGET_LINK_LIBRARIES(eqlaunch Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) IF(MSVC) diff --git a/loginserver/CMakeLists.txt b/loginserver/CMakeLists.txt index fd13b8041..b9a3e08c7 100644 --- a/loginserver/CMakeLists.txt +++ b/loginserver/CMakeLists.txt @@ -40,6 +40,8 @@ ENDIF(UNIX) ADD_EXECUTABLE(loginserver ${eqlogin_sources} ${eqlogin_headers}) +INSTALL(TARGETS loginserver RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) + TARGET_LINK_LIBRARIES(loginserver Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE}) IF(MSVC) diff --git a/queryserv/CMakeLists.txt b/queryserv/CMakeLists.txt index dca29b2cf..095f397e4 100644 --- a/queryserv/CMakeLists.txt +++ b/queryserv/CMakeLists.txt @@ -17,6 +17,8 @@ SET(qserv_headers ADD_EXECUTABLE(queryserv ${qserv_sources} ${qserv_headers}) +INSTALL(TARGETS queryserv RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) + ADD_DEFINITIONS(-DQSERV) TARGET_LINK_LIBRARIES(queryserv Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) diff --git a/shared_memory/CMakeLists.txt b/shared_memory/CMakeLists.txt index 2c665443c..01f79ec06 100644 --- a/shared_memory/CMakeLists.txt +++ b/shared_memory/CMakeLists.txt @@ -19,6 +19,8 @@ SET(shared_memory_headers ADD_EXECUTABLE(shared_memory ${shared_memory_sources} ${shared_memory_headers}) +INSTALL(TARGETS shared_memory RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) + TARGET_LINK_LIBRARIES(shared_memory Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) IF(MSVC) diff --git a/ucs/CMakeLists.txt b/ucs/CMakeLists.txt index 30af23655..d3fb50274 100644 --- a/ucs/CMakeLists.txt +++ b/ucs/CMakeLists.txt @@ -19,6 +19,8 @@ SET(ucs_headers ADD_EXECUTABLE(ucs ${ucs_sources} ${ucs_headers}) +INSTALL(TARGETS ucs RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) + ADD_DEFINITIONS(-DUCS) TARGET_LINK_LIBRARIES(ucs Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) diff --git a/world/CMakeLists.txt b/world/CMakeLists.txt index 1586ca49c..2e299d413 100644 --- a/world/CMakeLists.txt +++ b/world/CMakeLists.txt @@ -65,6 +65,8 @@ SET(world_headers ADD_EXECUTABLE(world ${world_sources} ${world_headers}) +INSTALL(TARGETS world RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) + ADD_DEFINITIONS(-DWORLD) TARGET_LINK_LIBRARIES(world Common ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) diff --git a/zone/CMakeLists.txt b/zone/CMakeLists.txt index 2e459e33e..ccba19144 100644 --- a/zone/CMakeLists.txt +++ b/zone/CMakeLists.txt @@ -154,6 +154,8 @@ SET(zone_headers ADD_EXECUTABLE(zone ${zone_sources} ${zone_headers}) +INSTALL(TARGETS zone RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}) + ADD_DEFINITIONS(-DZONE) TARGET_LINK_LIBRARIES(zone Common ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) From 7b0de551e1a28bee263ac3acc5db83d355bf07c1 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Mon, 20 May 2013 22:13:19 -0700 Subject: [PATCH 02/20] 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 03/20] 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 04/20] 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 05/20] 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 06/20] 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 07/20] 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 08/20] 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 09/20] 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 10/20] 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 11/20] 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 12/20] 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 13/20] 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 14/20] 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 15/20] 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 16/20] 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 17/20] 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); From d6ff01d63c005948bc24fc8ed4389f1b681083a6 Mon Sep 17 00:00:00 2001 From: j883376 Date: Thu, 23 May 2013 20:22:42 -0400 Subject: [PATCH 18/20] Fix several GCC warnings --- common/EQStream.cpp | 3 +++ common/MiscFunctions.h | 2 +- common/eqemu_exception.h | 6 ++--- common/rdtsc.cpp | 2 +- common/servertalk.h | 2 +- common/shareddb.cpp | 4 ++-- common/shareddb.h | 2 +- ucs/clientlist.cpp | 8 +++---- world/AdventureManager.cpp | 48 +++++++++++++++++++------------------- world/client.cpp | 4 ++-- zone/attack.cpp | 2 +- zone/client.cpp | 2 ++ zone/client_logs.cpp | 2 +- zone/client_packet.cpp | 25 ++++++++++---------- zone/command.cpp | 12 ++++++---- zone/embparser.cpp | 4 ++-- zone/entity.cpp | 2 ++ zone/merc.cpp | 4 ++-- zone/mob.cpp | 8 +++---- zone/mob.h | 17 +++++++------- zone/npc.cpp | 4 ++-- zone/spawngroup.cpp | 2 +- zone/special_attacks.cpp | 9 ++++--- zone/spell_effects.cpp | 5 ++-- zone/tasks.cpp | 9 +++---- zone/trading.cpp | 4 ++-- zone/zoning.cpp | 4 ++++ 27 files changed, 106 insertions(+), 90 deletions(-) diff --git a/common/EQStream.cpp b/common/EQStream.cpp index 2b8b2488c..5bfb53641 100644 --- a/common/EQStream.cpp +++ b/common/EQStream.cpp @@ -1356,6 +1356,9 @@ void EQStream::CheckTimeout(uint32 now, uint32 timeout) { _log(NET__DEBUG, _L "Timeout expired in established state. Closing connection." __L); _SendDisconnect(); SetState(DISCONNECTING); + break; + default: + break; } } } diff --git a/common/MiscFunctions.h b/common/MiscFunctions.h index d25a57dab..acbeacaa6 100644 --- a/common/MiscFunctions.h +++ b/common/MiscFunctions.h @@ -34,7 +34,7 @@ // #define VARSTRUCT_DECODE_TYPE(Type, Buffer) *(Type *)Buffer; Buffer += sizeof(Type); #define VARSTRUCT_DECODE_STRING(String, Buffer) strcpy(String, Buffer); Buffer += strlen(String)+1; -#define VARSTRUCT_ENCODE_STRING(Buffer, String) { sprintf(Buffer, String); Buffer += strlen(String) + 1; } +#define VARSTRUCT_ENCODE_STRING(Buffer, String) { sprintf(Buffer, "%s", String); Buffer += strlen(String) + 1; } #define VARSTRUCT_ENCODE_INTSTRING(Buffer, Number) { sprintf(Buffer, "%i", Number); Buffer += strlen(Buffer) + 1; } #define VARSTRUCT_ENCODE_TYPE(Type, Buffer, Value) { *(Type *)Buffer = Value; Buffer += sizeof(Type); } #define VARSTRUCT_SKIP_TYPE(Type, Buffer) Buffer += sizeof(Type); diff --git a/common/eqemu_exception.h b/common/eqemu_exception.h index 85086d1ad..1e888da85 100644 --- a/common/eqemu_exception.h +++ b/common/eqemu_exception.h @@ -95,11 +95,11 @@ namespace EQEmu */ const char* what() const throw() { return full_description().c_str(); } protected: - std::string name_; //!< Exception name - std::string desc_; //!< Exception Description mutable std::string full_desc_; //!< Full Exception Description - std::string file_; //!< File Name long line_; // *items_hash; EQEmu::MemoryMappedFile *faction_mmf; @@ -120,7 +121,6 @@ protected: EQEmu::FixedMemoryVariableHashSet *loot_table_hash; EQEmu::MemoryMappedFile *loot_drop_mmf; EQEmu::FixedMemoryVariableHashSet *loot_drop_hash; - EQEmu::MemoryMappedFile *skill_caps_mmf; }; #endif /*SHAREDDB_H_*/ diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp index 4c57190c8..aca14cd60 100644 --- a/ucs/clientlist.cpp +++ b/ucs/clientlist.cpp @@ -353,9 +353,6 @@ static void ProcessMailTo(Client *c, string MailMessage) { } } -static void ProcessMailTo(Client *c, string from, string subject, string message) { -} - static void ProcessSetMessageStatus(string SetMessageCommand) { int MessageNumber; @@ -1332,6 +1329,7 @@ void Client::SendChannelMessage(string Message) } if(RequiredChannel) + { if(RuleB(Chat, EnableAntiSpam)) { if(!RequiredChannel->IsModerated() || RequiredChannel->HasVoice(GetName()) || RequiredChannel->IsOwner(GetName()) || @@ -1386,6 +1384,7 @@ void Client::SendChannelMessage(string Message) else GeneralChannelMessage("Channel " + ChannelName + " is moderated and you have not been granted a voice."); } + } } @@ -1885,11 +1884,12 @@ void Client::ChannelModerate(string CommandString) { RequiredChannel->SetModerated(!RequiredChannel->IsModerated()); - if(!RequiredChannel->IsClientInChannel(this)) + if(!RequiredChannel->IsClientInChannel(this)) { if(RequiredChannel->IsModerated()) GeneralChannelMessage("Channel " + ChannelName + " is now moderated."); else GeneralChannelMessage("Channel " + ChannelName + " is no longer moderated."); + } } diff --git a/world/AdventureManager.cpp b/world/AdventureManager.cpp index 4a8321a4d..8c389d185 100644 --- a/world/AdventureManager.cpp +++ b/world/AdventureManager.cpp @@ -1279,8 +1279,8 @@ void AdventureManager::DoLeaderboardRequestWins(const char* player) strcpy((char*)pack->pBuffer, player); int place = -1; - int our_successes; - int our_failures; + int our_successes = 0; + int our_failures = 0; int i = 0; list::iterator iter = leaderboard_info_wins.begin(); while(i < 100 && iter != leaderboard_info_wins.end()) @@ -1346,8 +1346,8 @@ void AdventureManager::DoLeaderboardRequestPercentage(const char* player) strcpy((char*)pack->pBuffer, player); int place = -1; - int our_successes; - int our_failures; + int our_successes = 0; + int our_failures = 0; int i = 0; list::iterator iter = leaderboard_info_percentage.begin(); while(i < 100 && iter != leaderboard_info_percentage.end()) @@ -1413,8 +1413,8 @@ void AdventureManager::DoLeaderboardRequestWinsGuk(const char* player) strcpy((char*)pack->pBuffer, player); int place = -1; - int our_successes; - int our_failures; + int our_successes = 0; + int our_failures = 0; int i = 0; list::iterator iter = leaderboard_info_wins_guk.begin(); while(i < 100 && iter != leaderboard_info_wins_guk.end()) @@ -1480,8 +1480,8 @@ void AdventureManager::DoLeaderboardRequestPercentageGuk(const char* player) strcpy((char*)pack->pBuffer, player); int place = -1; - int our_successes; - int our_failures; + int our_successes = 0; + int our_failures = 0; int i = 0; list::iterator iter = leaderboard_info_percentage_guk.begin(); while(i < 100 && iter != leaderboard_info_percentage_guk.end()) @@ -1547,8 +1547,8 @@ void AdventureManager::DoLeaderboardRequestWinsMir(const char* player) strcpy((char*)pack->pBuffer, player); int place = -1; - int our_successes; - int our_failures; + int our_successes = 0; + int our_failures = 0; int i = 0; list::iterator iter = leaderboard_info_wins_mir.begin(); while(i < 100 && iter != leaderboard_info_wins_mir.end()) @@ -1614,8 +1614,8 @@ void AdventureManager::DoLeaderboardRequestPercentageMir(const char* player) strcpy((char*)pack->pBuffer, player); int place = -1; - int our_successes; - int our_failures; + int our_successes = 0; + int our_failures = 0; int i = 0; list::iterator iter = leaderboard_info_percentage_mir.begin(); while(i < 100 && iter != leaderboard_info_percentage_mir.end()) @@ -1681,8 +1681,8 @@ void AdventureManager::DoLeaderboardRequestWinsMmc(const char* player) strcpy((char*)pack->pBuffer, player); int place = -1; - int our_successes; - int our_failures; + int our_successes = 0; + int our_failures = 0; int i = 0; list::iterator iter = leaderboard_info_wins_mmc.begin(); while(i < 100 && iter != leaderboard_info_wins_mmc.end()) @@ -1748,8 +1748,8 @@ void AdventureManager::DoLeaderboardRequestPercentageMmc(const char* player) strcpy((char*)pack->pBuffer, player); int place = -1; - int our_successes; - int our_failures; + int our_successes = 0; + int our_failures = 0; int i = 0; list::iterator iter = leaderboard_info_percentage_mmc.begin(); while(i < 100 && iter != leaderboard_info_percentage_mmc.end()) @@ -1815,8 +1815,8 @@ void AdventureManager::DoLeaderboardRequestWinsRuj(const char* player) strcpy((char*)pack->pBuffer, player); int place = -1; - int our_successes; - int our_failures; + int our_successes = 0; + int our_failures = 0; int i = 0; list::iterator iter = leaderboard_info_wins_ruj.begin(); while(i < 100 && iter != leaderboard_info_wins_ruj.end()) @@ -1882,8 +1882,8 @@ void AdventureManager::DoLeaderboardRequestPercentageRuj(const char* player) strcpy((char*)pack->pBuffer, player); int place = -1; - int our_successes; - int our_failures; + int our_successes = 0; + int our_failures = 0; int i = 0; list::iterator iter = leaderboard_info_percentage_ruj.begin(); while(i < 100 && iter != leaderboard_info_percentage_ruj.end()) @@ -1949,8 +1949,8 @@ void AdventureManager::DoLeaderboardRequestWinsTak(const char* player) strcpy((char*)pack->pBuffer, player); int place = -1; - int our_successes; - int our_failures; + int our_successes = 0; + int our_failures = 0; int i = 0; list::iterator iter = leaderboard_info_wins_ruj.begin(); while(i < 100 && iter != leaderboard_info_wins_ruj.end()) @@ -2016,8 +2016,8 @@ void AdventureManager::DoLeaderboardRequestPercentageTak(const char* player) strcpy((char*)pack->pBuffer, player); int place = -1; - int our_successes; - int our_failures; + int our_successes = 0; + int our_failures = 0; int i = 0; list::iterator iter = leaderboard_info_percentage_tak.begin(); while(i < 100 && iter != leaderboard_info_percentage_tak.end()) diff --git a/world/client.cpp b/world/client.cpp index 12dd7180d..daa041a8b 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -257,7 +257,7 @@ void Client::SendMembershipSettings() { Membership_Details_Struct* mds = (Membership_Details_Struct*)outapp->pBuffer; mds->membership_setting_count = 66; - uint32 gold_settings[22] = {-1,-1,-1,-1,-1,-1,1,1,1,-1,1,-1,-1,1,1,1,1,1,1,-1,-1,0}; + int32 gold_settings[22] = {-1,-1,-1,-1,-1,-1,1,1,1,-1,1,-1,-1,1,1,1,1,1,1,-1,-1,0}; uint32 entry_count = 0; for (int setting_id=0; setting_id < 22; setting_id++) { @@ -1583,7 +1583,7 @@ bool CheckCharCreateInfoSoF(CharCreate_Struct *cc) uint32 max_stats = 0; uint32 allocs = character_create_allocations.size(); - RaceClassAllocation allocation; + RaceClassAllocation allocation = {0}; found = false; for(int i = 0; i < combos; ++i) { if(character_create_allocations[i].Index == class_combo.AllocationIndex) { diff --git a/zone/attack.cpp b/zone/attack.cpp index c08382838..730af11f6 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -1425,7 +1425,7 @@ void Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ if(dead) return; //cant die more than once... - int exploss; + int exploss = 0; mlog(COMBAT__HITS, "Fatal blow dealt by %s with %d damage, spell %d, skill %d", killerMob ? killerMob->GetName() : "Unknown", damage, spell, attack_skill); diff --git a/zone/client.cpp b/zone/client.cpp index 8f16956aa..2cf30eae6 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -7383,10 +7383,12 @@ FACTION_VALUE Client::GetFactionLevel(uint32 char_id, uint32 npc_id, uint32 p_ra if (IsInvisible(tnpc)) return FACTION_INDIFFERENT; if (tnpc && tnpc->GetOwnerID() != 0) // pets con amiably to owner and indiff to rest + { if (char_id == tnpc->GetOwner()->CastToClient()->CharacterID()) return FACTION_AMIABLE; else return FACTION_INDIFFERENT; + } //First get the NPC's Primary faction if(pFaction > 0) diff --git a/zone/client_logs.cpp b/zone/client_logs.cpp index 987a2ad24..e39f64190 100644 --- a/zone/client_logs.cpp +++ b/zone/client_logs.cpp @@ -128,7 +128,7 @@ void ClientLogs::EQEmuIO_pva(EQEMuLog::LogIDs id, const char *prefix, const char if(fmt[0] == '\n' || fmt[0] == '\r') return; //skip new lines... char *buf = _buffer; - int plen = snprintf(buf, MAX_CLIENT_LOG_MESSAGE_LENGTH, prefix); + int plen = snprintf(buf, MAX_CLIENT_LOG_MESSAGE_LENGTH, "%s", prefix); buf += plen; vsnprintf(buf, MAX_CLIENT_LOG_MESSAGE_LENGTH-plen, fmt, ap); _buffer[MAX_CLIENT_LOG_MESSAGE_LENGTH] = '\0'; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 427e624cf..bbe003238 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -3905,7 +3905,7 @@ void Client::Handle_OP_LDoNInspect(const EQApplicationPacket *app) void Client::Handle_OP_Dye(const EQApplicationPacket *app) { if(app->size!=sizeof(DyeStruct)) - printf("Wrong size of DyeStruct, Got: %i, Expected: %lu\n",app->size,sizeof(DyeStruct)); + printf("Wrong size of DyeStruct, Got: %i, Expected: %i\n",app->size,sizeof(DyeStruct)); else{ DyeStruct* dye = (DyeStruct*)app->pBuffer; DyeArmor(dye); @@ -3976,7 +3976,7 @@ void Client::Handle_OP_GuildPublicNote(const EQApplicationPacket *app) if (app->size < sizeof(GuildUpdate_PublicNote)) { // client calls for a motd on login even if they arent in a guild - printf("Error: app size of %i < size of OP_GuildPublicNote of %lu\n",app->size,sizeof(GuildUpdate_PublicNote)); + printf("Error: app size of %i < size of OP_GuildPublicNote of %i\n",app->size,sizeof(GuildUpdate_PublicNote)); return; } GuildUpdate_PublicNote* gpn=(GuildUpdate_PublicNote*)app->pBuffer; @@ -4034,7 +4034,7 @@ void Client::Handle_OP_SetGuildMOTD(const EQApplicationPacket *app) if (app->size != sizeof(GuildMOTD_Struct)) { // client calls for a motd on login even if they arent in a guild - printf("Error: app size of %i != size of GuildMOTD_Struct of %lu\n",app->size,sizeof(GuildMOTD_Struct)); + printf("Error: app size of %i != size of GuildMOTD_Struct of %i\n",app->size,sizeof(GuildMOTD_Struct)); return; } if(!IsInAGuild()) { @@ -5013,7 +5013,7 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) EQApplicationPacket* outapp = new EQApplicationPacket(OP_FinishTrade, 0); QueuePacket(outapp); safe_delete(outapp); - if(with->IsNPC()) + if(with->IsNPC()) { // Audit trade to database for player trade stream if(RuleB(QueryServ, PlayerLogHandins)) { uint16 handin_count = 0; @@ -5033,6 +5033,7 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) else { FinishTrade(with->CastToNPC()); } + } #ifdef BOTS else if(with->IsBot()) with->CastToBot()->FinishTrade(this, Bot::BotTradeClientNormal); @@ -6941,7 +6942,7 @@ void Client::Handle_OP_DeleteSpell(const EQApplicationPacket *app) void Client::Handle_OP_LoadSpellSet(const EQApplicationPacket *app) { if(app->size!=sizeof(LoadSpellSet_Struct)) { - printf("Wrong size of LoadSpellSet_Struct! Expected: %lu, Got: %i\n",sizeof(LoadSpellSet_Struct),app->size); + printf("Wrong size of LoadSpellSet_Struct! Expected: %i, Got: %i\n",sizeof(LoadSpellSet_Struct),app->size); return; } int i; @@ -6956,7 +6957,7 @@ void Client::Handle_OP_LoadSpellSet(const EQApplicationPacket *app) void Client::Handle_OP_PetitionBug(const EQApplicationPacket *app) { if(app->size!=sizeof(PetitionBug_Struct)) - printf("Wrong size of BugStruct! Expected: %lu, Got: %i\n",sizeof(PetitionBug_Struct),app->size); + printf("Wrong size of BugStruct! Expected: %i, Got: %i\n",sizeof(PetitionBug_Struct),app->size); else{ Message(0, "Petition Bugs are not supported, please use /bug."); } @@ -6966,7 +6967,7 @@ void Client::Handle_OP_PetitionBug(const EQApplicationPacket *app) void Client::Handle_OP_Bug(const EQApplicationPacket *app) { if(app->size!=sizeof(BugStruct)) - printf("Wrong size of BugStruct got %d expected %lu!\n", app->size, sizeof(BugStruct)); + printf("Wrong size of BugStruct got %d expected %i!\n", app->size, sizeof(BugStruct)); else{ BugStruct* bug=(BugStruct*)app->pBuffer; database.UpdateBug(bug); @@ -8362,7 +8363,7 @@ void Client::Handle_OP_OpenTributeMaster(const EQApplicationPacket *app) _pkt(TRIBUTE__IN, app); if(app->size != sizeof(StartTribute_Struct)) - printf("Error in OP_OpenTributeMaster. Expected size of: %lu, but got: %i\n",sizeof(StartTribute_Struct),app->size); + printf("Error in OP_OpenTributeMaster. Expected size of: %i, but got: %i\n",sizeof(StartTribute_Struct),app->size); else { //Opens the tribute master window StartTribute_Struct* st = (StartTribute_Struct*)app->pBuffer; @@ -8387,7 +8388,7 @@ void Client::Handle_OP_OpenGuildTributeMaster(const EQApplicationPacket *app) _pkt(TRIBUTE__IN, app); if(app->size != sizeof(StartTribute_Struct)) - printf("Error in OP_OpenGuildTributeMaster. Expected size of: %lu, but got: %i\n",sizeof(StartTribute_Struct),app->size); + printf("Error in OP_OpenGuildTributeMaster. Expected size of: %i, but got: %i\n",sizeof(StartTribute_Struct),app->size); else { //Opens the guild tribute master window StartTribute_Struct* st = (StartTribute_Struct*)app->pBuffer; @@ -8413,7 +8414,7 @@ void Client::Handle_OP_TributeItem(const EQApplicationPacket *app) //player donates an item... if(app->size != sizeof(TributeItem_Struct)) - printf("Error in OP_TributeItem. Expected size of: %lu, but got: %i\n",sizeof(StartTribute_Struct),app->size); + printf("Error in OP_TributeItem. Expected size of: %i, but got: %i\n",sizeof(StartTribute_Struct),app->size); else { TributeItem_Struct* t = (TributeItem_Struct*)app->pBuffer; @@ -8442,7 +8443,7 @@ void Client::Handle_OP_TributeMoney(const EQApplicationPacket *app) //player donates money if(app->size != sizeof(TributeMoney_Struct)) - printf("Error in OP_TributeMoney. Expected size of: %lu, but got: %i\n",sizeof(StartTribute_Struct),app->size); + printf("Error in OP_TributeMoney. Expected size of: %i, but got: %i\n",sizeof(StartTribute_Struct),app->size); else { TributeMoney_Struct* t = (TributeMoney_Struct*)app->pBuffer; @@ -8590,7 +8591,7 @@ void Client::Handle_OP_Ignore(const EQApplicationPacket *app) void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app) { if(app->size != sizeof(FindPersonRequest_Struct)) - printf("Error in FindPersonRequest_Struct. Expected size of: %lu, but got: %i\n",sizeof(FindPersonRequest_Struct),app->size); + printf("Error in FindPersonRequest_Struct. Expected size of: %i, but got: %i\n",sizeof(FindPersonRequest_Struct),app->size); else { FindPersonRequest_Struct* t = (FindPersonRequest_Struct*)app->pBuffer; diff --git a/zone/command.cpp b/zone/command.cpp index 3c04933db..988b4bed0 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -1759,10 +1759,12 @@ void command_timezone(Client *c, const Seperator *sep) c->Message(13, "Current timezone is: %ih %im", zone->zone_time.getEQTimeZoneHr(), zone->zone_time.getEQTimeZoneMin()); } else { - if(sep->arg[2]=="") - strcpy(sep->arg[2], "0"); - c->Message(13, "Setting timezone to %s h %s m", sep->arg[1], sep->arg[2]); - uint32 ntz=(atoi(sep->arg[1])*60)+atoi(sep->arg[2]); + uint8 hours = atoi(sep->arg[1]); + uint8 minutes = atoi(sep->arg[2]); + if(!sep->IsNumber(2)) + minutes = 0; + c->Message(13, "Setting timezone to %i h %i m", hours, minutes); + uint32 ntz=(hours*60)+minutes; zone->zone_time.setEQTimeZone(ntz); database.SetZoneTZ(zone->GetZoneID(), zone->GetInstanceVersion(), ntz); @@ -3897,7 +3899,7 @@ void command_fixmob(Client *c, const Seperator *sep) { uint32 Adjustment = 1; // Previous or Next - char codeMove; + char codeMove = 0; if (sep->arg[2]) { diff --git a/zone/embparser.cpp b/zone/embparser.cpp index b27293de4..8f2252f7b 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -1464,7 +1464,7 @@ bool PerlembParser::PlayerHasQuestSub(const char *subname) { if(playerQuestLoaded.count(zone->GetShortName()) == 0) LoadPlayerScript(zone->GetShortName()); - if(subname == "EVENT_CAST") + if(strcmp("EVENT_CAST",subname) == 0) return (playerQuestLoaded[zone->GetShortName()] == pQuestEventCast); return(perl->SubExists(packagename.c_str(), subname)); @@ -1477,7 +1477,7 @@ bool PerlembParser::GlobalPlayerHasQuestSub(const char *subname) { if(globalPlayerQuestLoaded == pQuestReadyToLoad) LoadGlobalPlayerScript(); - if(subname == "EVENT_CAST") + if(strcmp("EVENT_CAST",subname) == 0) return (globalPlayerQuestLoaded == pQuestEventCast); return(perl->SubExists(packagename.c_str(), subname)); diff --git a/zone/entity.cpp b/zone/entity.cpp index bfe12c17f..1f1540aca 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -1493,11 +1493,13 @@ void EntityList::RemoveFromTargets(Mob* mob, bool RemoveFromXTargets) m->RemoveFromHateList(mob); if(RemoveFromXTargets) + { if(m->IsClient()) m->CastToClient()->RemoveXTarget(mob, false); // FadingMemories calls this function passing the client. else if(mob->IsClient()) mob->CastToClient()->RemoveXTarget(m, false); + } } } diff --git a/zone/merc.cpp b/zone/merc.cpp index e1a4d0ec6..950fa5682 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -5062,7 +5062,7 @@ Merc* Merc::LoadMerc(Client *c, MercTemplate* merc_template, uint32 merchant_id, snprintf(c->GetEPP().merc_name, 64, "%s", c->GetMercInfo().merc_name); snprintf(npc_type->name, 64, "%s", c->GetMercInfo().merc_name); } - uint8 gender; + uint8 gender = 0; if(merchant_id > 0) { NPC* tar = entity_list.GetNPCByID(merchant_id); if(tar) { @@ -5586,7 +5586,7 @@ bool Merc::Suspend() { } bool Merc::Unsuspend(bool setMaxStats) { - Client* mercOwner; + Client* mercOwner = nullptr; bool loaded = false; if(GetMercOwner()) { diff --git a/zone/mob.cpp b/zone/mob.cpp index 3ec74db43..b8b7066cd 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -91,13 +91,13 @@ Mob::Mob(const char* in_name, mana_timer(2000), spellend_timer(0), rewind_timer(30000), //Timer used for determining amount of time between actual player position updates for /rewind. + bindwound_timer(10000), stunned_timer(0), spun_timer(0), bardsong_timer(6000), - flee_timer(FLEE_CHECK_TIMER), - bindwound_timer(10000), gravity_timer(1000), - viral_timer(0) + viral_timer(0), + flee_timer(FLEE_CHECK_TIMER) { targeted = 0; @@ -878,7 +878,7 @@ void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) // Changing the first string made it vanish, so it has some significance. if(lastname) - sprintf(ns->spawn.DestructibleModel, lastname); + sprintf(ns->spawn.DestructibleModel, "%s", lastname); // Changing the second string made no visible difference sprintf(ns->spawn.DestructibleName2, "%s", ns->spawn.name); // Putting a string in the final one that was previously empty had no visible effect. diff --git a/zone/mob.h b/zone/mob.h index b300eb9b6..52c1e626c 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -969,11 +969,6 @@ protected: Timer tic_timer; Timer mana_timer; - float rewind_x; - float rewind_y; - float rewind_z; - Timer rewind_timer; - //spell casting vars Timer spellend_timer; uint16 casting_spell_id; @@ -992,6 +987,11 @@ protected: uint8 bardsong_slot; uint32 bardsong_target_id; + float rewind_x; + float rewind_y; + float rewind_z; + Timer rewind_timer; + // Currently 3 max nimbus particle effects at a time uint32 nimbus_effect1; uint32 nimbus_effect2; @@ -1026,6 +1026,10 @@ protected: int16 rooted_mod; //Modifier to root break chance, defined when root is cast on a target. bool offhand; + // Bind wound + Timer bindwound_timer; + Mob* bindwound_target; + Timer stunned_timer; Timer spun_timer; Timer bardsong_timer; @@ -1108,9 +1112,6 @@ protected: uint32 pDontSnareMeBefore; uint32 pDontCureMeBefore; - // Bind wound - Timer bindwound_timer; - Mob* bindwound_target; // hp event int nexthpevent; int nextinchpevent; diff --git a/zone/npc.cpp b/zone/npc.cpp index bb5743956..8cd3c3324 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -110,10 +110,10 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float classattack_timer(1000), knightattack_timer(1000), assist_timer(AIassistcheck_delay), + qglobal_purge_timer(30000), sendhpupdate_timer(1000), enraged_timer(1000), - taunt_timer(TauntReuseTime * 1000), - qglobal_purge_timer(30000) + taunt_timer(TauntReuseTime * 1000) { //What is the point of this, since the names get mangled.. Mob* mob = entity_list.GetMob(name); diff --git a/zone/spawngroup.cpp b/zone/spawngroup.cpp index d31d53bae..587ef595f 100644 --- a/zone/spawngroup.cpp +++ b/zone/spawngroup.cpp @@ -130,7 +130,7 @@ void SpawnGroupList::AddSpawnGroup(SpawnGroup* newGroup) { SpawnGroup* SpawnGroupList::GetSpawnGroup(uint32 in_id) { if(groups.count(in_id) != 1) - return(false); + return nullptr; return(groups[in_id]); } diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 4950e3b35..4d4d07562 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -75,17 +75,20 @@ void Mob::ApplySpecialAttackMod(SkillType skill, int32 &dmg, int32 &mindmg) { case ROUND_KICK: case KICK: item_slot = SLOT_FEET; - break; + break; case BASH: item_slot = SLOT_SECONDARY; - break; + break; case DRAGON_PUNCH: case EAGLE_STRIKE: case TIGER_CLAW: item_slot = SLOT_HANDS; - break; + break; + + default: + break; } if (item_slot >= 0){ diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 58954ffe7..c4fbb0f39 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -4488,12 +4488,13 @@ int16 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, boo case SE_TriggerOnCast: { if(type == focusTriggerOnCast) - + { if(MakeRandomInt(0, 100) <= focus_spell.base[i]) value = focus_spell.base2[i]; else value = 0; + } break; } @@ -5106,7 +5107,7 @@ bool Mob::TryDivineSave() { SetHP(1); - uint16 EffectsToTry[] = + int16 EffectsToTry[] = { aabonuses.DivineSaveChance[1], itembonuses.DivineSaveChance[1], diff --git a/zone/tasks.cpp b/zone/tasks.cpp index 172f3d18c..129d53a41 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -2482,10 +2482,8 @@ void ClientTaskState::SendTaskHistory(Client *c, int TaskIndex) { thd1 = (TaskHistoryReplyData1_Struct*)Ptr; thd1->ActivityType = Task->Activity[i].Type; Ptr = (char *)thd1 + sizeof(TaskHistoryReplyData1_Struct); - sprintf(Ptr, Task->Activity[i].Text1); - Ptr = Ptr + strlen(Ptr) + 1; - sprintf(Ptr, Task->Activity[i].Text2); - Ptr = Ptr + strlen(Ptr) + 1; + VARSTRUCT_ENCODE_STRING(Ptr, Task->Activity[i].Text1); + VARSTRUCT_ENCODE_STRING(Ptr, Task->Activity[i].Text2); thd2 = (TaskHistoryReplyData2_Struct*)Ptr; thd2->GoalCount = Task->Activity[i].GoalCount; thd2->unknown04 = 0xffffffff; @@ -2493,8 +2491,7 @@ void ClientTaskState::SendTaskHistory(Client *c, int TaskIndex) { thd2->ZoneID = Task->Activity[i].ZoneID; thd2->unknown16 = 0x00000000; Ptr = (char *)thd2 + sizeof(TaskHistoryReplyData2_Struct); - sprintf(Ptr, Task->Activity[i].Text3); - Ptr = Ptr + strlen(Ptr) + 1; + VARSTRUCT_ENCODE_STRING(Ptr, Task->Activity[i].Text3); } } diff --git a/zone/trading.cpp b/zone/trading.cpp index aae28d0e8..d49eb798c 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -2144,7 +2144,7 @@ void Client::ShowBuyLines(const EQApplicationPacket *app) { // This packet produces the SoandSo is browsing your Buy Lines message bb->Action = Barter_SellerBrowsing; - sprintf(bb->PlayerName, GetName()); + sprintf(bb->PlayerName, "%s", GetName()); Buyer->QueuePacket(outapp); @@ -2710,7 +2710,7 @@ void Client::BuyerItemSearch(const EQApplicationPacket *app) { pdest = strstr(Name, Criteria); if (pdest != nullptr) { - sprintf(bisr->Results[Count].ItemName, item->Name); + sprintf(bisr->Results[Count].ItemName, "%s", item->Name); bisr->Results[Count].ItemID = item->ID; bisr->Results[Count].Unknown068 = item->Icon; bisr->Results[Count].Unknown072 = 0x00000000; diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 86684187e..d08b38b8d 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -93,6 +93,8 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { return; } break; + default: + break; }; } else { @@ -246,6 +248,8 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { LogFile->write(EQEMuLog::Error, "Zoning %s: Invalid unsolicited zone request to zone id '%s'. Not near a zone point.", GetName(), target_zone_name); SendZoneCancel(zc); return; + default: + break; }; //OK, now we should know where were going... From a66ef1b778ef2d4411d5e5fa26a650d3268e85e9 Mon Sep 17 00:00:00 2001 From: KimLS Date: Fri, 24 May 2013 00:52:28 -0700 Subject: [PATCH 19/20] Function for retrieving a qglobal or list of them --- zone/QGlobals.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++-- zone/QGlobals.h | 6 ++++ 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/zone/QGlobals.cpp b/zone/QGlobals.cpp index 54a081cc5..73faa8b2c 100644 --- a/zone/QGlobals.cpp +++ b/zone/QGlobals.cpp @@ -1,6 +1,8 @@ #include "../common/debug.h" #include "../common/StringUtil.h" #include "QGlobals.h" +#include "masterentity.h" +#include "zone.h" #include "zonedb.h" void QGlobalCache::AddGlobal(uint32 id, QGlobal global) @@ -16,7 +18,9 @@ void QGlobalCache::RemoveGlobal(std::string name, uint32 npcID, uint32 charID, u { if(name.compare((*iter).name) == 0) { - if((npcID == (*iter).npc_id || (*iter).npc_id == 0) && (charID == (*iter).char_id || (*iter).char_id == 0) && (zoneID == (*iter).zone_id || (*iter).zone_id == 0)) + if((npcID == (*iter).npc_id || (*iter).npc_id == 0) && + (charID == (*iter).char_id || (*iter).char_id == 0) && + (zoneID == (*iter).zone_id || (*iter).zone_id == 0)) { qGlobalBucket.erase(iter); return; @@ -33,7 +37,8 @@ void QGlobalCache::Combine(std::list &cacheA, std::list cacheB { QGlobal cur = (*iter); - if((cur.npc_id == npcID || cur.npc_id == 0) && (cur.char_id == charID || cur.char_id == 0) && (cur.zone_id == zoneID || cur.zone_id == 0)) + if((cur.npc_id == npcID || cur.npc_id == 0) && (cur.char_id == charID || cur.char_id == 0) && + (cur.zone_id == zoneID || cur.zone_id == 0)) { if(Timer::GetTimeSeconds() < cur.expdate) { @@ -44,6 +49,76 @@ void QGlobalCache::Combine(std::list &cacheA, std::list cacheB } } +void QGlobalCache::GetQGlobals(std::list &globals, NPC *n, Client *c, Zone *z) { + globals.clear(); + + QGlobalCache *npc_c = nullptr; + QGlobalCache *char_c = nullptr; + QGlobalCache *zone_c = nullptr; + uint32 npc_id = 0; + uint32 char_id = 0; + uint32 zone_id = 0; + + if(n) { + npc_id = n->GetNPCTypeID(); + npc_c = n->GetQGlobals(); + } + + if(c) { + char_id = c->CharacterID(); + char_c = c->GetQGlobals(); + } + + if(z) { + zone_id = z->GetZoneID(); + zone_c = z->GetQGlobals(); + } + + if(!npc_c && n) { + npc_c = n->CreateQGlobals(); + npc_c->LoadByNPCID(npc_id); + } + + if(!char_c && c) { + char_c = c->CreateQGlobals(); + char_c->LoadByCharID(char_id); + } + + if(!zone_c && z) { + zone_c = z->CreateQGlobals(); + zone_c->LoadByZoneID(zone_id); + zone_c->LoadByGlobalContext(); + } + + if(npc_c) { + QGlobalCache::Combine(globals, npc_c->GetBucket(), npc_id, char_id, zone_id); + } + + if(char_c) { + QGlobalCache::Combine(globals, char_c->GetBucket(), npc_id, char_id, zone_id); + } + + if(zone_c) { + QGlobalCache::Combine(globals, zone_c->GetBucket(), npc_id, char_id, zone_id); + } +} + +bool QGlobalCache::GetQGlobal(QGlobal &g, std::string name, NPC *n, Client *c, Zone *z) { + std::list globals; + QGlobalCache::GetQGlobals(globals, n, c, z); + + auto iter = globals.begin(); + while(iter != globals.end()) { + if(iter->name.compare(name) == 0) { + g = (*iter); + return true; + } + ++iter; + } + + return false; +} + void QGlobalCache::PurgeExpiredGlobals() { if(!qGlobalBucket.size()) diff --git a/zone/QGlobals.h b/zone/QGlobals.h index 577fd3c11..73a795186 100644 --- a/zone/QGlobals.h +++ b/zone/QGlobals.h @@ -6,6 +6,10 @@ #include #include "../common/timer.h" +class NPC; +class Client; +class Zone; + struct QGlobal { QGlobal() { } @@ -29,6 +33,8 @@ public: //assumes cacheA is already a valid or empty list and doesn't check for valid items. static void Combine(std::list &cacheA, std::list cacheB, uint32 npcID, uint32 charID, uint32 zoneID); + static void GetQGlobals(std::list &globals, NPC *n, Client *c, Zone *z); + static bool GetQGlobal(QGlobal &g, std::string name, NPC *n, Client *c, Zone *z); void PurgeExpiredGlobals(); void LoadByNPCID(uint32 npcID); //npc From 3c7f7beb6d2db0e2d44ae0244c0b5770f8cc75ad Mon Sep 17 00:00:00 2001 From: KimLS Date: Fri, 24 May 2013 01:10:19 -0700 Subject: [PATCH 20/20] Red. include string --- loginserver/Encryption.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/loginserver/Encryption.cpp b/loginserver/Encryption.cpp index c846e5130..bd947593b 100644 --- a/loginserver/Encryption.cpp +++ b/loginserver/Encryption.cpp @@ -20,8 +20,6 @@ #include "ErrorLog.h" #include -#include - extern ErrorLog *server_log; bool Encryption::LoadCrypto(std::string name)