Skip to content

Commit

Permalink
[CMake/Eluna] Make Eluna optional when compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
AntzMangos committed Jul 29, 2014
1 parent 3ee546f commit 5328ab5
Show file tree
Hide file tree
Showing 35 changed files with 396 additions and 17 deletions.
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ option(USE_STD_MALLOC "Use standard malloc instead of TBB" ON)
option(ACE_USE_EXTERNAL "Use external ACE" OFF)
option(POSTGRESQL "Use PostgreSQL" OFF)
option(BUILD_TOOLS "Build tools (map/vmap/mmap extractors)" OFF)
option(SCRIPT_LIB_ELUNA "Use Eluna as the scripting engine" ON)
option(SCRIPT_LIB_SD2 "Use ScriptDev2 as the scripting engine" ON)

if(PCHSupport_FOUND AND WIN32) # TODO: why only enable it on windows by default?
option(PCH "Use precompiled headers" ON)
Expand All @@ -49,12 +51,16 @@ message("")
message(
"This script builds the MaNGOS server.
Options that can be used in order to configure the process:
General:
CMAKE_INSTALL_PREFIX Path where the server should be installed to
PCH Use precompiled headers
DEBUG Debug mode
USE_STD_MALLOC Use standard malloc instead of TBB
ACE_USE_EXTERNAL Use external ACE
BUILD_TOOLS Build map/vmap/mmap extractors
Scripting engines:
SCRIPT_LIB_ELUNA Compile with support for Eluna scripts
SCRIPT_LIB_SD2 Compile with support for ScriptDev2 scripts
To set an option simply type -D<OPTION>=<VALUE> after 'cmake <srcs>'.
Also, you can specify the generator with -G. see 'cmake --help' for more details
Expand Down Expand Up @@ -355,6 +361,17 @@ else()
set(ENABLE_SOAP OFF)
endif()

set(ENABLE_ELUNA OFF)
set(ENABLE_SD2 OFF)

if (SCRIPT_LIB_ELUNA)
set(ENABLE_ELUNA ON)
endif()

if (SCRIPT_LIB_SD2)
set(ENABLE_SD2 ON)
endif()

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config.h")

add_subdirectory(dep)
Expand Down
4 changes: 4 additions & 0 deletions config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@

#cmakedefine ENABLE_SOAP

#cmakedefine ENABLE_ELUNA

#cmakedefine ENABLE_SD2

#define VERSION "${MANGOS_VERSION}"

#endif /* HAVE_CONFIG_H */
5 changes: 4 additions & 1 deletion dep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ endif()
add_subdirectory(recastnavigation)
add_subdirectory(src)
add_subdirectory(libmpq)
add_subdirectory(lualib)

if(SCRIPT_LIB_ELUNA)
add_subdirectory(lualib)
endif()
6 changes: 6 additions & 0 deletions src/game/AuctionHouseHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
#include "Mail.h"
#include "Util.h"
#include "Chat.h"
#ifdef ENABLE_ELUNA
#include "LuaEngine.h"
#endif /* ENABLE_ELUNA */

/** \addtogroup auctionhouse
* @{
Expand Down Expand Up @@ -338,7 +340,9 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recv_data)
SendAuctionCommandResult(AH, AUCTION_STARTED, AUCTION_OK);

// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnAdd(auctionHouse);
#endif /* ENABLE_ELUNA */
}

// this function is called when client bids or buys out auction
Expand Down Expand Up @@ -490,7 +494,9 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recv_data)
sAuctionMgr.RemoveAItem(auction->itemGuidLow);
auctionHouse->RemoveAuction(auction->Id);
// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnRemove(auctionHouse);
#endif /* ENABLE_ELUNA */
delete auction;
}

Expand Down
4 changes: 4 additions & 0 deletions src/game/AuctionHouseMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
#include "WorldPacket.h"
#include "WorldSession.h"
#include "Mail.h"
#ifdef ENABLE_ELUNA
#include "LuaEngine.h"
#endif /* ENABLE_ELUNA */

