Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/beats-fixs'
Browse files Browse the repository at this point in the history
  • Loading branch information
s2leandro155 committed Sep 26, 2024
2 parents 11bd3a6 + fe4113d commit 5159526
Show file tree
Hide file tree
Showing 358 changed files with 9,645 additions and 8,845 deletions.
28 changes: 16 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ set(VCPKG_BUILD_TYPE "release")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)



# *****************************************************************************
# Project canary
# *****************************************************************************
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
project(canary-debug)
else()
project(canary)
endif()


# *****************************************************************************
# Append cmake search path
# *****************************************************************************
Expand All @@ -51,7 +40,22 @@ include(LoggingHelper)
option(OPTIONS_ENABLE_CCACHE "Enable ccache" OFF)
option(OPTIONS_ENABLE_SCCACHE "Use sccache to speed up compilation process" OFF)
option(OPTIONS_ENABLE_IPO "Check and Enable interprocedural optimization (IPO/LTO)" ON)
option(FEATURE_METRICS "Enable metrics feature" OFF)
option(FEATURE_METRICS "Enable metrics feature" ON)


if(FEATURE_METRICS)
list(APPEND VCPKG_MANIFEST_FEATURES "metrics")
endif()


# *****************************************************************************
# Project canary
# *****************************************************************************
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
project(canary-debug)
else()
project(canary)
endif()

# *****************************************************************************
# Options Code
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/CanaryLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ target_include_directories(${PROJECT_NAME}_lib
${GMP_INCLUDE_DIRS}
${LUAJIT_INCLUDE_DIRS}
${PARALLEL_HASHMAP_INCLUDE_DIRS}
${ATOMIC_QUEUE_INCLUDE_DIRS}
)

# *****************************************************************************
Expand Down
70 changes: 70 additions & 0 deletions cmake/modules/CheckSIMDSupport.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
include(CheckCXXCompilerFlag)

