Skip to content

Commit

Permalink
Update build and add several tools and improvements (opentibiabr#611)
Browse files Browse the repository at this point in the history
- Updated appveyor with the new log library
and also added a zip files with all artifacts.

- Updated travis to build release and debug
versons, and also changed the ubuntu version
to bionic to use new gcc, also added the new
log library.

- Improved cmake file to enable more warnings,
to have a release and debug version, and to
generate the documentation when enabled.

- Updated docker files to install the
new log library.

- Added new account and players to docker
test server. Changed god account password
to 'god'

- Update all files headers to insert
the Copyright.

- Update all .h header files to use the
Google Style.

- Fixed all 'shadow' warning about variables
with the same name.

Signed-off-by: Renato Foot <[email protected]>
  • Loading branch information
Costallat authored and majestyotbr committed Sep 27, 2019
1 parent 3301344 commit 4896943
Show file tree
Hide file tree
Showing 184 changed files with 3,805 additions and 782 deletions.
12 changes: 10 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ configuration:
- Release

matrix:
fast_finish: true
fast_finish: false

only_commits:
files:
- src/
- vc14/
- .appveyor.yml
- cmake/
- CMakeLists.txt

install:
- cmd : vcpkg install boost-iostreams:x64-windows
Expand All @@ -32,6 +33,7 @@ install:
- cmd : vcpkg install libmariadb:x64-windows
- cmd : vcpkg install pugixml:x64-windows
- cmd : vcpkg install mpir:x64-windows
- cmd : vcpkg install spdlog:x64-windows
- cmd : vcpkg install boost-iostreams
- cmd : vcpkg install boost-asio
- cmd : vcpkg install boost-system
Expand All @@ -43,15 +45,21 @@ install:
- cmd : vcpkg install libmariadb
- cmd : vcpkg install pugixml
- cmd : vcpkg install mpir
- cmd : vcpkg install spdlog

build:
parallel: true
# MSBuild verbosity level
#verbosity: detailed
verbosity: detailed

# scripts to run after build (working directory and environment changes are persisted from the previous steps)
after_build:
- 7z a -tzip otbr.zip -r .\vc14\*.exe -ir!.\vc14\*.dll

cache:
- c:\tools\vcpkg\installed\

artifacts:
- path: vc14\**\theforgottenserver*.exe
- path: vc14\**\*.dll
- path: otbr.zip
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ bld/
[Bb]in/
[Oo]bj/
[Ll]og/
build/

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand Down Expand Up @@ -169,6 +170,9 @@ DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Doxygen files
doc/*

# Click-Once directory
publish/

Expand Down Expand Up @@ -352,6 +356,10 @@ MigrationBackup/
# Docker folders with generated artifacts
docker/**/otserver

# VSCode
settings.json
c_cpp_properties.json

## CUSTOM

libmysql.dll
Expand Down
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
sudo: required
dist: xenial
dist: bionic
language: cpp
compiler:
- clang
- gcc
env:
matrix:
- LUAJIT=OFF
- LUAJIT=ON
- BUILD_TYPE=Debug LUAJIT=OFF
- BUILD_TYPE=Debug LUAJIT=ON
- BUILD_TYPE=Release LUAJIT=OFF
- BUILD_TYPE=Release LUAJIT=ON
cache: apt
addons:
apt:
Expand All @@ -22,9 +24,10 @@ addons:
- libmysqlclient-dev
- libpugixml-dev
- libgmp3-dev
- libspdlog-dev

before_script:
- mkdir build && cd build
- cmake -DCMAKE_BUILD_TYPE=Release -DUSE_LUAJIT=${LUAJIT} ..
- cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DUSE_LUAJIT=${LUAJIT} ..

script: make -j`nproc`
104 changes: 83 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,56 +1,118 @@
cmake_minimum_required(VERSION 2.8)

# https://gitlab.kitware.com/cmake/cmake/issues/18403
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)

project(tfs)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(cotire)

add_compile_options(-Wall -Werror -pipe -fvisibility=hidden)

set(CMAKE_CXX_FLAGS_PERFORMANCE "${CMAKE_CXX_FLAGS_RELEASE} -march=native")