#include "Policies/Singleton.h"

Expand All @@ -62,7 +64,9 @@ AuctionHouseMgr::~AuctionHouseMgr()

AuctionHouseObject::~AuctionHouseObject()
{
#ifdef ENABLE_ELUNA
Eluna::RemoveRef(this);
#endif /* ENABLE_ELUNA */

for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
delete itr->second;
Expand Down
46 changes: 32 additions & 14 deletions src/game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ include_directories(
"${CMAKE_SOURCE_DIR}/dep/recastnavigation/Detour"
"${CMAKE_SOURCE_DIR}/dep/recastnavigation/"
"${CMAKE_SOURCE_DIR}/dep/include"
"${CMAKE_SOURCE_DIR}/dep/lualib"
"${CMAKE_SOURCE_DIR}/src/shared"
"${CMAKE_SOURCE_DIR}/src/framework"
"${CMAKE_SOURCE_DIR}/src/game/LuaEngine"
Expand All @@ -36,6 +35,10 @@ include_directories(
"${ACE_INCLUDE_DIR}"
)

if(SCRIPT_LIB_ELUNA)
include_directories("${CMAKE_SOURCE_DIR}/dep/lualib")
endif()

set(SRC_GRP_AHBOT
AuctionHouseBot/AuctionHouseBot.cpp
AuctionHouseBot/AuctionHouseBot.h
Expand All @@ -55,10 +58,12 @@ set(SRC_GRP_BATTLEGROUND
BattleGround/BattleGroundWS.h
)

file(GLOB SRC_FILES_LUAENGINE LuaEngine/*.cpp LuaEngine/*.h)
set(SRC_GRP_LUAENGINE
${SRC_FILES_LUAENGINE}
)
if (SCRIPT_LIB_ELUNA)
file(GLOB SRC_FILES_LUAENGINE LuaEngine/*.cpp LuaEngine/*.h)
set(SRC_GRP_LUAENGINE
${SRC_FILES_LUAENGINE}
)
endif()

set(SRC_GRP_CHAT_COMMANDS
debugcmds.cpp
Expand Down Expand Up @@ -375,7 +380,6 @@ set(SRC_GRP_WORLD_HANDLERS
set(LIBRARY_SRCS
${SRC_GRP_AHBOT}
${SRC_GRP_BATTLEGROUND}
${SRC_GRP_LUAENGINE}
${SRC_GRP_CHAT_COMMANDS}
${SRC_GRP_MOTION_GEN}
${SRC_GRP_MOVEMENT}
Expand All @@ -390,6 +394,10 @@ set(LIBRARY_SRCS
pchdef.h
)

if(SCRIPT_LIB_ELUNA)
list(APPEND LIBRARY_SRCS ${SRC_GRP_LUAENGINE})
endif()

source_group("AhBot"
FILES
${SRC_GRP_AHBOT}
Expand All @@ -400,10 +408,12 @@ source_group("BattleGround"
${SRC_GRP_BATTLEGROUND}
)

source_group("LuaEngine"
FILES
${SRC_GRP_LUAENGINE}
)
if(SCRIPT_LIB_ELUNA)
source_group("LuaEngine"
FILES
${SRC_GRP_LUAENGINE}
)
endif()

source_group("Chat Commands"
FILES
Expand Down Expand Up @@ -466,9 +476,12 @@ add_library(${LIBRARY_NAME} STATIC
target_link_libraries(${LIBRARY_NAME}
shared
detour
lualib
)

if(SCRIPT_LIB_ELUNA)
target_link_libraries(${LIBRARY_NAME} lualib)
endif()

if(UNIX)
# Both systems don't have libdl and don't need them
if (NOT (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "NetBSD"))
Expand All @@ -479,9 +492,12 @@ if(UNIX)
endif()

add_dependencies(${LIBRARY_NAME} revision.h)
add_dependencies(${LIBRARY_NAME} lualib)
if(SCRIPT_LIB_ELUNA)
add_dependencies(${LIBRARY_NAME} lualib)
endif()

if(NOT ACE_USE_EXTERNAL)
add_dependencies(${LIBRARY_NAME} ACE_Project)
add_dependencies(${LIBRARY_NAME} ACE_Project)
endif()

# Generate precompiled header
Expand All @@ -500,4 +516,6 @@ if(PCH)
endif()

add_subdirectory(AuctionHouseBot)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/LuaEngine/extensions DESTINATION ${BIN_DIR}/lua_scripts/)
if(SCRIPT_LIB_ELUNA)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/LuaEngine/extensions DESTINATION ${BIN_DIR}/lua_scripts/)
endif()
10 changes: 10 additions & 0 deletions src/game/CharacterHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
#include "Language.h"
#include "Chat.h"
#include "SpellMgr.h"
#ifdef ENABLE_ELUNA
#include "LuaEngine.h"
#endif /* ENABLE_ELUNA */

// config option SkipCinematics supported values
enum CinematicsSkipMode
Expand Down Expand Up @@ -366,7 +368,9 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recv_data)
sLog.outChar("Account: %d (IP: %s) Create Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), pNewChar->GetGUIDLow());

// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnCreate(pNewChar);
#endif /* ENABLE_ELUNA */

delete pNewChar; // created only to call SaveToDB()
}
Expand Down Expand Up @@ -412,7 +416,9 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recv_data)
sLog.outChar("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), lowguid);

// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnDelete(lowguid);
#endif /* ENABLE_ELUNA */

if (sLog.IsOutCharDump()) // optimize GetPlayerDump call
{
Expand Down Expand Up @@ -711,8 +717,10 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
}

// Used by Eluna
#ifdef ENABLE_ELUNA
if (pCurrChar->HasAtLoginFlag(AT_LOGIN_FIRST))
sEluna->OnFirstLogin(pCurrChar);
#endif /* ENABLE_ELUNA */


/* We've done what we need to, remove the flag */
Expand Down Expand Up @@ -758,7 +766,9 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
m_playerLoading = false;

// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnLogin(pCurrChar);
#endif /* ENABLE_ELUNA */

/* Used for movement */
m_clientTimeDelay = 0;
Expand Down
6 changes: 6 additions & 0 deletions src/game/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
#include "PoolManager.h"
#include "GameEventMgr.h"
#include "AuctionHouseBot/AuctionHouseBot.h"
#ifdef ENABLE_ELUNA
#include "LuaEngine.h"
#endif /* ENABLE_ELUNA */

// Supported shift-links (client generated and server side)
// |color|Harea:area_id|h[name]|h|r
Expand Down Expand Up @@ -1200,17 +1202,21 @@ void ChatHandler::ExecuteCommand(const char* text)
}
case CHAT_COMMAND_UNKNOWN_SUBCOMMAND:
{
#ifdef ENABLE_ELUNA
if (!sEluna->OnCommand(m_session ? m_session->GetPlayer() : NULL, fullcmd.c_str()))
return;
#endif /* ENABLE_ELUNA */
SendSysMessage(LANG_NO_SUBCMD);
ShowHelpForCommand(command->ChildCommands, text);
SetSentErrorMessage(true);
break;
}
case CHAT_COMMAND_UNKNOWN:
{
#ifdef ENABLE_ELUNA
if (!sEluna->OnCommand(m_session ? m_session->GetPlayer() : NULL, fullcmd.c_str()))
return;
#endif /* ENABLE_ELUNA */
SendSysMessage(LANG_NO_CMD);
SetSentErrorMessage(true);
break;
Expand Down
Loading

1 comment on commit 5328ab5

@billy1arm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Author is @lfxgroove

Please sign in to comment.