if(MSVC)
check_cxx_compiler_flag("/arch:AVX2" COMPILER_SUPPORTS_AVX2)
if(COMPILER_SUPPORTS_AVX2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
add_definitions(-D__AVX2__ -D__SSE4_2__ -D__SSE4_1__ -D__SSE3__ -D__SSE2__ -D__SSE__)
log_option_enabled("AVX2: Advanced Vector Extensions 2 supported and enabled.")
elseif(COMPILER_SUPPORTS_AVX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX")
add_definitions(-D__AVX__ -D__SSE4_2__ -D__SSE4_1__ -D__SSE3__ -D__SSE2__ -D__SSE__)
log_option_enabled("AVX: Advanced Vector Extensions supported and enabled.")
elseif(COMPILER_SUPPORTS_SSE42)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE4.2")
add_definitions(-D__SSE4_2__ -D__SSE4_1__ -D__SSE3__ -D__SSE2__ -D__SSE__)
log_option_enabled("SSE4.2: Streaming SIMD Extensions 4.2 supported and enabled.")
elseif(COMPILER_SUPPORTS_SSE41)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE4.1")
add_definitions(-D__SSE4_1__ -D__SSE3__ -D__SSE2__ -D__SSE__)
log_option_enabled("SSE4.1: Streaming SIMD Extensions 4.1 supported and enabled.")
elseif(COMPILER_SUPPORTS_SSE3)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE3")
add_definitions(-D__SSE3__ -D__SSE2__ -D__SSE__)
log_option_enabled("SSE3: Streaming SIMD Extensions 3 supported and enabled.")
elseif(COMPILER_SUPPORTS_SSE2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
add_definitions(-D__SSE2__ -D__SSE__)
log_option_enabled("SSE2: Streaming SIMD Extensions 2 supported and enabled.")
elseif(COMPILER_SUPPORTS_SSE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE")
add_definitions(-D__SSE__)
log_option_enabled("SSE: Streaming SIMD Extensions supported and enabled.")
else()
message(STATUS "No advanced SIMD support found. Proceeding with the default instruction set.")
endif()
else()
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-mavx2" COMPILER_SUPPORTS_AVX2)
if(COMPILER_SUPPORTS_AVX2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2")
add_definitions(-D__AVX2__)
log_option_enabled("AVX2: Advanced Vector Extensions 2 supported and enabled.")
elseif(COMPILER_SUPPORTS_AVX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
add_definitions(-D__AVX__)
log_option_enabled("AVX: Advanced Vector Extensions supported and enabled.")
elseif(COMPILER_SUPPORTS_SSE42)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
add_definitions(-D__SSE4_2__)
log_option_enabled("SSE4.2: Streaming SIMD Extensions 4.2 supported and enabled.")
elseif(COMPILER_SUPPORTS_SSE41)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
add_definitions(-D__SSE4_1__)
log_option_enabled("SSE4.1: Streaming SIMD Extensions 4.1 supported and enabled.")
elseif(COMPILER_SUPPORTS_SSE3)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse3")
add_definitions(-D__SSE3__)
log_option_enabled("SSE3: Streaming SIMD Extensions 3 supported and enabled.")
elseif(COMPILER_SUPPORTS_SSE2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
add_definitions(-D__SSE2__)
log_option_enabled("SSE2: Streaming SIMD Extensions 2 supported and enabled.")
elseif(COMPILER_SUPPORTS_SSE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse")
add_definitions(-D__SSE__)
log_option_enabled("SSE: Streaming SIMD Extensions supported and enabled.")
else()
message(STATUS "No advanced SIMD support found. Proceeding with the default instruction set.")
endif()
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,36 @@ condition:setParameter(CONDITION_PARAM_HEALTHGAIN, 0.01)
condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 7 * 1000)

local gazHaragothHeal = CreatureEvent("GazHaragothHeal")
function gazHaragothHeal.onThink(creature)
local hp = (creature:getHealth() / creature:getMaxHealth()) * 100
if hp < 12.5 and not creature:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT, 88888) then
creature:addCondition(condition)
creature:say("Gaz'haragoth begins to draw on the nightmares to HEAL himself!", TALKTYPE_MONSTER_YELL)
addEvent(function(cid)
local creature = Creature(cid)
if not creature then
return
function gazHaragothHeal.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if not creature then
return true
end
local creatureName = creature:getName():lower() == "gaz'haragoth"
if creatureName then
if attacker then
local hp = (creature:getHealth() / creature:getMaxHealth()) * 100
if hp > 12.5 then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
if hp <= 12.5 and not creature:getCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT, 88888) then
if not creature then
return true
end
creature:addCondition(condition)
creature:say("Gaz'haragoth begins to draw on the nightmares to HEAL himself!", TALKTYPE_MONSTER_YELL)
addEvent(function()
if not creature then
return true
end
creature:addHealth(300000)
creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
creature:say("Gaz'haragoth HEALS himself!", TALKTYPE_MONSTER_YELL)
return true
end, 7000, creature:getId())
end
creature:addHealth(300000)
creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
creature:say("Gaz'haragoth HEALS himself!", TALKTYPE_MONSTER_YELL)
return true
end, 7000, creature:getId())
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end

gazHaragothHeal:register()
6 changes: 3 additions & 3 deletions data/XML/groups.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@
<flag cannotusecombat="0" /> <!-- Is combat not allowed? Set to 0 to enable the two flags below. If set to 1 these two flags below will be ignored. -->
<flag cannotattackplayer="1" /> <!-- If combat is allowed (set to 0 above), attack players is not allowed? -->
<flag cannotattackmonster="0" /> <!-- If combat is allowed (set to 0 above), attack monsters is not allowed? -->
<flag cannotbeattacked="1" />
<flag cannotbeattacked="0" />
<flag canconvinceall="1" />
<flag cansummonall="1" />
<flag canillusionall="1" />
<flag cansenseinvisibility="1" />
<flag ignoredbymonsters="1" />
<flag ignoredbynpcs="1" />
<flag ignoredbymonsters="0" />
<flag ignoredbynpcs="0" />
<flag notgaininfight="1" />
<flag hasinfinitemana="1" />
<flag hasinfinitesoul="1" />
Expand Down
2 changes: 2 additions & 0 deletions qodana.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
version: "1.0"

linter: jetbrains/qodana-clang:latest

profile:
name: qodana.recommended

Expand Down
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ cmake_minimum_required(VERSION 3.22 FATAL_ERROR)

# Base configurations and settings for the project
include(BaseConfig)
include(CheckSIMDSupport)
include(GNUInstallDirs)

# Import configurations, source definitions, and linker settings
include(CanaryLib)

# Define main executable target, set it up and link to main library
add_executable(${PROJECT_NAME} main.cpp)
add_executable(${PROJECT_NAME} main.cpp
utils/counter_pointer.hpp)

if(MSVC)
# Add executable icon for Windows
Expand Down
22 changes: 10 additions & 12 deletions src/account/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include "account/account.hpp"

#include "account/account_repository_db.hpp"
#include "config/configmanager.hpp"
#include "utils/definitions.hpp"
#include "security/argon.hpp"
#include "utils/tools.hpp"
#include "lib/logging/log_with_spd_log.hpp"
Expand Down Expand Up @@ -66,7 +64,7 @@ uint8_t Account::reload() {
return load();
}

uint8_t Account::save() {
uint8_t Account::save() const {
if (!m_accLoaded) {
return enumToValue(AccountErrors_t::NotInitialized);
}
Expand Down Expand Up @@ -164,7 +162,7 @@ void Account::registerCoinTransaction(const uint8_t &transactionType, const uint

[[nodiscard]] uint32_t Account::getID() const {
return m_account.id;
};
}

std::string Account::getDescriptor() const {
return m_descriptor;
Expand All @@ -185,8 +183,8 @@ std::string Account::getPassword() {
}

void Account::addPremiumDays(const int32_t &days) {
auto timeLeft = std::max(0, static_cast<int>((m_account.premiumLastDay - getTimeNow()) % 86400));
setPremiumDays(m_account.premiumRemainingDays + days);
const auto timeLeft = std::max(0, static_cast<int>((m_account.premiumLastDay - getTimeNow()) % 86400));
setPremiumDays(static_cast<int32_t>(m_account.premiumRemainingDays) + days);
m_account.premiumDaysPurchased += days;

if (timeLeft > 0) {
Expand Down Expand Up @@ -222,13 +220,13 @@ uint8_t Account::setAccountType(const uint8_t &accountType) {
}

void Account::updatePremiumTime() {
time_t lastDay = m_account.premiumLastDay;
uint32_t remainingDays = m_account.premiumRemainingDays;
const time_t lastDay = m_account.premiumLastDay;
const uint32_t remainingDays = m_account.premiumRemainingDays;

time_t currentTime = getTimeNow();
const time_t currentTime = getTimeNow();

auto daysLeft = static_cast<int32_t>((lastDay - currentTime) / 86400);
auto timeLeft = static_cast<int32_t>((lastDay - currentTime) % 86400);
const auto daysLeft = static_cast<int32_t>((lastDay - currentTime) / 86400);
const auto timeLeft = static_cast<int32_t>((lastDay - currentTime) % 86400);

m_account.premiumRemainingDays = daysLeft > 0 ? daysLeft : 0;

Expand Down Expand Up @@ -280,7 +278,7 @@ bool Account::authenticateSession() {
}

bool Account::authenticatePassword(const std::string &password) {
if (Argon2 {}.argon(password.c_str(), getPassword())) {
if (Argon2().argon(password, getPassword())) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/account/account.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Account {
*
* @return AccountErrors_t AccountErrors_t::Ok(0) Success, otherwise Fail.
*/
uint8_t save();
uint8_t save() const;

/**
* @brief Load Account Information.
Expand Down
3 changes: 0 additions & 3 deletions src/account/account_repository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "account/account_repository.hpp"

#include "lib/di/container.hpp"

AccountRepository &AccountRepository::getInstance() {
Expand Down
2 changes: 1 addition & 1 deletion src/account/account_repository.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AccountRepository {
virtual bool loadBySession(const std::string &email, AccountInfo &acc) = 0;
virtual bool save(const AccountInfo &accInfo) = 0;

virtual bool getCharacterByAccountIdAndName(const uint32_t &id, const std::string &name) = 0;
virtual bool getCharacterByNameAndAccountId(const uint32_t &id, const std::string &name) = 0;

virtual bool getPassword(const uint32_t &id, std::string &password) = 0;

Expand Down
Loading

0 comments on commit 5159526

Please sign in to comment.