Skip to content

Commit

Permalink
Improvements and fixes (opentibiabr#2534)
Browse files Browse the repository at this point in the history
* Fix some checks notifications
* Update builds
* Delete vc14 folder
* General improvements
  • Loading branch information
Costallat authored Apr 22, 2021
1 parent f5049e4 commit b8ac54c
Show file tree
Hide file tree
Showing 32 changed files with 158 additions and 583 deletions.
48 changes: 24 additions & 24 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ shallow_clone: true
# set clone depth
clone_depth: 1

# environment:
# APPVEYOR_SAVE_CACHE_ON_ERROR: true

platform:
- x64

configuration:
- Release

matrix:
fast_finish: false
fast_finish: true

only_commits:
files:
Expand All @@ -24,35 +27,32 @@ only_commits:
- CMakeLists.txt

install:
- cmd: vcpkg install boost-asio:x64-windows
- cmd: vcpkg install boost-filesystem:x64-windows
- cmd: vcpkg install boost-iostreams:x64-windows
- cmd: vcpkg install boost-lockfree:x64-windows
- cmd: vcpkg install boost-system:x64-windows
- cmd: vcpkg install boost-variant:x64-windows
- cmd: vcpkg install cryptopp:x64-windows
- cmd: vcpkg install curl:x64-windows
- cmd: vcpkg install jsoncpp:x64-windows
- cmd: vcpkg install libmariadb:x64-windows
- cmd: vcpkg install luajit:x64-windows
- cmd: vcpkg install mpir:x64-windows
- cmd: vcpkg install pugixml:x64-windows
- cmd: vcpkg install spdlog:x64-windows
- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
- cd C:\Tools\vcpkg
- git pull
- .\bootstrap-vcpkg.bat
- .\vcpkg integrate install
- cd %APPVEYOR_BUILD_FOLDER%

before_build:
- cmd: |-
if not exist build mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=C:\Tools\vcpkg\scripts\buildsystems\vcpkg.cmake ..
cmake --build . --config Release
build:
project: C:\projects\otservbr-global\build\otbr.sln
verbosity: minimal
parallel: true
# MSBuild verbosity level
# verbosity: detailed

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

cache:
- c:\tools\vcpkg\installed\
- C:\projects\otservbr-global\build\vcpkg_installed\
- C:\Users\appveyor\AppData\Local\vcpkg\archives

artifacts:
- path: vc14\**\otservbr-global*.exe
- path: vc14\**\*.dll
- path: otservbr-global.zip
- path: \build\bin\otservbr-global.zip
7 changes: 6 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ indent_size = 2
indent_brace_style = K&R
spaces_around_brackets = none

[*.{yml,yaml}]
[*.{yml,yaml,json}]
indent_style = space
indent_size = 2

# CMake
[CMakeLists.txt]
indent_style = space
indent_size = 2
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# These are supported funding model platforms
---

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

name: Build on Ubuntu

on:
Expand Down Expand Up @@ -58,7 +60,7 @@ jobs:
appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }}
vcpkgTriplet: ${{ matrix.triplet }}
additionalCachedPaths: ${{ github.workspace }}/build/vcpkg_installed
vcpkgGitCommitId: 030cfaa24de9ea1bbf0a4d9c615ce7312ba77af1
vcpkgGitCommitId: ${{ secrets.VCPKG_ID }}

- name: 'Run CMake with Ninja, install dependencies with vcpkg, build with CMake'
uses: lukka/run-cmake@v3
Expand Down
68 changes: 37 additions & 31 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

name: Build on Windows

on:
Expand Down Expand Up @@ -41,24 +43,15 @@ jobs:
run: rm -r -fo C:/mysql-5.7.21-winx64
if: contains( matrix.os, 'windows')

# - name: Restore artifacts, or setup vcpkg (do not install any package)
# uses: lukka/run-vcpkg@v7
# id: runvcpkg
# with:
# setupOnly: true
# vcpkgDirectory: '${{ github.workspace }}/vcpkg'
# appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }}
# vcpkgTriplet: ${{ matrix.triplet }}
# additionalCachedPaths: ${{ github.workspace }}/build/vcpkg_installed
# vcpkgGitCommitId: 030cfaa24de9ea1bbf0a4d9c615ce7312ba77af1

