diff --git a/CMakeLists.txt b/CMakeLists.txt index a7897be92..a1b60619f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,77 @@ IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE) ENDIF(NOT CMAKE_BUILD_TYPE) +SET(VLD_FOUND FALSE) + +## VLD works only in Microsoft Visual Studio on Windows: +IF(WIN32) +IF(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)") + +FIND_PATH(VLD_INCLUDE_DIR vld.h + $ENV{VLD_HOME}/include + $ENV{VLD_HOME} + "$ENV{ProgramFiles}/Microsoft Visual Studio .NET 2003/Vc7/include" + ) +#MESSAGE("VLD_INCLUDE_DIR=${VLD_INCLUDE_DIR}") + +## this is just required for runtim enabling/disabling: +FIND_PATH(VLD_INCLUDE_DIR_API vldapi.h + $ENV{VLD_HOME}/include + $ENV{VLD_HOME} + "$ENV{ProgramFiles}/Microsoft Visual Studio .NET 2003/Vc7/include" +) +#MESSAGE("VLD_INCLUDE_DIR_API=${VLD_INCLUDE_DIR}") + +FIND_LIBRARY(VLD_LIBRARY_VLD + NAMES vld + PATHS + $ENV{VLD_HOME}/lib + $ENV{VLD_HOME} + "$ENV{ProgramFiles}/Microsoft Visual Studio .NET 2003/Vc7/lib" + DOC "Visual Leak Debugger multithreaded library" + ) +#MESSAGE("VLD_LIBRARY_VLD=${VLD_LIBRARY_VLD}") + +FIND_LIBRARY(VLD_LIBRARY_VLDMT + NAMES vldmt + PATHS + $ENV{VLD_HOME}/lib + $ENV{VLD_HOME} + "$ENV{ProgramFiles}/Microsoft Visual Studio .NET 2003/Vc7/lib" + DOC "Visual Leak Debugger multithreaded library" + ) +#MESSAGE("VLD_LIBRARY_VLDMT=${VLD_LIBRARY_VLDMT}") + +FIND_LIBRARY(VLD_LIBRARY_VLDMTDLL + NAMES vldmtdll + PATHS + $ENV{VLD_HOME}/lib + $ENV{VLD_HOME} + "$ENV{ProgramFiles}/Microsoft Visual Studio .NET 2003/Vc7/lib" + DOC "Visual Leak Debugger multithreaded library" + ) +#MESSAGE("VLD_LIBRARY_VLDMTDLL=${VLD_LIBRARY_VLDMTDLL}") + +IF(VLD_INCLUDE_DIR) + IF (VLD_LIBRARY_VLD OR VLD_LIBRARY_VLDMT OR VLD_LIBRARY_VLDMTDLL) + ## do NOT add LIBRARIES because dependencies are handled through pragmas. + SET(VLD_FOUND TRUE) + # MESSAGE("found VLD.") + ENDIF (VLD_LIBRARY_VLD OR VLD_LIBRARY_VLDMT OR VLD_LIBRARY_VLDMTDLL) +ENDIF(VLD_INCLUDE_DIR) + +MARK_AS_ADVANCED( + VLD_INCLUDE_DIR + VLD_INCLUDE_DIR_API + VLD_LIBRARY_VLD + VLD_LIBRARY_VLDMT + VLD_LIBRARY_VLDMTDLL + VLD_LIBRARIES +) + +ENDIF(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)") +ENDIF(WIN32) + #Add our various windows definitions IF(MSVC OR MINGW) ADD_DEFINITIONS(-D_WINDOWS) @@ -139,7 +210,7 @@ ADD_DEFINITIONS(-DMAP_DIR="./Maps") FIND_PACKAGE(ZLIB REQUIRED) FIND_PACKAGE(MySQL REQUIRED) FIND_PACKAGE(PerlLibs REQUIRED) -INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIRS}" "${PERL_INCLUDE_PATH}" "${MySQL_INCLUDE_DIR}") +INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIRS}" "${PERL_INCLUDE_PATH}" "${MySQL_INCLUDE_DIR}" "${VLD_INCLUDE_DIR}") IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS) ADD_SUBDIRECTORY(common) diff --git a/eqlaunch/CMakeLists.txt b/eqlaunch/CMakeLists.txt index 8483b9bb0..14257fef9 100644 --- a/eqlaunch/CMakeLists.txt +++ b/eqlaunch/CMakeLists.txt @@ -13,7 +13,7 @@ SET(eqlaunch_headers ADD_EXECUTABLE(eqlaunch ${eqlaunch_sources} ${eqlaunch_headers}) -TARGET_LINK_LIBRARIES(eqlaunch Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE}) +TARGET_LINK_LIBRARIES(eqlaunch Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) IF(MSVC) diff --git a/eqlaunch/worldserver.cpp b/eqlaunch/worldserver.cpp index a3071f3df..1f314bd8f 100644 --- a/eqlaunch/worldserver.cpp +++ b/eqlaunch/worldserver.cpp @@ -126,7 +126,6 @@ void WorldServer::Process() { default: { _log(LAUNCHER__NET, "Unknown opcode 0x%x from World of len %d", pack->opcode, pack->size); - //DumpPacket(pack->pBuffer, pack->size); break; } } diff --git a/queryserv/CMakeLists.txt b/queryserv/CMakeLists.txt index 96cdaf69c..4e319ddad 100644 --- a/queryserv/CMakeLists.txt +++ b/queryserv/CMakeLists.txt @@ -19,7 +19,7 @@ ADD_EXECUTABLE(queryserv ${qserv_sources} ${qserv_headers}) ADD_DEFINITIONS(-DQSERV) -TARGET_LINK_LIBRARIES(queryserv Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE}) +TARGET_LINK_LIBRARIES(queryserv Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) IF(MSVC) diff --git a/shared_memory/CMakeLists.txt b/shared_memory/CMakeLists.txt index 74629fdd1..902ffb2ff 100644 --- a/shared_memory/CMakeLists.txt +++ b/shared_memory/CMakeLists.txt @@ -19,7 +19,7 @@ SET(shared_memory_headers ADD_EXECUTABLE(shared_memory ${shared_memory_sources} ${shared_memory_headers}) -TARGET_LINK_LIBRARIES(shared_memory Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE}) +TARGET_LINK_LIBRARIES(shared_memory Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) IF(MSVC) SET_TARGET_PROPERTIES(shared_memory PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") diff --git a/ucs/CMakeLists.txt b/ucs/CMakeLists.txt index 6f0d023a0..1218541a3 100644 --- a/ucs/CMakeLists.txt +++ b/ucs/CMakeLists.txt @@ -21,7 +21,7 @@ ADD_EXECUTABLE(ucs ${ucs_sources} ${ucs_headers}) ADD_DEFINITIONS(-DUCS) -TARGET_LINK_LIBRARIES(ucs Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE}) +TARGET_LINK_LIBRARIES(ucs Common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) IF(MSVC) diff --git a/world/CMakeLists.txt b/world/CMakeLists.txt index f36ba87fa..768072677 100644 --- a/world/CMakeLists.txt +++ b/world/CMakeLists.txt @@ -67,7 +67,7 @@ ADD_EXECUTABLE(world ${world_sources} ${world_headers}) ADD_DEFINITIONS(-DWORLD) -TARGET_LINK_LIBRARIES(world Common ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE}) +TARGET_LINK_LIBRARIES(world Common ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) IF(MSVC) diff --git a/zone/CMakeLists.txt b/zone/CMakeLists.txt index e0b0d01b6..9554802bf 100644 --- a/zone/CMakeLists.txt +++ b/zone/CMakeLists.txt @@ -155,12 +155,82 @@ ADD_EXECUTABLE(zone ${zone_sources} ${zone_headers}) ADD_DEFINITIONS(-DZONE) -TARGET_LINK_LIBRARIES(zone Common ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE}) +TARGET_LINK_LIBRARIES(zone Common ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY} ${VLD_LIBRARY_VLD}) IF(MSVC) SET_TARGET_PROPERTIES(zone PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") TARGET_LINK_LIBRARIES(zone "Ws2_32.lib") ENDIF(MSVC) +SET(VLD_FOUND FALSE) + +## VLD works only in Microsoft Visual Studio on Windows: +IF(WIN32) +IF(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)") + +FIND_PATH(VLD_INCLUDE_DIR vld.h + $ENV{VLD_HOME}/include + $ENV{VLD_HOME} + "$ENV{ProgramFiles}/Microsoft Visual Studio .NET 2003/Vc7/include" + ) +#MESSAGE("VLD_INCLUDE_DIR=${VLD_INCLUDE_DIR}") + +## this is just required for runtim enabling/disabling: +FIND_PATH(VLD_INCLUDE_DIR_API vldapi.h + $ENV{VLD_HOME}/include + $ENV{VLD_HOME} + "$ENV{ProgramFiles}/Microsoft Visual Studio .NET 2003/Vc7/include" +) +#MESSAGE("VLD_INCLUDE_DIR_API=${VLD_INCLUDE_DIR}") + +FIND_LIBRARY(VLD_LIBRARY_VLD + NAMES vld + PATHS + $ENV{VLD_HOME}/lib + $ENV{VLD_HOME} + "$ENV{ProgramFiles}/Microsoft Visual Studio .NET 2003/Vc7/lib" + DOC "Visual Leak Debugger multithreaded library" + ) +#MESSAGE("VLD_LIBRARY_VLD=${VLD_LIBRARY_VLD}") + +FIND_LIBRARY(VLD_LIBRARY_VLDMT + NAMES vldmt + PATHS + $ENV{VLD_HOME}/lib + $ENV{VLD_HOME} + "$ENV{ProgramFiles}/Microsoft Visual Studio .NET 2003/Vc7/lib" + DOC "Visual Leak Debugger multithreaded library" + ) +#MESSAGE("VLD_LIBRARY_VLDMT=${VLD_LIBRARY_VLDMT}") + +FIND_LIBRARY(VLD_LIBRARY_VLDMTDLL + NAMES vldmtdll + PATHS + $ENV{VLD_HOME}/lib + $ENV{VLD_HOME} + "$ENV{ProgramFiles}/Microsoft Visual Studio .NET 2003/Vc7/lib" + DOC "Visual Leak Debugger multithreaded library" + ) +#MESSAGE("VLD_LIBRARY_VLDMTDLL=${VLD_LIBRARY_VLDMTDLL}") + +IF(VLD_INCLUDE_DIR) + IF (VLD_LIBRARY_VLD OR VLD_LIBRARY_VLDMT OR VLD_LIBRARY_VLDMTDLL) + ## do NOT add LIBRARIES because dependencies are handled through pragmas. + SET(VLD_FOUND TRUE) + # MESSAGE("found VLD.") + ENDIF (VLD_LIBRARY_VLD OR VLD_LIBRARY_VLDMT OR VLD_LIBRARY_VLDMTDLL) +ENDIF(VLD_INCLUDE_DIR) + +MARK_AS_ADVANCED( + VLD_INCLUDE_DIR + VLD_INCLUDE_DIR_API + VLD_LIBRARY_VLD + VLD_LIBRARY_VLDMT + VLD_LIBRARY_VLDMTDLL + VLD_LIBRARIES +) + +ENDIF(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv)") +ENDIF(WIN32) IF(MINGW) TARGET_LINK_LIBRARIES(zone "WS2_32") @@ -175,4 +245,6 @@ IF(UNIX) ADD_DEFINITIONS(-fPIC) ENDIF(UNIX) +INCLUDE_DIRECTORIES(${VLD_INCLUDE_DIR}) + SET(EXECUTABLE_OUTPUT_PATH ../Bin) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 778d2fdd4..5e0a9d578 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -3540,7 +3540,6 @@ void Client::Handle_OP_WearChange(const EQApplicationPacket *app) { if (app->size != sizeof(WearChange_Struct)) { cout << "Wrong size: OP_WearChange, size=" << app->size << ", expected " << sizeof(WearChange_Struct) << endl; - DumpPacket(app); return; } @@ -3595,7 +3594,6 @@ void Client::Handle_OP_WhoAllRequest(const EQApplicationPacket *app) { if (app->size != sizeof(Who_All_Struct)) { cout << "Wrong size on OP_WhoAll. Got: " << app->size << ", Expected: " << sizeof(Who_All_Struct) << endl; - DumpPacket(app); return; } Who_All_Struct* whoall = (Who_All_Struct*) app->pBuffer; @@ -7385,6 +7383,24 @@ void Client::Handle_OP_Emote(const EQApplicationPacket *app) memcpy(out->message, name, len_name); memcpy(&out->message[len_name], in->message, len_msg); + /* + if (target && target->IsClient()) { + entity_list.QueueCloseClients(this, outapp, false, 100, target); + + cptr = outapp->pBuffer + 2; + + // not sure if live does this or not. thought it was a nice feature, but would take a lot to + // clean up grammatical and other errors. Maybe with a regex parser... + replacestr((char *)cptr, target->GetName(), "you"); + replacestr((char *)cptr, " he", " you"); + replacestr((char *)cptr, " she", " you"); + replacestr((char *)cptr, " him", " you"); + replacestr((char *)cptr, " her", " you"); + target->CastToClient()->QueuePacket(outapp); + + } + else + */ entity_list.QueueCloseClients(this, outapp, true, 100,0,true,FilterSocials); safe_delete(outapp); @@ -13580,6 +13596,7 @@ void Client::Handle_OP_MercenaryHire(const EQApplicationPacket *app) uint32 merchant_id = mmrq->MercMerchantID; uint32 merc_unk1 = mmrq->MercUnk01; uint32 merc_unk2 = mmrq->MercUnk02; + if(MERC_DEBUG > 0) Message(7, "Mercenary Debug: Template ID (%i), Merchant ID (%i), Unknown1 (%i), Unknown2 (%i)", merc_template_id, merchant_id, merc_unk1, merc_unk2); @@ -13641,7 +13658,6 @@ void Client::Handle_OP_MercenarySuspendRequest(const EQApplicationPacket *app) SuspendMercenary_Struct* sm = (SuspendMercenary_Struct*) app->pBuffer; uint32 merc_suspend = sm->SuspendMerc; // Seen 30 for suspending or unsuspending - if(MERC_DEBUG > 0) Message(7, "Mercenary Debug: Suspend ( %i ) received.", merc_suspend); @@ -13666,7 +13682,7 @@ void Client::Handle_OP_MercenaryCommand(const EQApplicationPacket *app) uint32 merc_command = mc->MercCommand; // Seen 0 (zone in with no merc or suspended), 1 (dismiss merc), 5 (normal state), 20 (unknown), 36 (zone in with merc) int32 option = mc->Option; // Seen -1 (zone in with no merc), 0 (setting to passive stance), 1 (normal or setting to balanced stance) - if(MERC_DEBUG > 0) + if(MERC_DEBUG > 0) Message(7, "Mercenary Debug: Command %i, Option %i received.", merc_command, option); if(!RuleB(Mercs, AllowMercs)) diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 87afcf62a..aa81f9371 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -1307,7 +1307,7 @@ void Client::OPMoveCoin(const EQApplicationPacket* app) uint64 value = 0, amount_to_take = 0, amount_to_add = 0; int32 *from_bucket = 0, *to_bucket = 0; Mob* trader = trade->With(); - + // could just do a range, but this is clearer and explicit if ( diff --git a/zone/doors.cpp b/zone/doors.cpp index 53315f413..c638ef746 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -148,7 +148,6 @@ void Doors::HandleClick(Client* sender, uint8 trigger) EQApplicationPacket* outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct)); MoveDoor_Struct* md = (MoveDoor_Struct*)outapp->pBuffer; - md->doorid = door_id; ///////////////////////////////////////////////////////////////// //used_pawn: Locked doors! Rogue friendly too =) diff --git a/zone/merc.cpp b/zone/merc.cpp index 8326b8b97..eda622255 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -71,6 +71,7 @@ Merc::Merc(const NPCType* d, float x, float y, float z, float heading) } Merc::~Merc() { + AI_Stop(); safe_delete(ourNPCData); //Since mercs are dynamically alloc'd we should probably safe_delete the data they were made from. I'm not entirely sure this is safe to delete a const. entity_list.RemoveMerc(this->GetID()); UninitializeBuffSlots(); @@ -1911,15 +1912,16 @@ void Merc::AI_Process() { } void Merc::AI_Start(int32 iMoveDelay) { - Mob::AI_Start(iMoveDelay); + NPC::AI_Start(iMoveDelay); + if (!pAIControlled) return; if (merc_spells.size() == 0) { - AIautocastspell_timer = new Timer(1000); + AIautocastspell_timer->SetTimer(1000); AIautocastspell_timer->Disable(); } else { - AIautocastspell_timer = new Timer(750); + AIautocastspell_timer->SetTimer(750); AIautocastspell_timer->Start(RandomTimer(0, 2000), false); } @@ -5572,10 +5574,6 @@ bool Merc::Suspend() { SetSuspended(true); - if(HasGroup()) { - RemoveMercFromGroup(this, GetGroup()); - } - Save(); mercOwner->GetMercInfo().IsSuspended = true; @@ -5623,31 +5621,43 @@ bool Merc::Unsuspend(bool setMaxStats) { mercOwner->GetPTimers().Clear(&database, pTimerMercSuspend); mercOwner->SendMercPersonalInfo(); + Group* g = entity_list.GetGroupByClient(mercOwner); - if(!mercOwner->IsGrouped()) - { - Group *g = new Group(mercOwner); - if(g && AddMercToGroup(this, g)) + if(!g) + { //nobody from our group is here... start a new group + g = new Group(mercOwner); + + if(!g) { - entity_list.AddGroup(g); + delete g; + g = NULL; + return false; + } + entity_list.AddGroup(g); + + if(g->GetID() == 0) { + delete g; + g = NULL; + Message(13, "Unable to get new group id. Cannot create group."); + mercOwner->Message(13, "Unable to get new group id. Cannot create group."); + return false; + } + + if(AddMercToGroup(this, g)) + { + entity_list.AddGroup(g, g->GetID()); database.SetGroupLeaderName(g->GetID(), mercOwner->GetName()); database.SetGroupID(mercOwner->GetName(), g->GetID(), mercOwner->CharacterID()); database.SetGroupID(this->GetName(), g->GetID(), mercOwner->CharacterID(), true); database.RefreshGroupFromDB(mercOwner); g->SaveGroupLeaderAA(); - loaded = true; } else { - if(MERC_DEBUG > 0) - mercOwner->Message(7, "Mercenary failed to join the group - Suspending"); - - Suspend(); - safe_delete(g); - return false; + g->DisbandGroup(); } - } + } //else, somebody from our group is already here... else if (AddMercToGroup(this, mercOwner->GetGroup())) { database.SetGroupID(GetName(), mercOwner->GetGroup()->GetID(), mercOwner->CharacterID(), true); diff --git a/zone/net.cpp b/zone/net.cpp index 33a0997c4..2b152f01c 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -20,6 +20,7 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) #include "../common/features.h" #include using namespace std; +#include #include #include #include diff --git a/zone/npc.cpp b/zone/npc.cpp index 86efc0579..121eae692 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -248,6 +248,7 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float npc_aggro = d->npc_aggro; + if(!IsMerc()) //memleak fix, this really shouldn't be here AI_Start(); d_meele_texture1 = d->d_meele_texture1; diff --git a/zone/tasks.cpp b/zone/tasks.cpp index 56b9de4d4..efc45175f 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -2559,7 +2559,6 @@ void Client::SendTaskFailed(int TaskID, int TaskIndex) { tac->unknown5 = 0; // 0 for task complete or failed. _log(TASKS__UPDATE, "TaskFailed"); - _pkt(TASKS__PACKETS, outapp); QueuePacket(outapp); diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 30851b038..0f050368d 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -517,7 +517,6 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac outp->reply_code = 0x00000000; //success for finding it... user->QueuePacket(outapp); - safe_delete(outapp); @@ -664,7 +663,6 @@ void Client::TradeskillSearchResults(const char *query, unsigned long qlen, reply->recipe_id = recipe; reply->trivial = trivial; strn0cpy(reply->recipe_name, name, sizeof(reply->recipe_name)); - FastQueuePacket(&outapp); } mysql_free_result(result);