# GCC is fairly aggressive about it: enabling strict aliasing will cause it to think that pointers that are "obviously" equivalent to a human (as in, foo *a; bar *b = (bar *) a;) cannot alias, which allows for some very aggressive transformations, but can obviously break non-carefully written code.
if (CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(-fno-strict-aliasing)
endif()

include(FindCXX11)
include(FindLTO)
# default build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

# compile flags
# https://kristerw.blogspot.com/2017/09/useful-gcc-warning-options-not-enabled.html
set(WARNING_FLAGS "-Wall -Werror")

set(CMAKE_CXX_FLAGS "${WARNING_FLAGS} ${CMAKE_CXX_FLAGS}")

# cmake ..
set(CMAKE_CXX_FLAGS_RELEASE "${WARNING_FLAGS} -pipe -fvisibility=hidden -march=native -O2")

# cmake -DCMAKE_BUILD_TYPE=Debug ..
set(CMAKE_CXX_FLAGS_DEBUG "${WARNING_FLAGS} -pipe -O0 -g -Wextra -Wconversion -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -Wnull-dereference -Wold-style-cast -Wuseless-cast -Wdouble-promotion -Wshadow -Wformat=2 -Wno-error")

# Find packages.
find_package(Cotire REQUIRED)
find_package(LTO REQUIRED)
find_package(CXX11 REQUIRED)
find_package(Crypto++ REQUIRED)
find_package(PugiXML REQUIRED)
find_package(MySQL)
find_package(Threads)
find_package(MySQL REQUIRED)
find_package(Threads REQUIRED)
find_package(Spdlog REQUIRED)
find_package(Boost 1.53.0 COMPONENTS system filesystem iostreams REQUIRED)

# Selects LuaJIT if user defines or auto-detected
if(DEFINED USE_LUAJIT AND NOT USE_LUAJIT)
set(FORCE_LUAJIT ${USE_LUAJIT})
set(FORCE_LUAJIT ${USE_LUAJIT})
else()
find_package(LuaJIT)
set(FORCE_LUAJIT ${LuaJIT_FOUND})
find_package(LuaJIT)
set(FORCE_LUAJIT ${LuaJIT_FOUND})
endif()
option(USE_LUAJIT "Use LuaJIT" ${FORCE_LUAJIT})

if(FORCE_LUAJIT)
if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "-pagezero_size 10000 -image_base 100000000")
endif()
if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "-pagezero_size 10000 -image_base 100000000")
endif()
else()
find_package(Lua REQUIRED)
find_package(Lua REQUIRED)
endif()

find_package(Boost 1.53.0 COMPONENTS system filesystem iostreams REQUIRED)

add_subdirectory(src)
add_executable(tfs ${tfs_SRC})

include_directories(${MYSQL_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${PUGIXML_INCLUDE_DIR} ${Crypto++_INCLUDE_DIR})
target_link_libraries(tfs ${MYSQL_CLIENT_LIBS} ${LUA_LIBRARIES} ${Boost_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY} ${PUGIXML_LIBRARIES} ${Crypto++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
# cmake -DBUILD_DOC=ON ..
option(BUILD_DOC "Build documentation" OFF)
if(BUILD_DOC)

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc)

find_package(Doxygen)
if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)

add_custom_target( doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )

else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)

find_program(LDOC_EXECUTABLE ldoc FALSE)
if(NOT LDOC_EXECUTABLE)
find_program(LDOC_EXECUTABLE ldoc.lua FALSE)
endif()
if (LDOC_EXECUTABLE)
# set input and output files
set(LDOC_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/config.ld.in)
set(LDOC_OUT ${CMAKE_CURRENT_BINARY_DIR}/config.ld)