- name: Run vcpkg
uses: lukka/run-vcpkg@v5
- name: Restore artifacts, or setup vcpkg (do not install any package)
uses: lukka/run-vcpkg@v7
with:
vcpkgArguments: ${{ matrix.packages }}
vcpkgDirectory: ${{ runner.workspace }}/vcpkg/
setupOnly: true
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }}
vcpkgTriplet: ${{ matrix.triplet }}
vcpkgGitCommitId: 7db401cb1ef1fc559ec9f9ce814d064c328fd767
additionalCachedPaths: ${{ github.workspace }}/build/vcpkg_installed
vcpkgGitCommitId: ${{ secrets.VCPKG_ID }}

- name: Run CMake to install the dependencies specified in the vcpkg.json manifest, generate project file and build the project
uses: lukka/run-cmake@v3
Expand All @@ -68,24 +61,37 @@ jobs:
useVcpkgToolchainFile: true
buildWithCMake: true

- name: Create datapack
- name: Copy artifacts
if: ${{ matrix.buildtype == 'Release' }}
shell: powershell
shell: pwsh
run: |
md ${{ runner.workspace }}\otservbr-global\otservbr-global
Copy-Item ${{ runner.workspace }}\otservbr-global\config.lua.dist ${{ runner.workspace }}\otservbr-global\otservbr-global
Copy-Item ${{ runner.workspace }}\otservbr-global\key.pem ${{ runner.workspace }}\otservbr-global\otservbr-global
Copy-Item ${{ runner.workspace }}\otservbr-global\LICENSE ${{ runner.workspace }}\otservbr-global\otservbr-global
Copy-Item ${{ runner.workspace }}\otservbr-global\README.md ${{ runner.workspace }}\otservbr-global\otservbr-global
Copy-Item ${{ github.workspace }}\build\bin\otbr.exe ${{ runner.workspace }}\otservbr-global\otservbr-global\otbr.exe
get-childitem -path ${{ runner.workspace }}\build -filter *.dll -recurse | copy-item -destination ${{ runner.workspace }}\otservbr-global\otservbr-global
Copy-Item ${{ runner.workspace }}\otservbr-global\data -Destination ${{ runner.workspace }}\otservbr-global\otservbr-global\data
Copy-Item -Path ${{ runner.workspace }}\otservbr-global\data\* -Destination ${{ runner.workspace }}\otservbr-global\otservbr-global\data -Recurse
Compress-Archive -Path ${{ runner.workspace }}\otservbr-global\otservbr-global -DestinationPath ${{ runner.workspace }}\otservbr.zip
Copy-Item -Path ${{ github.workspace }}\build\bin\* -Destination ${{ github.workspace }} -Recurse
- name: Create and Upload Full Datapack
if: ${{ matrix.buildtype == 'Release' }}
uses: actions/upload-artifact@v2
with:
name: otbr-full-${{ matrix.os }}-${{ matrix.buildtype }}-${{ github.sha }}
path: |
${{ github.workspace }}
!${{ github.workspace }}/build/
!${{ github.workspace }}/vcpkg/
!${{ github.workspace }}/.git/
!${{ github.workspace }}/.github/
!${{ github.workspace }}/.appveyor.yml
!${{ github.workspace }}/.editorconfig
!${{ github.workspace }}/.gitignore
!${{ github.workspace }}/.reviewdog.yml
!${{ github.workspace }}/.travis.yml
!${{ github.workspace }}/tests/
!${{ github.workspace }}/cmake/
!${{ github.workspace }}/sonar-project.properties
!${{ github.workspace }}/Jenkinsfile
- name: Upload datapack
- name: Create and Upload Server Only
if: ${{ matrix.buildtype == 'Release' }}
uses: actions/upload-artifact@v2
with:
name: otbr-${{ matrix.os }}-${{ matrix.buildtype }}-${{ github.sha }}
path: ${{ runner.workspace }}/otservbr.zip
name: otbr-server-only-${{ matrix.os }}-${{ matrix.buildtype }}-${{ github.sha }}
path: |
${{ github.workspace }}/build/bin/
2 changes: 2 additions & 0 deletions .github/workflows/codacy-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

name: Codacy Security Scan

on:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

name: "CodeQL"

on:
Expand Down Expand Up @@ -45,7 +47,7 @@ jobs:
appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }}
vcpkgTriplet: ${{ matrix.triplet }}
additionalCachedPaths: ${{ github.workspace }}/build/vcpkg_installed
vcpkgGitCommitId: 030cfaa24de9ea1bbf0a4d9c615ce7312ba77af1
vcpkgGitCommitId: ${{ secrets.VCPKG_ID }}

