Changes to building

This commit is contained in:
KimLS 2019-08-25 14:45:54 -07:00
parent 83cae7aaf3
commit 72a922f2ba
47 changed files with 596 additions and 1812 deletions

View File

@ -1,128 +1,26 @@
#EQEmu CMake
#Variables used:
#EQEMU_DISABLE_CRT_SECURE_WARNINGS
#EQEMU_FAST_FLOATINGPOINT
#EQEMU_ENABLE_CRASH_LOGGING
#EQEMU_DISABLE_SAFESEH
#EQEMU_BUILD_MSVC_MP
#EQEMU_DEBUG_LEVEL
#EQEMU_LOG_LEVEL_STATUS
#EQEMU_LOG_LEVEL_NORMAL
#EQEMU_LOG_LEVEL_ERROR
#EQEMU_LOG_LEVEL_DEBUG
#EQEMU_LOG_LEVEL_QUEST
#EQEMU_LOG_LEVEL_COMMANDS
#EQEMU_LOG_LEVEL_CRASH
#EQEMU_DEPOP_INVALIDATES_CACHE
#EQEMU_ENABLE_BOTS
#EQEMU_DISABLE_LOGSYS
#EQEMU_COMMANDS_LOGGING
#EQEMU_BUILD_SERVER
#EQEMU_BUILD_LOGIN
#EQEMU_BUILD_TESTS
#EQEMU_BUILD_PERL
#EQEMU_BUILD_LUA
#EQEMU_SANITIZE_LUA_LIBS
#EQEMU_BUILD_CLIENT_FILES
#EQEMU_USE_MAP_MMFS
#EQEMU_MAP_DIR
#EQEMU_ARCH
#EQEMU_ARCH_ALT
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
IF(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
ENDIF()
#FindMySQL is located here so lets make it so CMake can find it
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH})
#Our project name is EQEmu
CMAKE_POLICY(SET CMP0074 NEW)
PROJECT(EQEmu)
#Default build type is set to RelWithDebInfo for generators that honor that like makefiles
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/dependencies" "${CMAKE_PREFIX_PATH}")
#Add our various windows definitions
IF(MSVC OR MINGW)
ADD_DEFINITIONS(-D_WINDOWS)
IF(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN64)
ELSE(CMAKE_CL_64)
ADD_DEFINITIONS(-DWIN32)
ENDIF(CMAKE_CL_64)
ENDIF(MSVC OR MINGW)
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS OFF)
IF(MSVC)
IF(CMAKE_CL_64)
SET(EQEMU_ARCH "x64")
SET(EQEMU_ARCH_ALT "x64")
ELSE(CMAKE_CL_64)
SET(EQEMU_ARCH "x86")
SET(EQEMU_ARCH_ALT "Win32")
ENDIF(CMAKE_CL_64)
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_${EQEMU_ARCH}")
IF(VCPKG_TOOLCHAIN)
IF(NOT MSVC_VERSION GREATER 1800)
SET(SODIUM_INCLUDE_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/include")
ENDIF()
ELSE(VCPKG_TOOLCHAIN)
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_${EQEMU_ARCH}")
SET(LUA_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/luaj_${EQEMU_ARCH}")
SET(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/openssl_${EQEMU_ARCH}")
SET(SODIUM_INCLUDE_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/include")
ENDIF(VCPKG_TOOLCHAIN)
IF(SODIUM_INCLUDE_HINTS)
IF(MSVC_VERSION GREATER 1800)
SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/${EQEMU_ARCH_ALT}/Release/v140/dynamic")
ELSEIF(MSVC_VERSION EQUAL 1800)
SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/${EQEMU_ARCH_ALT}/Release/v120/dynamic")
ELSE()
SET(SODIUM_LIBRARY_HINTS "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/libsodium/${EQEMU_ARCH_ALT}/Release/v110/dynamic")
ENDIF()
ENDIF(SODIUM_INCLUDE_HINTS)
#disable CRT warnings on windows cause they're annoying as shit and we use C functions everywhere
OPTION(EQEMU_DISABLE_CRT_SECURE_WARNINGS "Disable Secure CRT Warnings" ON)
IF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
#fast FP if you'd like it
OPTION(EQEMU_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
IF(EQEMU_FAST_FLOATINGPOINT)
ADD_DEFINITIONS(/fp:fast)
ENDIF(EQEMU_FAST_FLOATINGPOINT)
#crash logging currently only works on windows x86/x64
OPTION(EQEMU_ENABLE_CRASH_LOGGING "Enable crash logging" ON)
IF(EQEMU_ENABLE_CRASH_LOGGING)
ADD_DEFINITIONS(-DCRASH_LOGGING)
ENDIF(EQEMU_ENABLE_CRASH_LOGGING)
OPTION(EQEMU_BUILD_MSVC_MP "Enable build with multiple processes." ON)
IF(EQEMU_BUILD_MSVC_MP)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
ENDIF(EQEMU_BUILD_MSVC_MP)
#We want to compile /MT not /MD so we change that
FOREACH(flag_var CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
IF(${flag_var} MATCHES "/MD")
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
ENDIF(${flag_var} MATCHES "/MD")
ENDFOREACH(flag_var)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-DNOMINMAX)
ADD_DEFINITIONS(-DCRASH_LOGGING)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
ELSE(MSVC)
#Normally set by perl but we don't use the perl flags anymore so we set it.
ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
ENDIF(MSVC)
@ -139,197 +37,269 @@ IF(UNIX)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
ENDIF(UNIX)
#debug level, 5 is default. Most people wont ever change this but it's there if you want to
SET(EQEMU_DEBUG_LEVEL 5 CACHE STRING "EQEmu debug level:
0 - Quiet mode Errors to file Status and Normal ignored
1 - Status and Normal to console, Errors to logfile
2 - Status, Normal, and Error to console and logfile
3 - Light debug release errors and status
4 - Moderate debug release errors and status
5 - Maximum debug release errors and status
10 - More errors than you ever wanted to see"
)
SET(EQEMU_LOG_LEVEL_STATUS 2 CACHE STRING "EQEmu logging level for [Status]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
SET(EQEMU_LOG_LEVEL_NORMAL 3 CACHE STRING "EQEmu logging level for [Normal]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
SET(EQEMU_LOG_LEVEL_ERROR 2 CACHE STRING "EQEmu logging level for [Error]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
SET(EQEMU_LOG_LEVEL_DEBUG 3 CACHE STRING "EQEmu logging level for [Debug]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
SET(EQEMU_LOG_LEVEL_QUEST 2 CACHE STRING "EQEmu logging level for [Quest]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
SET(EQEMU_LOG_LEVEL_COMMANDS 1 CACHE STRING "EQEmu logging level for [Commands]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
SET(EQEMU_LOG_LEVEL_CRASH 3 CACHE STRING "EQEmu logging level for [Crash]:
0 - Disabled
1 - Ouput to File Enabled
2 - Output to stdout Enabled
3 - Output to File and stdout Enabled
8 - Output to stderr Enabled
9 - Output to File and stderr Enabled
11 - Output to File, stdout and stderr Enabled"
)
MARK_AS_ADVANCED(EQEMU_LOG_LEVEL_STATUS EQEMU_LOG_LEVEL_NORMAL EQEMU_LOG_LEVEL_ERROR EQEMU_LOG_LEVEL_DEBUG EQEMU_LOG_LEVEL_QUEST EQEMU_LOG_LEVEL_COMMANDS EQEMU_LOG_LEVEL_CRASH)
#NPC Types Cache Behavior
OPTION(EQEMU_DEPOP_INVALIDATES_CACHE "#repop invalidates the npc_types cache (will cause a larger database hit on #repop but is more convienent)." ON)
#Bots are a compile time option so on/off
OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF)
#Disable entire _mlog system (excludes trade/command logs)
OPTION(EQEMU_DISABLE_LOGSYS "Disable Logging INI System" ON)
#Enable GM Command log system
OPTION(EQEMU_COMMANDS_LOGGING "Enable GM Command logs" ON)
IF(EQEMU_COMMANDS_LOGGING)
ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
ENDIF(EQEMU_COMMANDS_LOGGING)
IF(EQEMU_DISABLE_LOGSYS)
ADD_DEFINITIONS(-DDISABLE_LOGSYS)
ENDIF(EQEMU_DISABLE_LOGSYS)
IF(EQEMU_ENABLE_BOTS)
ADD_DEFINITIONS(-DBOTS)
ENDIF(EQEMU_ENABLE_BOTS)
#What to build
OPTION(EQEMU_BUILD_SERVER "Build the game server." ON)
OPTION(EQEMU_BUILD_LOGIN "Build the login server." OFF)
OPTION(EQEMU_BUILD_HC "Build the headless client." OFF)
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
OPTION(EQEMU_BUILD_LUA "Build Lua parser." ON)
OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
#C++11 stuff
IF(NOT MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reserved-user-defined-literal")
ENDIF()
ENDIF(NOT MSVC)
#Various definitions
IF(EQEMU_BUILD_PERL)
ADD_DEFINITIONS(-DEMBPERL)
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
ENDIF(EQEMU_BUILD_PERL)
IF(EQEMU_BUILD_LUA)
ADD_DEFINITIONS(-DLUA_EQEMU)
ENDIF(EQEMU_BUILD_LUA)
#Disabled until reevaluation performed
#OPTION(EQEMU_USE_MAP_MMFS "Create and use Zone Map MMF files." OFF)
#IF(EQEMU_USE_MAP_MMFS)
# ADD_DEFINITIONS(-DUSE_MAP_MMFS)
#ENDIF(EQEMU_USE_MAP_MMFS)
SET(EQEMU_MAP_DIR "./Maps" CACHE STRING "The dir that maps, water maps, and paths are located in.")
ADD_DEFINITIONS(-DEQDEBUG=${EQEMU_DEBUG_LEVEL})
ADD_DEFINITIONS(-DINVERSEXY)
ADD_DEFINITIONS(-DFIELD_ITEMS)
ADD_DEFINITIONS(-DMAP_DIR="${EQEMU_MAP_DIR}")
ADD_DEFINITIONS(-DLOG_LEVEL_STATUS=${EQEMU_LOG_LEVEL_STATUS})
ADD_DEFINITIONS(-DLOG_LEVEL_NORMAL=${EQEMU_LOG_LEVEL_NORMAL})
ADD_DEFINITIONS(-DLOG_LEVEL_ERROR=${EQEMU_LOG_LEVEL_ERROR})
ADD_DEFINITIONS(-DLOG_LEVEL_DEBUG=${EQEMU_LOG_LEVEL_DEBUG})
ADD_DEFINITIONS(-DLOG_LEVEL_QUEST=${EQEMU_LOG_LEVEL_QUEST})
ADD_DEFINITIONS(-DLOG_LEVEL_COMMANDS=${EQEMU_LOG_LEVEL_COMMANDS})
ADD_DEFINITIONS(-DLOG_LEVEL_CRASH=${EQEMU_LOG_LEVEL_CRASH})
ADD_DEFINITIONS(-DGLM_FORCE_RADIANS)
ADD_DEFINITIONS(-DGLM_FORCE_CTOR_INIT)
ADD_DEFINITIONS(-DGLM_ENABLE_EXPERIMENTAL)
#Find everything we need
FIND_PACKAGE(Boost REQUIRED)
FIND_PACKAGE(MySQL)
FIND_PACKAGE(MariaDB)
FIND_PACKAGE(ZLIB)
FIND_PACKAGE(MySQL REQUIRED)
IF(EQEMU_BUILD_PERL)
FIND_PACKAGE(PerlLibs REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM "${PERL_INCLUDE_PATH}")
ENDIF(EQEMU_BUILD_PERL)
FIND_PACKAGE(OpenSSL)
FIND_PACKAGE(Lua51)
FIND_PACKAGE(PerlLibs)
FIND_PACKAGE(Sodium)
FIND_PACKAGE(mbedTLS)
SET(SERVER_LIBS common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} uv_a fmt RecastNavigation::Detour)
MESSAGE(STATUS "**************************************************")
MESSAGE(STATUS "* Library Detection *")
MESSAGE(STATUS "**************************************************")
FIND_PACKAGE(Sodium REQUIRED)
IF(SODIUM_FOUND)
OPTION(EQEMU_ENABLE_SECURITY "Use Encryption For TCP Connections" ON)
IF(EQEMU_ENABLE_SECURITY)
INCLUDE_DIRECTORIES(SYSTEM "${SODIUM_INCLUDE_DIRS}")
ADD_DEFINITIONS(-DENABLE_SECURITY)
SET(SERVER_LIBS ${SERVER_LIBS} ${SODIUM_LIBRARIES})
ENDIF()
IF(MYSQL_FOUND)
MESSAGE(STATUS "* MySQL: FOUND *")
ELSE()
MESSAGE(STATUS "* MySQL: MISSING *")
ENDIF()
IF(MARIADB_FOUND)
MESSAGE(STATUS "* MariaDB: FOUND *")
ELSE()
MESSAGE(STATUS "* MariaDB: MISSING *")
ENDIF()
IF(ZLIB_FOUND)
OPTION(EQEMU_BUILD_ZLIB "Build internal version of zlib." OFF)
MESSAGE(STATUS "* ZLIB: FOUND *")
ELSE()
MESSAGE(STATUS "* ZLIB: MISSING *")
ENDIF()
IF(Lua51_FOUND)
MESSAGE(STATUS "* Lua: FOUND *")
ELSE()
MESSAGE(STATUS "* Lua: MISSING *")
ENDIF()
IF(PerlLibs_FOUND)
MESSAGE(STATUS "* Perl: FOUND *")
ELSE()
MESSAGE(STATUS "* Perl: MISSING *")
ENDIF()
IF(SODIUM_FOUND)
MESSAGE(STATUS "* libsodium: FOUND *")
ELSE()
MESSAGE(STATUS "* libsodium: MISSING *")
ENDIF()
IF(OpenSSL_FOUND)
MESSAGE(STATUS "* OpenSSL: FOUND *")
ELSE()
MESSAGE(STATUS "* OpenSSL: MISSING *")
ENDIF()
IF(MBEDTLS_FOUND)
MESSAGE(STATUS "* mbedTLS: FOUND *")
ELSE()
MESSAGE(STATUS "* mbedTLS: MISSING *")
ENDIF()
MESSAGE(STATUS "**************************************************")
#options
OPTION(EQEMU_DEPOP_INVALIDATES_CACHE "#repop invalidates the npc_types cache (will cause a larger database hit on #repop but is more convienent)." ON)
OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF)
OPTION(EQEMU_COMMANDS_LOGGING "Enable GM Command logs" ON)
OPTION(EQEMU_BUILD_SERVER "Build the game server." ON)
OPTION(EQEMU_BUILD_HC "Build the headless client." OFF)
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
IF(EQEMU_COMMANDS_LOGGING)
ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
ENDIF(EQEMU_COMMANDS_LOGGING)
IF(EQEMU_ENABLE_BOTS)
ADD_DEFINITIONS(-DBOTS)
ENDIF(EQEMU_ENABLE_BOTS)
#database
IF(MySQL_FOUND AND MariaDB_FOUND)
SET(DATABASE_LIBRARY_SELECTION MariaDB CACHE STRING "Database library to use:
MySQL
MariaDB"
)
IF(EQEMU_BUILD_ZLIB)
INCLUDE_DIRECTORIES(BEFORE SYSTEM "${CMAKE_CURRENT_BINARY_DIR}/libs/zlibng" "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
SET(SERVER_LIBS ${SERVER_LIBS} "zlibstatic")
IF(DATABASE_LIBRARY_SELECTION STREQUAL "MySQL")
SET(DATABASE_LIBRARY_TYPE " MySQL")
SET(DATABASE_LIBRARY_LIBS ${MySQL_LIBRARIES})
SET(DATABASE_LIBRARY_INCLUDE ${MySQL_INCLUDE_DIR})
ELSEIF(DATABASE_LIBRARY_SELECTION STREQUAL "MariaDB")
SET(DATABASE_LIBRARY_TYPE "MariaDB")
SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
SET(DATABASE_LIBRARY_INCLUDE ${MariaDB_INCLUDE_DIR})
ELSE()
INCLUDE_DIRECTORIES(SYSTEM "${ZLIB_INCLUDE_DIRS}")
SET(SERVER_LIBS ${SERVER_LIBS} ${ZLIB_LIBRARY})
MESSAGE(FATAL_ERROR "Unknown database library set, should be one of: MySQL, MariaDB")
ENDIF()
ELSEIF(MariaDB_FOUND)
SET(DATABASE_LIBRARY_TYPE "MariaDB")
SET(DATABASE_LIBRARY_LIBS ${MariaDB_LIBRARIES})
SET(DATABASE_LIBRARY_INCLUDE ${MariaDB_INCLUDE_DIR})
ELSEIF(MySQL_FOUND)
SET(DATABASE_LIBRARY_TYPE " MySQL")
SET(DATABASE_LIBRARY_LIBS ${MySQL_LIBRARIES})
SET(DATABASE_LIBRARY_INCLUDE ${MySQL_INCLUDE_DIR})
ELSE()
MESSAGE(FATAL_ERROR "One of MySQL or MariaDB is a required dependency.")
ENDIF()
#security
#prefer openssl to mbedtls (arbitrary)
IF(OpenSSL_FOUND AND MBEDTLS_FOUND)
SET(TLS_LIBRARY_SELECTION OpenSSL CACHE STRING "TLS library to use:
OpenSSL
mbedTLS"
)
IF(TLS_LIBRARY_SELECTION STREQUAL "OpenSSL")
SET(TLS_LIBRARY_TYPE " OpenSSL")
SET(TLS_LIBRARY_ENABLED ON)
SET(TLS_LIBRARY_LIBS ${OPENSSL_LIBRARIES})
SET(TLS_LIBRARY_INCLUDE ${OPENSSL_INCLUDE_DIR})
ADD_DEFINITIONS(-DEQEMU_USE_OPENSSL)
ELSEIF(TLS_LIBRARY_SELECTION STREQUAL "mbedTLS")
SET(TLS_LIBRARY_TYPE " mbedTLS")
SET(TLS_LIBRARY_ENABLED ON)
SET(TLS_LIBRARY_LIBS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
SET(TLS_LIBRARY_INCLUDE ${MBEDTLS_INCLUDE_DIR})
ADD_DEFINITIONS(-DEQEMU_USE_MBEDTLS)
ELSE()
MESSAGE(FATAL_ERROR "Unknown TLS library set, should be one of: OpenSSL, mbedTLS")
ENDIF()
ELSEIF(OpenSSL_FOUND)
SET(TLS_LIBRARY_TYPE " OpenSSL")
SET(TLS_LIBRARY_ENABLED ON)
SET(TLS_LIBRARY_LIBS ${OPENSSL_LIBRARIES})
SET(TLS_LIBRARY_INCLUDE ${OPENSSL_INCLUDE_DIR})
ADD_DEFINITIONS(-DEQEMU_USE_OPENSSL)
ELSEIF(MBEDTLS_FOUND)
SET(TLS_LIBRARY_TYPE " mbedTLS")
SET(TLS_LIBRARY_ENABLED ON)
SET(TLS_LIBRARY_LIBS ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
SET(TLS_LIBRARY_INCLUDE ${MBEDTLS_INCLUDE_DIR})
ADD_DEFINITIONS(-DEQEMU_USE_MBEDTLS)
ELSE()
SET(TLS_LIBRARY_TYPE "Disabled")
SET(TLS_LIBRARY_ENABLED OFF)
ENDIF()
IF(SODIUM_FOUND)
SET(SODIUM_LIBRARY_TYPE "Libsodium")
SET(SODIUM_LIBRARY_ENABLED ON)
SET(SODIUM_LIBRARY_LIBS ${SODIUM_LIBRARIES})
SET(SODIUM_LIBRARY_INCLUDE ${SODIUM_INCLUDE_DIRS})
ADD_DEFINITIONS(-DENABLE_SECURITY)
ELSE()
SET(SODIUM_LIBRARY_TYPE " Disabled")
SET(SODIUM_LIBRARY_ENABLED OFF)
ENDIF()
IF(Lua51_FOUND)
SET(LUA_LIBRARY_TYPE " Lua 5.1")
SET(LUA_LIBRARY_LIBS ${LUA_LIBRARY} luabind)
SET(LUA_LIBRARY_INCLUDE ${LUA_INCLUDE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
OPTION(EQEMU_BUILD_LUA "Build Lua parser." ON)
IF(EQEMU_BUILD_LUA)
ADD_DEFINITIONS(-DLUA_EQEMU)
OPTION(EQEMU_SANITIZE_LUA_LIBS "Sanitize Lua Libraries (Remove OS and IO standard libraries from being able to run)." ON)
IF(EQEMU_SANITIZE_LUA_LIBS)
ADD_DEFINITIONS(-DSANITIZE_LUA_LIBS)
ENDIF()
ENDIF()
ELSE()
MESSAGE(STATUS "Could NOT find ZLIB - using ZLIBSTATIC package.")
SET(EQEMU_BUILD_ZLIB ON)
INCLUDE_DIRECTORIES(BEFORE SYSTEM "${CMAKE_CURRENT_BINARY_DIR}/libs/zlibng" "${CMAKE_CURRENT_SOURCE_DIR}/libs/zlibng")
SET(SERVER_LIBS ${SERVER_LIBS} "zlibstatic")
SET(LUA_LIBRARY_TYPE "Disabled")
ENDIF()
IF(PerlLibs_FOUND)
SET(PERL_LIBRARY_TYPE " Perl")
SET(PERL_LIBRARY_LIBS ${PERL_LIBRARY})
SET(PERL_LIBRARY_INCLUDE ${PERL_INCLUDE_PATH})
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
IF(EQEMU_BUILD_PERL)
ADD_DEFINITIONS(-DEMBPERL)
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
ENDIF()
ELSE()
SET(PERL_LIBRARY_TYPE "Disabled")
ENDIF()
#use zlib if exists
IF(ZLIB_FOUND)
OPTION(EQEMU_BUILD_ZLIB "Build internal version of zlib." OFF)
IF(EQEMU_BUILD_ZLIB)
SET(ZLIB_LIBRARY_TYPE "zlib-ng")
SET(ZLIB_LIBRARY_LIBS "zlibstatic")
SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/submodules/zlibng")
ELSE()
SET(ZLIB_LIBRARY_TYPE " zlib")
SET(ZLIB_LIBRARY_LIBS ${ZLIB_LIBRARY})
SET(ZLIB_LIBRARY_INCLUDE ${ZLIB_INCLUDE_DIRS})
ENDIF()
ELSE()
SET(ZLIB_LIBRARY_TYPE "zlib-ng")
SET(ZLIB_LIBRARY_LIBS "zlibstatic")
SET(ZLIB_LIBRARY_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/submodules/zlibng")
ENDIF()
MESSAGE(STATUS "")
MESSAGE(STATUS "**************************************************")
MESSAGE(STATUS "* Library Usage *")
MESSAGE(STATUS "**************************************************")
MESSAGE(STATUS "* Database: ${DATABASE_LIBRARY_TYPE} *")
MESSAGE(STATUS "* TLS: ${TLS_LIBRARY_TYPE} *")
MESSAGE(STATUS "* Sodium: ${SODIUM_LIBRARY_TYPE} *")
MESSAGE(STATUS "* Lua: ${LUA_LIBRARY_TYPE} *")
MESSAGE(STATUS "* Perl: ${PERL_LIBRARY_TYPE} *")
MESSAGE(STATUS "* zlib: ${ZLIB_LIBRARY_TYPE} *")
MESSAGE(STATUS "**************************************************")
#setup server libs and headers
SET(SERVER_LIBS common ${DATABASE_LIBRARY_LIBS} ${ZLIB_LIBRARY_LIBS} ${Boost_LIBRARIES} uv_a fmt RecastNavigation::Detour)
INCLUDE_DIRECTORIES(SYSTEM "${DATABASE_LIBRARY_INCLUDE}")
INCLUDE_DIRECTORIES(SYSTEM "${ZLIB_LIBRARY_INCLUDE}")
INCLUDE_DIRECTORIES(SYSTEM "${Boost_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/glm")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/cereal/include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/fmt/include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/libuv/include" )
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DebugUtils/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Detour/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DetourCrowd/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DetourTileCache/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Recast/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/websocketpp")
IF(TLS_LIBRARY_ENABLED)
SET(SERVER_LIBS ${SERVER_LIBS} ${TLS_LIBRARY_LIBS})
INCLUDE_DIRECTORIES(SYSTEM "${TLS_LIBRARY_INCLUDE}")
ENDIF()
IF(SODIUM_LIBRARY_ENABLED)
SET(SERVER_LIBS ${SERVER_LIBS} ${SODIUM_LIBRARY_LIBS})
INCLUDE_DIRECTORIES(SYSTEM "${SODIUM_LIBRARY_INCLUDE}")
ENDIF()
IF(EQEMU_BUILD_LUA)
SET(SERVER_LIBS ${SERVER_LIBS} ${LUA_LIBRARY_LIBS})
INCLUDE_DIRECTORIES(SYSTEM "${LUA_LIBRARY_INCLUDE}")
ENDIF()
IF(EQEMU_BUILD_PERL)
SET(SERVER_LIBS ${SERVER_LIBS} ${PERL_LIBRARY_LIBS})
INCLUDE_DIRECTORIES(SYSTEM "${PERL_LIBRARY_INCLUDE}")
ENDIF()
IF(WIN32)
@ -344,52 +314,34 @@ IF(UNIX)
SET(SERVER_LIBS ${SERVER_LIBS} "uuid")
ENDIF()
IF(EQEMU_BUILD_LUA)
FIND_PACKAGE(EQLua51 REQUIRED)
SET(Boost_USE_STATIC_LIBS OFF)
SET(Boost_USE_MULTITHREADED ON)
SET(Boost_USE_STATIC_RUNTIME OFF)
SET(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/boost")
IF(EQEMU_BUILD_LOGIN AND NOT TLS_LIBRARY_ENABLED)
MESSAGE(FATAL_ERROR "Login server requires a TLS Library to build.")
ENDIF()
FIND_PACKAGE(Boost REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM "${LUA_INCLUDE_DIR}" "${Boost_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/libs/luabind")
OPTION(EQEMU_SANITIZE_LUA_LIBS "Sanitize Lua Libraries (Remove OS and IO standard libraries from being able to run)." ON)
IF(EQEMU_SANITIZE_LUA_LIBS)
ADD_DEFINITIONS(-DSANITIZE_LUA_LIBS)
ENDIF(EQEMU_SANITIZE_LUA_LIBS)
ENDIF(EQEMU_BUILD_LUA)
INCLUDE_DIRECTORIES(SYSTEM "${MySQL_INCLUDE_DIR}")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/glm")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/cereal/include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/fmt/include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/libuv/include" )
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DebugUtils/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Detour/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DetourCrowd/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/DetourTileCache/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/recastnavigation/Recast/Include")
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/submodules/websocketpp")
IF(EQEMU_BUILD_HC AND NOT TLS_LIBRARY_ENABLED)
MESSAGE(FATAL_ERROR "Headless client requires a TLS Library to build.")
ENDIF()
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(libs)
ADD_SUBDIRECTORY(submodules/fmt)
ADD_SUBDIRECTORY(submodules/libuv)
SET(RECASTNAVIGATION_DEMO OFF CACHE BOOL "Build demo")
SET(RECASTNAVIGATION_TESTS OFF CACHE BOOL "Build tests")
SET(RECASTNAVIGATION_EXAMPLES OFF CACHE BOOL "Build examples")
ADD_SUBDIRECTORY(submodules/recastnavigation)
IF(EQEMU_BUILD_ZLIB)
SET(ZLIB_COMPAT ON CACHE BOOL "Compile with zlib compatible API")
SET(ZLIB_ENABLE_TESTS OFF CACHE BOOL "Build test binaries")
ADD_SUBDIRECTORY(libs/zlibng)
ADD_SUBDIRECTORY(submodules/zlibng)
ENDIF()
SET(RECASTNAVIGATION_DEMO OFF CACHE BOOL "Build demo")
SET(RECASTNAVIGATION_TESTS OFF CACHE BOOL "Build tests")
SET(RECASTNAVIGATION_EXAMPLES OFF CACHE BOOL "Build examples")
ADD_SUBDIRECTORY(submodules/recastnavigation)
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
MESSAGE(STATUS "Libs: ${SERVER_LIBS}")
IF(EQEMU_BUILD_SERVER)
ADD_SUBDIRECTORY(shared_memory)
ADD_SUBDIRECTORY(world)
@ -398,6 +350,7 @@ IF(EQEMU_BUILD_SERVER)
ADD_SUBDIRECTORY(queryserv)
ADD_SUBDIRECTORY(eqlaunch)
ENDIF(EQEMU_BUILD_SERVER)
IF(EQEMU_BUILD_LOGIN)
ADD_SUBDIRECTORY(loginserver)
ENDIF(EQEMU_BUILD_LOGIN)

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
add_subdirectory(import)
add_subdirectory(export)

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
SET(export_sources
main.cpp

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
SET(import_sources
main.cpp

View File

@ -1,124 +0,0 @@
#CMake - Cross Platform Makefile Generator
#Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
#All rights reserved.
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions
#are met:
#
#* Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
#* Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#* Neither the names of Kitware, Inc., the Insight Software Consortium,
# nor the names of their contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
#HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# This module defines
# LUA51_FOUND, if false, do not try to link to Lua
# LUA_LIBRARIES
# LUA_INCLUDE_DIR, where to find lua.h
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
IF(LUA_ROOT)
FIND_PATH(LUA_INCLUDE_DIR
NAMES lua.h
HINTS
ENV LUA_DIR
PATHS
${LUA_ROOT}
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include src
)
FIND_LIBRARY(LUA_LIBRARY
NAMES lua51 lua5.1 lua-5.1 lua
HINTS
ENV LUA_DIR
PATHS
${LUA_ROOT}
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
PATH_SUFFIXES lib bin
)
ELSE(LUA_ROOT)
FIND_PATH(LUA_INCLUDE_DIR
NAMES lua.h
HINTS
ENV LUA_DIR
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include
)
FIND_LIBRARY(LUA_LIBRARY
NAMES lua51 lua5.1 lua-5.1 lua
HINTS
ENV LUA_DIR
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
PATH_SUFFIXES lib bin
)
ENDIF(LUA_ROOT)
IF(LUA_LIBRARY)
# include the math library for Unix
IF(UNIX AND NOT APPLE)
FIND_LIBRARY(LUA_MATH_LIBRARY m)
SET(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
# For Windows and Mac, don't need to explicitly include the math library
ELSE()
SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
ENDIF()
ENDIF()
IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
FILE(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
UNSET(lua_version_str)
ENDIF()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
VERSION_VAR LUA_VERSION_STRING)
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)

87
cmake/FindMariaDB.cmake Normal file
View File

@ -0,0 +1,87 @@
# - Find mariadbclient
#
# -*- cmake -*-
#
# Find the native MariaDB includes and library
#
# MariaDB_INCLUDE_DIR - where to find mysql.h, etc.
# MariaDB_LIBRARIES - List of libraries when using MariaDB.
# MariaDB_FOUND - True if MariaDB found.
# The following can be used as a hint as to where to search:
# MARIADB_ROOT
IF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARIES)
# Already in cache, be silent
SET(MariaDB_FIND_QUIETLY TRUE)
ENDIF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARIES)
# Include dir
IF(MARIADB_ROOT)
FIND_PATH(MariaDB_INCLUDE_DIR
NAMES mariadb_version.h
PATHS ${MARIADB_ROOT}/include
PATH_SUFFIXES mysql mariadb
NO_DEFAULT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
)
FIND_PATH(MariaDB_INCLUDE_DIR
NAMES mariadb_version.h
PATH_SUFFIXES mysql mariadb
)
ELSE(MARIADB_ROOT)
FIND_PATH(MariaDB_INCLUDE_DIR
NAMES mariadb_version.h
PATH_SUFFIXES mysql mariadb
)
ENDIF(MARIADB_ROOT)
# Library
SET(MariaDB_NAMES libmariadb)
IF(MARIADB_ROOT)
FIND_LIBRARY(MariaDB_LIBRARY
NAMES ${MariaDB_NAMES}
PATHS ${MARIADB_ROOT}/lib
PATH_SUFFIXES mysql mariadb
NO_DEFAULT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
)
FIND_LIBRARY(MariaDB_LIBRARY
NAMES ${MariaDB_NAMES}
PATH_SUFFIXES mysql mariadb
)
ELSE(MARIADB_ROOT)
FIND_LIBRARY(MariaDB_LIBRARY
NAMES ${MariaDB_NAMES} mariadbclient_r mariadbclient
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
PATH_SUFFIXES mysql mariadb
)
ENDIF(MARIADB_ROOT)
IF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARY)
SET(MariaDB_FOUND TRUE)
SET(MariaDB_LIBRARIES ${MariaDB_LIBRARY})
ELSE (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARY)
SET(MariaDB_FOUND FALSE)
SET(MariaDB_LIBRARIES)
ENDIF (MariaDB_INCLUDE_DIR AND MariaDB_LIBRARY)
# handle the QUIETLY and REQUIRED arguments and set MariaDB_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MariaDB DEFAULT_MSG MariaDB_LIBRARY MariaDB_INCLUDE_DIR)
IF(MariaDB_FOUND)
SET( MariaDB_LIBRARY_RELEASE ${MariaDB_LIBRARY} )
SET( MariaDB_LIBRARY_DEBUG ${MariaDB_LIBRARY} )
SET( MariaDB_LIBRARIES ${MariaDB_LIBRARY_RELEASE} ${MariaDB_LIBRARY_DEBUG} )
ELSE(MariaDB_FOUND)
SET( MariaDB_LIBRARIES )
ENDIF(MariaDB_FOUND)
MARK_AS_ADVANCED(
MariaDB_LIBRARY_DEBUG
MariaDB_LIBRARY_RELEASE
MariaDB_INCLUDE_DIR
)

93
cmake/FindmbedTLS.cmake Normal file
View File

@ -0,0 +1,93 @@
# - Try to find mbedTLS
# Once done this will define
#
# Read-Only variables
# MBEDTLS_FOUND - system has mbedTLS
# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
# MBEDTLS_LIBRARIES - Link these to use mbedTLS
# MBEDTLS_LIBRARY - path to mbedTLS library
# MBEDX509_LIBRARY - path to mbedTLS X.509 library
# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
#
# Hint
# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
SET(_MBEDTLS_ROOT_HINTS
${MBEDTLS_ROOT_DIR}
ENV MBEDTLS_ROOT_DIR
)
SET(_MBEDTLS_ROOT_HINTS_AND_PATHS
HINTS ${_MBEDTLS_ROOT_HINTS}
PATHS ${_MBEDTLS_ROOT_PATHS}
)
FIND_PATH(MBEDTLS_INCLUDE_DIR
NAMES mbedtls/version.h
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES include
)
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
# Already in cache, be silent
SET(MBEDTLS_FIND_QUIETLY TRUE)
ENDIF()
FIND_LIBRARY(MBEDTLS_LIBRARY
NAMES mbedtls libmbedtls
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES library
)
FIND_LIBRARY(MBEDX509_LIBRARY
NAMES mbedx509 libmbedx509
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES library
)
FIND_LIBRARY(MBEDCRYPTO_LIBRARY
NAMES mbedcrypto libmbedcrypto
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES library
)
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
SET(MBEDTLS_FOUND TRUE)
ENDIF()
IF(MBEDTLS_FOUND)
# split mbedTLS into -L and -l linker options, so we can set them for pkg-config
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
IF(NOT MBEDTLS_FIND_QUIETLY)
MESSAGE(STATUS "Found mbedTLS:")
FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
IF (MBEDTLSMATCH)
STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
ENDIF(MBEDTLSMATCH)
MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
ENDIF(NOT MBEDTLS_FIND_QUIETLY)
ELSE(MBEDTLS_FOUND)
IF(MBEDTLS_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find mbedTLS")
ENDIF(MBEDTLS_FIND_REQUIRED)
ENDIF(MBEDTLS_FOUND)
MARK_AS_ADVANCED(
MBEDTLS_INCLUDE_DIR
MBEDTLS_LIBRARY_DIR
MBEDTLS_LIBRARIES
MBEDTLS_LIBRARY
MBEDX509_LIBRARY
MBEDCRYPTO_LIBRARY
)

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
SET(common_sources
base_packet.cpp

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
SET(eqlaunch_sources
eqlaunch.cpp

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
SET(hc_sources
eq.cpp
@ -13,14 +13,10 @@ SET(hc_headers
world.h
)
FIND_PACKAGE(OpenSSL REQUIRED)
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
ADD_EXECUTABLE(hc ${hc_sources} ${hc_headers})
INSTALL(TARGETS hc RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
TARGET_LINK_LIBRARIES(hc ${SERVER_LIBS} ${OPENSSL_LIBRARIES})
TARGET_LINK_LIBRARIES(hc ${SERVER_LIBS})
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
SET(lb_sources
src/class.cpp

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
SET(eqlogin_sources
client.cpp
@ -27,14 +27,10 @@ SET(eqlogin_headers
world_server.h
)
FIND_PACKAGE(OpenSSL REQUIRED)
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
ADD_EXECUTABLE(loginserver ${eqlogin_sources} ${eqlogin_headers})
INSTALL(TARGETS loginserver RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
TARGET_LINK_LIBRARIES(loginserver ${SERVER_LIBS} ${OPENSSL_LIBRARIES})
TARGET_LINK_LIBRARIES(loginserver ${SERVER_LIBS})
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

View File

@ -1,6 +1,14 @@
#ifdef EQEMU_USE_OPENSSL
#include <openssl/des.h>
#include <openssl/sha.h>
#include <openssl/md5.h>
#endif
#ifdef EQEMU_USE_MBEDTLS
#include <mbedtls/des.h>
#include <mbedtls/md5.h>
#include <mbedtls/sha1.h>
#include <mbedtls/sha512.h>
#endif
#include <cstring>
#include <string>
#ifdef ENABLE_SECURITY
@ -8,22 +16,90 @@
#endif
const char* eqcrypt_block(const char *buffer_in, size_t buffer_in_sz, char* buffer_out, bool enc) {
#ifdef EQEMU_USE_MBEDTLS
if (enc) {
if (buffer_in_sz % 8 != 0) {
auto temp_buffer_sz = ((buffer_in_sz / 8) + 1) * 8;
unsigned char *temp_buffer = new unsigned char[temp_buffer_sz];
unsigned char *temp_buffer_in = &temp_buffer[0];
unsigned char *temp_buffer_out = &temp_buffer[temp_buffer_sz];
memset(temp_buffer, 0, temp_buffer_sz * 2);
memcpy(temp_buffer_in, buffer_in, buffer_in_sz);
unsigned char key[MBEDTLS_DES_KEY_SIZE];
unsigned char iv[8];
memset(&key, 0, MBEDTLS_DES_KEY_SIZE);
memset(&iv, 0, 8);
mbedtls_des_context context;
mbedtls_des_setkey_enc(&context, key);
mbedtls_des_crypt_cbc(&context, MBEDTLS_DES_ENCRYPT, temp_buffer_sz, iv, (const unsigned char*)temp_buffer_in, (unsigned char*)temp_buffer_out);
memcpy(buffer_out, temp_buffer_out, temp_buffer_sz);
delete[] temp_buffer;
}
else {
unsigned char key[MBEDTLS_DES_KEY_SIZE];
unsigned char iv[8];
memset(&key, 0, MBEDTLS_DES_KEY_SIZE);
memset(&iv, 0, 8);
mbedtls_des_context context;
mbedtls_des_setkey_enc(&context, key);
mbedtls_des_crypt_cbc(&context, MBEDTLS_DES_ENCRYPT, buffer_in_sz, iv, (const unsigned char*)buffer_in, (unsigned char*)buffer_out);
}
}
else {
if (buffer_in_sz && buffer_in_sz % 8 != 0) {
return nullptr;
}
unsigned char key[MBEDTLS_DES_KEY_SIZE];
unsigned char iv[8];
memset(&key, 0, MBEDTLS_DES_KEY_SIZE);
memset(&iv, 0, 8);
mbedtls_des_context context;
mbedtls_des_setkey_dec(&context, key);
mbedtls_des_crypt_cbc(&context, MBEDTLS_DES_DECRYPT, buffer_in_sz, iv, (const unsigned char*)buffer_in, (unsigned char*)buffer_out);
}
#endif
#ifdef EQEMU_USE_OPENSSL
DES_key_schedule k;
DES_cblock v;
memset(&k, 0, sizeof(DES_key_schedule));
memset(&v, 0, sizeof(DES_cblock));
if (!enc && buffer_in_sz && buffer_in_sz % 8 != 0) {
return nullptr;
}
DES_ncbc_encrypt((const unsigned char*)buffer_in, (unsigned char*)buffer_out, (long)buffer_in_sz, &k, &v, enc);
#endif
return buffer_out;
}
std::string eqcrypt_md5(const std::string &msg) {
std::string ret;
ret.reserve(32);
#ifdef EQEMU_USE_MBEDTLS
unsigned char digest[16];
char temp[4];
if (0 == mbedtls_md5_ret((const unsigned char*)msg.c_str(), msg.length(), digest)) {
for (int i = 0; i < 16; ++i) {
sprintf(&temp[0], "%02x", digest[i]);
ret.push_back(temp[0]);
ret.push_back(temp[1]);
}
}
#endif
#ifdef EQEMU_USE_OPENSSL
unsigned char md5_digest[16];
char tmp[4];
@ -34,12 +110,29 @@ std::string eqcrypt_md5(const std::string &msg) {
ret.push_back(tmp[0]);
ret.push_back(tmp[1]);
}
#endif
return ret;
}
std::string eqcrypt_sha1(const std::string &msg) {
std::string ret;
ret.reserve(40);
#ifdef EQEMU_USE_MBEDTLS
unsigned char digest[20];
char temp[4];
if (0 == mbedtls_sha1_ret((const unsigned char*)msg.c_str(), msg.length(), digest)) {
for (int i = 0; i < 20; ++i) {
sprintf(&temp[0], "%02x", digest[i]);
ret.push_back(temp[0]);
ret.push_back(temp[1]);
}
}
#endif
#ifdef EQEMU_USE_OPENSSL
unsigned char sha_digest[20];
char tmp[4];
@ -50,12 +143,29 @@ std::string eqcrypt_sha1(const std::string &msg) {
ret.push_back(tmp[0]);
ret.push_back(tmp[1]);
}
#endif
return ret;
}
std::string eqcrypt_sha512(const std::string &msg) {
std::string ret;
ret.reserve(128);
#ifdef EQEMU_USE_MBEDTLS
unsigned char digest[64];
char temp[4];
if (0 == mbedtls_sha512_ret((const unsigned char*)msg.c_str(), msg.length(), digest, 0)) {
for (int i = 0; i < 64; ++i) {
sprintf(&temp[0], "%02x", digest[i]);
ret.push_back(temp[0]);
ret.push_back(temp[1]);
}
}
#endif
#ifdef EQEMU_USE_OPENSSL
unsigned char sha_digest[64];
char tmp[4];
@ -66,6 +176,7 @@ std::string eqcrypt_sha512(const std::string &msg) {
ret.push_back(tmp[0]);
ret.push_back(tmp[1]);
}
#endif
return ret;
}

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
SET(qserv_sources
database.cpp

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
SET(shared_memory_sources
base_data.cpp

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
ADD_SUBDIRECTORY(cppunit)

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
SET(cppunit_sources
collectoroutput.cpp

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
SET(ucs_sources
chatchannel.cpp

47
wi/.gitignore vendored
View File

@ -1,47 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity

View File

@ -1,17 +0,0 @@
# Building EQEmu Web Interface Reference Implementation
## Required Software
- [NodeJS](https://nodejs.org)
## Install
First: Make sure you have required software installed.
Install 3rd Party Libraries first with the following command:
npm install
## Run
Run with either your favorite NodeJS process manager or with the following command:
node .

View File

@ -1,27 +0,0 @@
const jwt = require('jsonwebtoken');
var Auth = function (req, res, next) {
var token = '';
try {
token = req.headers.authorization.substring(7);
} catch(ex) {
console.log(ex);
res.sendStatus(401);
return;
}
jwt.verify(token, req.key, function(err, decoded) {
if(err) {
console.log(err);
res.sendStatus(401);
return;
}
req.token = decoded;
next();
});
};
module.exports = {
'auth': Auth
}

View File

@ -1,4 +0,0 @@
var sodium = require('libsodium-wrappers-sumo');
var hash = sodium.crypto_pwhash_str('password', 3, 32768);
console.log(hash);

View File

@ -1,26 +0,0 @@
var auth = require('../core/jwt_auth.js').auth;
function RegisterFunction(path, fn, app, api) {
app.post(path, auth, function (req, res) {
var params = req.body.params || [];
api.Call(fn, params)
.then(function(value) {
res.send({ response: value });
})
.catch(function(reason) {
if(reason.message) {
res.send({ status: reason.message });
}
else if(reason === 'Not connected to world server.') {
res.send({ status: 'ENCONNECTED' });
} else {
res.sendStatus(500);
}
});
});
}
module.exports = {
'Register': RegisterFunction
}

View File

@ -1,16 +0,0 @@
var endpoint = require('./endpoint.js');
var auth = require('../../core/jwt_auth.js').auth;
var sql = require('./sql.js');
var RegisterAPI = function(app, api) {
endpoint.Register(app, api, 'account', 'account', 'id');
//Can register custom controller actions here.
app.post('/api/data/account/search', auth, function (req, res) {
sql.Search(req, res, 'account', 'id', ['id', 'name']);
});
};
module.exports = {
'Register': RegisterAPI
}

View File

@ -1,20 +0,0 @@
var auth = require('../../core/jwt_auth.js').auth;
var sql = require('./sql.js');
var RegisterEndpoint = function(app, api, endpoint_verb, table_name, pkey) {
app.get('/api/data/' + endpoint_verb + '/:' + pkey, auth, function (req, res) {
sql.Retrieve(req, res, table_name, pkey);
});
app.put('/api/data/' + endpoint_verb + '/:' + pkey, auth, function (req, res) {
sql.CreateUpdate(req, res, table_name, pkey);
});
app.delete('/api/data/' + endpoint_verb + '/:' + pkey, auth, function (req, res) {
sql.Delete(req, res, table_name, pkey);
});
};
module.exports = {
'Register': RegisterEndpoint
}

View File

@ -1,8 +0,0 @@
var RegisterAPI = function(app, api) {
require('./account.js').Register(app, api);
require('./item.js').Register(app, api);
};
module.exports = {
'Register': RegisterAPI
}

View File

@ -1,16 +0,0 @@
var endpoint = require('./endpoint.js');
var auth = require('../../core/jwt_auth.js').auth;
var sql = require('./sql.js');
var RegisterAPI = function(app, api) {
endpoint.Register(app, api, 'item', 'items', 'id');
//Can register custom controller actions here.
app.post('/api/data/item/search', auth, function (req, res) {
sql.Search(req, res, 'items', 'id', ['id', 'name', 'icon']);
});
};
module.exports = {
'Register': RegisterAPI
}

View File

@ -1,319 +0,0 @@
var moment = require('moment');
function CreateReplace(table, body, fields) {
try {
var query = 'REPLACE INTO ' + table + ' VALUES(';
var first = true;
var args = [];
for(var idx in fields) {
if(first) {
first = false;
} else {
query += ',';
}
query += '?';
var entry = fields[idx];
if(entry.type === 12) {
try {
var d = new moment(body[entry.name]);
if(d.isValid()) {
args.push(d.format('YYYY-MM-DD HH:mm:ss'));
} else {
args.push(null);
}
} catch(ex) {
args.push(null);
}
} else {
args.push(body[entry.name]);
}
}
query += ')';
return { 'query': query, 'args': args };
} catch(ex) {
return { 'query': '', 'args': [] };
}
}
function CreateUpdate(req, res, table, pkey) {
req.mysql.getConnection(function(err, connection) {
try {
if(err) {
console.log(err);
connection.release();
res.sendStatus(500);
return;
}
if(req.body[pkey] !== parseInt(req.params[pkey], 10)) {
connection.release();
res.sendStatus(400);
return;
}
connection.query('SELECT * FROM ' + table + ' WHERE ' + pkey + '=? LIMIT 1', [req.params[pkey]], function (error, results, fields) {
try {
if(error) {
console.log(error);
connection.release();
res.sendStatus(400);
return;
}
var replace = CreateReplace(table, req.body, fields);
if(replace.query === '') {
connection.release();
res.sendStatus(400);
return;
}
connection.query(replace.query, replace.args, function(error, results, fields) {
try {
if(error) {
console.log(error);
connection.release();
res.sendStatus(400);
return;
}
connection.release();
res.sendStatus(200);
} catch(ex) {
console.log(ex);
connection.release();
res.sendStatus(500);
}
});
} catch(ex) {
console.log(ex);
connection.release();
res.sendStatus(500);
}
});
} catch(ex) {
console.log(ex);
connection.release();
res.sendStatus(500);
}
});
}
function Retrieve(req, res, table, pkey) {
req.mysql.getConnection(function(err, connection) {
try {
if(err) {
console.log(err);
connection.release();
res.sendStatus(500);
return;
}
connection.query('SELECT * FROM ' + table + ' WHERE ' + pkey + '=? LIMIT 1', [req.params[pkey]], function (error, results, fields) {
try {
if(results.length == 0) {
connection.release();
res.sendStatus(404);
return;
}
var result = results[0];
var ret = { };
for(var idx in result) {
var value = result[idx];
ret[idx] = value;
}
connection.release();
res.json(ret);
} catch(ex) {
console.log(ex);
connection.release();
res.sendStatus(500);
}
});
} catch(ex) {
console.log(ex);
connection.release();
res.sendStatus(500);
}
});
}
function Delete(req, res, table, pkey) {
req.mysql.getConnection(function(err, connection) {
try {
if(err) {
console.log(err);
connection.release();
res.sendStatus(500);
return;
}
connection.query('DELETE FROM ' + table + ' WHERE ' + pkey + '=? LIMIT 1', [req.params[pkey]], function (error, results, fields) {
try {
if(error) {
console.log(error);
connection.release();
res.sendStatus(400);
return;
}
connection.release();
res.sendStatus(200);
} catch(ex) {
console.log(ex);
connection.release();
res.sendStatus(500);
}
});
} catch(ex) {
console.log(ex);
connection.release();
res.sendStatus(500);
}
});
}
function getLimit(req, columns) {
var limit = '';
var len = parseInt(req.body['length']);
if(len > 100) {
len = 100;
}
if(req.body.hasOwnProperty('start') && len != -1) {
limit = 'LIMIT ' + req.body['start'] + ', ' + req.body['length'];
}
return limit;
}
function getOrder(req, columns) {
var order = '';
if (req.body.hasOwnProperty('order') && req.body['order'].length) {
var orderBy = [];
for(var i = 0; i < req.body['order'].length; ++i) {
var columnIdx = parseInt(req.body['order'][i].column);
var column = req.body['columns'][columnIdx];
var columnId = column.data;
var dir = req.body['order'][i].dir === 'asc' ? 'ASC' : 'DESC';
orderBy.push(req.mysql.escapeId(columnId) + ' ' + dir);
}
order = 'ORDER BY ' + orderBy.join(',');
}
return order;
}
function filter(req, columns, args) {
var where = '';
var globalSearch = [];
var columnSearch = [];
if (req.body.hasOwnProperty('search') && req.body['search'].value.length) {
var searchTerm = req.body['search'].value;
for(var i = 0; i < req.body['columns'].length; ++i) {
var column = req.body['columns'][i];
if(column.searchable) {
globalSearch.push(req.mysql.escapeId(column.data) + ' LIKE ?');
args.push('%' + searchTerm + '%');
}
}
}
for(var i = 0; i < req.body['columns'].length; ++i) {
var column = req.body['columns'][i];
var searchTerm = column.search.value;
if(searchTerm !== '' && column.searchable) {
columnSearch.push(req.mysql.escapeId(column.data) + ' LIKE ?');
args.push('%' + searchTerm + '%');
}
}
if(globalSearch.length) {
where = globalSearch.join(' OR ');
}
if(columnSearch.length) {
if(where === '') {
where = columnSearch.join(' AND ');
} else {
where += ' AND ';
where += columnSearch.join(' AND ');
}
}
if(where !== '') {
where = 'WHERE ' + where;
}
return where;
}
function Search(req, res, table, pkey, columns) {
var args = [];
var limit = getLimit(req, columns);
var order = getOrder(req, columns);
var where = filter(req, columns, args);
var query = 'SELECT ' + columns.join(', ') + ' FROM ' + table + ' ' + where + ' ' + order + ' ' + limit;
req.mysql.getConnection(function(err, connection) {
try {
if(err) {
console.log(err);
connection.release();
res.sendStatus(500);
return;
}
connection.query(query, args, function (error, results, fields) {
try {
var ret = [];
for(var i in results) {
var result = results[i];
var obj = { };
for(var idx in result) {
var value = result[idx];
obj[idx] = value;
}
ret.push(obj);
}
connection.release();
res.json(ret);
} catch(ex) {
console.log(ex);
connection.release();
res.sendStatus(500);
}
});
} catch(ex) {
console.log(ex);
connection.release();
res.sendStatus(500);
}
});
};
module.exports = {
'CreateUpdate': CreateUpdate,
'Retrieve': Retrieve,
'Delete': Delete,
'Search': Search,
}

View File

@ -1,16 +0,0 @@
const common = require('./common.js');
var RegisterEQW = function(app, api) {
common.Register('/api/eqw/getconfig', 'EQW::GetConfig', app, api);
common.Register('/api/eqw/islocked', 'EQW::IsLocked', app, api);
common.Register('/api/eqw/lock', 'EQW::Lock', app, api);
common.Register('/api/eqw/unlock', 'EQW::Unlock', app, api);
common.Register('/api/eqw/getplayercount', 'EQW::GetPlayerCount', app, api);
common.Register('/api/eqw/getzonecount', 'EQW::GetZoneCount', app, api);
common.Register('/api/eqw/getlaunchercount', 'EQW::GetLauncherCount', app, api);
common.Register('/api/eqw/getloginservercount', 'EQW::GetLoginServerCount', app, api);
};
module.exports = {
'Register': RegisterEQW
}

View File

@ -1,9 +0,0 @@
var RegisterAPI = function(app, api) {
require('./eqw.js').Register(app, api);
require('./token.js').Register(app);
require('./data').Register(app, api);
};
module.exports = {
'Register': RegisterAPI
}

View File

@ -1,43 +0,0 @@
const sodium = require('libsodium-wrappers-sumo');
const jwt = require('jsonwebtoken');
var RegisterToken = function(app) {
app.post('/api/token', function (req, res) {
try {
req.mysql.getConnection(function(err, connection) {
if(err) {
console.log(err);
res.sendStatus(500);
connection.release();
return;
}
connection.query('SELECT password FROM account WHERE name = ? LIMIT 1', [req.body.username], function (error, results, fields) {
if(results.length == 0) {
res.sendStatus(401);
connection.release();
return;
}
if(sodium.crypto_pwhash_str_verify(results[0].password, req.body.password)) {
var expires = Math.floor(Date.now() / 1000) + (60 * 60 * 24 * 7);
var token = jwt.sign({ username: req.body.username, exp: expires }, req.key);
res.send({token: token, expires: expires});
connection.release();
} else {
res.sendStatus(401);
connection.release();
}
});
});
} catch(ex) {
res.sendStatus(500);
console.log(ex);
}
});
};
module.exports = {
'Register': RegisterToken
}

View File

@ -1,56 +0,0 @@
const fs = require('fs');
const settings = JSON.parse(fs.readFileSync('settings.json', 'utf8'));
const key = fs.readFileSync(settings.key, 'utf8');
var server;
if(settings.https.enabled) {
const options = {
key: fs.readFileSync(settings.https.key),
cert: fs.readFileSync(settings.https.cert)
};
server = require('https').createServer();
} else {
server = require('http').createServer();
}
const servertalk = require('./network/servertalk_api.js');
const websocket_iterface = require('./ws/ws_interface.js');
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const uuid = require('node-uuid');
const jwt = require('jsonwebtoken');
var mysql = require('mysql').createPool(settings.db);
var api = new servertalk.api();
var wsi = new websocket_iterface.wsi(server, key, api);
api.Init(settings.servertalk.addr, settings.servertalk.port, false, settings.servertalk.key);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
next();
});
//make sure all routes can see our injected dependencies
app.use(function (req, res, next) {
req.servertalk = api;
req.mysql = mysql;
req.key = key;
next();
});
app.get('/', function (req, res) {
res.send({ status: "online" });
});
require('./http').Register(app, api);
require('./ws').Register(wsi, api);
server.on('request', app);
server.listen(settings.port, function () { console.log('Listening on ' + server.address().port) });

View File

@ -1,27 +0,0 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAoijNhaW4sH2yLEQOUCNLSU0qIGnr9mxewEPXSNURKFExC1WE
ah983xy+WTbKjakH6Rp2OwCvLxNIu6QBKRgcJ963ICWY7ysn4bU2Q2KoSJgAEel8
UMDHWYfyyAPdr4DUwUw7YMf4LBThCGBC5DTPilZiVqQNyOf8KL5w/oKcavVMddod
eBNE1ewoxVveHN6WUDkYQKZK2AsrpNG6TjfJc3wI3Z722tRHui4E772l/sD0SuEj
41pBzOG0VM7DHwUpHQosnvnwx9kjefPNE/uvo14PuzP5yYG2h2PFkQ7uuXjK2/le
iVcyap/zgheOHjlYmOJGT1cnVSodv+rY56eilwIDAQABAoIBAQAM/sAZqcI3Qpt4
uKt8+Jcb9Lcfid2DDgQ53DXwfEK3vGn1wpCuAH/9UUxf0ehBmf4sTBaVe+SOHTmC
8A23wVrgRxTd2qV65TZ4/BCxLcLWrney98cioZBYOHDYXpbxbZ2fMADCLMRSpAm0
piI2L5VCPNH8p4EDTLQEf96GRulKGOWETeVNai3C7Ept6Fxv0YIiiER8j2oPsb1O
LVCBKBPsNs0IlabJAzfDnaqdfWzuLWIT0L4w/qvzfwkdM8tVxch2zjEVosbz4ser
rPO3tle3mobgDvXrW9jEYkIpOtEqCS7l4ybidVuEfY55KlkZ7rGBQ2N1jbLvKjb5
AUyHUBchAoGBAOKjzzBPB/mofycF8iF1QJwripGTDUGM7aXBS0Clp4mh0ksvBsUf
Zg+Qnzr2xZaN53lU65xQlMrebMJow4iJj71VesF9FWPPNbIhh7eMTX4pABcKZNvc
Y0iFf5XZAl3LFdDocQSuB3j5WLNrjSFMBZuYUiZhgiRadtcdpQr+O4lbAoGBALcq
ltbFogxXoo7/CIajbYdNUGbba96jQMOzC1D7yeim1MTtDNGs56ZhDjFZepMRMyfX
/Z7iqxjZQQ1m1THtuiM4g+ug08EYI8G/7DYO5DqMABGFb3vKU9ilhYASqfznpKMJ
2sl/d5j8ocS7crkKwR8Tbo3ZG8NgObQNTL+mIFR1AoGAJS66zzIoHM2IDt7q2pJi
Bz0dfsShaB+23XrY3cJPukTSO4N7mNuN4v/XH9VclVayozVLclnGD4JuVXbanYv0
CRv9B8F9wOI97PuTSIm8LPaNDTqnUWrW3w8H34261ah768o2wI3MrAw8gTMj9FKE
mQJkd+eHcm9lD+XNLgCHxAECgYBiMQ2t00L89NnraKLscp4b44GPsl9QehoVD12o
q2JhO1Ziv2WY3eVNV0hhgkNopdbTrEGFNKRebNEn2xG9c2DO0tQ9s/jw0f0RN87s
Z+1HyZebzPmn1h4+zPUVZGwGbTPgRz8nuBKoS/541bg5pJ9FBojEuDfe9C3a7SpQ
r0EzpQKBgBmYrKi07wTUSZ3TjHWvOK75XhJ5pOdfbuDZk+N02jzhmihzI2M/Sh7s
l1gavtY9o9JGUAW35L/Ju4X1Xgm3t5Cg9+4n6ecOfSKP9nJpgj1EvHyWvw9t8ZSg
V9M0Hf5EoSPWuEj+mlWrIuvV/HgkouUVqDzUm6wUuyTqdTCgUQrA
-----END RSA PRIVATE KEY-----

View File

@ -1,148 +0,0 @@
const servertalk = require('./servertalk_client.js');
const uuid = require('node-uuid');
class ServertalkAPI
{
Init(addr, port, ipv6, credentials) {
this.client = new servertalk.client();
this.client.Init(addr, port, ipv6, 'WebInterface', credentials);
this.pending_calls = {};
this.subscriptions = {};
var self = this;
this.client.on('connecting', function() {
//console.log('Connecting...');
});
this.client.on('connect', function(){
//console.log('Connected');
});
this.client.on('close', function(){
//console.log('Closed');
});
this.client.on('error', function(err){
});
this.client.on('message', function(opcode, packet) {
if(opcode == 47) {
var response = Buffer.from(packet).toString('utf8');
try {
var res = JSON.parse(response);
if(res.id) {
if(self.pending_calls.hasOwnProperty(res.id)) {
var entry = self.pending_calls[res.id];
if(res.error) {
var reject = entry[1];
reject(res.error);
} else {
var resolve = entry[0];
resolve(res.response);
}
delete self.pending_calls[res.id];
}
}
} catch(ex) {
console.log('Error processing response from server:\n', ex);
}
} else if(opcode == 104) {
var message = Buffer.from(packet).toString('utf8');
try {
var msg = JSON.parse(message);
if(msg.event) {
if(self.subscriptions.hasOwnProperty(msg.event)) {
var subs = self.subscriptions[msg.event];
for(var idx in subs) {
try {
var sub = subs[idx];
sub.emit('subscriptionMessage', msg);
} catch(ex) {
console.log('Error dispatching subscription message', ex);
}
}
}
}
} catch(ex) {
console.log('Error processing response from server:\n', ex);
}
}
});
}
Call(method, args, timeout) {
if(!timeout) {
timeout = 15000
}
var self = this;
return new Promise(
function(resolve, reject) {
if(!self.client.Connected()) {
reject('Not connected to world server.');
return;
}
var id = uuid.v4();
self.pending_calls[id] = [resolve, reject];
var c = { id: id, method: method, params: args };
self.client.Send(47, Buffer.from(JSON.stringify(c)));
setTimeout(function() {
delete self.pending_calls[id];
reject('Request timed out after ' + timeout + 'ms');
}, timeout);
}
);
}
Notify(method, args) {
var c = { method: method, params: args };
client.Send(47, Buffer.from(JSON.stringify(c)));
}
Subscribe(event_id, who) {
this.Unsubscribe(event_id, who);
var subs = this.subscriptions[event_id];
if(subs) {
//console.log('Subscribe', who.uuid, 'to', event_id);
subs[who.uuid] = who;
} else {
//console.log('Subscribe', who.uuid, 'to', event_id);
this.subscriptions[event_id] = { };
this.subscriptions[event_id][who.uuid] = who;
//Tell our server we have a subscription for event_id
}
}
Unsubscribe(event_id, who) {
var subs = this.subscriptions[event_id];
if(subs) {
//console.log('Unsubscribe', who.uuid, 'from', event_id);
delete subs[who.uuid];
if(Object.keys(subs).length === 0) {
delete this.subscriptions[event_id];
//Tell our server we no longer have a subscription for event_id
}
}
}
UnsubscribeAll(who) {
for(var sub_idx in this.subscriptions) {
this.Unsubscribe(sub_idx, who);
}
}
}
module.exports = {
'api': ServertalkAPI
}

View File

@ -1,299 +0,0 @@
var net = require('net');
var sodium = require('libsodium-wrappers');
const EventEmitter = require('events');
var ServertalkPacketType =
{
ServertalkClientHello: 1,
ServertalkServerHello: 2,
ServertalkClientHandshake: 3,
ServertalkClientDowngradeSecurityHandshake: 4,
ServertalkMessage: 5,
};
class ServertalkClient extends EventEmitter
{
Init(addr, port, ipv6, identifier, credentials) {
this.m_addr = addr;
this.m_identifier = identifier;
this.m_credentials = credentials;
this.m_connecting = false;
this.m_port = port;
this.m_ipv6 = ipv6;
this.m_encrypted = false;
this.m_connection = null;
this.m_buffer = Buffer.alloc(0);
this.m_public_key_ours = null;
this.m_private_key_ours = null;
this.m_nonce_ours = null;
this.m_public_key_theirs = null;
this.m_nonce_theirs = null;
this.m_shared_key = null;
var self = this;
setInterval(function() { self.Connect(); }, 100);
}
Send(opcode, p) {
try {
var out;
if(this.m_encrypted) {
if(p.length == 0) {
p = Buffer.alloc(1);
}
out = Buffer.alloc(6);
out.writeUInt32LE(p.length + sodium.crypto_secretbox_MACBYTES, 0);
out.writeUInt16LE(opcode, 4);
var cipher = sodium.crypto_box_easy_afternm(p, this.m_nonce_ours, this.m_shared_key);
this.IncrementUint64(this.m_nonce_ours);
out = Buffer.concat([out, Buffer.from(cipher)], out.length + cipher.length);
} else {
out = Buffer.alloc(6);
out.writeUInt32LE(p.length, 0);
out.writeUInt16LE(opcode, 4);
out = Buffer.concat([out, p], out.length + p.length);
}
this.InternalSend(ServertalkPacketType.ServertalkMessage, out);
} catch(ex) {
this.emit('error', new Error(ex));
}
}
Connected() {
return this.m_connection && !this.m_connecting;
}
Connect() {
if (this.m_port == 0 || this.m_connection || this.m_connecting) {
return;
}
this.m_connecting = true;
this.emit('connecting');
var self = this;
this.m_connection = net.connect({port: this.m_port, host: this.m_addr}, function() {
self.m_connection.on('close', function(had_error) {
self.emit('close');
self.m_connection = null;
self.m_encrypted = false;
});
self.m_connection.on('data', function(buffer) {
self.ProcessData(buffer);
});
self.SendHello();
self.m_connecting = false;
});
this.m_connection.on('error', function() {
self.emit('close');
self.m_connection = null;
self.m_connecting = false;
});
}
ProcessData(buffer) {
this.m_buffer = Buffer.concat([this.m_buffer, buffer], this.m_buffer.length + buffer.length);
this.ProcessReadBuffer();
}
SendHello() {
var p = Buffer.alloc(0);
this.InternalSend(ServertalkPacketType.ServertalkClientHello, p);
}
InternalSend(type, p) {
if(!this.m_connection) {
return;
}
var out = Buffer.alloc(5);
out.writeUInt32LE(p.length, 0);
out.writeUInt8(type, 4);
if (p.length > 0) {
out = Buffer.concat([out, p], out.length + p.length);
}
this.m_connection.write(out);
}
ProcessReadBuffer() {
var current = 0;
var total = this.m_buffer.length;
while (current < total) {
var left = total - current;
var length = 0;
var type = 0;
if (left < 5) {
break;
}
length = this.m_buffer.readUInt32LE(current);
type = this.m_buffer.readUInt8(current + 4);
if (current + 5 + length > total) {
break;
}
if (length == 0) {
var p = Buffer.alloc(0);
switch (type) {
case ServertalkPacketType.ServertalkServerHello:
this.ProcessHello(p);
break;
case ServertalkPacketType.ServertalkMessage:
this.ProcessMessage(p);
break;
}
}
else {
var p = this.m_buffer.slice(current + 5, current + 5 + length);
switch (type) {
case ServertalkPacketType.ServertalkServerHello:
this.ProcessHello(p);
break;
case ServertalkPacketType.ServertalkMessage:
this.ProcessMessage(p);
break;
}
}
current += length + 5;
}
if (current == total) {
this.m_buffer = Buffer.alloc(0);
}
else {
this.m_buffer = this.m_buffer.slice(current);
}
}
ProcessHello(p) {
this.m_encrypted = false;
this.m_public_key_ours = null;
this.m_public_key_theirs = null;
this.m_private_key_ours = null;
this.m_nonce_ours = null;
this.m_nonce_theirs = null;
this.m_shared_key = null;
try {
var enc = p.readUInt8(0) == 1 ? true : false;
if (enc) {
if (p.length == (1 + sodium.crypto_box_PUBLICKEYBYTES + sodium.crypto_box_NONCEBYTES)) {
this.m_public_key_theirs = p.slice(1, 1 + sodium.crypto_box_PUBLICKEYBYTES);
this.m_nonce_theirs = p.slice(1 + sodium.crypto_box_PUBLICKEYBYTES, 1 + sodium.crypto_box_PUBLICKEYBYTES + sodium.crypto_box_NONCEBYTES);
this.m_encrypted = true;
this.SendHandshake(false);
this.emit('connect');
}
else {
this.emit('error', new Error('Could not process hello, size !=', 1 + sodium.crypto_box_PUBLICKEYBYTES + sodium.crypto_box_NONCEBYTES));
}
} else {
this.SendHandshake(false);
this.emit('connect');
}
} catch(ex) {
this.emit('error', new Error(ex));
}
}
ProcessMessage(p) {
try {
var length = p.readUInt32LE(0);
var opcode = p.readUInt16LE(4);
if(length > 0) {
var data = p.slice(6);
if(this.m_encrypted) {
var message_len = length - sodium.crypto_secretbox_MACBYTES;
var decrypted = sodium.crypto_box_open_easy_afternm(data, this.m_nonce_theirs, this.m_shared_key);
this.IncrementUint64(this.m_nonce_theirs);
this.emit('message', opcode, decrypted);
} else {
this.emit('message', opcode, data);
}
} else {
this.emit('message', opcode, Buffer.alloc(0));
}
} catch(ex) {
this.emit('error', new Error(ex));
}
}
SendHandshake() {
var handshake;
if(this.m_encrypted) {
var keypair = sodium.crypto_box_keypair();
this.m_public_key_ours = keypair.publicKey;
this.m_private_key_ours = keypair.privateKey;
this.m_nonce_ours = Buffer.from(sodium.randombytes_buf(sodium.crypto_box_NONCEBYTES));
this.m_shared_key = sodium.crypto_box_beforenm(this.m_public_key_theirs, this.m_private_key_ours);
this.m_public_key_theirs = null;
this.m_private_key_ours = null;
var message = Buffer.alloc(this.m_identifier.length + this.m_credentials.length + 2);
message.write(this.m_identifier, 0);
message.write(this.m_credentials, this.m_identifier.length + 1);
var ciphertext = sodium.crypto_box_easy_afternm(message, this.m_nonce_ours, this.m_shared_key);
handshake = Buffer.concat([Buffer.from(this.m_public_key_ours), Buffer.from(this.m_nonce_ours), Buffer.from(ciphertext)], sodium.crypto_box_PUBLICKEYBYTES + sodium.crypto_box_NONCEBYTES + ciphertext.length);
this.IncrementUint64(this.m_nonce_ours);
this.m_public_key_ours = null;
} else {
handshake = Buffer.alloc(this.m_identifier.length + this.m_credentials.length + 2);
handshake.write(this.m_identifier, 0);
handshake.write(this.m_credentials, this.m_identifier.length() + 1);
}
this.InternalSend(ServertalkPacketType.ServertalkClientHandshake, handshake);
}
IncrementUint64(value) {
var bytes = [];
for(var i = 0; i < 8; ++i) {
bytes[i] = value[i];
}
bytes[0] += 1;
for(i = 0; i < 7; ++i) {
if(bytes[i] >= 0x100) {
bytes[0] = 0;
bytes[i + 1] += 1;
}
}
if(bytes[7] >= 0x100) {
bytes[7] = 0;
}
for(var i = 0; i < 8; ++i) {
value[i] = bytes[i];
}
}
}
module.exports = {
'client': ServertalkClient
}

View File

@ -1,24 +0,0 @@
{
"name": "wi",
"version": "1.0.0",
"description": "Web interface connection for EQEmu",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "KimLS",
"license": "GPL-3.0",
"dependencies": {
"body-parser": "^1.15.2",
"express": "^4.14.0",
"hammerjs": "^2.0.8",
"jsonwebtoken": "^7.2.1",
"libsodium": "^0.4.8",
"libsodium-wrappers": "^0.4.8",
"libsodium-wrappers-sumo": "^0.4.8",
"moment": "^2.17.1",
"mysql": "^2.12.0",
"node-uuid": "^1.4.7",
"ws": "^1.1.1"
}
}

View File

@ -1,21 +0,0 @@
{
"db": {
"connectionLimit": 10,
"host": "localhost",
"user": "root",
"password": "blink",
"database": "eqdb"
},
"servertalk": {
"addr": "localhost",
"port": "9101",
"key": "ujwn2isnal1987scanb"
},
"https": {
"enabled": false,
"key": "key.pem",
"cert": "cert.pem"
},
"port": 9080,
"key": "key.pem"
}

View File

@ -1,11 +0,0 @@
const WebSocket = require('ws');
const ws = new WebSocket('ws://localhost:9080');
ws.on('open', function open() {
ws.send(JSON.stringify({authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IktTcHJpdGUxIiwiZXhwIjoxNDg2MzI4MDI3LCJpYXQiOjE0ODU3MjMyMjd9.fJUeSQsxb5C13ICANox81YdE5yImkrVw-lRCP3O40-E', method: 'EQW::ZoneUpdate::Subscribe'}));
ws.send(JSON.stringify({authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6IktTcHJpdGUxIiwiZXhwIjoxNDg2MzI4MDI3LCJpYXQiOjE0ODU3MjMyMjd9.fJUeSQsxb5C13ICANox81YdE5yImkrVw-lRCP3O40-E', method: 'EQW::ClientUpdate::Subscribe'}));
});
ws.on('message', function(data, flags) {
console.log(data);
});

View File

@ -1,18 +0,0 @@
const common = require('./wi_common.js');
var RegisterEQW = function(wsi, api) {
common.Register('EQW::GetConfig', wsi, api);
common.Register('EQW::IsLocked', wsi, api);
common.Register('EQW::Lock', wsi, api);
common.Register('EQW::Unlock', wsi, api);
common.Register('EQW::GetPlayerCount', wsi, api);
common.Register('EQW::GetZoneCount', wsi, api);
common.Register('EQW::GetLauncherCount', wsi, api);
common.Register('EQW::GetLoginServerCount', wsi, api);
common.RegisterSubscription('EQW::ZoneUpdate', wsi, api);
common.RegisterSubscription('EQW::ClientUpdate', wsi, api);
};
module.exports = {
'Register': RegisterEQW
}

View File

@ -1,7 +0,0 @@
var RegisterAPI = function(wsi, api) {
require('./eqw.js').Register(wsi, api);
};
module.exports = {
'Register': RegisterAPI
}

View File

@ -1,27 +0,0 @@
function Register(name, wsi, api) {
wsi.Register(name,
function(request) {
api.Call(name, request.params)
.then(function(value) {
wsi.Send(request, value);
})
.catch(function(reason) {
wsi.SendError(request, reason);
});
}, true);
}
function RegisterSubscription(event, wsi, api) {
wsi.Register(event + '::Subscribe', function(request) {
api.Subscribe(event, request.ws);
});
wsi.Register(event + '::Unsubscribe', function(request) {
api.Unsubscribe(event, request.ws);
});
}
module.exports = {
'Register': Register,
'RegisterSubscription': RegisterSubscription
}

View File

@ -1,118 +0,0 @@
const WebSocketServer = require('ws').Server;
const jwt = require('jsonwebtoken');
const uuid = require('node-uuid');
class WebSocketInterface
{
constructor(server, key, api) {
this.wss = new WebSocketServer({ server: server });
this.methods = {};
var self = this;
this.wss.on('connection', function connection(ws) {
self.ws = ws;
ws.uuid = uuid.v4();
ws.on('message', function incoming(message) {
try {
var request = JSON.parse(message);
request.ws = ws;
if(request.method) {
var method = self.methods[request.method];
if(!method) {
self.SendError(request, 'Method not found: ' + request.method);
return;
}
if(method.requires_auth) {
if(!request.authorization) {
self.SendError(request, 'Authorization Required');
return;
}
jwt.verify(request.authorization, key, function(err, decoded) {
if(err) {
self.SendError(request, 'Authorization Required');
return;
}
request.token = decoded;
method.fn(request);
});
return;
}
method.fn(request);
} else {
self.SendError(request, 'No method supplied');
}
} catch(ex) {
console.log('Error parsing message:', ex);
self.SendError(null, 'No method supplied');
}
});
ws.on('close', function() {
api.UnsubscribeAll(ws);
});
ws.on('subscriptionMessage', function(msg) {
self.SendRaw(msg);
});
});
}
Register(method, fn, requires_auth) {
var entry = { fn: fn, requires_auth: requires_auth };
this.methods[method] = entry;
}
SendError(request, msg) {
try {
if(this.ws) {
var error = {};
if(request && request.id) {
error.id = request.id;
}
error.error = msg;
this.ws.send(JSON.stringify(error));
}
} catch(ex) {
console.log(ex);
}
}
Send(request, value) {
try {
if(this.ws) {
var response = {};
if(request && request.id) {
response.id = response.id;
}
response.response = value;
this.ws.send(JSON.stringify(response));
}
} catch(ex) {
console.log(ex);
}
}
SendRaw(obj) {
try {
this.ws.send(JSON.stringify(obj));
} catch(ex) {
console.log(ex);
}
}
}
module.exports = {
'wsi': WebSocketInterface
}

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
SET(world_sources
adventure.cpp
@ -65,8 +65,4 @@ ADD_DEFINITIONS(-DWORLD)
TARGET_LINK_LIBRARIES(world ${SERVER_LIBS})
IF(EQEMU_BUILD_PERL)
TARGET_LINK_LIBRARIES(world ${PERL_LIBRARY})
ENDIF()
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
SET(zone_sources
aa.cpp
@ -262,12 +262,4 @@ ADD_DEFINITIONS(-DZONE)
TARGET_LINK_LIBRARIES(zone ${SERVER_LIBS})
IF(EQEMU_BUILD_PERL)
TARGET_LINK_LIBRARIES(zone ${PERL_LIBRARY})
ENDIF()
IF(EQEMU_BUILD_LUA)
TARGET_LINK_LIBRARIES(zone luabind ${LUA_LIBRARY})
ENDIF(EQEMU_BUILD_LUA)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

View File

@ -1,3 +1,5 @@
#ifdef LUA_EQEMU
#include "lua.hpp"
#include <luabind/luabind.hpp>
#include <luabind/object.hpp>
@ -629,3 +631,5 @@ void LuaMod::GetExperienceForKill(Client *self, Mob *against, uint32 &returnValu
lua_pop(L, n);
}
}
#endif

View File

@ -1300,8 +1300,6 @@ QuestEventID LuaParser::ConvertLuaEvent(QuestEventID evt) {
}
}
#endif
void LuaParser::MeleeMitigation(Mob *self, Mob *attacker, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault)
{
for (auto &mod : mods_) {
@ -1374,3 +1372,5 @@ uint32 LuaParser::GetExperienceForKill(Client *self, Mob *against, bool &ignoreD
}
return retval;
}
#endif

View File

@ -1,3 +1,5 @@
#ifdef LUA_EQEMU
#include "lua.hpp"
#include <luabind/luabind.hpp>
@ -1536,4 +1538,6 @@ luabind::scope lua_register_stat_bonuses() {
.def("Assassinate", &Lua_StatBonuses::GetAssassinate)
.def("AssassinateLevel", &Lua_StatBonuses::GetAssassinateLevel)
.def("ReduceTradeskillFail", &Lua_StatBonuses::GetReduceTradeskillFail);
}
}
#endif