# request to configure the file
configure_file(${LDOC_IN} ${LDOC_OUT} @ONLY)
# execute_process(COMMAND sh -c "${LDOC_EXECUTABLE} .")
add_custom_target( doc_ldoc ALL
COMMAND ${LDOC_EXECUTABLE} .
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Ldoc")
else (LDOC_EXECUTABLE)
message("Ldoc need to be installed to generate the ldoc documentation")
endif (LDOC_EXECUTABLE)

endif (BUILD_DOC)

include_directories(SYSTEM ${MYSQL_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${PUGIXML_INCLUDE_DIR} ${Crypto++_INCLUDE_DIR} ${spdlog_INCLUDE_DIR})

target_link_libraries(tfs ${MYSQL_CLIENT_LIBS} ${LUA_LIBRARIES} ${Boost_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY} ${PUGIXML_LIBRARIES} ${Crypto++_LIBRARIES} ${Spdlog_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})

set_target_properties(tfs PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "src/otpch.h")
set_target_properties(tfs PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)

cotire(tfs)
File renamed without changes.
13 changes: 13 additions & 0 deletions cmake/FindSpdlog.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Locate Spdlog library
# This module defines
# Spdlog_FOUND
# Spdlog_INCLUDE_DIR
# Spdlog_LIBRARIES

find_path(Spdlog_INCLUDE_DIR NAMES cryptopp/cryptlib.h)
find_library(Spdlog_LIBRARIES NAMES cryptopp libcryptopp)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Spdlog DEFAULT_MSG Spdlog_INCLUDE_DIR Spdlog_LIBRARIES)

mark_as_advanced(Spdlog_INCLUDE_DIR Spdlog_LIBRARIES)
11 changes: 11 additions & 0 deletions data/actions/scripts/others/objects/stringOfMending.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
------------
-- Alternative to no-magic style.
-- Description here
----

---- string of mending id "22542"-----
local ITEMS = {
[13877] = { -----Broken Ring Id "13877" Ring of ending "22516"
{"ring of ending", 50.50} ----- 1.97 es la probabilidad de crear el item
}
}

---- onUse [opt]
-- @param cid Player ID
-- @param item Item ID
-- @param fromPosition Current Position
-- @param[opt] itemEx Item change
-- @param[opt] toPosition Nem position
function onUse(cid, item, fromPosition, itemEx, toPosition)
local cadena = ITEMS[itemEx.itemid]
if cadena == nil then
Expand Down
5 changes: 3 additions & 2 deletions docker/server-only/build-env/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ RUN apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/test
luajit-dev \
make \
mariadb-connector-c-dev \
pugixml-dev
pugixml-dev \
spdlog-dev

ENTRYPOINT cd /tmp/otserver && mkdir build && cd build && cmake .. && make -j`nproc`
ENTRYPOINT cd /tmp/otserver && mkdir build && cd build && cmake --entrypoint -DCMAKE_BUILD_TYPE=Debug .. && make -j`nproc`

4 changes: 2 additions & 2 deletions docker/server-only/docker-test-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ else
exit
fi

maxcounter=45
maxcounter=450
counter=1
while ! mysql --protocol TCP -u"dbuser" -p"dbpassword" -e "show databases;" > /dev/null 2>&1; do
sleep 30
sleep 5
counter=`expr $counter + 1`
if [ $counter -gt $maxcounter ]; then
>&2 echo "We have been waiting for MySQL too long already; failing."
Expand Down
3 changes: 2 additions & 1 deletion docker/server-only/run-env/Dockerfile.run
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ RUN apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/test
gmp \
luajit \
mariadb-connector-c \
pugixml
pugixml \
spdlog-dev

RUN ln -s /usr/lib/libcryptopp.so /usr/lib/libcryptopp.so.5.6

Expand Down
22 changes: 20 additions & 2 deletions docker/server-only/run-test-env/test_account.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
UPDATE accounts SET password = '356a192b7913b04c54574d18c28d46e6395428ab' WHERE id = 1;
UPDATE players SET account_id = 1 WHERE id = 6;
--
-- Account teste/teste
--

INSERT INTO `accounts`
(`id`, `name`, `password`, `type`) VALUES
(2, 'test', 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1);

INSERT INTO `players`
(`id`, `name`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `mana`, `manamax`, `town_id`, `conditions`, `cap`, `sex`) VALUES
(2, 'Rook Sample', 1, 2, 1, 0, 150, 150, 0, 106, 95, 78, 116, 128, 5, 5, 6, '', 400, 0),
(3, 'Sorcerer Sample', 1, 2, 8, 1, 185, 185, 4200, 106, 95, 78, 116, 128, 40, 40, 2, '', 470, 1),
(4, 'Druid Sample', 1, 2, 8, 2, 185, 185, 4200, 106, 95, 78, 116, 128, 40, 40, 2, '', 470, 1),
(5, 'Paladin Sample', 1, 2, 8, 3, 185, 185, 4200, 106, 95, 78, 116, 128, 40, 40, 2, '', 470, 1),
(6, 'Knight Sample', 1, 2, 8, 4, 185, 185, 4200, 106, 95, 78, 116, 128, 40, 40, 2, '', 470, 1),
(7, 'Rook', 1, 2, 1, 0, 150, 150, 0, 106, 95, 78, 116, 128, 5, 5, 6, '', 400, 0),
(8, 'Sorcerer', 1, 2, 500, 1, 2645, 2645, 2058474, 106, 95, 78, 116, 128, 14800, 14800, 2, '', 5390, 1),
(9, 'Druid', 1, 2, 500, 2, 2645, 2645, 2058474, 106, 95, 78, 116, 128, 14800, 14800, 2, '', 5390, 1),
(10, 'Paladin', 1, 2, 500, 3, 5105, 5105, 2058474, 106, 95, 78, 116, 128, 7420, 7420, 2, '', 10310, 1),
(11, 'Knight', 1, 2, 500, 4, 7565, 7565, 2058474, 106, 95, 78, 116, 128, 2500, 2500, 2, '', 12770, 1);
Loading

0 comments on commit 4896943

Please sign in to comment.