- name: 'Run CMake with Ninja, install dependencies with vcpkg, build with CMake'
if: ${{ matrix.language == 'cpp' }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

name: "Pull Request Labeler"
on:
- pull_request_target
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

name: Review
on: [pull_request]
jobs:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

name: 'Stale issues and PRs'
on:
schedule:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ StyleCopReport.xml
*.pidb
*.svclog
*.scc
CMakeSettings.json

# Chutzpah Test files
_Chutzpah*
Expand Down
4 changes: 3 additions & 1 deletion .reviewdog.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
runner:

cppcheck:
Expand All @@ -7,7 +8,8 @@ runner:
level: warning

luacheck:
cmd: luacheck --formatter=plain --no-color --no-config --no-global --no-unused --no-unused-args --no-cache -d ./data/
cmd: luacheck --formatter=plain --no-color --no-config --no-global \
--no-unused --no-unused-args --no-cache -d ./data/
errorformat:
- "%f:%l:%c: %m"
level: warning
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET)
endif()

set(VCPKG_FEATURE_FLAGS "versions")
set(VCPKG_BUILD_TYPE "release")

# *****************************************************************************
# Project otbr
Expand Down
16 changes: 0 additions & 16 deletions CMakeSettings.json

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

[![Build status](https://ci.appveyor.com/api/projects/status/github/opentibiabr/otservbr-global?branch=develop&passingText=develop%20-%20OK&svg=true)](https://ci.appveyor.com/project/opentibiabr/otservbr-global/build/artifacts "Download nightly builds for Windows")

[![Build on MacOS](https://github.com/opentibiabr/otservbr-global/workflows/Build%20on%20MacOS/badge.svg)](https://github.com/opentibiabr/otservbr-global/actions?query=workflow%3A%22Build+on+MacOS%22)
[![Build on Ubuntu](https://github.com/opentibiabr/otservbr-global/workflows/Build%20on%20Ubuntu/badge.svg)](https://github.com/opentibiabr/otservbr-global/actions?query=workflow%3A%22Build+on+Ubuntu%22)
[![Build on Windows](https://github.com/opentibiabr/otservbr-global/workflows/Build%20on%20Windows/badge.svg)](https://github.com/opentibiabr/otservbr-global/actions?query=workflow%3A%22Build+on+Windows%22)

Expand All @@ -30,7 +29,7 @@ You are subject to our code of conduct, read at [this link](https://github.com/o

* **WARNING: YOU NEED TO UNZIP THE MAP BEFORE START THE SERVER.**
* [Compiling on Windows](https://forums.otserv.com.br/index.php?/forums/topic/169235-windowsvc2019-compilando-sources-otservbr-global/), alternatively if you are ****not** going to change anything on the source** you can download the latest compiled version for windows from [nightly builds for Windows](https://ci.appveyor.com/project/opentibiabr/otservbr-global/build/artifacts).
* Wiki: Compiling ([Debian](https://github.com/opentibiabr/otservbr-global/wiki/Compiling-on-Debian-GNU-Linux), [Ubuntu](https://github.com/opentibiabr/otservbr-global/wiki/Compiling-on-Ubuntu), [Windows](https://github.com/opentibiabr/otservbr-global/wiki/Compiling-on-Windows-(vcpkg)))
* Wiki: Compiling ([Ubuntu/Debian](https://github.com/opentibiabr/otservbr-global/wiki/Compiling-on-Ubuntu-or-Debian-GNU-Linux), [Windows](https://github.com/opentibiabr/otservbr-global/wiki/Compiling-on-Windows-(vcpkg)))

### Issues

Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ option(DEBUG_LOG "Enable Debug Log" OFF)
# *****************************************************************************
# Client
# *****************************************************************************
add_executable(${PROJECT_NAME} "")
if (MSVC)
add_executable(${PROJECT_NAME} "" ../cmake/otservbr-global.rc)
else()
add_executable(${PROJECT_NAME} "")
endif()


# *****************************************************************************
Expand Down
24 changes: 16 additions & 8 deletions src/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ void Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatPa
}

if ((damage.primary.value < 0 || damage.secondary.value < 0)) {
if (caster && caster->getPlayer() && target->getSkull() != SKULL_BLACK && target->getPlayer()) {
if (caster && target && caster->getPlayer() && target->getSkull() != SKULL_BLACK && target->getPlayer()) {
damage.primary.value /= 2;
damage.secondary.value /= 2;
}
Expand Down Expand Up @@ -540,7 +540,7 @@ void Combat::CombatConditionFunc(Creature* caster, Creature* target, const Comba
if (player->isImmuneCleanse(condition->getType())) {
player->sendCancelMessage("You are still immune against this spell.");
return;
} else if (caster->getMonster()) {
} else if (caster && caster->getMonster()) {
uint16_t playerCharmRaceid = player->parseRacebyCharm(CHARM_CLEANSE, false, 0);
if (playerCharmRaceid != 0) {
MonsterType* mType = g_monsters.getMonsterType(caster->getName());
Expand Down Expand Up @@ -574,7 +574,9 @@ void Combat::CombatConditionFunc(Creature* caster, Creature* target, const Comba

void Combat::CombatDispelFunc(Creature*, Creature* target, const CombatParams& params, CombatDamage*)
{
target->removeCombatCondition(params.dispelType);
if(target) {
target->removeCombatCondition(params.dispelType);
}
}

void Combat::CombatNullFunc(Creature* caster, Creature* target, const CombatParams& params, CombatDamage*)
Expand Down Expand Up @@ -847,7 +849,9 @@ void Combat::CombatFunc(Creature* caster, const Position& pos, const AreaCombat*
void Combat::doCombatHealth(Creature* caster, Creature* target, CombatDamage& damage, const CombatParams& params)
{
bool canCombat = !params.aggressive || (caster != target && Combat::canDoCombat(caster, target) == RETURNVALUE_NOERROR);
if ((caster == target || canCombat) && params.impactEffect != CONST_ME_NONE) {
if ( (caster && target)
&& (caster == target || canCombat)
&& (params.impactEffect != CONST_ME_NONE)) {
g_game.addMagicEffect(target->getPosition(), params.impactEffect);
}

Expand Down Expand Up @@ -875,7 +879,7 @@ void Combat::doCombatHealth(Creature* caster, Creature* target, CombatDamage& da
}
}
if (canCombat) {
if (caster && params.distanceEffect != CONST_ANI_NONE) {
if (target && caster && params.distanceEffect != CONST_ANI_NONE) {
addDistanceEffect(caster, caster->getPosition(), target->getPosition(), params.distanceEffect);
}

Expand Down Expand Up @@ -903,7 +907,9 @@ void Combat::doCombatHealth(Creature* caster, const Position& position, const Ar
void Combat::doCombatMana(Creature* caster, Creature* target, CombatDamage& damage, const CombatParams& params)
{
bool canCombat = !params.aggressive || (caster != target && Combat::canDoCombat(caster, target) == RETURNVALUE_NOERROR);
if ((caster == target || canCombat) && params.impactEffect != CONST_ME_NONE) {
if ( (caster && target)
&& (caster == target || canCombat)
&& (params.impactEffect != CONST_ME_NONE)) {
g_game.addMagicEffect(target->getPosition(), params.impactEffect);
}

Expand Down Expand Up @@ -974,7 +980,9 @@ void Combat::doCombatDispel(Creature* caster, const Position& position, const Ar
void Combat::doCombatDispel(Creature* caster, Creature* target, const CombatParams& params)
{
bool canCombat = !params.aggressive || (caster != target && Combat::canDoCombat(caster, target) == RETURNVALUE_NOERROR);
if ((caster == target || canCombat) && params.impactEffect != CONST_ME_NONE) {
if ( (caster && target)
&& (caster == target || canCombat)
&& (params.impactEffect != CONST_ME_NONE)) {
g_game.addMagicEffect(target->getPosition(), params.impactEffect);
}

Expand All @@ -984,7 +992,7 @@ void Combat::doCombatDispel(Creature* caster, Creature* target, const CombatPara
params.targetCallback->onTargetCombat(caster, target);
}

if (caster && params.distanceEffect != CONST_ANI_NONE) {
if (target && caster && params.distanceEffect != CONST_ANI_NONE) {
addDistanceEffect(caster, caster->getPosition(), target->getPosition(), params.distanceEffect);
}
}
Expand Down
Loading

0 comments on commit b8ac54c

Please sign in to comment.