From ed73df5ef5275155408b430d9bf84440f3ec3d98 Mon Sep 17 00:00:00 2001 From: David Parra Date: Sun, 10 Mar 2024 13:17:44 +0000 Subject: [PATCH] Replace submodule with fetchcontent (#97) --- .gitmodules | 3 - CMakeLists.txt | 27 ++++----- cmake/options.cmake | 43 ++++++------- cmake/showoptions.cmake | 12 ++-- src/CMakeLists.txt | 46 ++++++++++---- src/game/CMakeLists.txt | 84 +++++--------------------- src/game/Chat/Chat.cpp | 8 +-- src/game/Chat/Chat.h | 2 +- src/game/Chat/ChatHandler.cpp | 6 +- src/game/Entities/CharacterHandler.cpp | 10 +-- src/game/Entities/Creature.h | 2 +- src/game/Entities/Player.cpp | 20 +++--- src/game/Entities/Player.h | 8 +-- src/game/Groups/Group.cpp | 4 +- src/game/Maps/Map.cpp | 2 +- src/game/Quests/QuestHandler.cpp | 6 +- src/game/Server/WorldSession.cpp | 22 +++---- src/game/Server/WorldSession.h | 4 +- src/game/Spells/Spell.cpp | 2 +- src/game/Spells/SpellHandler.cpp | 2 +- src/game/World/World.cpp | 8 +-- src/mangosd/CMakeLists.txt | 13 ++-- src/mangosd/Main.cpp | 4 +- src/modules/Bots | 1 - src/modules/CMakeLists.txt | 24 -------- src/shared/Database/Database.cpp | 2 +- 26 files changed, 153 insertions(+), 212 deletions(-) delete mode 160000 src/modules/Bots delete mode 100644 src/modules/CMakeLists.txt diff --git a/.gitmodules b/.gitmodules index 939f8c9ed2..e69de29bb2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "src/modules/Bots"] - path = src/modules/Bots - url = https://github.com/celguar/mangosbot-bots.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b66d3dcd4..4a711b6f06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -363,24 +363,21 @@ if(NOT BUILD_GAME_SERVER AND BUILD_SCRIPTDEV) message(STATUS "BUILD_SCRIPTDEV forced to OFF due to BUILD_GAME_SERVER is not set") endif() -if(NOT BUILD_GAME_SERVER AND BUILD_PLAYERBOT) - set(BUILD_PLAYERBOT OFF) - message(STATUS "BUILD_PLAYERBOT forced to OFF due to BUILD_GAME_SERVER is not set") +if(NOT BUILD_GAME_SERVER AND BUILD_DEPRECATED_PLAYERBOT) + set(BUILD_DEPRECATED_PLAYERBOT OFF) + message(STATUS "BUILD_DEPRECATED_PLAYERBOT forced to OFF due to BUILD_GAME_SERVER is not set") endif() -if(NOT BUILD_GAME_SERVER AND BUILD_IKE3_BOTS) - set(BUILD_IKE3_BOTS OFF) - message(STATUS "BUILD_PLAYERBOTS forced to OFF due to BUILD_GAME_SERVER is not set") -endif() - -if(BUILD_IKE3_BOTS) - set(BUILD_PLAYERBOT OFF) - message(STATUS "CMaNGOS bots DISABLED because Ike3 bots enabled") -endif() +if(BUILD_PLAYERBOTS) + if(BUILD_DEPRECATED_PLAYERBOT) + set(BUILD_DEPRECATED_PLAYERBOT OFF) + message(STATUS "BUILD_DEPRECATED_PLAYERBOT forced to OFF because BUILD_PLAYERBOTS is set") + endif() -if(BUILD_PLAYERBOT) - set(BUILD_IKE3_BOTS OFF) - message(STATUS "Ike3 bots DISABLED because CMaNGOS bots enabled") + if(NOT BUILD_GAME_SERVER) + set(BUILD_PLAYERBOTS OFF) + message(STATUS "BUILD_PLAYERBOTS forced to OFF due to BUILD_GAME_SERVER is not set") + endif() endif() if(BUILD_MODULES AND NOT BUILD_GAME_SERVER) diff --git a/cmake/options.cmake b/cmake/options.cmake index b320cf1d9c..c9b04cd222 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -1,17 +1,22 @@ -option(DEBUG "Include additional debug-code in core" OFF) -option(WARNINGS "Show all warnings during compile" OFF) -option(POSTGRESQL "Use PostgreSQL" OFF) -option(PCH "Use precompiled headers" ON) -option(BUILD_GAME_SERVER "Build game server" ON) -option(BUILD_LOGIN_SERVER "Build login server" ON) -option(BUILD_EXTRACTORS "Build map/dbc/vmap/mmap extractors" OFF) -option(BUILD_SCRIPTDEV "Build ScriptDev. (OFF Speedup build)" ON) -option(BUILD_PLAYERBOT "Build Playerbot mod" OFF) -option(BUILD_IKE3_BOTS "Build ike3 Playerbots" OFF) -option(BUILD_AHBOT "Build Auction House Bot mod" OFF) +option(DEBUG "Include additional debug-code in core" OFF) +option(WARNINGS "Show all warnings during compile" OFF) +option(POSTGRESQL "Use PostgreSQL" OFF) +option(PCH "Use precompiled headers" ON) +option(BUILD_GAME_SERVER "Build game server" ON) +option(BUILD_LOGIN_SERVER "Build login server" ON) +option(BUILD_EXTRACTORS "Build map/dbc/vmap/mmap extractors" OFF) +option(BUILD_SCRIPTDEV "Build ScriptDev. (OFF Speedup build)" ON) +option(BUILD_PLAYERBOTS "Build Playerbots mod" OFF) +option(BUILD_AHBOT "Build Auction House Bot mod" OFF) +option(BUILD_METRICS "Build Metrics, generate data for Grafana" OFF) +option(BUILD_RECASTDEMOMOD "Build map/vmap/mmap viewer" OFF) +option(BUILD_GIT_ID "Build git_id" OFF) +option(BUILD_DOCS "Build documentation with doxygen" OFF) +option(CMAKE_INTERPROCEDURAL_OPTIMIZATION "Enable link-time optimizations" OFF) +option(BUILD_DEPRECATED_PLAYERBOT "Build previous version of Playerbot mod" OFF) # Modules -option(BUILD_MODULES "Build module system" OFF) +option(BUILD_MODULES "Build module system" OFF) foreach(MODULE_NAME ${MODULE_NAMES}) if(NOT ${MODULE_NAME} STREQUAL "MODULES") string(TOLOWER ${MODULE_NAME} LOWER_MODULE_NAME) @@ -19,11 +24,6 @@ foreach(MODULE_NAME ${MODULE_NAMES}) endif() endforeach() -option(BUILD_METRICS "Build Metrics, generate data for Grafana" OFF) -option(BUILD_RECASTDEMOMOD "Build map/vmap/mmap viewer" OFF) -option(BUILD_GIT_ID "Build git_id" OFF) -option(BUILD_DOCS "Build documentation with doxygen" OFF) -option(CMAKE_INTERPROCEDURAL_OPTIMIZATION "Enable link-time optimizations" OFF) set(DEV_BINARY_DIR ${CMAKE_BINARY_DIR} CACHE STRING "Executable directory on Windows") # TODO: options that should be checked/created: @@ -44,16 +44,17 @@ message(STATUS BUILD_GAME_SERVER Build game server (core server) BUILD_LOGIN_SERVER Build login server (auth server) BUILD_EXTRACTORS Build map/dbc/vmap/mmap extractor - BUILD_SCRIPTDEV Build scriptdev. (Disable it to speedup build in dev mode by not including scripts) - BUILD_PLAYERBOT Build Playerbot mod - BUILD_IKE3_BOTS Build Ike3 Playerbot mod + BUILD_PLAYERBOTS Build Playerbots mod + BUILD_MODULES Build modules system BUILD_AHBOT Build Auction House Bot mod - BUILD_MODULES Build module system BUILD_METRICS Build Metrics, generate data for Grafana BUILD_RECASTDEMOMOD Build map/vmap/mmap viewer BUILD_GIT_ID Build git_id BUILD_DOCS Build documentation with doxygen CMAKE_INTERPROCEDURAL_OPTIMIZATION Enable link-time optimizations + BUILD_DEPRECATED_PLAYERBOT Build Playerbot mod (deprecated) + BUILD_SCRIPTDEV Build scriptdev. (Disable it to speedup build + in dev mode by not including scripts) DEV_BINARY_DIR Target directory for executables on Windows only diff --git a/cmake/showoptions.cmake b/cmake/showoptions.cmake index fb616ef670..eecca19876 100644 --- a/cmake/showoptions.cmake +++ b/cmake/showoptions.cmake @@ -61,16 +61,16 @@ else() message(STATUS "Build METRICs : No (default)") endif() -if(BUILD_PLAYERBOT) - message(STATUS "Build Playerbot : Yes") +if(BUILD_DEPRECATED_PLAYERBOT) + message(STATUS "Build OLD Playerbot : Yes") else() - message(STATUS "Build Playerbot : No (default)") + message(STATUS "Build OLD Playerbot : No (default)") endif() -if(BUILD_IKE3_BOTS) - message(STATUS "Build ike3 Playerbots : Yes") +if(BUILD_PLAYERBOTS) + message(STATUS "Build Playerbots : Yes") else() - message(STATUS "Build ike3 Playerbots : No (default)") + message(STATUS "Build Playerbots : No (default)") endif() # Modules diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4d4292c553..4c01c1bf1a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,6 +21,38 @@ if(BUILD_GAME_SERVER OR BUILD_LOGIN_SERVER OR BUILD_EXTRACTORS) add_subdirectory(shared) endif() +# Playerbots module +if(BUILD_PLAYERBOTS) + include(FetchContent) + + FetchContent_Declare( + playerbots + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/modules/playerbots" + GIT_REPOSITORY "https://github.com/cmangos/playerbots.git" + GIT_TAG "master" + ) + + FetchContent_GetProperties(playerbots) + if (NOT playerbots_POPULATED) + FetchContent_Populate(playerbots) + message(STATUS "Playerbots module source dir: ${playerbots_SOURCE_DIR}") + else() + message(STATUS "Playerbots module already populated: ${playerbots_POPULATED}") + endif() + + #target_include_directories(Bots PUBLIC ${playerbots_SOURCE_DIR}) + message(STATUS "Playerbots module source dir: ${playerbots_SOURCE_DIR}") + message(STATUS "Playerbots module binary dir: ${playerbots_BINARY_DIR}") + message(STATUS "Playerbots module populated: ${playerbots_POPULATED}") + + add_subdirectory(${playerbots_SOURCE_DIR}) + +else() + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/playerbots) + file(REMOVE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/modules/playerbots) + endif() +endif() + if(BUILD_GAME_SERVER) add_subdirectory(game) add_subdirectory(mangosd) @@ -30,10 +62,6 @@ if(BUILD_LOGIN_SERVER) add_subdirectory(realmd) endif() -if(BUILD_IKE3_BOTS) -add_subdirectory(modules) -endif() - # Install modules if(BUILD_MODULES) list(LENGTH MODULE_NAMES MODULE_COUNT) @@ -48,21 +76,15 @@ if(BUILD_MODULES) FetchContent_Declare( ${LOWER_MODULE_NAME} + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/modules/${LOWER_MODULE_NAME}" GIT_REPOSITORY "${MODULE_URL}" GIT_TAG "main" ) + FetchContent_GetProperties(${LOWER_MODULE_NAME}) if(NOT ${LOWER_MODULE_NAME}_POPULATED) message(STATUS "Fetching ${LOWER_MODULE_NAME} module...") - FetchContent_Populate(${LOWER_MODULE_NAME}) - - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/${LOWER_MODULE_NAME}) - file(REMOVE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/modules/${LOWER_MODULE_NAME}) - endif() - - file(COPY ${${LOWER_MODULE_NAME}_SOURCE_DIR}/. DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/modules/${LOWER_MODULE_NAME}) - message(STATUS "${LOWER_MODULE_NAME} module fetched and populated in ${CMAKE_CURRENT_SOURCE_DIR}/modules/${LOWER_MODULE_NAME}") endif() diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt index 023ccaa1d7..61d7db49df 100644 --- a/src/game/CMakeLists.txt +++ b/src/game/CMakeLists.txt @@ -40,7 +40,7 @@ if(NOT BUILD_SCRIPTDEV) endforeach() endif() -if(NOT BUILD_PLAYERBOT) +if(NOT BUILD_DEPRECATED_PLAYERBOT) # exclude Playerbot folder set (EXCLUDE_DIR "PlayerBot/") foreach (TMP_PATH ${LIBRARY_SRCS}) @@ -51,9 +51,9 @@ if(NOT BUILD_PLAYERBOT) endforeach() endif() -if(NOT BUILD_IKE3_BOTS) - # exclude Ike3 Playerbots folder - set (EXCLUDE_DIR "Bots/") +if(NOT BUILD_PLAYERBOTS) + # exclude Playerbots folder + set (EXCLUDE_DIR "playerbots/") foreach (TMP_PATH ${LIBRARY_SRCS}) string (FIND ${TMP_PATH} ${EXCLUDE_DIR} EXCLUDE_DIR_FOUND) if (NOT ${EXCLUDE_DIR_FOUND} EQUAL -1) @@ -95,7 +95,7 @@ target_link_libraries(${LIBRARY_NAME} ) # include additionals headers -if(NOT BUILD_IKE3_BOTS) +if(NOT BUILD_PLAYERBOTS) set(ADDITIONAL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/vmap @@ -122,66 +122,10 @@ target_include_directories(${LIBRARY_NAME} PRIVATE ${Boost_INCLUDE_DIRS} ) -if(BUILD_IKE3_BOTS) - include_directories( - ${CMAKE_SOURCE_DIR}/src/modules/Bots/playerbot - ${CMAKE_SOURCE_DIR}/src/modules/Bots/ahbot - ${CMAKE_SOURCE_DIR}/src/game - ${CMAKE_SOURCE_DIR}/src/game/AI - ${CMAKE_SOURCE_DIR}/src/game/Accounts - ${CMAKE_SOURCE_DIR}/src/game/Addons - ${CMAKE_SOURCE_DIR}/src/game/Arena - ${CMAKE_SOURCE_DIR}/src/game/AuctionHouse - ${CMAKE_SOURCE_DIR}/src/game/BattleGround - ${CMAKE_SOURCE_DIR}/src/game/Chat - ${CMAKE_SOURCE_DIR}/src/game/ChatCommands - ${CMAKE_SOURCE_DIR}/src/game/Combat - ${CMAKE_SOURCE_DIR}/src/game/DBScripts - ${CMAKE_SOURCE_DIR}/src/game/Entities - ${CMAKE_SOURCE_DIR}/src/game/GMTickets - ${CMAKE_SOURCE_DIR}/src/game/GameEvents - ${CMAKE_SOURCE_DIR}/src/game/Globals - ${CMAKE_SOURCE_DIR}/src/game/Grids - ${CMAKE_SOURCE_DIR}/src/game/Groups - ${CMAKE_SOURCE_DIR}/src/game/Guilds - ${CMAKE_SOURCE_DIR}/src/game/LFG - ${CMAKE_SOURCE_DIR}/src/game/Loot - ${CMAKE_SOURCE_DIR}/src/game/Mails - ${CMAKE_SOURCE_DIR}/src/game/Maps - ${CMAKE_SOURCE_DIR}/src/game/MotionGenerators - ${CMAKE_SOURCE_DIR}/src/game/Movement - ${CMAKE_SOURCE_DIR}/src/game/Object - ${CMAKE_SOURCE_DIR}/src/game/OutdoorPvP - ${CMAKE_SOURCE_DIR}/src/game/Pools - ${CMAKE_SOURCE_DIR}/src/game/Quests - ${CMAKE_SOURCE_DIR}/src/game/References - ${CMAKE_SOURCE_DIR}/src/game/Reputation - ${CMAKE_SOURCE_DIR}/src/game/Server - ${CMAKE_SOURCE_DIR}/src/game/Server - ${CMAKE_SOURCE_DIR}/src/game/Skills - ${CMAKE_SOURCE_DIR}/src/game/Social - ${CMAKE_SOURCE_DIR}/src/game/Spells - ${CMAKE_SOURCE_DIR}/src/game/Tools - ${CMAKE_SOURCE_DIR}/src/game/Trade - ${CMAKE_SOURCE_DIR}/src/game/VoiceChat - ${CMAKE_SOURCE_DIR}/src/game/Warden - ${CMAKE_SOURCE_DIR}/src/game/Weather - ${CMAKE_SOURCE_DIR}/src/game/World - ${CMAKE_SOURCE_DIR}/src/game/WorldHandlers - ${CMAKE_SOURCE_DIR}/src/game/movement - ${CMAKE_SOURCE_DIR}/src/game/vmap - ${CMAKE_SOURCE_DIR}/src/shared - ${CMAKE_SOURCE_DIR}/src/shared/Auth - ${CMAKE_SOURCE_DIR}/src/shared/Config - ${CMAKE_SOURCE_DIR}/src/shared/Common - ${CMAKE_SOURCE_DIR}/src/shared/Database - ${CMAKE_SOURCE_DIR}/src/shared/DataStores - ${CMAKE_SOURCE_DIR}/src/shared/Utilities - ${CMAKE_SOURCE_DIR}/src/shared/Log - ${CMAKE_SOURCE_DIR}/src/shared/Threading - ) - target_link_libraries(${LIBRARY_NAME} PUBLIC Bots) - add_dependencies(${LIBRARY_NAME} Bots) +if(BUILD_PLAYERBOTS) + target_link_libraries(${LIBRARY_NAME} PUBLIC playerbots) + target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/src/modules/playerbots) + add_dependencies(${LIBRARY_NAME} playerbots) endif() # Add modules to project @@ -229,13 +173,13 @@ if (BUILD_METRICS) add_definitions(-DBUILD_METRICS) endif() -# Define BUILD_PLAYERBOT if need -if (BUILD_PLAYERBOT) - add_definitions(-DBUILD_PLAYERBOT) +# Define BUILD_DEPRECATED_PLAYERBOT if need +if (BUILD_DEPRECATED_PLAYERBOT) + add_definitions(-DBUILD_DEPRECATED_PLAYERBOT) endif() -# Define Ike3 Bots ENABLE_PLAYERBOTS if need -if (BUILD_IKE3_BOTS) +# Define ENABLE_PLAYERBOTS if need +if (BUILD_PLAYERBOTS) add_definitions(-DENABLE_PLAYERBOTS) endif() diff --git a/src/game/Chat/Chat.cpp b/src/game/Chat/Chat.cpp index c47356d07b..c31cd251c3 100644 --- a/src/game/Chat/Chat.cpp +++ b/src/game/Chat/Chat.cpp @@ -36,9 +36,9 @@ #include "GameEvents/GameEventMgr.h" #ifdef ENABLE_PLAYERBOTS -#include "AhBot.h" -#include "playerbot.h" -#include "PlayerbotAIConfig.h" +#include "ahbot/AhBot.h" +#include "playerbot/playerbot.h" +#include "playerbot/PlayerbotAIConfig.h" #endif #ifdef ENABLE_MODULES @@ -1011,7 +1011,7 @@ ChatCommand* ChatHandler::getCommandTable() { "quit", SEC_CONSOLE, true, &ChatHandler::HandleQuitCommand, "", nullptr }, { "mmap", SEC_GAMEMASTER, false, nullptr, "", mmapCommandTable }, { "worldstate", SEC_ADMINISTRATOR, false, nullptr, "", worldStateTable }, -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT { "bot", SEC_PLAYER, false, &ChatHandler::HandlePlayerbotCommand, "", nullptr }, #endif { nullptr, 0, false, nullptr, "", nullptr } diff --git a/src/game/Chat/Chat.h b/src/game/Chat/Chat.h index 46e770d846..2c54d943a1 100644 --- a/src/game/Chat/Chat.h +++ b/src/game/Chat/Chat.h @@ -752,7 +752,7 @@ class ChatHandler bool HandleStableCommand(char* args); bool HandleWaterwalkCommand(char* args); bool HandleQuitCommand(char* args); -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT bool HandlePlayerbotCommand(char* args); #endif diff --git a/src/game/Chat/ChatHandler.cpp b/src/game/Chat/ChatHandler.cpp index 6ebd47691f..486836dfd4 100644 --- a/src/game/Chat/ChatHandler.cpp +++ b/src/game/Chat/ChatHandler.cpp @@ -38,8 +38,8 @@ #include "Anticheat/Anticheat.hpp" #ifdef ENABLE_PLAYERBOTS -#include "playerbot.h" -#include "RandomPlayerbotMgr.h" +#include "playerbot/playerbot.h" +#include "playerbot/RandomPlayerbotMgr.h" #endif #ifdef ENABLE_MODULES @@ -48,7 +48,7 @@ bool WorldSession::CheckChatMessage(std::string& msg, bool addon/* = false*/) { -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT // bot check can be avoided if (_player->GetPlayerbotAI()) return true; diff --git a/src/game/Entities/CharacterHandler.cpp b/src/game/Entities/CharacterHandler.cpp index b541f765c4..aaecc91053 100644 --- a/src/game/Entities/CharacterHandler.cpp +++ b/src/game/Entities/CharacterHandler.cpp @@ -42,13 +42,13 @@ #include "Anticheat/Anticheat.hpp" #include "Mails/Mail.h" -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT #include "PlayerBot/Base/PlayerbotMgr.h" #endif #ifdef ENABLE_PLAYERBOTS -#include "playerbot.h" -#include "PlayerbotAIConfig.h" +#include "playerbot/playerbot.h" +#include "playerbot/PlayerbotAIConfig.h" #endif // config option SkipCinematics supported values @@ -247,7 +247,7 @@ class CharacterHandler } #endif } -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT // This callback is different from the normal HandlePlayerLoginCallback in that it // sets up the bot's world session and also stores the pointer to the bot player in the master's // world session m_playerBots map @@ -674,7 +674,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket& recv_data) CharacterDatabase.DelayQueryHolder(&chrHandler, &CharacterHandler::HandlePlayerLoginCallback, holder); } -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT // Can't easily reuse HandlePlayerLoginOpcode for logging in bots because it assumes // a WorldSession exists for the bot. The WorldSession for a bot is created after the character is loaded. void PlayerbotMgr::LoginPlayerBot(ObjectGuid playerGuid) diff --git a/src/game/Entities/Creature.h b/src/game/Entities/Creature.h index 9e71e676a4..3d25a10bf9 100644 --- a/src/game/Entities/Creature.h +++ b/src/game/Entities/Creature.h @@ -570,7 +570,7 @@ class Creature : public Unit bool IsTemporarySummon() const { return m_subtype == CREATURE_SUBTYPE_TEMPORARY_SUMMON; } bool IsCritter() const { return m_creatureInfo->CreatureType == CREATURE_TYPE_CRITTER; } -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT // Adds functionality to load/unload bots from NPC, also need to apply SQL scripts void LoadBotMenu(Player* pPlayer); #endif diff --git a/src/game/Entities/Player.cpp b/src/game/Entities/Player.cpp index 1c957ebda7..ce54b8c51a 100644 --- a/src/game/Entities/Player.cpp +++ b/src/game/Entities/Player.cpp @@ -62,15 +62,15 @@ #include "World/WorldState.h" #include "Anticheat/Anticheat.hpp" -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT #include "PlayerBot/Base/PlayerbotAI.h" #include "PlayerBot/Base/PlayerbotMgr.h" #include "Config/Config.h" #endif #ifdef ENABLE_PLAYERBOTS -#include "playerbot.h" -#include "PlayerbotAIConfig.h" +#include "playerbot/playerbot.h" +#include "playerbot/PlayerbotAIConfig.h" #endif #ifdef ENABLE_MODULES @@ -93,7 +93,7 @@ #define SKILL_PERM_BONUS(x) int16(PAIR32_HIPART(x)) #define MAKE_SKILL_BONUS(t, p) MAKE_PAIR32(t,p) -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT extern Config botConfig; #endif @@ -473,7 +473,7 @@ void TradeData::SetAccepted(bool state, bool crosssend /*= false*/) Player::Player(WorldSession* session): Unit(), m_taxiTracker(*this), m_mover(this), m_camera(this), m_reputationMgr(this), m_launched(false) { -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT m_playerbotAI = 0; m_playerbotMgr = 0; #endif @@ -691,7 +691,7 @@ Player::~Player() for (auto& itr : m_boundInstances) itr.second.state->RemovePlayer(this); -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT if (m_playerbotAI) { delete m_playerbotAI; @@ -1639,7 +1639,7 @@ void Player::Update(const uint32 diff) GetVisibilityData().SetVisibilityDistanceOverride(VisibilityDistanceType::Normal); } -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT if (m_playerbotAI) m_playerbotAI->UpdateAI(diff); else if (m_playerbotMgr) @@ -1959,7 +1959,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati if (HasCharmer()) return false; -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT // If this user has bots, tell them to stop following master // so they don't try to follow the master after the master teleports if (GetPlayerbotMgr()) @@ -11766,7 +11766,7 @@ void Player::PrepareGossipMenu(WorldObject* pSource, uint32 menuId, bool forceQu break; // no checks case GOSSIP_OPTION_BOT: { -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT if (botConfig.GetBoolDefault("PlayerbotAI.DisableBots", false) && !pCreature->isInnkeeper()) { ChatHandler(this).PSendSysMessage("|cffff0000Playerbot system is currently disabled!"); @@ -12047,7 +12047,7 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId) GetSession()->SendBattleGroundList(guid, bgTypeId); break; } -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT case GOSSIP_OPTION_BOT: { // DEBUG_LOG("GOSSIP_OPTION_BOT"); diff --git a/src/game/Entities/Player.h b/src/game/Entities/Player.h index a50a856416..22412cd744 100644 --- a/src/game/Entities/Player.h +++ b/src/game/Entities/Player.h @@ -58,7 +58,7 @@ class Spell; class Item; struct FactionTemplateEntry; -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT #include "PlayerBot/Base/PlayerbotMgr.h" #include "PlayerBot/Base/PlayerbotAI.h" #endif @@ -1372,7 +1372,7 @@ class Player : public Unit void AddTimedQuest(uint32 quest_id) { m_timedquests.insert(quest_id); } void RemoveTimedQuest(uint32 quest_id) { m_timedquests.erase(quest_id); } -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT void chompAndTrim(std::string& str); bool getNextQuestId(const std::string& pString, unsigned int& pStartPos, unsigned int& pId); void skill(std::list& m_spellsToLearn); @@ -2218,7 +2218,7 @@ class Player : public Unit void SendMessageToPlayer(std::string const& message) const; // debugging purposes void SendThreatMessageToPlayer(std::string const& message) const; -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT // A Player can either have a playerbotMgr (to manage its bots), or have playerbotAI (if it is a bot), or // neither. Code that enables bots must create the playerbotMgr and set it using SetPlayerbotMgr. void SetPlayerbotAI(PlayerbotAI* ai) { assert(!m_playerbotAI && !m_playerbotMgr); m_playerbotAI = ai; } @@ -2544,7 +2544,7 @@ class Player : public Unit MapReference m_mapRef; std::unique_ptr m_playerMenu; -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT PlayerbotAI* m_playerbotAI; PlayerbotMgr* m_playerbotMgr; #endif diff --git a/src/game/Groups/Group.cpp b/src/game/Groups/Group.cpp index db0698017f..d696f71729 100644 --- a/src/game/Groups/Group.cpp +++ b/src/game/Groups/Group.cpp @@ -33,7 +33,7 @@ #include "Maps/MapPersistentStateMgr.h" #include "LFG/LFGMgr.h" #include "LFG/LFGQueue.h" -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT #include "PlayerBot/Base/PlayerbotMgr.h" #endif @@ -390,7 +390,7 @@ bool Group::AddMember(ObjectGuid guid, const char* name, uint8 joinMethod) uint32 Group::RemoveMember(ObjectGuid guid, uint8 method) { Player* player = sObjectMgr.GetPlayer(guid); -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT // if master leaves group, all bots leave group if (player && player->GetPlayerbotMgr()) player->GetPlayerbotMgr()->RemoveAllBotsFromGroup(); diff --git a/src/game/Maps/Map.cpp b/src/game/Maps/Map.cpp index 646b8b2191..05662d6ed9 100644 --- a/src/game/Maps/Map.cpp +++ b/src/game/Maps/Map.cpp @@ -47,7 +47,7 @@ #include #ifdef ENABLE_PLAYERBOTS -#include "playerbot.h" +#include "playerbot/playerbot.h" #endif #ifdef _WIN32 diff --git a/src/game/Quests/QuestHandler.cpp b/src/game/Quests/QuestHandler.cpp index d247749ab9..cedd648e38 100644 --- a/src/game/Quests/QuestHandler.cpp +++ b/src/game/Quests/QuestHandler.cpp @@ -31,7 +31,7 @@ #include "Groups/Group.h" #include "Tools/Formulas.h" -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT #include "PlayerBot/Base/PlayerbotAI.h" #endif @@ -599,12 +599,12 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket) continue; } -#ifndef BUILD_PLAYERBOT +#ifndef BUILD_DEPRECATED_PLAYERBOT pPlayer->GetPlayerMenu()->SendQuestGiverQuestDetails(pQuest, _player->GetObjectGuid(), true); #endif pPlayer->SetDividerGuid(_player->GetObjectGuid()); -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT if (pPlayer->GetPlayerbotAI()) pPlayer->GetPlayerbotAI()->AcceptQuest(pQuest, _player); else diff --git a/src/game/Server/WorldSession.cpp b/src/game/Server/WorldSession.cpp index b7612b7c9e..86bac0d0f3 100644 --- a/src/game/Server/WorldSession.cpp +++ b/src/game/Server/WorldSession.cpp @@ -47,13 +47,13 @@ #include #include -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT #include "PlayerBot/Base/PlayerbotMgr.h" #include "PlayerBot/Base/PlayerbotAI.h" #endif #ifdef ENABLE_PLAYERBOTS -#include "playerbot.h" +#include "playerbot/playerbot.h" #endif // select opcodes appropriate for processing in Map::Update context for current session state @@ -197,7 +197,7 @@ void WorldSession::SetPlayer(Player* plr, uint32 playerGuid) /// Send a packet to the client void WorldSession::SendPacket(WorldPacket const& packet, bool forcedSend /*= false*/) const { -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT // Send packet to bot AI if (GetPlayer()) { @@ -398,7 +398,7 @@ bool WorldSession::Update(uint32 diff) // lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT if (_player && _player->GetPlayerbotMgr()) _player->GetPlayerbotMgr()->HandleMasterIncomingPacket(*packet); #endif @@ -456,7 +456,7 @@ bool WorldSession::Update(uint32 diff) } } -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT // Process player bot packets // The PlayerbotAI class adds to the packet queue to simulate a real player // since Playerbots are known to the World obj only by its master's WorldSession object @@ -632,7 +632,7 @@ void WorldSession::LogoutPlayer() if (_player) { -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT // Log out all player bots owned by this toon if (_player->GetPlayerbotMgr()) _player->GetPlayerbotMgr()->LogoutAllBots(true); @@ -708,7 +708,7 @@ void WorldSession::LogoutPlayer() // No SQL injection as AccountID is uint32 static SqlStatementID id; -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT if (!_player->GetPlayerbotAI()) { // Unmodded core code below @@ -767,7 +767,7 @@ void WorldSession::LogoutPlayer() // GM ticket notification sTicketMgr.OnPlayerOnlineState(*_player, false); -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT // Remember player GUID for update SQL below uint32 guid = _player->GetGUIDLow(); #endif @@ -808,7 +808,7 @@ void WorldSession::LogoutPlayer() static SqlStatementID updChars; -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT // Set for only character instead of accountid // Different characters can be alive as bots SqlStatement stmt = CharacterDatabase.CreateStatement(updChars, "UPDATE characters SET online = 0 WHERE guid = ?"); @@ -859,7 +859,7 @@ void WorldSession::KickPlayer(bool save, bool inPlace, bool kickSession) return; } -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT if (!_player) return; @@ -1330,7 +1330,7 @@ void WorldSession::SetDelayedAnticheat(std::unique_ptrGetRemoteAddress() : "disconnected/bot"; } #else @@ -258,7 +258,7 @@ class WorldSession void SetDelayedAnticheat(std::unique_ptr&& anticheat); SessionAnticheatInterface* GetAnticheat() const { return m_anticheat.get(); } -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT void SetNoAnticheat(); #endif diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp index 4c06354917..de7a20f0f2 100644 --- a/src/game/Spells/Spell.cpp +++ b/src/game/Spells/Spell.cpp @@ -48,7 +48,7 @@ #include "Entities/ObjectGuid.h" #ifdef ENABLE_PLAYERBOTS -#include "PlayerbotAI.h" +#include "playerbot/PlayerbotAI.h" #endif #ifdef ENABLE_MODULES diff --git a/src/game/Spells/SpellHandler.cpp b/src/game/Spells/SpellHandler.cpp index 5623698429..91419f9ba3 100644 --- a/src/game/Spells/SpellHandler.cpp +++ b/src/game/Spells/SpellHandler.cpp @@ -376,7 +376,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) // client provided targets SpellCastTargets targets; -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT recvPacket >> targets.ReadForCaster(mover); #else recvPacket >> targets.ReadForCaster(_player); diff --git a/src/game/World/World.cpp b/src/game/World/World.cpp index 5fa0e1e629..08c488d376 100644 --- a/src/game/World/World.cpp +++ b/src/game/World/World.cpp @@ -78,9 +78,9 @@ #endif #ifdef ENABLE_PLAYERBOTS -#include "AhBot.h" -#include "PlayerbotAIConfig.h" -#include "RandomPlayerbotMgr.h" +#include "ahbot/AhBot.h" +#include "playerbot/PlayerbotAIConfig.h" +#include "playerbot/RandomPlayerbotMgr.h" #endif #ifdef ENABLE_MODULES @@ -1497,7 +1497,7 @@ void World::SetInitialWorldSettings() #endif // BUILD_METRICS -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT PlayerbotMgr::SetInitialWorldSettings(); #endif diff --git a/src/mangosd/CMakeLists.txt b/src/mangosd/CMakeLists.txt index 868c4d5741..e5483213d7 100644 --- a/src/mangosd/CMakeLists.txt +++ b/src/mangosd/CMakeLists.txt @@ -90,10 +90,15 @@ if(WIN32) COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/src/game/Anticheat/module/warden_modules/ $/warden_modules DEPENDS ${EXECUTABLE_NAME}) - if(BUILD_PLAYERBOT) + if(BUILD_DEPRECATED_PLAYERBOT) add_custom_command(TARGET ${EXECUTABLE_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different \"${CMAKE_SOURCE_DIR}/src/game/PlayerBot/playerbot.conf.dist.in\" \"$/playerbot.conf.dist\") endif() + + if(BUILD_PLAYERBOTS) + add_custom_command(TARGET ${EXECUTABLE_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different \"${CMAKE_SOURCE_DIR}/src/modules/playerbots/playerbot/aiplayerbot.conf.dist.in\" \"$/aiplayerbot.conf.dist\") + endif() if(BUILD_AHBOT) add_custom_command(TARGET ${EXECUTABLE_NAME} POST_BUILD @@ -122,9 +127,9 @@ install(TARGETS ${EXECUTABLE_NAME} DESTINATION ${BIN_DIR}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mangosd.conf.dist.in ${CMAKE_CURRENT_BINARY_DIR}/mangosd.conf.dist) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mangosd.conf.dist DESTINATION ${CONF_DIR}) -# Define BUILD_PLAYERBOT if need -if (BUILD_PLAYERBOT) - add_definitions(-DBUILD_PLAYERBOT) +# Define BUILD_DEPRECATED_PLAYERBOT if need +if (BUILD_DEPRECATED_PLAYERBOT) + add_definitions(-DBUILD_DEPRECATED_PLAYERBOT) configure_file(${CMAKE_SOURCE_DIR}/src/game/PlayerBot/playerbot.conf.dist.in ${CMAKE_CURRENT_BINARY_DIR}/playerbot.conf.dist) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/playerbot.conf.dist DESTINATION ${CONF_DIR}) endif() diff --git a/src/mangosd/Main.cpp b/src/mangosd/Main.cpp index c5a564a92f..4836d292f6 100644 --- a/src/mangosd/Main.cpp +++ b/src/mangosd/Main.cpp @@ -74,7 +74,7 @@ int main(int argc, char* argv[]) desc.add_options() ("ahbot,a", boost::program_options::value(&auctionBotConfig), "ahbot configuration file") ("config,c", boost::program_options::value(&configFile)->default_value(_MANGOSD_CONFIG), "configuration file") -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT ("playerbot,p", boost::program_options::value(&playerBotConfig)->default_value(_D_PLAYERBOT_CONFIG), "playerbot configuration file") #endif ("help,h", "prints usage") @@ -116,7 +116,7 @@ int main(int argc, char* argv[]) if (vm.count("ahbot")) sAuctionHouseBot.SetConfigFileName(auctionBotConfig); -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT if (vm.count("playerbot")) _PLAYERBOT_CONFIG = playerBotConfig; #endif diff --git a/src/modules/Bots b/src/modules/Bots deleted file mode 160000 index f1720edd6c..0000000000 --- a/src/modules/Bots +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f1720edd6ca54eed57a140b6a42ad87486ec3f60 diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt deleted file mode 100644 index 10efa42e94..0000000000 --- a/src/modules/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# MaNGOS is a full featured server for World of Warcraft, supporting -# the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 -# -# Copyright (C) 2005-2018 MaNGOS project -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -# Include Player Bots if enabled -if(BUILD_IKE3_BOTS) - add_subdirectory(Bots) -endif() \ No newline at end of file diff --git a/src/shared/Database/Database.cpp b/src/shared/Database/Database.cpp index 305e160049..9f3fc38c82 100644 --- a/src/shared/Database/Database.cpp +++ b/src/shared/Database/Database.cpp @@ -495,7 +495,7 @@ bool Database::CheckRequiredField(char const* table_name, char const* required_n sLog.outErrorDb(" [B] You need: --> `%s.sql`", req_sql_update_name); sLog.outErrorDb(); sLog.outErrorDb("You must apply all updates after [A] to [B] to use mangos with this database."); -#ifdef BUILD_PLAYERBOT +#ifdef BUILD_DEPRECATED_PLAYERBOT if (reqName.find("playerbot") != std::string::npos) { sLog.outErrorDb("These updates are included in the [sql/PlayerBot] folder.");