Skip to content

perf: improve dispatcher walk event#2933

Merged
dudantas merged 17 commits intomainfrom
add_event_walk
Oct 22, 2024
Merged

perf: improve dispatcher walk event#2933
dudantas merged 17 commits intomainfrom
add_event_walk

Conversation

@mehah
Copy link
Copy Markdown
Contributor

@mehah mehah commented Oct 2, 2024

The walking events are now separated from the other events, that is, all the walkEvents are executed, then the asynchronous events related to the walk, such as pathfinder, update target and update friend list and then the remaining events such as combat, etc...

@dudantas dudantas changed the title improve: Dispatcher Walk Event perf: improve dispatcher walk event Oct 21, 2024
@sonarqubecloud
Copy link
Copy Markdown

@dudantas dudantas merged commit 6f9754f into main Oct 22, 2024
@dudantas dudantas deleted the add_event_walk branch October 22, 2024 12:13
vllsystems pushed a commit to vllsystems/canary that referenced this pull request Oct 24, 2024
The walking events are now separated from the other events, that is, all
the walkEvents are executed, then the asynchronous events related to the
walk, such as pathfinder, update target and update friend list and then
the remaining events such as combat, etc.
Bennet92 added a commit to Bennet92/materia_v2 that referenced this pull request Oct 26, 2024
commit 89b3073
Author: murilo09 <[email protected]>
Date:   Sat Oct 26 08:22:33 2024 -0300

    fix: update forge prices according to latest fusion rates (opentibiabr#3017)

    New prices: https://tibia.fandom.com/wiki/Equipment_Upgrade#Fusion)

commit 8479c65
Author: Eduardo Dantas <[email protected]>
Date:   Sat Oct 26 08:18:07 2024 -0300

    fix: circular inclusion on tools.hpp/remove const ref from string view (opentibiabr#3019)

    This commit addresses two issues:

    Circular Inclusion in tools.hpp:
    • Resolved a circular inclusion problem in tools.hpp, which was causing compilation issues in certain contexts due to repeated and conflicting header dependencies. The inclusion logic has been adjusted to prevent this, improving the overall stability of the build process.

    Removed const& from std::string_view:
    • Removed the unnecessary const& from std::string_view parameters. Since std::string_view is a lightweight, non-owning reference type, passing it by reference doesn’t provide any performance benefit, and can instead introduce potential inefficiencies. This change improves both readability and performance.

    These fixes contribute to a cleaner, more maintainable codebase and improve the compilation reliability.

commit 65ab552
Author: Beats <[email protected]>
Date:   Fri Oct 25 01:32:31 2024 -0300

    perf: optimized logging with profiling and efficient file management (#7777) (opentibiabr#2832)

    This improves the performance of the logging system and adds
    profiling functionality with automatic log generation. Additionally,
    optimizations have been performed to ensure that logs are written
    efficiently to text files.

    ---------
    Co-authored-by: Eduardo Dantas <[email protected]>

commit 469e09a
Author: Pedro Cruz <[email protected]>
Date:   Fri Oct 25 00:35:48 2024 -0300

    fix: forge cores consumption (opentibiabr#3001)

    Fixes the exalted core consumption between normal and convergence
    transfers.

commit 7684026
Author: Eduardo Dantas <[email protected]>
Date:   Tue Oct 22 10:36:42 2024 -0300

    perf: EventCallback optimization (opentibiabr#3004)

    This PR refactors how event callbacks are stored and retrieved.
    Specifically, the internal structure for managing callbacks was changed
    from `std::vector` to a more efficient `phmap::flat_hash_map`. This
    change avoids the need to recreate a vector every time event callbacks
    are accessed, improving performance and reducing memory overhead.

    Additionally, the following issues were addressed:

    Duplicate log messages: A duplicate log was being created in luaEventCallbackCreate. This has been removed, as the message was already sent earlier in the process.
    ---------

    Co-authored-by: Renato Machado <[email protected]>

commit 6f9754f
Author: Renato Machado <[email protected]>
Date:   Tue Oct 22 09:13:05 2024 -0300

    perf: improve dispatcher walk event (opentibiabr#2933)

    The walking events are now separated from the other events, that is, all
    the walkEvents are executed, then the asynchronous events related to the
    walk, such as pathfinder, update target and update friend list and then
    the remaining events such as combat, etc.

commit 3f107dc
Author: aokisama <[email protected]>
Date:   Mon Oct 21 19:37:55 2024 -0500

    fix: container check changes so we can still sell all loot from pouch (opentibiabr#2971)

    Able to sell all loot in pouch

commit c5b2804
Author: Eduardo Dantas <[email protected]>
Date:   Sun Oct 20 20:33:22 2024 -0300

    improve: change from memset/memcpy to modern cpp ranges (opentibiabr#2989)

    This refactors several parts of the codebase to modernize
    it by replacing C-style memory operations (`memset`, `memcpy`) with
    safer and more expressive C++ standard library features such as
    `std::fill`, `std::copy`, and `std::ranges::copy`. These changes improve
    code readability, maintainability, and safety by leveraging C++ best
    practices.

    Specifically, the following areas were improved:
    • Replaced `memcpy` with `std::ranges::copy` to handle buffer copying
    more safely.
    • Replaced `memset` with `std::fill` to initialize memory with zeros in
    a type-safe manner.
    • Replaced C-style array manipulations with `std::array` and modern C++
    iterators to avoid unsafe pointer arithmetic.

commit 1af76e2
Author: Marco <[email protected]>
Date:   Thu Oct 17 22:06:04 2024 -0300

    refactor: optimize time formatting function for better performance (opentibiabr#2904)

    Refactors the getTimeInWords function to improve performance and
    code readability. The new implementation adopts a more efficient
    approach for calculating and formatting time in days, hours, minutes,
    and seconds, reducing redundancy and simplifying the logical flow.

    • Optimized the function for better execution speed.
    • Simplified the conditions and formatting structure.
    • Maintained the same functionality with clearer and more efficient
    code.

commit 2735b8c
Author: Marco <[email protected]>
Date:   Thu Oct 17 22:03:29 2024 -0300

    refactor: improve readability and optimize toPosition function (opentibiabr#2928)

    Refactors the string.toPosition function to improve
    readability and optimize the code. The main changes include:

    • Renaming variables to more descriptive names.
    • Optimized pattern matching by reusing patterns.
    • Returning nil when no pattern is matched, improving error handling.

    These changes make the code clearer and more efficient without altering
    its functionality.

commit 665e90c
Author: Eduardo Dantas <[email protected]>
Date:   Thu Oct 17 21:56:41 2024 -0300

    improve: change filestream/fileloader to std::ranges::copy (opentibiabr#2984)

    Revert accidental prey loading change from: opentibiabr#2980

    Refactored FileStream and FileLoader to utilize `std::ranges::copy` and
    other modern C++ features, replacing `memcpy` and `reinterpret_cast` for
    better readability and maintainability.

commit f05fb5d
Author: Eduardo Dantas <[email protected]>
Date:   Thu Oct 17 16:49:19 2024 -0300

    improve: some fixes and adjustments (opentibiabr#2980)

    Fixes:
    • In the solution build
    • In the debug build
    • Check for race id 0 in prey and taskhunting
    • Fixes in pop_front of some queues
    • Fix in Argon2::parseBitShift for debug build
    • Fix in NetworkMessage functions for debug build

    • Added try/catch in IOLoginData::savePlayer to avoid unhandled
    exceptions
    • New caseInsensitiveCompare function for use in some ongoing pull
    requests

commit e70c8c5
Author: Marco <[email protected]>
Date:   Thu Oct 17 16:47:45 2024 -0300

    refactor: modularize look event callback and improve code readability (opentibiabr#2858)

    This commit refactors the code related to the onLook event by
    modularizing the logic into separate functions for handling item and
    creature descriptions. Additionally, admin-specific details have been
    moved to a dedicated function. These changes improve readability, reduce
    code repetition, and make future maintenance easier.
    Resolves opentibiabr#2856

commit 68e9c3b
Author: Leonardo <[email protected]>
Date:   Wed Oct 16 18:43:06 2024 -0300

    fix: bug when player dies with skillLost false (opentibiabr#2979)

    Changed the location of the function to execute in all scenarios.

commit 0c7aafe
Author: Eduardo Dantas <[email protected]>
Date:   Tue Oct 15 18:43:58 2024 -0300

    perf: optimized account players badge loading (opentibiabr#2977)

    This change optimizes the player information retrieval process by
    selecting only the pertinent details of each character instead of
    loading all player objects for an account. This prevents unnecessary
    memory allocation and reduces server load, especially in scenarios where
    accounts have multiple characters.

commit 74bd126
Author: pudimtibia <[email protected]>
Date:   Tue Oct 15 18:41:53 2024 -0300

    fix: disable ssl/tls verification for newer version of mysql (opentibiabr#2978)

    The directive included in the connection options ignores the SSL check.

commit 92c07cf
Author: Karin <[email protected]>
Date:   Mon Oct 14 10:41:44 2024 -0300

    fix: code error when adding text attribute (opentibiabr#2975)

    Fix code error when adding text attribute

commit 72917d4
Author: LeoTK <[email protected]>
Date:   Mon Oct 14 10:40:56 2024 -0300

    fix: onLook nil value (opentibiabr#2856)

    Showing nil on look monsters and npcs.

commit 3d483fc
Author: Leilani A. <[email protected]>
Date:   Mon Oct 14 10:38:27 2024 -0300

    perf: optimize spawn cleanup removing redundant iteration (opentibiabr#2913)

    This improves efficiency by avoiding an intermediate list for removal,
    saving time and memory. The map is traversed only once, with iterators
    updated after each removal, making the process more efficient.
    Additionally, it eliminates redundant lookups by directly modifying the
    map during iteration.

commit 90eff79
Author: Karin <[email protected]>
Date:   Mon Oct 14 10:36:51 2024 -0300

    fix: prevent sell items with duration to the npc (opentibiabr#2898)

    This fix prevents players from selling items with used duration in NPC trades.

commit a60f27f
Author: pudimtibia <[email protected]>
Date:   Mon Oct 14 10:30:05 2024 -0300

    fix: remove poff effect when killing monsters (opentibiabr#2942)

    Remove POFF when killing a creature, I'm not sure why it was included but it differs from global tibia.

commit 2682065
Author: Felipe Paluco <[email protected]>
Date:   Mon Oct 14 10:29:26 2024 -0300

    fix: npc zoltan giving free ferumbras hat (opentibiabr#2945)

    Change the NPC Zoltan to prevent exploits and having Ferumbras Hat for free.

commit 2591213
Author: Felipe Paluco <[email protected]>
Date:   Mon Oct 14 10:28:49 2024 -0300

    fix: wrong positions on scourge of oblivion boss lever (opentibiabr#2970)

    Not all users are being teleported to the Scourge of Oblivion Boss Room.
    The current positions is +1 SQM to the right

commit ff26833
Author: Beats <[email protected]>
Date:   Sun Oct 13 00:54:20 2024 -0300

    update: gha build (opentibiabr#2641)

commit c4786c4
Author: Beats <[email protected]>
Date:   Sat Oct 12 19:29:22 2024 -0300

    perf: build cmake (opentibiabr#2972)

commit 34baa0a
Author: Leilani A. <[email protected]>
Date:   Fri Oct 11 11:02:33 2024 -0300

    fix: player wheel string conversion (opentibiabr#2967)

    Now checks to ensure that strings are numeric before converting them to
    numbers with std::stoull. If the strings are not numeric, it falls back
    to a lexicographical comparison, preventing crashes caused by invalid
    conversions.

    Resolves opentibiabr#2966

commit 35550d1
Author: Eduardo Dantas <[email protected]>
Date:   Fri Oct 11 11:01:51 2024 -0300

    fix: eventcallback from std::forward to args (opentibiabr#2962)

    Using std::forward inside a loop can cause rvalue arguments to be moved
    and invalidated after the first iteration. This happens because
    std::forward preserves the value category, allowing rvalues to be moved.
    To ensure arguments remain valid across all iterations when invoking
    callbacks, avoid using std::forward inside the loop and pass arguments
    directly as args....

    Resolves opentibiabr#2959

commit e71a259
Author: Leonardo <[email protected]>
Date:   Fri Oct 11 10:44:02 2024 -0300

    fix: handle nil value for soul war to prevent errors with custom data (opentibiabr#2964)

commit 3cd4031
Author: Marco <[email protected]>
Date:   Thu Oct 10 14:30:51 2024 -0300

    fix: resolve nil method error in battlemart.lua callback (opentibiabr#2961)

    Replaced the method npc:getFormattedCategoryNames(itemsTable) with
    the function GetFormattedShopCategoryNames(SupplyShopConfigTable),
    which correctly formats the shop category names.

    This fixes the error and allows the NPC to properly display the
    selection of item categories.

commit ad56722
Author: Eduardo Dantas <[email protected]>
Date:   Wed Oct 9 23:22:15 2024 -0300

    fix: npc submenu shop window (opentibiabr#2852)

    • Fixed to open submenus even after having a shop window open
    • Fixed so that when saying "trade" it informs the other available
    categories

commit 5b55f96
Author: Eduardo Dantas <[email protected]>
Date:   Wed Oct 9 18:34:59 2024 -0300

    fix: crash when removing items during iteration with ContainerIterator (opentibiabr#2901)

    The enhancements to the ContainerIterator address critical issues
    related to deeply nested and cyclic container structures. By
    implementing cycle detection, traversal depth limitation, the iterator
    becomes a more reliable and efficient tool for managing complex
    container hierarchies. These improvements are essential for maintaining
    the system's performance and stability as it scales and evolves.

    OBS: Added a talkaction that will make it easier to test (both counting
    items/subcontainers, which will call the getItems function, which
    internally calls the ContainerIterator). This will make it easier to
    know if the modification was done correctly.

commit 95dbe28
Author: Eduardo Dantas <[email protected]>
Date:   Wed Oct 9 18:15:14 2024 -0300

    improve: remove qodana and fix eventcallback error (opentibiabr#2958)

commit aff5014
Author: Eduardo Dantas <[email protected]>
Date:   Wed Oct 9 17:47:56 2024 -0300

    ci/cd: remove qodana (opentibiabr#2957)

commit c229548
Author: Eduardo Dantas <[email protected]>
Date:   Wed Oct 9 17:42:13 2024 -0300

    fix: eventcallback crash (pointer uninitialized) (opentibiabr#2956)

commit 90e205d
Author: Eduardo Dantas <[email protected]>
Date:   Wed Oct 9 17:01:49 2024 -0300

    improve: config manager context from string to source location (opentibiabr#2955)

    Change from std::string hardcoded to std::source_location from
    ConfigManager functions (getNumber, getString, getBoolean, getFloat)

    In addition to displaying the exact line from the log, this approach is
    also more concise as it eliminates the need to pass a second argument.

commit adbe715
Author: Eduardo Dantas <[email protected]>
Date:   Wed Oct 9 16:18:53 2024 -0300

    fix: overload when setting item decay when player logs in (opentibiabr#2927)

    This change optimizes the decay initiation process for items within
    containers. Previously, `Container::startDecaying()` method would
    recursively start the decay for each item in a container upon the
    container's own decay initiation. This could lead to inefficiencies,
    especially with many nested containers. The updated
    approach collects all decaying items in a vector first and then
    initiates decay after all have been added, improving performance by
    reducing overhead and simplifying the management of decay states.

    In the stop decay process, instead of iterating through all containers, we will now halt the decay immediately after each item is saved. This approach leverages an existing function, eliminating the need for an additional overlay and enhancing efficiency.

commit 1fcb348
Author: Eduardo Dantas <[email protected]>
Date:   Wed Oct 9 15:52:53 2024 -0300

    fix: sonarcloud check (opentibiabr#2954)

commit 01e9a81
Author: Eduardo Dantas <[email protected]>
Date:   Wed Oct 9 14:59:32 2024 -0300

    fix: sonarcloud (opentibiabr#2953)

commit da92674
Author: Leonardo <[email protected]>
Date:   Wed Oct 9 14:33:31 2024 -0300

    fix: change mana shield limit (wrong uint16 to uint32) (opentibiabr#2952)

commit 6fbf533
Author: Eduardo Dantas <[email protected]>
Date:   Wed Oct 9 13:33:20 2024 -0300

    fix: login crash and memory corruption (opentibiabr#2951)

    Fixed memory corruption using debug build in ~Container
    Fixed memory corruption using debug build in Argon2::parseBitShift
    Fixed crash on login

    Resolves opentibiabr#2947

commit 80e19d3
Author: Eduardo Dantas <[email protected]>
Date:   Sat Oct 5 10:41:24 2024 -0300

    fix: debug build from solution and improve NetworkMessage::add function (opentibiabr#2926)

    This fixes the issue in the debug build for solution (pch was configured
    incorrectly)
    It also fixes a crash that occurred in the debug build with asan.

commit f2f52cc
Author: Eduardo Dantas <[email protected]>
Date:   Thu Oct 3 15:30:46 2024 -0300

    fix: remove loading of basic info only (opentibiabr#2937)

    Some database tables are completely deleted to add the "new" one, which
    replaces the existing data with empty data. In the future I will make an
    improvement to remove the DELETE FROM and come back with the feature.

commit d94e23a
Author: roberto furtado <[email protected]>
Date:   Wed Oct 2 20:13:23 2024 -0300

    fix: stamina green delay (opentibiabr#2884)

commit 1d921ae
Author: kokekanon <[email protected]>
Date:   Wed Oct 2 20:12:55 2024 -0300

    fix: colored text loot in OTC 13.40 (opentibiabr#2929)

commit b503adb
Author: HT Cesta <[email protected]>
Date:   Wed Oct 2 20:12:07 2024 -0300

    fix: quests from version 10 revised (opentibiabr#2855)

commit e938b75
Author: Eduardo Dantas <[email protected]>
Date:   Sun Sep 29 14:57:41 2024 -0300

    fix: circular inclusion related to network/protocol/connection (opentibiabr#2924)

    Bug Fixes and Improvements

    • Fixed a minor bug in the unit test.
    • Improved the tests build and run scripts.
    • Removed all redundant pch.hpp includes from the .cpp files as the
    directive ```target_precompile_headers(${PROJECT_NAME}_lib PUBLIC
    pch.hpp)``` now handles that automatically.
    • Added the precompiled file correctly in the visual studio solution
    • Resolved several circular dependencies involving the following
    components:
    - Connection
    - KV
    - Protocol

commit 899c1eb
Author: Eduardo Dantas <[email protected]>
Date:   Sun Sep 29 13:32:05 2024 -0300

    fix: player lose items with wrong loading offline informations (opentibiabr#2919)

    When the player is offline, in some scenarios the empty items would load
    and the items would be overlapped with the empty table of the offline
    player.

    Resolves opentibiabr#2917

    Related to: opentibiabr#2910

commit 04fa248
Author: Eduardo Dantas <[email protected]>
Date:   Sat Sep 28 22:45:51 2024 -0300

    refactor: replace C-style array with std::array for buffer management (opentibiabr#2914)

    Refactored buffer management by replacing C-style arrays with std::array<uint8_t, NETWORKMESSAGE_MAXSIZE> in the NetworkMessage and OutputMessage classes. This change enhances memory safety by providing compile-time size checks and prevents buffer overflows through safer access methods. Transitioned all instances of memcpy to std::ranges::copy and replaced memset with std::fill for improved readability and type safety. Removed the use of reinterpret_cast for safer type conversions.

    Introduced enhanced logging using std::source_location and added an optional function parameter to the addString and getString functions, providing better contextual information for both C++ and Lua scripts. Fixed a bug in the decodeHeader function and added corresponding unit tests to validate the fix.

    This update addresses potential buffer overflow issues, improves code clarity, and enhances debugging capabilities. It also includes integration tests to ensure the correct behavior of buffer management under various conditions, such as large message handling and stress testing. The changes aim to modernize the codebase, reduce manual memory management risks, and align the implementation with modern C++ best practices.

commit 09c16ff
Author: Eduardo Dantas <[email protected]>
Date:   Fri Sep 27 23:47:15 2024 -0300

    fix: can't sell containers with items inside (opentibiabr#2911)

    It will not be possible to sell backpacks that contain items inside.

commit edeff04
Author: Eduardo Dantas <[email protected]>
Date:   Fri Sep 27 23:46:00 2024 -0300

    fix: convergence wrong price calculation (opentibiabr#2918)

    Resolves opentibiabr#2523

commit 11bd3a6
Author: Eduardo Dantas <[email protected]>
Date:   Tue Sep 24 21:37:48 2024 -0300

    fix: forge correct slots (opentibiabr#2850)

    Resolves opentibiabr#2718

commit 4bc7a5c
Author: Eduardo Dantas <[email protected]>
Date:   Tue Sep 24 18:03:05 2024 -0300

    fix: CPU overload when loading many nested containers (opentibiabr#2909)

    This addresses an issue where excessive CPU load occurs when dealing
    with deeply nested containers due to repeated calls to the `isRemoved`
    function in the `canDecay` method. To mitigate this, the order of checks
    in `canDecay` has been changed to evaluate the decay conditions first,
    and only check for removal status (`isRemoved`) as the last step.

commit 15180dc
Author: Eduardo Dantas <[email protected]>
Date:   Tue Sep 24 17:51:36 2024 -0300

    fix: disable irrelevant informations (opentibiabr#2910)

    The "PlayerBadge" was loading a lot of unnecessary information for all
    players on the account. I moved the if statement up, ensuring that only
    the preload and level are properly loaded, which are actually relevant
    information.

    If more information is identified that should be loaded in the preload,
    we should move it to the loadPlayerFirst function.

commit a444901
Author: Luan Luciano <[email protected]>
Date:   Tue Sep 24 17:48:34 2024 -0300

    fix: task context is being sent empty (opentibiabr#2871)

    Solve the problem where the message "[Task::Task] is sent: the task
    context cannot be empty!" because 'DispatcherContext::addEvent' and
    'DispatcherContext::tryAddEvent' methods are not receiving the "context"
    parameter.

commit a399c26
Author: Luan Luciano <[email protected]>
Date:   Tue Sep 24 17:34:26 2024 -0300

    feat: transferring money bank from main/main and rookgaard/rookgaard (opentibiabr#2878)

    Rookguard town is `town id` 3, so `minTownIdToBankTransfer` defaults to 4

    Resolves opentibiabr#2778

commit f0830c3
Author: Marco <[email protected]>
Date:   Tue Sep 24 17:32:22 2024 -0300

    refactor: removeMoneyBank (opentibiabr#2887)

    Improved the `Player.removeMoneyBank` function to make it more
    efficient. It now uses intermediate variables to avoid repeated calls
    and simplifies the construction of the message. The logic and messages
    have been kept as they were.

commit a289602
Author: Marco <[email protected]>
Date:   Tue Sep 24 17:31:04 2024 -0300

    fix: remove non-existent 'pet' flag from monsters (opentibiabr#2890)

    Removed the non-existent 'pet' flag from monsters to avoid unnecessary
    errors and improve data consistency. No other changes were made to the
    monster configurations.

commit 10823e3
Author: Eduardo Dantas <[email protected]>
Date:   Tue Sep 24 01:05:21 2024 -0300

    fix: nil value on soul war quest and log to debug (opentibiabr#2906)

    Resolves opentibiabr#2897

commit ae39682
Author: Karin <[email protected]>
Date:   Thu Sep 19 02:01:25 2024 -0300

    fix: crash in use with creature (add nullptr check) (opentibiabr#2899)

commit 563b0f7
Author: Eduardo Dantas <[email protected]>
Date:   Wed Sep 18 22:51:17 2024 -0300

    fix: qodana linter (opentibiabr#2902)

commit b3b19a6
Author: Pedro Cruz <[email protected]>
Date:   Sat Sep 14 17:58:40 2024 -0300

    fix: login into another accounts (opentibiabr#2853)

    Fixes the login to other account when injecting a custom login.php

commit e4f0cdb
Author: Luan Luciano <[email protected]>
Date:   Sat Sep 14 15:59:58 2024 -0300

    fix: field doesn`t display the condition (opentibiabr#2882)

commit 687aba5
Author: Eduardo Dantas <[email protected]>
Date:   Thu Sep 12 23:40:07 2024 -0300

    fix: float precision in config retrieval (opentibiabr#2889)

    Description:
    This addresses the issue where floating point values
    retrieved from the configuration were not being rounded properly,
    leading to slight inaccuracies. This fix ensures that all float values
    are correctly rounded to two decimal places before being passed to Lua,
    thereby ensuring consistent behavior and data accuracy.

    Expected behavior:
    With the implemented changes, when floating point values are retrieved,
    they will now be rounded to two decimal places. For example, a
    configured value of `1.15` will correctly be returned as `1.15` in Lua
    scripts.

commit 5bcbc39
Author: Eduardo Dantas <[email protected]>
Date:   Wed Sep 11 19:32:24 2024 -0300

    feat: full soul war quest (opentibiabr#2535)

    Remember that for this quest to work properly, it is necessary to delete
    the old Soul War scripts (the repository had the quest divided into
    parts, and I completely redid it using modern features and systems, such
    as BossLever, Zones, EventCallback, and others).

    It is also necessary to update the soul war map, the new map is in the
    releases

    I won’t document all the changes here for obvious reasons; the quest is
    mostly written in Lua, so there are many monster scripts and other
    elements that were added or modified, making this a large pull request
    as a result. I thought about separating the pull request into smaller
    commits, but I came to the conclusion that this could cause confusion,
    since the quest would depend on several other commits to work correctly,
    so I decided to keep everything in one to avoid future "problems".

    Added talkactions:
    /distanceeffect (for testing distance effects)
    /testtaintconditions (for testing taint icons on player inventory bar)

    • The "Missing configuration for identifier" log has set to debug, since
    in cpp there are default values ​​already to avoid putting all the
    values ​​in lua
    • Fixed some EventCallbacks that were not properly passing arguments as
    references (using std::ref)
    • Added a check for EventCallbacks with the same names, improving the
    resource management of callbacks. Each time a callback was called, a new
    element was created in the vector. Now there will only be one and it
    will be reused with each execution
    • Passed some vectors from CreatureVector for copying, thus avoiding
    possible crashes when changing the vectors, it was necessary due to the
    change of maps in ebb and flow in real time (so the player can be in the
    creature vector during the vector reading and be removed)
    • Added new callback for MonsterType (lua scripts) called "onSpawn",
    which will execute whenever the creature is created
    • Added new callback for MonsterType (lua scripts) called
    "onPlayerAttack", which will be executed whenever a player attacks the
    monster, it should be used with care as the same callback will be valid
    for all instances of the same monster
    • Added new EventCallback called "playerOnThink", thus facilitating
    players' onThink
    • Added new EventCallbacks called "creatureOnCombat" and "mapOnLoad", to
    facilitate the development of the quest
    • Added a new function argument on the CreatureEvent
    "executeOnPrepareDeath" called "realDamage"
    • The Lua function "monster:setType" now includes a new argument called
    "restoreHealth" (boolean). This argument determines whether the function
    will restore the monster's health after setting its type.
    • The Lua function "player:addOutfit" now accept the "outfit name" and
    includes new argument called "addon" for setting the outfit's addon
    • New Lua function "player:sendCreatureAppear" to update the creature's
    appearance to the client (necessary for changing the ebb and flow maps,
    same reason I mentioned above, the player is on the map during the
    change, so it is necessary to send the update to the client)
    • Removed the exception for the message: "The map in folder 'x' is
    missing or corrupted", this prevents the console from stopping loading
    and closing the server, as in the case of a misconfigured worldchange.

    Co-authored-by: Pedro Henrique Alves Cruz <[email protected]>

commit a9e4875
Author: Paulo Henrique Lisboa <[email protected]>
Date:   Wed Sep 11 11:10:25 2024 -0300

    fix: wild growth (opentibiabr#2885)

commit b330a33
Author: Karin <[email protected]>
Date:   Mon Sep 9 14:22:52 2024 -0300

    fix: fix load unique items from map (opentibiabr#2881)

    This fix the load of unique items.
    Enable purchasing backpacks when the player doesn't have a main backpack

commit dec6ad0
Author: André Morais <[email protected]>
Date:   Fri Sep 6 10:35:31 2024 -0300

    fix: container:addItem missing return (opentibiabr#2857)

commit d4b1b61
Author: Eduardo Dantas <[email protected]>
Date:   Thu Sep 5 21:16:38 2024 -0300

    fix: remove bakragore icons talkaction (opentibiabr#2828)

commit 8056ca6
Author: Majesty <[email protected]>
Date:   Thu Aug 29 19:45:55 2024 -0300

    fix: datapacks tools actions (opentibiabr#2851)

commit a154773
Author: Majesty <[email protected]>
Date:   Thu Aug 29 09:00:26 2024 -0300

    fix: data-canary errors and warnings (opentibiabr#2844)

commit 0d924e8
Author: Majesty <[email protected]>
Date:   Thu Aug 29 08:59:22 2024 -0300

    feat: Nimmersatt's monsters (opentibiabr#2831)

    Add Nimmersatt's monsters:
    - Dragolisk,
    - Wardragon,
    - Mega Dragon.
    - Step in Teleport.

    Co-authored-by: hecmo94 <[email protected]>

commit 0f8929d
Author: Majesty <[email protected]>
Date:   Thu Aug 29 08:55:41 2024 -0300

    fix: price mismatch between NPCs and typo in the rent house message (opentibiabr#2830)

    Monitoring feature to alert whenever there's a price mismatch between NPCs for item transactions.
    This ensures any instance where an item is sold for less than its purchase price, or vice versa, is promptly identified and reported.

    Co-authored-by: Leilani A. <[email protected]>
dudantas added a commit that referenced this pull request Nov 9, 2024
un000000 added a commit to vaigu-com/otserver that referenced this pull request Apr 23, 2025
* fix: crash when spawn cleanup (opentibiabr#3034)

Crash fix introduced in opentibiabr#2913 

This crash occurs when the iterator attempts to access a container that
was modified during the creature removal process, while
spawnedMonsterMap and/or erase_if is being executed.

* feat: new augments and update item description (amber items) (opentibiabr#2900)

This updates the augments to be able to handle the substitution of
the Increase Damage, Strong Impact and Powerful Impact into Base Damage
and Base Healing. It also adds the new item description to handle the
new Amber Items with elemental attack greater than 0 and physical attack
value equal 0.

* improve: AreaSpawnEvent::executeEvent remove unused variable (opentibiabr#3036)

Removed unused variable and added pointer to const ref.

* improve: account enums direcly instead of raw types (opentibiabr#3038)

Added a function to Database::getNumber to call enums directly, making maintainability easier.

* docs: add CONTRIBUTING.md Guidelines for Canary Project (opentibiabr#3041)

This PR introduces a comprehensive CONTRIBUTING.md file to guide new and
existing contributors to the Canary project. The document includes
sections covering our Code of Conduct, development standards, issue and
pull request guidelines, and usage of the KV System for data
persistence. It also sets expectations for code formatting, quality, and
contribution best practices, helping ensure that contributions align
with project standards and goals.

* fix: browseField crash, improve readability, fix shadowing (opentibiabr#3031)

This refactors the `Container::create` function and rename to
`createBrowseField` for improved readability and maintainability. The
refactor includes using `continue` to skip iterations early when items
do not meet specific conditions, reducing nesting and making the code
clearer. Additionally, it resolves a critical issue where two different
`container` variables were confused within the same loop, which could
lead to bugs.

These changes ensure the function is cleaner and less prone to errors,
making the logic behind item addition more transparent.

* feat: add mystery box item action (opentibiabr#3040)

When using mystery box after getting from the NPC (which is only
possible after defeating final boss of cults of tibia), not is happening.

* fix: some conflict errors (opentibiabr#3048)

Fixed some issues caused by git conflicts.

* improve: load player town and fix player badge escape string (opentibiabr#3055)

Simplified the town assignment logic when loading player data:
- If the town ID associated with the player is invalid, the system will
first attempt to assign the town "Thais". If "Thais" is unavailable, the
player is assigned the first valid town from the list.
- This change reduces the chain of conditional checks, making the logic
more readable and efficient, while ensuring a player is assigned to a
valid town whenever possible.

Fix for Escaping Strings in PlayerBadge:
- Added proper string escaping using `g_database().escapeString()` in
`PlayerBadge::getPlayersInfoByAccount()` to prevent SQL syntax errors
when player names contain special characters.
- This fix addresses issues with malformed queries that previously
resulted in SQL syntax errors.

* fix: prevent crash in condition light division (opentibiabr#3053)

Fix opentibiabr#3047 

Now min light level is always 1, prevent division by zero.

* fix: remove mystery box duplicated action (opentibiabr#3057)

* improve: optimize experience gain and loss calculations (opentibiabr#2905)

Optimized the experience gain and loss calculations in the
`onGainExperience` and `onLoseExperience` functions, adjusting the
application of bonuses like stamina, VIP, and boosted creatures. This
ensures more efficient performance and more accurate handling of player
experience management.

* fix: character cyclopedia item inspection imbuements (opentibiabr#3065)

This fixes the icons from the character item imbuements inspection cyclopedia.

* style: tryAddEvent to safeCall (opentibiabr#3045)

safeCall basically keeps calls safe when they are being executed
asynchronously, that is, if the calls inside safeCall are being executed
in a thread other than the dispatcher, they will simply be sent to that
thread, thus avoiding concurrency.

What I just wrote is already being done with tryAddEvent, but it is not
a very intuitive name, and it is visually polluted. In the safeCall
method, besides being short, you can simply send 'this' as a parameter
to the lambda, without having to fear that its execution will be done
when the reference no longer exists, because inside safeCall, there is a
reference check, if it has already been destroyed, it will simply not be
executed.

* improve: safecall (opentibiabr#3072)

Added check if creature was removed.

* improve: prevent crash in checkCreatures (opentibiabr#3073)

Apparently the creature can be destroyed while it is running in
checkCreatures, so let's increase the counter to ensure it still exists.

Note: It's had a rare crash while doing some testing.

* perf: remove unnecessary event callbacks (opentibiabr#3076)

Removed Lua callbacks from `MonsterType` of various monsters. These
callbacks were empty, which meant the functions were still being
"called" by the monsters without performing any action, creating a
significant performance bottleneck.

Removed the `onHear` event callback, which had a significant impact on
the server and was not used anywhere. It executed the `onHear` callback
for each spectator, causing an unnecessary overload without any real
benefit, especially as we have other methods to check for these events.

Additionally, the `monsterOnSpawn` event callback was removed and
replaced with `MonsterType::onSpawn`, which is much more efficient since
it only needs to be declared in the script for each monster that
actually uses it.

Finally, the way `setRewardBoss` was handled was improved. Previously,
it was executed in an `onSpawn` event callback, but now it is done
directly during the parsing of each monster script, marking them as
reward bosses at the time of script loading, improving efficiency.

* improve: add check to boosted boss name empty (opentibiabr#3081)

Checks if the boosted boss name is empty

* improve: lower boss name on boss lever system (opentibiabr#3070)

This ensures the integrity of the name during searches. If a name is
added with a different capitalization than the monster's actual name, it
can lead to conflicts, preventing the onDeath code from executing
properly.

* fix: review quests version 11 (opentibiabr#3049)

Fixing the PR opentibiabr#2938 levers and related parts. Since the original code
was quite extensive, perhaps some mechanics that should have been done
when pulling the lever were removed.

* fix: object variable renamed (opentibiabr#3082)

fixed the cobras console error, the problem was being caused because of
the object name handleCobraOnSpawn

* fix: creature teleport with dispatcher walk event (opentibiabr#3066)

Resolves bug implemented after: opentibiabr#2933

* feat: add new "soul cores" market category (opentibiabr#3092)

New category from 13.40
Uses with: Arch-Mina/Assets-Editor#36

* improve: fix circular dependencies on iologindata.hpp (opentibiabr#3093)

* improve: fix circular dependencies on weapons.hpp (opentibiabr#3094)

* fix: speed and conditions (opentibiabr#3063)

This fixes the high speed bug that overflow the uint16_t because the
lack of checks and also fixes the conditions mysql issue when saving
conditions greater than 64KB.


Fixes opentibiabr#2712 
Fixes opentibiabr#2456

* fix: typo and missing lookfeet (opentibiabr#3054)

Missing lookFeet.
Default colours.
Fix typos.

* improve: spectators and map sector (opentibiabr#3062)

Improves the spectators to find monsters and npcs, adds excludeMaster
and excludePlayerMaster to filter monsters without masters. Added
vectors to cache the monsters and npcs in spectators and map sectors as
well.

* fix: house mailboxes (opentibiabr#3096)

Fixes the houses mailbox that were not sending parcels and consuming
them.

Fixes opentibiabr#2891

* cleanup: remove unnecessary inheritance from lua interface classes (opentibiabr#3046)

Fixed circular dependencies
Removed various unnecessary inheritance from lua interface
Removed legacy unused codes

* fix: remove empty if block and prevent use of pointer after erase (opentibiabr#3098)

This removes an empty `if` block that was originally used back when
pointer management was manual using raw pointers (*). At that time,
the 'if' block was intended to decrement the reference counter in a
manual garbage collection mechanism. Since the project now uses modern
smart pointers, this block has become obsolete and can be safely removed
without affecting functionality.

The change also prevents the use of the 'container' pointer after
erasing the iterator 'it' from the 'openContainers' map, which was
causing undefined behavior and potential crashes.

* improve: removed cache map dead code (opentibiabr#3086)

As per this PR: opentibiabr#2667

useCacheMap has been disabled, but the code is still there just for
decoration, so this PR will remove all that code.

* feat: add soul core items (opentibiabr#3099)

Add 660 Soulcore items, in preparation to further Soulpit Development.

* fix: freequests storages (opentibiabr#3044)

* fix: safe call add creatures on tile get/creation (opentibiabr#3090)

* fix: combat type out of index in ashes item (opentibiabr#3106)

Fixes opentibiabr#2874

* fix: remove bit_functions from vcxproj (opentibiabr#3108)

At some point, the bit_functions.cpp and bit_functions.h files were
removed from the project, but they continued to be referenced in the
Visual Studio .vcxproj file, causing an error when trying to compile
using it.

* fix: add source location to combatTypeToIndex (opentibiabr#3095)

* fix: wheel bonuses (opentibiabr#3058)

This fixes all vocations wheel spell and gem bonuses, const references
and refactors.

Fixes opentibiabr#3032 
Fixes opentibiabr#2150 
Fixes opentibiabr#2039

* fix: sending items to stash interrupted by items obtained from store (opentibiabr#2886)

• When send items from a container to the stash, the process is
interrupted when there are items obtained from the store.
• Fixed issue with sending items from the loot pouch to the stash

* fix: crash concurrent modification/casting in tile management (opentibiabr#3107)

This adds the implementation for dynamically determining the type of
tile (HouseTile, StaticTile, DynamicTile) when creating a new tile
object. The motivation is to correctly identify and assign specific tile
types, which enhances code readability and maintainability. The change
also ensures that houses have associated HouseTile objects for better
data integrity.

* refactor: move blessing bytes to cpp (opentibiabr#3064)

Moving bytes from modules to cpp.

* fix: teleport effect from "onUse" actions (opentibiabr#3109)

Fixed teleport effect from "onUse" actions and passed some pointers to const ref

* fix: transfer house crash (opentibiabr#3104)

This addresses an issue in the 'House::resetTransferItem function where
the 'transferItem' pointer was being set to 'nullptr' before being used
later in the function, leading to potential undefined behavior or
crashes. The solution involves reordering the operations to ensure that
'transferItem' is only set to 'nullptr' after all required operations
are completed. This change ensures that the object remains accessible
until all necessary manipulations are performed.

* improvement: enable custom duration and simplify expiration calculation (opentibiabr#3083)

Allows setting a custom ban duration and simplifies the expiration time
calculation.

* enhance and refactor: multiple scripts for better functionality (opentibiabr#3007)

1. Fixes a minor issue where, when emptying the balloons, they were
transformed into 255 instead of being reset to 1.
2. Adjusts the usage of the "bathtub" in datapacks, in addition to the
RLMap, ensuring better compatibility.
3. Makes minor aesthetic changes to enhance the code's readability.

Resolves opentibiabr#2923

* cleanup: simplify some account functions and fix console error (opentibiabr#3110)

Removes a duplicate function.
Fixed console error related to missing string.format.

* fix: disable ladder effect and add support for all ladders (opentibiabr#3114)

This PR updates the teleport action for ladders by disabling the effect
when using the ladder and modifying the logic to support all ladder IDs
dynamically.

1. The effect of moving up or down is now disabled when using the
ladder.
2. The script now automatically recognizes all ladder IDs, removing the
need for hardcoded values.

* fix: resolve nil index issue in destroy script callback (opentibiabr#3117)

Fixed an error in the item destruction script where calling
`ActionsLib.destroyItem` resulted in a `nil` reference. The function
call was adjusted to use `destroyItem` directly, ensuring the script
works correctly and avoids global index errors.

* fix: wheel spells bonuses (opentibiabr#3122)


This fixes the issue that some spells was sharing bonuses between all
other spells

* fix: blessings calculations (opentibiabr#3126)

Wrong blessing calculations

* fix: wands and rods chain damage (opentibiabr#3128)

This fixes the damage when chain system enabled for wands and rods.

Fixes opentibiabr#2472

* fix: ebb and flow boat summons teleport (opentibiabr#3125)


This fixes the ebb and flow boat teleport that was not teleporting
player summons

Fixes opentibiabr#2943

* fix: xp rates display (opentibiabr#3123)

This fixes the display xp rates with low level bonus and boost xp.

* fix: forge history (opentibiabr#3124)

This fixes the history forge that is crashing the server trying to
access an index of a empty vector.

Fixes opentibiabr#3121

* fix: sharpshooter not applying paralyze icon (opentibiabr#3119)

This commit aims to fix a problem that occurs when a player cast
sharpshooter.
The main behavior should be remove haste icon and apply paralyze,
counting on the speed decrease.

* perf: replace manual function name extraction with std::source_location (opentibiabr#3132)

Replaced the previous string concatenation approach for logging function
names with `std::source_location::current().function_name()`. This
change significantly improves performance by avoiding runtime string
operations. Instead of manually manipulating function signatures using
`methodName` to extract function names, `std::source_location` provides
this information directly in an efficient manner.

* feat: specific meal purchase option for hireling (opentibiabr#3105)

This update introduces a new feature for the hireling NPC, allowing
players to choose specific meals for 90,000 gold, aligning with the
latest global updates. The NPC now prompts players with options for a
"specific" or "surprise" meal, guiding them through the selection
process. If "specific" is chosen, players are presented with a list of
available dishes.

* fix: lua getNumber overflow with "MoveEvent::EquipItem" function (opentibiabr#3136)

Fixed overflow with "MoveEvent::EquipItem" and added imbuement shrine to canary temple

* fix: remove duplicate "update impact tracker" for elemental damage (opentibiabr#3137)

It's already send here:
https://github.com/opentibiabr/canary/blob/729387bc8b8a6171de32d936a6442cb285c9da42/src/game/game.cpp#L7375

* fix: quiver replacement logic and shield-weapon equip handling (opentibiabr#3138)

• Added logic to replace an existing quiver when equipping a new one,
ensuring proper unequip and feedback to the player.
• Refactored shield equip logic to properly handle scenarios where a
two-handed weapon is equipped in the left slot, preventing unnecessary
unequips.
• Improved equip flow to ensure consistent behavior for different weapon
and item types, avoiding conflicts between equipped items.

* fix: initialize totalCost correctly and refactor blessing purchase logic (opentibiabr#3142)

This fixes the initialization of the `totalCost` variable and
refactors the blessing purchase logic. Improvements include replacing
string concatenation with `string.format` for more efficient formatting,
as well as adjustments for better code clarity and readability. The code
is now more organized, and the calculation error has been fixed.

* fix: prevent teleportation (opentibiabr#3143)

This fixes an issue where the player was teleported even when a Lua
script was blocking the action.

* fix: item usage mechanics to obtain Phantasmal Jade (opentibiabr#3112)

This fixes the item usage mechanics for obtaining the
Phantasmal Jade mount.
It ensures that the correct number of items are used, and the mount is
granted when all requirements are met.
Additionally, it automates the registration of item IDs to simplify the
code and reduce redundancy.

Close opentibiabr#3100

* fix: boss lever check god access (opentibiabr#3141)

Check god access instead of normal, to ensure that tutors also count towards the cooldown

* fix: wrong loot items from bosses (opentibiabr#3148)

* fix: crash on try gem grade upgrade greater than 3 (opentibiabr#3151)

Fixes the crash when trying to upgrade gem to a grade greater than 3

* perf: optimize getInbox usage and shared pointer handling in loops (opentibiabr#3150)

This addresses performance issues by optimizing the use of shared
pointers and removing redundant calls. Specifically, the `getInbox` call
was removed from extensive loops to prevent unnecessary reference count
increments, which were causing CPU overhead. Additionally, shared
pointers used in recursive or iteration-heavy functions, such as the
`ContainerIterator`, were changed to `const&` where applicable, reducing
the impact of reference counting on performance.

* fix: console error related to wrong "monster" to "self" (opentibiabr#3166)

* fix: docker gha build workflow (opentibiabr#3167)

* fix: check creatures crash (opentibiabr#3168)

* perf: multithreading in updateTargetList in all events (opentibiabr#3074)

Previously, the multithreading of updateTargetList only worked for walk
events, now all requests to these methods will be executed async.

* refactor: split player death event handler into smaller functions (opentibiabr#3113)

This refactors the PlayerDeath event script to improve code
readability and maintainability. The original function has been split
into smaller, more focused functions, each handling a specific part of
the player death processing logic. This includes identifying the killer,
logging deaths in the database, sending messages to the guild channel,
and checking guild wars.

With this refactoring, the code is more modular and easier to
understand, making future modifications and maintenance more manageable.
The PlayerDeath event logic remains unchanged, ensuring the system
continues to function as expected.

Changes:
•. Split the onDeath function into smaller local functions.
•. Improved SQL query formatting using string.format for clarity and to
avoid repetitive code.
•. Renamed local variables to follow the camelCase convention.

* perf: onRemoveCreature->onCreatureLeave async (opentibiabr#3152)

the call to onCreatureLeave in Monster::onRemoveCreature will be called
asynchronously.

* fix: resolve nil value errors in handleGuildWar function (opentibiabr#3172)

I made corrections to the `death.lua` script to resolve nil value errors
in the `handleGuildWar` function. I added checks to ensure that both the
player and the killer are valid and that both belong to a guild before
proceeding with the guild war logic. This helps prevent failures when
one of the objects is undefined.

Fixes from: opentibiabr@3c98b41

* fix: packet interpretation parseSetOutfit for otcv8/old protocol (opentibiabr#3162)

Resolves opentibiabr#3155

* Compatibility with Basic CPUs (opentibiabr#3146)

Some servers or vps now come with modifications for basic cpu such as:
QEMU Virtual CPU version 2.5+, this function makes it possible to run
canary

* Improve: creature actions (opentibiabr#3084)

Some creature actions, such as checkCreatureAttack, checkCreatureWalk,
updateCreatureWalk, were processed based on the creature ID, as canary
works with smart pointer, we no longer have problems working with the
object reference, before it used the ID to maintain security, because at
the time of execution, the object could no longer exist.

* perf: onThink multithreading (opentibiabr#3075)

* improve: migration database update (opentibiabr#3071)

This improves the database migration process by removing the need to
manually define if more migrations are required with return values in
Lua scripts. The new approach automatically processes all migration
files based on their version, reducing complexity and making the update
process more robust. This change aims to streamline the database update
logic and eliminate manual steps previously required.

* fix: remove unsupported compiler flags for MSVC (opentibiabr#3173)

Resolves warnings issued during the Windows build
process with MSVC caused by unsupported compiler flags `(-march, -mtune,
-mno-avx, and -mno-sse4)`.

* fix: infinite loop in Zone:randomPosition when no valid tile exist (opentibiabr#3178)


This commit fixes an infinite loop issue in the `Zone:randomPosition`
function. When no valid positions (walkable tiles) exist in the zone,
the function would previously enter an infinite loop. The updated logic
now filters all positions upfront to identify walkable tiles, and if
none are found, the function returns `nil` with appropriate logging.
This change ensures better error handling and prevents server freezes
due to infinite loops.

* fix: position after try to cross bridge (opentibiabr#3175)


The problem was that the ladder action was executed first, followed
immediately by the teleportTo action, causing the Player to move above
the ladder with the possibility of crossing the bridge.

* enhance: Monster::getDanceStep code duplication (opentibiabr#2997)


Refactored the `getDanceStep` function to avoid code duplication by
introducing a helper function `tryAddDirection`. This change improves
code readability and maintainability by reducing repetitive logic.

* fix: hazard spawn initialization (opentibiabr#3184)

Fixes bugs introduced here:
opentibiabr#3076

By mistake I removed the onSpawn from the hazard and didn't realize it.

* fix: suppress get byte log (opentibiabr#3185)

Resolves opentibiabr#3153

This simple "suppress" the "getByte" log, some locations send "0" by
default, so we don't need to send log in these locations.

* fix: death call several times (opentibiabr#3186)


fix opentibiabr#3177

* fix: warning on decode lenght (opentibiabr#3188)

Resolves opentibiabr#3002

* fix: for lava tiles in entrance of The Pits of Inferno Quest (opentibiabr#3196)

Implements an alternative solution to handle lava
tiles in The Pits of Inferno Quest. The logic in register_actions.lua
has been modified to transform existing lava items (ID: 21477) into the
floor item (ID: 5815) using Tile:getItemById and Item:transform, instead
of relying on Game.createItem.
This addresses an issue where lava tiles in The Pits of Inferno Quest
were not behaving as expected
Resolves opentibiabr#3144

* fix: party shared experience (opentibiabr#3133)

This fixes the party shared experience that was not providing the correct amount of experience giving the unique vocations count and party size.

* feat: cyclopedia house auction (opentibiabr#3022)

* fix: damage console (opentibiabr#3203)

* fix: adjust character limit for player names (opentibiabr#3174)

* fix: lava lurker heals on fire damage (opentibiabr#3176)

* fix: add missing storage breaking the ice quest (opentibiabr#3201)

* feat: monsters and npcs rotten blood quest (opentibiabr#2686)

* fix: imbuement shrine and time guardian script errors (opentibiabr#2877)

* fix: problem with stack of items on the podium after server save (opentibiabr#2879)

* fix: distro rotten blood quest warnings (opentibiabr#3204)

* fix: balancing 13.40 (opentibiabr#3206)

* feat: add missing constants for client OS (opentibiabr#3179)

* fix: thorgrin callbacks (opentibiabr#3202)

* fix: prevent player corpses from being removed during tile cleaning (opentibiabr#3205)

* fix: preserve decimal precision for skill percentage calculation (opentibiabr#3207)

* fix: remove unnecessary function for data-canary (opentibiabr#2973)

* feat: create database backup on server shutdown (opentibiabr#3069)

This update introduces a refined automatic database backup feature
during the server shutdown process. The main improvements include:

1. Automatic Compression: The database backup is now always
compressed using gzip, reducing disk space usage.

2. Backup Management: The system organizes backup files into folders
named by date and automatically deletes backups older than 7 days. This
ensures that the backup storage remains manageable over time without
manual intervention.

The motivation behind these changes is to create a more efficient and
reliable way of managing database backups, ensuring data safety while
optimizing storage space usage. The feature can be highly useful for
production servers, as it creates backups during shutdown and maintains
them efficiently by automatically removing old backups.

* improve: boosted boss selection (opentibiabr#3208)

* perf: npc/monster storage with vector indexing (opentibiabr#3209)

This modifies the internal storage of NPCs and monsters in the Game class from std::unordered_map to a combination of std::vector and std::unordered_map indexes for improved lookup efficiency and better memory locality.

Motivation
Previously, every time a search was performed for an NPC or a monster, the unordered map was iterated, and even though it provides average O(1) complexity for lookups, the actual cost becomes significant when handling a large dataset (e.g., 80,000 monsters). This cost arises from the overhead of hashing and poor memory locality, as unordered maps store elements in a hash table.

Switching to a vector with index-based lookup improves the following:

1. Memory locality: Vectors store elements contiguously in memory, improving cache efficiency when accessing elements sequentially or repeatedly.
2. Lookup efficiency: Using an unordered map as an index to the vector allows leveraging direct index-based access (constant time) to the actual data, combining the best of both structures.

* perf: change zone positions to phmap::flat_hash_set (opentibiabr#3210)

This replaces `std::unordered_set` with `phmap::flat_hash_set` in the
`Zone` class to improve performance by reducing hash collisions and
optimizing memory usage.

Motivation:

The use of `std::unordered_set` for the `positions` attribute caused
performance issues due to hash collisions, especially when managing
large datasets or heavily clustered data. Collisions result in increased
lookup, insertion, and deletion times as the hash table degrades into a
linked list traversal for conflicting buckets.

Switching to `phmap::flat_hash_set` provides several benefits:
1. Reduced hash collisions: The hashing strategy used by
`phmap::flat_hash_set` significantly reduces the likelihood of
collisions, improving lookup and insertion performance.
2. Improved memory locality: Unlike `std::unordered_set`, which uses
separate allocations for each bucket, `flat_hash_set` uses a contiguous
memory layout, enhancing cache efficiency and reducing overhead.
3. Faster operations: Benchmarks show that `flat_hash_set`
outperforms `std::unordered_set` in scenarios with frequent insertions,
lookups, and deletions due to its optimized design.

* fix: concurrency crash in closeAllShopWindows caused by use-after-free (opentibiabr#3211)

This fixes a concurrency crash in the `closeAllShopWindows` method.
The issue occurred when the `shopPlayers` map was cleared while being iterated over, leading to a use-after-free scenario. The solution removes the use of references when iterating over `shopPlayers` keys, ensuring that the keys are copied instead of directly referencing the map. This change prevents crashes and improves stability in concurrent environments.

* perf: optimize condition creation with ObjectPool (opentibiabr#3212)

This introduces an ObjectPool for managing Condition objects, replacing frequent calls to std::make_shared with a lock-free pooling allocator. This optimization reduces memory allocation overhead, improves performance, and enhances thread safety in scenarios where Conditions are created and destroyed frequently, such as in onThink events or condition updates.

By reusing objects from the pool instead of allocating and deallocating memory repeatedly, this change significantly reduces the strain on the memory management system and improves runtime efficiency. The pool is designed to handle up to 1024 objects per Condition type and supports safe, high-performance multithreaded operations.

* fix: add null check for moveFunction to prevent crashes (opentibiabr#3213)

This adds a null check for the moveFunction in the MoveEvent::fireAddRemItem method. Previously, the code accessed moveFunction directly without verifying its validity, which could lead to crashes if it was nullptr. The fix ensures stability by:

Logging an error message when moveFunction is null.
Returning early to prevent further execution with an invalid function pointer.
This change improves the reliability of the function, particularly in scenarios where moveFunction might not be properly initialized.

* fix: crash on daily reward (opentibiabr#3215)

* perf: replace SELECT * with specific columns in SQL queries (opentibiabr#3214)

This replaces all occurrences of `SELECT *` in SQL queries with
explicit column names. The use of `SELECT *` often retrieves unnecessary
data, increasing query processing time and bandwidth usage. By
specifying the required columns, this change improves performance and
reduces resource usage.

* perf: fixes exhaustion to 'playerEquipItem' (opentibiabr#3165)

* fix: shadowing "date", move to the correct place (opentibiabr#3219)

* fix: ensure isPodium check works correctly (opentibiabr#3221)

* fix: highscore sql query (opentibiabr#3222)

* feat: add morguthis wall action (opentibiabr#3226)

* fix: negative absorb percent (opentibiabr#3228)

Fixes opentibiabr#3218

* fix: fields without owner (opentibiabr#3229)

Fixes opentibiabr#2696

* feat: login and disconnect protection (opentibiabr#3223)

Tibia 9.50: https://www.tibia.com/news/?subtopic=newsarchive&id=2009
X-Logging: https://tibia.fandom.com/wiki/X-Logging

* fix: quests from version 12 revised (opentibiabr#3042)

* fix: combat type 255 when monster walk on field (none) (opentibiabr#3235)

Fixes the combat type 255 error when monsters walk on a field with stepin moveevent and without a damage type specified.

* perf: wheel (opentibiabr#3157)

Fixes performance issues in the wheel ui, also add the disable of the apply button when the changes be applied and some functions calling order.

* fix: getstorage talkaction sanitization (opentibiabr#3240)

Now all strings can be correct sanitized.

* fix: do walk back handling (opentibiabr#3189)

* fix: Monster::removeTarget crash (opentibiabr#3237)

Fixes removing an expired "weak_ptr"

* fix: mount crash (opentibiabr#3236)

* fix: revert some onSpawn monstertype callbacks (opentibiabr#3194)

* fix: familiars upon death (opentibiabr#3231)

* perf: configmanager cache (opentibiabr#3232)

This introduces a performance enhancement by implementing a cache within the ConfigManager. This change reduces the overhead associated with accessing standard configuration variables, leading to more efficient retrieval and improved overall performance.

* fix: rotten bosses wrong looktype (opentibiabr#3234)

* fix: npc crash (opentibiabr#3238)

* fix: item usage under players and doors (opentibiabr#3239)

* fix: empty fluid containers load (opentibiabr#3243)

Fixes the empty containers load that were being loaded as water filled.

* fix: gha warnings (opentibiabr#3244)

* Revert "fix: item usage under players and doors" (opentibiabr#3248)

Reverts opentibiabr#3239

This caused inconsistencies in the "onUse" of other things, several
people reported bugs in onUse to me so I preferred to revert, so the
author can analyze it better and we can test the new pr with the reports
made. For example, when there is a "border" below a dummy, it gets the
id of the border and not the dummy (when using exercise rod)

* fix: database backup escape special characters (opentibiabr#3247)

Actually, the function didn’t escape "special characters" to db user and
password, which caused an error when connecting to the database. Now, it
works correctly.

* fix: showing cyclopedia houses correctly (opentibiabr#3245)

* fix: correct fee validation logic in market offer creation (opentibiabr#3250)

This fixes an issue with the market offer creation process where the player was incorrectly prevented from posting items for sale due to a faulty calculation of the required funds. The validation now ensures the player has enough money to pay only the market fee, rather than the total price of the items plus the fee.

* fix: market bitvise colision (opentibiabr#3257)

This fixes an issue in the market system where the `offer.counter` value experienced collisions due to the use of a bitwise AND operation with a 16-bit mask (`& 0xFFFF`). 
When the `id` value exceeded multiples of 65,536 (e.g., 65,536, 131,072), the result would reset to `0`, causing incorrect behavior.
The fix introduces a transformation using the XOR operator (`^0xABCDEF`) before applying the mask to distribute the values more uniformly and avoid collisions.

* fix: root desync (opentibiabr#3253)

* fix: sanguine itens status (opentibiabr#3255)

* fix: player death corpse description (opentibiabr#3191)

* fix: player summon lasthit addUnjustifiedKills (opentibiabr#3256)

This addresses an issue where unjustified kills were not being properly activated when the last hit on a player was caused by a summon.
The issue occurred because the master of the summon was not being correctly treated as responsible for the kill in certain scenarios. 
This fix ensures that the master of the summon is correctly identified and unjustified kills are processed appropriately.

* fix: ferumbras ascension quest storages (opentibiabr#3269)

* fix: npc eruaran (opentibiabr#3270)

* fix: grave danger quest storages on freequests (opentibiabr#3271)

* fix: faceless bane boss (opentibiabr#3276)

* fix: inquisition quest storage (opentibiabr#3277)

* fix: house transfer item to owner (opentibiabr#3258)

This fixes an issue with the house item transfer system during server startup. Specifically, the `getPlayerByGUID` function was not passing `true` to retrieve offline players, which caused items belonging to offline players to be removed instead of being correctly transferred to their inbox. Additionally, the logic for handling ownership of items was improved to ensure the correct transfer of items to their respective owners, even when no players are online during server startup.

* fix: add note in toggleCyclopediaHouseAuction on config.lua (opentibiabr#3282)

* fix: add missing houses (opentibiabr#3278)

* fix: necklace/ring slots exhaustion (opentibiabr#3272)

This extends opentibiabr#3165 in the following manner:
I've separated necklace and ring slots in different groups, so the `ACTIONS_DELAY_INTERVAL` delay flag works on the groups separately. 
This means the exhaustion delay continues to be applied on equip items, but considering groups separately. In other words, the players are now able to equip necklaces and rings at the same time, but when trying to equip different necklaces (or rings) they are subject to `ACTIONS_DELAY_INTERVAL`.

* fix: magic wall and rush wood onlook description (opentibiabr#3273)

* feat: add candia doors, ladders and ramps (opentibiabr#3283)

* fix: crash in last mount on debug compilation (opentibiabr#3284)

* fix: action golden idol storage function (opentibiabr#3285)

* fix: ferumbras ascension quest actions and creaturescripts (opentibiabr#3286)

* fix: action boss timira fight (opentibiabr#3290)

* fix: add missing houses (opentibiabr#3291)

* fix: dawnport vocation trial and npc plunderpurse (opentibiabr#3292)

* feat: soul pit arena/animus mastery/soul core (opentibiabr#3230)

SoulPit fighting arena along with Animus Mastery Logic.

---------

Co-authored-by: Pedro Henrique Alves Cruz <[email protected]>

* fix: add soulpit includes on visual studio solution (opentibiabr#3296)

* fix: warning on transformItem (opentibiabr#3302)

* fix: ferumbras ascension quest bosses (opentibiabr#3297)

* fix: forgotten knowledge quest bosses (opentibiabr#3298)

* fix: grave danger quest bosses (opentibiabr#3299)

* fix: heart of destruction quest bosses (opentibiabr#3300)

* fix: the secret library quest bosses (opentibiabr#3301)

* fix: move rotten blood quest files to quest folder (opentibiabr#3303)

* fix: move bosses levers to quests folders (opentibiabr#3305)

* fix: werecrocodile raceid (opentibiabr#3308)

* fix: grand master oberon immunity and butterfly's raceid (opentibiabr#3307)

* fix: imbuement slot validation to prevent duplicate applications (opentibiabr#3316)

* fix: set db version to last migration version (opentibiabr#3319)

* fix: add missing exit action on morguthis tomb (opentibiabr#3327)

* refactor: soulcore removal logic (opentibiabr#3326)

* feat: add mitmah vanguard boss (opentibiabr#3332)

* feat: update yasir shop offers (opentibiabr#3333)

* feat: add missing monsters from version 13.30 (opentibiabr#3334)

* feat: update foods action (opentibiabr#3335)

* feat: update items (opentibiabr#3336)

* feat: add missing monsters from version 13.40 (opentibiabr#3337)

* feat: add magic effects and shoot types (opentibiabr#3338)

* fix: duplicate player creation on death screen (opentibiabr#3325)

* fix: stash bugs and adjustments (opentibiabr#3324)

Allow GM access to depot tiles and refine supply stash notifications:
• Fixed "Your depot contains/stash contains" message to appear in the "serverlog".
• Enable God/GM accounts to step on depot tiles to trigger stash/depot search.
• Restrict the "You can't use supply stash right now." message to normal players only.
• Activate step-in tile functionality on player login, excluding only teleports.

* fix: weight error when adding potions to container (opentibiabr#3331)

* fix: colored loot message on bosses (opentibiabr#3342)

* fix: casks and kegs (opentibiabr#3344)

* fix: client debug (opentibiabr#3264)

* fix: null dereferencing on onAttackedCreatureDrainHealth function (opentibiabr#3350)

* fix: wrath of the emperor quest reward (opentibiabr#3352)

* fix: hireling topic handler and adjustments (opentibiabr#3351)

* fix: spells and runes interactions  (opentibiabr#3328)

* fix: imbuement check for empty slots (opentibiabr#3370)

This improves the handling of imbuement slots by checking if a slot is empty before attempting to retrieve imbuement information.
Previously, the function `getImbuementInfo` would return an invalid imbuement even when the slot was empty. Now, it ensures that only valid imbuements are considered.

* fix: set mount bool (opentibiabr#3371)

Fixes mount change on the set outfit only.

* fix: white pk skull (opentibiabr#3372)

Fix white skull correctly removes only if it isn't in fight mode.

* fix: monster loot from raids (opentibiabr#3376)

* fix: house water (opentibiabr#3378)

* fix: the dream courts quest cracked tile movement (opentibiabr#3387)

* fix: barbarian arena quest fur backpack reward (opentibiabr#3388)

* fix: void charm call wrong function (opentibiabr#3389)

* feat: add teleport to candia (opentibiabr#3390)

* fix: unintended depot message and improve code (opentibiabr#3361)

* fix: mass healing area aug II wheel of destiny (opentibiabr#3391)

* fix: spirit of fire combat damage (opentibiabr#3394)

* fix: aleta grav behaviour (opentibiabr#3398)


This fixes multiple issues regarding house door list handling and
door usage via the "aleta grav" spell. The changes ensure that:

• The "House Door List" spell now works correctly when the player is
both in front of and inside the door.
• Both door lists are properly loaded from the database, and cached
entries are cleared once applied.
• The door usage check now validates that the player's current tile
belongs to the same house as the door, preventing usage when the player
is outside the house.

* feat: checks if someone is training on the dummy (opentibiabr#3397)

• Dummy Movement Restriction:
Before: The dummy could be moved or rotated without strict ownership
verification.
Now: Only the house owner is allowed to move or rotate the dummy.
Additionally, the system checks if someone is training on the dummy
before allowing the action. This prevents unauthorized modifications and
ensures that the dummy is only used as intended.

• Enhanced Account-Level Checks:
New Feature: A "buy house" talk action has been added specifically for
god-level accounts.
Improvement: The system now verifies the player's account type when
processing talk actions. This means that if a talk action requires a
certain account privilege (for example, only GM-level or lower actions),
the system will enforce that check. In short, even if a character
appears eligible based on their group, the underlying account type must
also have the necessary permissions.

* fix: the ape city quest storage (opentibiabr#3365)

* fix: inquisition quest (opentibiabr#3395)

* fix: MOTA freequest access and npc gareth outfit (opentibiabr#3396)

* fix: npc tereban (opentibiabr#3402)

* fix: check quest reward nil value on setStorage (opentibiabr#3403)

* fix: encounter set reward (opentibiabr#3404)

* fix: koshei the deathless quest itemId and itemPos (opentibiabr#3405)

* fix: game monster cache on Monster:setType (opentibiabr#3249)

* fix: concurrency crash on item attributes (opentibiabr#3304)


This refactors the `Attributes` class by replacing
`std::shared_ptr<std::string>` with `std::string` in the `value`
variant. The previous implementation introduced unnecessary heap
allocations and potential crashes due to incorrect shared pointer
management. The refactor ensures safer and more efficient handling of
string attributes.

* feat: magic shield potion excluded from exhaustion system (opentibiabr#3393)

Fix to the magic shield potion not trigger the exhaustion.

Co-authored-by: valdzera <[email protected]>

* fix: rotten blood quest entrances (opentibiabr#3410)

* fix: the secret library quest storages (opentibiabr#3425)

# Description

Fix the secret library quest storages

### Fixes opentibiabr#3417 

## Type of change

  - [X] Bug fix (non-breaking change which fixes an issue)

**Test Configuration**:

  - Server Version: Latest (main)
  - Client: 13.40
  - Operating System: Windows

## Checklist

  - [X] My code follows the style guidelines of this project
  - [X] I have performed a self-review of my own code
  - [X] I checked the PR checks reports
- [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have made corresponding changes to the documentation
  - [X] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works

* perf: skip spectator iteration if container has holding player (opentibiabr#3421)

Optimized `onUpdateContainerItem` and `onRemoveContainerItem` to avoid
iterating over spectators when the container has a holding player. If a
holding player is present, updates are sent directly to them, preventing
unnecessary performance overhead. This change reduces unnecessary
iterations and improves efficiency when handling item updates inside
player containers.

* fix: chagorz and vemiath specpos (opentibiabr#3434)

* fix: guild leader channel (opentibiabr#3433)

* fix: corrected mana spent for exercise wand (opentibiabr#3431)

* fix: low blow charm aligned to global behaviour (opentibiabr#3392)

This change fixes an issue in the `Combat::applyExtensions` function
where the "Low Blow" charm critical hit was incorrectly triggering the
global critical hit as well, resulting in unexpected behavior. The bug
was caused by the independent calculation of `lowBlowChance` using
`charm->percent` alone, which led to a downstream misinterpretation of
critical hits. The fix adjusts the "Low Blow" chance calculation to
`baseChance + charm->percent`, aligning it with the Tibia Global
mechanics where "Low Blow" acts as an extension of the base critical
chance, only triggering when the global critical does not occur.
Additionally, this PR adapts `applyExtensions` to handle multiple
targets instead of a single target, improving compatibility with
area-based combat effects.

Co-authored-by: valdzera <[email protected]>

* fix: spell range on south walls (opentibiabr#3412)

* fix: remove player from party on death (opentibiabr#3384)

* fix: prevent crashes by validating userdata in Lua bindings (opentibiabr#3435)

Refactored getUserdataShared<T> to validate userdata before
dereferencing, preventing crashes caused by invalid or outdated Lua
bindings. This fix ensures that instead of a crash, an error message is
logged in the console.

Applied this change across multiple occurrences, potentially fixing
other crashes beyond the openImbuementWindow function. Also included a
regex pattern to help others update their codebase easily.

Regular expression:
(?:Lua::)?getUserdataShared<\s*(?:const\s+)?([\w\d_]+)\s*>\(\s*([\w\d_]+)\s*,\s*([\w\d_]+)\s*\)

Replace:
Lua::getUserdataShared<$1>($2, $3, "$1")

Fixes opentibiabr#3418

* fix: crash on map cache (opentibiabr#3440)

Resolves opentibiabr#3420

* fix: remove unnecessary mutex (opentibiabr#3442)

Fixes console loop related to: opentibiabr#3440

* fix: disconnect client message (opentibiabr#3439)

* fix: hotkey swaps, house potion use, and loot pouch equip handling (opentibiabr#3436)


This update includes several fixes and improvements to item management
in the game, ensuring a more intuitive and consistent experience.

- Item swaps via hotkey should respect the container settings in Manage
Containers.
- Guests in houses should be able to use potions via hotkey.
- Equipping an item from the Loot Pouch should correctly place the
swapped item in the designated container.

* fix: lua bind validation from inheritance class names (opentibiabr#3444)

This fixes some bugs related to the pr opentibiabr#3435 (0c07fb7)

* improve: player components to scoped object (opentibiabr#3130)

Refactored Player interfaces to use scoped objects instead of unique_ptr

• Replaced std::unique_ptr with scoped objects for Player interfaces (Wheel, Achievement, Badge, Title, Cyclopedia, VIP, etc.).
• Improved performance by avoiding unnecessary allocations/deallocations (from unique ptr) when players log in and out.
• Simplified code by removing redundant make_unique calls.
• Centralized includes in player.hpp to streamline dependencies.

* fix: compilation windows visual studio solution (opentibiabr#3445)

Related to opentibiabr#3130

* fix: exori gran con damage bonus (opentibiabr#3321)

This fixes the excessive damage output from skill wheel such as enhanced
ethereal spear, the damage output still too high in comparison to real
tibia. (The high output is on all the spells boosted by skill wheel )

Resolves opentibiabr#3313

* fix: concurrency crash in spectators wheel (opentibiabr#3449)

Disable spectators cache for async functions.

* fix: double kill unjustified (opentibiabr#3446)

Resolves opentibiabr#3429

* fix: update player stats skill bar on boost add/end (opentibiabr#3441)

Resolves opentibiabr#3423

This sent update for the "stats skills" player when add/end.

* fix: add quiver category to managed containers (opentibiabr#3454)

* fix: wrong calculation from elemental damage for weapons (opentibiabr#3187)

This fixes an issue with the calculation of elemental weapon damage.
Previously, the damage calculation for elemental weapons duplicated the
damage instead of distributing it as 60% elemental and 40% physical.
This resulted in incorrect damage values and an overpowered effect for
certain weapons.

The corrected logic ensures that the total damage remains consistent,
splitting appropriately based on the elemental and physical proportions
while applying target resistances/weaknesses correctly.

Co-authored-by: valdzera <[email protected]>

* fix: add ui exhausted to imbuement apply/clear (opentibiabr#3455)

* feat: features OTCR natively in canary (opentibiabr#3061)

Client modification: Feature improvements per opentibiabr/otclient#962

• Added opcode 0x43 handler in ProtocolGame to process feature enablement from the server.
• Implemented a loop to read a count of features and enable each one when its flag is set.
• Supported features include: • Creature AE + Shader (compatible with both cipsoft and v8 clients)
• send disableFeature/enableFeature (making it easy to modify via config.lua)
• Outfit enhancements (wings, aura, shader)
• TypingIcon support
• Map shader support
• Item shader support
---------

Co-authored-by: Eduardo Dantas <[email protected]>

* fix: add taint experience boost for Soul War monsters (opentibiabr#3494)

# Description

This PR introduces a fix and enhancement for the experience boost system
related to the Soul War quest. Specifically, it ensures that the taint
level of the player is correctly factored into the experience
calculation when defeating monsters listed in the
SoulWarQuest.bagYouDesireMonsters.

## Behaviour
### **Actual**
The taint level boost was not applied correctly in some cases.
Experience calculation did not account for edge cases where the taint
level or boost map might be undefined.

### **Expected**

The taint level boost is applied consistently and correctly.
Experience calculation handles edge cases gracefully.

## Type of change

  - [x] New feature (non-breaking change which adds functionality)

## How Has This Been Tested

- [x] Hunt any SoulWar monster and see the EXP increasing with different
taint levels.

## Checklist

  - [x] My code follows the style guidelines of this project
  - [x] I have performed a self-review of my own code
  - [x] I checked the PR checks reports
- [x] I have commented my code, particularly in hard-to-understand areas
  - [x] I have made corresponding changes to the documentation
  - [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works

* fix: merge fixes

* fix: merge fixes

* fix: merge migrations fixes

---------

Co-authored-by: Leilani A. <[email protected]>
Co-authored-by: Pedro Cruz <[email protected]>
Co-authored-by: Eduardo Dantas <[email protected]>
Co-authored-by: Felipe Paluco <[email protected]>
Co-authored-by: murilo09 <[email protected]>
Co-authored-by: Marco <[email protected]>
Co-authored-by: Renato Machado <[email protected]>
Co-authored-by: Paulo Henrique Lisboa <[email protected]>
Co-authored-by: HT Cesta <[email protected]>
Co-authored-by: Felipe Muniz <[email protected]>
Co-authored-by: Luan Luciano <[email protected]>
Co-authored-by: valdzera <[email protected]>
Co-authored-by: kokekanon <[email protected]>
Co-authored-by: odisk777 <[email protected]>
Co-authored-by: Felipe Pessoa <[email protected]>
Co-authored-by: Jean Carlo de Souza <[email protected]>
Co-authored-by: pudimtibia <[email protected]>
Co-authored-by: Filipe Arruda <[email protected]>
Co-authored-by: Elson Costa <[email protected]>
Co-authored-by: mdbeng <[email protected]>
Co-authored-by: Sorairei <[email protected]>
Co-authored-by: feliphechaves <[email protected]>
Co-authored-by: Samuel Gomes <[email protected]>
Co-authored-by: Majesty <[email protected]>
Co-authored-by: aphirotx <[email protected]>
Co-authored-by: Jonyrewind <[email protected]>
Co-authored-by: Guilherme <[email protected]>
Co-authored-by: Aerwix <[email protected]>
Co-authored-by: bdzicc <[email protected]>
un000000 added a commit to vaigu-com/otserver that referenced this pull request Jan 1, 2026
* perf: onThink multithreading (#3075)

* improve: migration database update (#3071)

This improves the database migration process by removing the need to
manually define if more migrations are required with return values in
Lua scripts. The new approach automatically processes all migration
files based on their version, reducing complexity and making the update
process more robust. This change aims to streamline the database update
logic and eliminate manual steps previously required.

* fix: remove unsupported compiler flags for MSVC (#3173)

Resolves warnings issued during the Windows build
process with MSVC caused by unsupported compiler flags `(-march, -mtune,
-mno-avx, and -mno-sse4)`.

* fix: infinite loop in Zone:randomPosition when no valid tile exist (#3178)


This commit fixes an infinite loop issue in the `Zone:randomPosition`
function. When no valid positions (walkable tiles) exist in the zone,
the function would previously enter an infinite loop. The updated logic
now filters all positions upfront to identify walkable tiles, and if
none are found, the function returns `nil` with appropriate logging.
This change ensures better error handling and prevents server freezes
due to infinite loops.

* fix: position after try to cross bridge (#3175)


The problem was that the ladder action was executed first, followed
immediately by the teleportTo action, causing the Player to move above
the ladder with the possibility of crossing the bridge.

* enhance: Monster::getDanceStep code duplication (#2997)


Refactored the `getDanceStep` function to avoid code duplication by
introducing a helper function `tryAddDirection`. This change improves
code readability and maintainability by reducing repetitive logic.

* fix: hazard spawn initialization (#3184)

Fixes bugs introduced here:
https://github.com/opentibiabr/canary/pull/3076

By mistake I removed the onSpawn from the hazard and didn't realize it.

* fix: suppress get byte log (#3185)

Resolves #3153

This simple "suppress" the "getByte" log, some locations send "0" by
default, so we don't need to send log in these locations.

* fix: death call several times (#3186)


fix #3177

* fix: warning on decode lenght (#3188)

Resolves #3002

* fix: for lava tiles in entrance of The Pits of Inferno Quest (#3196)

Implements an alternative solution to handle lava
tiles in The Pits of Inferno Quest. The logic in register_actions.lua
has been modified to transform existing lava items (ID: 21477) into the
floor item (ID: 5815) using Tile:getItemById and Item:transform, instead
of relying on Game.createItem.
This addresses an issue where lava tiles in The Pits of Inferno Quest
were not behaving as expected
Resolves #3144

* fix: party shared experience (#3133)

This fixes the party shared experience that was not providing the correct amount of experience giving the unique vocations count and party size.

* feat: cyclopedia house auction (#3022)

* fix: damage console (#3203)

* fix: adjust character limit for player names (#3174)

* fix: lava lurker heals on fire damage (#3176)

* fix: add missing storage breaking the ice quest (#3201)

* feat: monsters and npcs rotten blood quest (#2686)

* fix: imbuement shrine and time guardian script errors (#2877)

* fix: problem with stack of items on the podium after server save (#2879)

* fix: distro rotten blood quest warnings (#3204)

* Quests refactor (#38)

* quest identifier is renamed to english counterpart; string

* batch new quest system

* rollback experimental kv

* batch updates

* batch update

* batch upates

* batch updates

* batch updates

* Map update (#37)

* map updates

* batch merge mirko + new content

* batch map updates

* batch map update

* fix linux build (#32)

* batch map update

* Map update (#34)

* map updates

* batch merge mirko + new content

* batch map updates

* batch map update

* batch map update

* batch map update

* batch map update

* batch map update

* batch map update

* batch map update

* batch map update

* batch map update

* batch map update

* batch map update

* batch map update

* batch map update

* batch map update

* cleanup

* map update

* batch updates

* batch update

* batch updates

* batch updates

* fix town id crash

* batch updates

* batch updates

* fix missing house

* batch updates

* batch updates

* batch updates

* batch updates

* batch updates

* batch updates

* batch updates

* revert reset data-otservbr-global and data-canary to state from dev branch

* renamings

---------

Co-authored-by: Paweł Antoniuk <[email protected]>

* fix: balancing 13.40 (#3206)

* feat: add missing constants for client OS (#3179)

* fix: thorgrin callbacks (#3202)

* fix: prevent player corpses from being removed during tile cleaning (#3205)

* fix: preserve decimal precision for skill percentage calculation (#3207)

* fix: remove unnecessary function for data-canary (#2973)

* feat: create database backup on server shutdown (#3069)

This update introduces a refined automatic database backup feature
during the server shutdown process. The main improvements include:

1. Automatic Compression: The database backup is now always
compressed using gzip, reducing disk space usage.

2. Backup Management: The system organizes backup files into folders
named by date and automatically deletes backups older than 7 days. This
ensures that the backup storage remains manageable over time without
manual intervention.

The motivation behind these changes is to create a more efficient and
reliable way of managing database backups, ensuring data safety while
optimizing storage space usage. The feature can be highly useful for
production servers, as it creates backups during shutdown and maintains
them efficiently by automatically removing old backups.

* improve: boosted boss selection (#3208)

* perf: npc/monster storage with vector indexing (#3209)

This modifies the internal storage of NPCs and monsters in the Game class from std::unordered_map to a combination of std::vector and std::unordered_map indexes for improved lookup efficiency and better memory locality.

Motivation
Previously, every time a search was performed for an NPC or a monster, the unordered map was iterated, and even though it provides average O(1) complexity for lookups, the actual cost becomes significant when handling a large dataset (e.g., 80,000 monsters). This cost arises from the overhead of hashing and poor memory locality, as unordered maps store elements in a hash table.

Switching to a vector with index-based lookup improves the following:

1. Memory locality: Vectors store elements contiguously in memory, improving cache efficiency when accessing elements sequentially or repeatedly.
2. Lookup efficiency: Using an unordered map as an index to the vector allows leveraging direct index-based access (constant time) to the actual data, combining the best of both structures.

* perf: change zone positions to phmap::flat_hash_set (#3210)

This replaces `std::unordered_set` with `phmap::flat_hash_set` in the
`Zone` class to improve performance by reducing hash collisions and
optimizing memory usage.

Motivation:

The use of `std::unordered_set` for the `positions` attribute caused
performance issues due to hash collisions, especially when managing
large datasets or heavily clustered data. Collisions result in increased
lookup, insertion, and deletion times as the hash table degrades into a
linked list traversal for conflicting buckets.

Switching to `phmap::flat_hash_set` provides several benefits:
1. Reduced hash collisions: The hashing strategy used by
`phmap::flat_hash_set` significantly reduces the likelihood of
collisions, improving lookup and insertion performance.
2. Improved memory locality: Unlike `std::unordered_set`, which uses
separate allocations for each bucket, `flat_hash_set` uses a contiguous
memory layout, enhancing cache efficiency and reducing overhead.
3. Faster operations: Benchmarks show that `flat_hash_set`
outperforms `std::unordered_set` in scenarios with frequent insertions,
lookups, and deletions due to its optimized design.

* fix: concurrency crash in closeAllShopWindows caused by use-after-free (#3211)

This fixes a concurrency crash in the `closeAllShopWindows` method.
The issue occurred when the `shopPlayers` map was cleared while being iterated over, leading to a use-after-free scenario. The solution removes the use of references when iterating over `shopPlayers` keys, ensuring that the keys are copied instead of directly referencing the map. This change prevents crashes and improves stability in concurrent environments.

* perf: optimize condition creation with ObjectPool (#3212)

This introduces an ObjectPool for managing Condition objects, replacing frequent calls to std::make_shared with a lock-free pooling allocator. This optimization reduces memory allocation overhead, improves performance, and enhances thread safety in scenarios where Conditions are created and destroyed frequently, such as in onThink events or condition updates.

By reusing objects from the pool instead of allocating and deallocating memory repeatedly, this change significantly reduces the strain on the memory management system and improves runtime efficiency. The pool is designed to handle up to 1024 objects per Condition type and supports safe, high-performance multithreaded operations.

* fix: add null check for moveFunction to prevent crashes (#3213)

This adds a null check for the moveFunction in the MoveEvent::fireAddRemItem method. Previously, the code accessed moveFunction directly without verifying its validity, which could lead to crashes if it was nullptr. The fix ensures stability by:

Logging an error message when moveFunction is null.
Returning early to prevent further execution with an invalid function pointer.
This change improves the reliability of the function, particularly in scenarios where moveFunction might not be properly initialized.

* fix: crash on daily reward (#3215)

* perf: replace SELECT * with specific columns in SQL queries (#3214)

This replaces all occurrences of `SELECT *` in SQL queries with
explicit column names. The use of `SELECT *` often retrieves unnecessary
data, increasing query processing time and bandwidth usage. By
specifying the required columns, this change improves performance and
reduces resource usage.

* perf: fixes exhaustion to 'playerEquipItem' (#3165)

* fix: shadowing "date", move to the correct place (#3219)

* fix: ensure isPodium check works correctly (#3221)

* Use key to register scripts (#39)

* feature: register scripts per key

* item:getKey method added

* build fixes

* batch map update

* add keys: immovable item, permanently closed door

* key is stored in item node; remove vaigu_item node

* set correect KEY attribute enum

* convert most otbm aid to keys

* most scripts now use 'kv_store' instead of 'player_storage'

* revert unnecessary comment

* fix: highscore sql query (#3222)

* Loot layer (#40)

* feature: register scripts per key

* item:getKey method added

* build fixes

* batch map update

* add keys: immovable item, permanently closed door

* key is stored in item node; remove vaigu_item node

* set correect KEY attribute enum

* convert most otbm aid to keys

* most scripts now use 'kv_store' instead of 'player_storage'

* revert unnecessary comment

* corpse loot message now splits loot into categories

* minor map fixes

* misc prey fixes

* feat: add morguthis wall action (#3226)

* fix: negative absorb percent (#3228)

Fixes #3218

* fix: fields without owner (#3229)

Fixes #2696

* feat: login and disconnect protection (#3223)

Tibia 9.50: https://www.tibia.com/news/?subtopic=newsarchive&id=2009
X-Logging: https://tibia.fandom.com/wiki/X-Logging

* fix: quests from version 12 revised (#3042)

* fix: combat type 255 when monster walk on field (none) (#3235)

Fixes the combat type 255 error when monsters walk on a field with stepin moveevent and without a damage type specified.

* perf: wheel (#3157)

Fixes performance issues in the wheel ui, also add the disable of the apply button when the changes be applied and some functions calling order.

* fix: getstorage talkaction sanitization (#3240)

Now all strings can be correct sanitized.

* fix: do walk back handling (#3189)

* fix: Monster::removeTarget crash (#3237)

Fixes removing an expired "weak_ptr"

* fix: mount crash (#3236)

* fix: revert some onSpawn monstertype callbacks (#3194)

* fix: familiars upon death (#3231)

* perf: configmanager cache (#3232)

This introduces a performance enhancement by implementing a cache within the ConfigManager. This change reduces the overhead associated with accessing standard configuration variables, leading to more efficient retrieval and improved overall performance.

* fix: rotten bosses wrong looktype (#3234)

* fix: npc crash (#3238)

* fix: item usage under players and doors (#3239)

* fix: empty fluid containers load (#3243)

Fixes the empty containers load that were being loaded as water filled.

* fix: gha warnings (#3244)

* Revert "fix: item usage under players and doors" (#3248)

Reverts opentibiabr/canary#3239

This caused inconsistencies in the "onUse" of other things, several
people reported bugs in onUse to me so I preferred to revert, so the
author can analyze it better and we can test the new pr with the reports
made. For example, when there is a "border" below a dummy, it gets the
id of the border and not the dummy (when using exercise rod)

* fix: database backup escape special characters (#3247)

Actually, the function didn’t escape "special characters" to db user and
password, which caused an error when connecting to the database. Now, it
works correctly.

* fix: showing cyclopedia houses correctly (#3245)

* fix: correct fee validation logic in market offer creation (#3250)

This fixes an issue with the market offer creation process where the player was incorrectly prevented from posting items for sale due to a faulty calculation of the required funds. The validation now ensures the player has enough money to pay only the market fee, rather than the total price of the items plus the fee.

* fix: market bitvise colision (#3257)

This fixes an issue in the market system where the `offer.counter` value experienced collisions due to the use of a bitwise AND operation with a 16-bit mask (`& 0xFFFF`). 
When the `id` value exceeded multiples of 65,536 (e.g., 65,536, 131,072), the result would reset to `0`, causing incorrect behavior.
The fix introduces a transformation using the XOR operator (`^0xABCDEF`) before applying the mask to distribute the values more uniformly and avoid collisions.

* fix: root desync (#3253)

* fix: sanguine itens status (#3255)

* fix: player death corpse description (#3191)

* fix: player summon lasthit addUnjustifiedKills (#3256)

This addresses an issue where unjustified kills were not being properly activated when the last hit on a player was caused by a summon.
The issue occurred because the master of the summon was not being correctly treated as responsible for the kill in certain scenarios. 
This fix ensures that the master of the summon is correctly identified and unjustified kills are processed appropriately.

* fix: ferumbras ascension quest storages (#3269)

* fix: npc eruaran (#3270)

* fix: grave danger quest storages on freequests (#3271)

* fix: faceless bane boss (#3276)

* fix: inquisition quest storage (#3277)

* fix: house transfer item to owner (#3258)

This fixes an issue with the house item transfer system during server startup. Specifically, the `getPlayerByGUID` function was not passing `true` to retrieve offline players, which caused items belonging to offline players to be removed instead of being correctly transferred to their inbox. Additionally, the logic for handling ownership of items was improved to ensure the correct transfer of items to their respective owners, even when no players are online during server startup.

* tracked quests are stored server-side (#42)

* tracked quests are stored server-side

* remove useless code

* Monster objects can have own loot table; LuaRaid refactor (#43)

* Monster (not MonsterType) can have own loot table

* LuaRaid refactor; Raid monsters drop silver tokens

* misc fixes (#44)

* Merge upstream changes (#45)

* fix: add note in toggleCyclopediaHouseAuction on config.lua (#3282)

* fix: add missing houses (#3278)

* fix: necklace/ring slots exhaustion (#3272)

This extends #3165 in the following manner:
I've separated necklace and ring slots in different groups, so the `ACTIONS_DELAY_INTERVAL` delay flag works on the groups separately. 
This means the exhaustion delay continues to be applied on equip items, but considering groups separately. In other words, the players are now able to equip necklaces and rings at the same time, but when trying to equip different necklaces (or rings) they are subject to `ACTIONS_DELAY_INTERVAL`.

* fix: magic wall and rush wood onlook description (#3273)

* feat: add candia doors, ladders and ramps (#3283)

* fix: crash in last mount on debug compilation (#3284)

* fix: action golden idol storage function (#3285)

* fix: ferumbras ascension quest actions and creaturescripts (#3286)

* fix: action boss timira fight (#3290)

* syntax and startup error fixes (#46)

* MIgrations update; Sample start date (#47)

* migrations update

* change days since start to start date

* fix incorrect table reference

* fix: add missing houses (#3291)

* fix: dawnport vocation trial and npc plunderpurse (#3292)

* feat: soul pit arena/animus mastery/soul core (#3230)

SoulPit fighting arena along with Animus Mastery Logic.

---------

Co-authored-by: Pedro Henrique Alves Cruz <[email protected]>

* fix: add soulpit includes on visual studio solution (#3296)

* add missing otservbr-global datapack files (#49)

* fix: warning on transformItem (#3302)

* fix: ferumbras ascension quest bosses (#3297)

* fix: forgotten knowledge quest bosses (#3298)

* fix: grave danger quest bosses (#3299)

* fix: heart of destruction quest bosses (#3300)

* fix: the secret library quest bosses (#3301)

* fix: move rotten blood quest files to quest folder (#3303)

* fix: move bosses levers to quests folders (#3305)

* fix: werecrocodile raceid (#3308)

* Fixes in main data and vaigu datapack (#50)

* fixes batch 1

* misc fixes in data and vaigu datapack

* update monster and monster spells

* remove unnecessary prints

* fix: grand master oberon immunity and butterfly's raceid (#3307)

* fix: imbuement slot validation to prevent duplicate applications (#3316)

* fix: set db version to last migration version (#3319)

* fix: add missing exit action on morguthis tomb (#3327)

* refactor: soulcore removal logic (#3326)

* feat: add mitmah vanguard boss (#3332)

* feat: update yasir shop offers (#3333)

* feat: add missing monsters from version 13.30 (#3334)

* feat: update foods action (#3335)

* feat: update items (#3336)

* feat: add missing monsters from version 13.40 (#3337)

* feat: add magic effects and shoot types (#3338)

* new ItemType:getNameDescription method

* feature: layer stackable items are shown once, as one big stack

* Npc updates (#51)

* fix: send correct action-specific context now

* fix: use correct string template now

* update npc looktype

* transport npc open window without greeting

* update transport routes

* fix: correctly place npc marks on minimap

* improve: log possible errors

* Quest system update (#52)

* batch map updates

* batch map updates

* most of old npcs placed on map

* minor map fixes

* npc name fixes

* fix npc pos

* place new npcs on map

* batch map updates

* batch map updates

* batch map updates

* add items from startup

* monsters and npc update

* add missing includes

* update cmake preset

* batch map updates

* fix: add missing Item:getKey lua method

* add uniqueName methods for npc and monster

* feature: serialize ALL registered npcs/monsters to xml

* npc name fixes

* fix: level door uses key instead of storage

* improve: teleport for becoming citizen chooses nearest town temple

* fix: add missing storage

* improve: 'prodigal son' blackboard uses Look()

* fix: missing functions

* improve: logging important things

* fix: misc fixes and comments

* improve: 'desert quest' signs use Look()

* feature: use key instead of aid in new quest definitions

* fix: comment out buggy, unused monster

* improve: move all resolver code to own file

* feature: startupItems changed on onUse declarations (without creating items on map)

* fix: update new quests with OnUseDeclaration

* fix: correctly ref player

* fix: missing functions

* fix: renamings; misc

* improve: renamings

* fix: onUseDeclaration correct parsing and registering

* fix: missing enum

* fix: missing functions; renamings

* fix: duplicate player creation on death screen (#3325)

* fix: stash bugs and adjustments (#3324)

Allow GM access to depot tiles and refine supply stash notifications:
• Fixed "Your depot contains/stash contains" message to appear in the "serverlog".
• Enable God/GM accounts to step on depot tiles to trigger stash/depot search.
• Restrict the "You can't use supply stash right now." message to normal players only.
• Activate step-in tile functionality on player login, excluding only teleports.

* fix: weight error when adding potions to container (#3331)

* fix: colored loot message on bosses (#3342)

* fix: casks and kegs (#3344)

* fix: client debug (#3264)

* fix: null dereferencing on onAttackedCreatureDrainHealth function (#3350)

* fix: wrath of the emperor quest reward (#3352)

* fix: hireling topic handler and adjustments (#3351)

* feature: only monsters with count >20 on map can be chosen in prey grid

* Door keys (#53)

* feature: key collection; refactorings

* feature: only perform registered Look().onLook

* fix: add key ring to .dat

* fix: key door action

* fix: bank system (#54)

* fix: spells and runes interactions  (#3328)

* Map update (#48)

* batch map updates

* batch map updates

* most of old npcs placed on map

* minor map fixes

* npc name fixes

* fix npc pos

* place new npcs on map

* batch map updates

* batch map updates

* batch map updates

* add items from startup

* monsters and npc update

* batch map updates

* batch map updates

* fix: imbuement check for empty slots (#3370)

This improves the handling of imbuement slots by checking if a slot is empty before attempting to retrieve imbuement information.
Previously, the function `getImbuementInfo` would return an invalid imbuement even when the slot was empty. Now, it ensures that only valid imbuements are considered.

* fix: set mount bool (#3371)

Fixes mount change on the set outfit only.

* fix: white pk skull (#3372)

Fix white skull correctly removes only if it isn't in fight mode.

* fix: monster loot from raids (#3376)

* fix: house water (#3378)

* fix: the dream courts quest cracked tile movement (#3387)

* fix: barbarian arena quest fur backpack reward (#3388)

* fix: void charm call wrong function (#3389)

* feat: add teleport to candia (#3390)

* fix: unintended depot message and improve code (#3361)

* fix: mass healing area aug II wheel of destiny (#3391)

* fix: spirit of fire combat damage (#3394)

* fix: aleta grav behaviour (#3398)


This fixes multiple issues regarding house door list handling and
door usage via the "aleta grav" spell. The changes ensure that:

• The "House Door List" spell now works correctly when the player is
both in front of and inside the door.
• Both door lists are properly loaded from the database, and cached
entries are cleared once applied.
• The door usage check now validates that the player's current tile
belongs to the same house as the door, preventing usage when the player
is outside the house.

* feat: checks if someone is training on the dummy (#3397)

• Dummy Movement Restriction:
Before: The dummy could be moved or rotated without strict ownership
verification.
Now: Only the house owner is allowed to move or rotate the dummy.
Additionally, the system checks if someone is training on the dummy
before allowing the action. This prevents unauthorized modifications and
ensures that the dummy is only used as intended.

• Enhanced Account-Level Checks:
New Feature: A "buy house" talk action has been added specifically for
god-level accounts.
Improvement: The system now verifies the player's account type when
processing talk actions. This means that if a talk action requires a
certain account privilege (for example, only GM-level or lower actions),
the system will enforce that check. In short, even if a character
appears eligible based on their group, the underlying account type must
also have the necessary permissions.

* fix: the ape city quest storage (#3365)

* fix: inquisition quest (#3395)

* fix: MOTA freequest access and npc gareth outfit (#3396)

* fix: npc tereban (#3402)

* fix: check quest reward nil value on setStorage (#3403)

* fix: encounter set reward (#3404)

* fix: koshei the deathless quest itemId and itemPos (#3405)

* fix: game monster cache on Monster:setType (#3249)

* fix: concurrency crash on item attributes (#3304)


This refactors the `Attributes` class by replacing
`std::shared_ptr<std::string>` with `std::string` in the `value`
variant. The previous implementation introduced unnecessary heap
allocations and potential crashes due to incorrect shared pointer
management. The refactor ensures safer and more efficient handling of
string attributes.

* feat: magic shield potion excluded from exhaustion system (#3393)

Fix to the magic shield potion not trigger the exhaustion.

Co-authored-by: valdzera <[email protected]>

* fix: rotten blood quest entrances (#3410)

* fix: the secret library quest storages (#3425)

# Description

Fix the secret library quest storages

### Fixes #3417 

## Type of change

  - [X] Bug fix (non-breaking change which fixes an issue)

**Test Configuration**:

  - Server Version: Latest (main)
  - Client: 13.40
  - Operating System: Windows

## Checklist

  - [X] My code follows the style guidelines of this project
  - [X] I have performed a self-review of my own code
  - [X] I checked the PR checks reports
- [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have made corresponding changes to the documentation
  - [X] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works

* perf: skip spectator iteration if container has holding player (#3421)

Optimized `onUpdateContainerItem` and `onRemoveContainerItem` to avoid
iterating over spectators when the container has a holding player. If a
holding player is present, updates are sent directly to them, preventing
unnecessary performance overhead. This change reduces unnecessary
iterations and improves efficiency when handling item updates inside
player containers.

* fix: chagorz and vemiath specpos (#3434)

* fix: guild leader channel (#3433)

* fix: corrected mana spent for exercise wand (#3431)

* fix: low blow charm aligned to global behaviour (#3392)

This change fixes an issue in the `Combat::applyExtensions` function
where the "Low Blow" charm critical hit was incorrectly triggering the
global critical hit as well, resulting in unexpected behavior. The bug
was caused by the independent calculation of `lowBlowChance` using
`charm->percent` alone, which led to a downstream misinterpretation of
critical hits. The fix adjusts the "Low Blow" chance calculation to
`baseChance + charm->percent`, aligning it with the Tibia Global
mechanics where "Low Blow" acts as an extension of the base critical
chance, only triggering when the global critical does not occur.
Additionally, this PR adapts `applyExtensions` to handle multiple
targets instead of a single target, improving compatibility with
area-based combat effects.

Co-authored-by: valdzera <[email protected]>

* fix: spell range on south walls (#3412)

* fix: remove player from party on death (#3384)

* fix: prevent crashes by validating userdata in Lua bindings (#3435)

Refactored getUserdataShared<T> to validate userdata before
dereferencing, preventing crashes caused by invalid or outdated Lua
bindings. This fix ensures that instead of a crash, an error message is
logged in the console.

Applied this change across multiple occurrences, potentially fixing
other crashes beyond the openImbuementWindow function. Also included a
regex pattern to help others update their codebase easily.

Regular expression:
(?:Lua::)?getUserdataShared<\s*(?:const\s+)?([\w\d_]+)\s*>\(\s*([\w\d_]+)\s*,\s*([\w\d_]+)\s*\)

Replace:
Lua::getUserdataShared<$1>($2, $3, "$1")

Fixes #3418

* fix: crash on map cache (#3440)

Resolves #3420

* fix: remove unnecessary mutex (#3442)

Fixes console loop related to: #3440

* fix: disconnect client message (#3439)

* fix: hotkey swaps, house potion use, and loot pouch equip handling (#3436)


This update includes several fixes and improvements to item management
in the game, ensuring a more intuitive and consistent experience.

- Item swaps via hotkey should respect the container settings in Manage
Containers.
- Guests in houses should be able to use potions via hotkey.
- Equipping an item from the Loot Pouch should correctly place the
swapped item in the designated container.

* fix: lua bind validation from inheritance class names (#3444)

This fixes some bugs related to the pr #3435 (0c07fb75aba4dbabae293d851f46fdf336e66d0c)

* improve: player components to scoped object (#3130)

Refactored Player interfaces to use scoped objects instead of unique_ptr

• Replaced std::unique_ptr with scoped objects for Player interfaces (Wheel, Achievement, Badge, Title, Cyclopedia, VIP, etc.).
• Improved performance by avoiding unnecessary allocations/deallocations (from unique ptr) when players log in and out.
• Simplified code by removing redundant make_unique calls.
• Centralized includes in player.hpp to streamline dependencies.

* fix: compilation windows visual studio solution (#3445)

Related to #3130

* fix: exori gran con damage bonus (#3321)

This fixes the excessive damage output from skill wheel such as enhanced
ethereal spear, the damage output still too high in comparison to real
tibia. (The high output is on all the spells boosted by skill wheel )

Resolves #3313

* fix: concurrency crash in spectators wheel (#3449)

Disable spectators cache for async functions.

* fix: double kill unjustified (#3446)

Resolves #3429

* fix: update player stats skill bar on boost add/end (#3441)

Resolves #3423

This sent update for the "stats skills" player when add/end.

* fix: add quiver category to managed containers (#3454)

* fix: wrong calculation from elemental damage for weapons (#3187)

This fixes an issue with the calculation of elemental weapon damage.
Previously, the damage calculation for elemental weapons duplicated the
damage instead of distributing it as 60% elemental and 40% physical.
This resulted in incorrect damage values and an overpowered effect for
certain weapons.

The corrected logic ensures that the total damage remains consistent,
splitting appropriately based on the elemental and physical proportions
while applying target resistances/weaknesses correctly.

Co-authored-by: valdzera <[email protected]>

* fix: add ui exhausted to imbuement apply/clear (#3455)

* feat: features OTCR natively in canary (#3061)

Client modification: Feature improvements per https://github.com/mehah/otclient/pull/962

• Added opcode 0x43 handler in ProtocolGame to process feature enablement from the server.
• Implemented a loop to read a count of features and enable each one when its flag is set.
• Supported features include: • Creature AE + Shader (compatible with both cipsoft and v8 clients)
• send disableFeature/enableFeature (making it easy to modify via config.lua)
• Outfit enhancements (wings, aura, shader)
• TypingIcon support
• Map shader support
• Item shader support
---------

Co-authored-by: Eduardo Dantas <[email protected]>

* fix: add taint experience boost for Soul War monsters (#3494)

# Description

This PR introduces a fix and enhancement for the experience boost system
related to the Soul War quest. Specifically, it ensures that the taint
level of the player is correctly factored into the experience
calculation when defeating monsters listed in the
SoulWarQuest.bagYouDesireMonsters.

## Behaviour
### **Actual**
The taint level boost was not applied correctly in some cases.
Experience calculation did not account for edge cases where the taint
level or boost map might be undefined.

### **Expected**

The taint level boost is applied consistently and correctly.
Experience calculation handles edge cases gracefully.

## Type of change

  - [x] New feature (non-breaking change which adds functionality)

## How Has This Been Tested

- [x] Hunt any SoulWar monster and see the EXP increasing with different
taint levels.

## Checklist

  - [x] My code follows the style guidelines of this project
  - [x] I have performed a self-review of my own code
  - [x] I checked the PR checks reports
- [x] I have commented my code, particularly in hard-to-understand areas
  - [x] I have made corresponding changes to the documentation
  - [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works

* Systems and quest fixes (#56)

* batch map updates

* init

* perf: animation-only creature optimizations

* improve: crossroad runner

* fix: missing functions

* improve: create MinigameData class - based on EncounterData

* batch map updates

* batch map updates

* batch map updates

* batch map updates

* batch map updates

* fix: add key ring item

* batch map updates

* batch map updates

* batch map updates

* batch map updates

* feature: custom stairs

* feature: forge fusion always requires tier 0 as second item

* feature: player individual attack speed is used

* fix: use correct table for npc display name translation

* fix: minigame misc fixes

* feature: custom movement speed bonus on mount

* improve: bring back onSpawn callback

* feature: dont allow potion/rune/spell use during minigames

* fix: correctly reroll daily boosted monster before startup

* fix: monster cannot destroy/push items with non-empty key

* feature: monster encounter difficulty increases final damage

* fix: correctly get/set player language on login/logout

* fix: correctly update and display fullName

* feature: can set monster encounter difficulty on lua side

* fix: return null instead of empty key

* fix: formatting

* fix: correctly merge exercis weapons

* improve: indicate that magic gold converter requires gold pouch

* fix: autotrack quests; minor fixes

* fix: only dispose empty player-send parcels on login

* fix: correctly add atelier items to loottable

* perf: optimize message broadcast

* improve: can always move items within inbox, else key makes item immovable

* fix: encounter system fixes and improvements

* improve: add zone getRandomPlayer(); minor fixes

* improve: alter exp and skill stages

* refactor: use encounter getters

* fix: dont show swim animation on walkable water

* fix: keydoor fixes;

* fix: add missing onUse down/up teleports

* improve: add constants for item ids

* fix: use wiki data for lootbox-like items

* fix: default onLook minor fixes; allow player see admin details with !debug

* fix: update global enums

* improve: show total and per-scroll wheel points

* fix: corectly calculate bonus exp; change formula

* improve: encounter rewardboss loot ignores participation and uses difficulty

* improve: new item manipulation functions

* fix: ensure correct lib load order

* fix: position fixes and improvements

* fix: player inventory function fixes  and improvements

* fix: add crucial quest-related global tables

* refactor: rename npc/monster definitions xml serializers

* improve: check and warn for duplicate registered events

* fix: systems fixes and improvements

* fix: quests fixes and improvements

* fix: add missing GreetCallbackContext class

* fix: minor fixes and refactorings

* fix: dont allow desintegrating items with key attribute

* feature: magic shield has realtibia pool but no cooldown or cost

* fix: load item id table as early as possible

* improve: use Player::AddCustomItem instead of addItem

* improve: directories and minor fixes

* improve: add medal of honour (quest item) to monkey loot table

* fix: add missing custom task bosses

* feat: add custom oldschool monsters

* improve: increase midnight panther head droprate for quest

* feat: add medal of hope to cursed apes for quest purposes

* feat: reduce animated snowman damage

* feat: add steppes magic shop

* feat: add training dummy monsters

* fix: /i command creates untakeable item at player position

* fix: monster fixes

* improve: add monster validation to luaraid and task monsters

* feature: train travel; refactors

* fix: spawnlock fixes

* fix: minigame fixes

* fix: misc minigame fixes

* fix: minor fixes and refactorings

* fix: warzone fixes

* fix: questlog fixes

* fix: bigfoot burden quest descriptions

* fix: minor fixes

* feature: bestiary - gryphon is rare; iks apu is common

* fix: add missing cow monster

* feature: add custom bestiary kill counts

* improve: weaken magic shield

* improve: disable manashield potion

* batch map updates

* fix: inventory related fixes

* batch map update

* fix: temporarily bring back 13.40 original assets

* improve: update vsc launch config

* fix: gamestore exp price (#3496)

By making this modification it will work and visually the correct amount
of expboost will be charged.

* fix: suspicious device wrong id (#3492)

* feat: talkaction playericon (#3488)

This new command is to add an icon to the player, it also has a counter
function to use the command, follow the examples:

/playericon 1, 10 -- this way it will apply icon 1 with the counter at
10 and it will decrease every second after reaching 0, it will be
removed after 10 seconds.

/playericon 1, 10, up -- this way the counter will start at 0 and will
go up to 10 after 10 seconds, it will remove the icon.

* fix the lootmonger remotely trade. (#3482)

Fix the npc lootmonger where players can shop remotely from anywhere.

Fixes #3481

* fix: check value purchase exp boost (#3501)

Related to pr: https://github.com/opentibiabr/canary/pull/3496

* build: update to recent vcpkg to fix compilation (#3503)

Update ThreadPool and magic_enum includes for vcpkg compatibility

- Adapt ThreadPool implementation to the updated BS::thread_pool v5.0.0
interface:
- Changed inheritance from `BS::thread_pool` to
`BS::thread_pool<BS::tp::none>`.

- Updated magic_enum include directives following recent vcpkg changes:
  - Changed from `<magic_enum.hpp>` to `<magic_enum/magic_enum.hpp>`.

These updates resolve compilation issues arising after recent vcpkg
dependency updates.

* fix: player bypassing SQM restrictions when pushed (#3480)

Fix #3475

* fix: mana drain on analyzer (#3473)

Show mana drain on input analyzer

* fix: wrap/unwrap owner bug for on use items (#3474)

Items that were "used" and transformed into others lost their store
attribute when wrapping/unwrapping and could no longer be moved to the
inbox store.

* fix: toolgear lua log error (#3465)

This solves the log error associated with the use of toolgears.

[error] Lua Script Error Detected
---------------------------------------
Interface: Scripts Interface
Script ID: /home/samuk/canary-base/canary/data/scripts/actions/tools/toolgear.lua:callback
Error Description: ...ry/data-otservbr-global/scripts/lib/register_actions.lua:675: attempt to call method 'getActionId' (a nil value)
stack traceback:
        [C]: in function 'getActionId'
        ...ry/data-otservbr-global/scripts/lib/register_actions.lua:675: in function 'onUsePick'
        ...nary-base/canary/data/scripts/actions/tools/toolgear.lua:7: in function <...nary-base/canary/data/scripts/actions/tools/toolgear.lua:3>
---------------------------------------
[error] Lua Script Error Detected
---------------------------------------
Interface: Scripts Interface
Script ID: /home/samuk/canary-base/canary/data/scripts/actions/tools/toolgear.lua:callback
Error Description: ...ry/data-otservbr-global/scripts/lib/register_actions.lua:949: attempt to call method 'getId' (a nil value)
stack traceback:
        [C]: in function 'getId'
        ...ry/data-otservbr-global/scripts/lib/register_actions.lua:949: in function 'onUseSpoon'
        ...nary-base/canary/data/scripts/actions/tools/toolgear.lua:10: in function <...nary-base/canary/data/scripts/actions/tools/toolgear.lua:3>

* fix: kilmaresh ladders (#3437)


Ladders in Issavi (ids 31129 and 31130) are not steppable but clickable
instead. This only fixes that.

* Merge canary upstream changes (#59)

* fix: crash when spawn cleanup (#3034)

Crash fix introduced in #2913 

This crash occurs when the iterator attempts to access a container that
was modified during the creature removal process, while
spawnedMonsterMap and/or erase_if is being executed.

* feat: new augments and update item description (amber items) (#2900)

This updates the augments to be able to handle the substitution of
the Increase Damage, Strong Impact and Powerful Impact into Base Damage
and Base Healing. It also adds the new item description to handle the
new Amber Items with elemental attack greater than 0 and physical attack
value equal 0.

* improve: AreaSpawnEvent::executeEvent remove unused variable (#3036)

Removed unused variable and added pointer to const ref.

* improve: account enums direcly instead of raw types (#3038)

Added a function to Database::getNumber to call enums directly, making maintainability easier.

* docs: add CONTRIBUTING.md Guidelines for Canary Project (#3041)

This PR introduces a comprehensive CONTRIBUTING.md file to guide new and
existing contributors to the Canary project. The document includes
sections covering our Code of Conduct, development standards, issue and
pull request guidelines, and usage of the KV System for data
persistence. It also sets expectations for code formatting, quality, and
contribution best practices, helping ensure that contributions align
with project standards and goals.

* fix: browseField crash, improve readability, fix shadowing (#3031)

This refactors the `Container::create` function and rename to
`createBrowseField` for improved readability and maintainability. The
refactor includes using `continue` to skip iterations early when items
do not meet specific conditions, reducing nesting and making the code
clearer. Additionally, it resolves a critical issue where two different
`container` variables were confused within the same loop, which could
lead to bugs.

These changes ensure the function is cleaner and less prone to errors,
making the logic behind item addition more transparent.

* feat: add mystery box item action (#3040)

When using mystery box after getting from the NPC (which is only
possible after defeating final boss of cults of tibia), not is happening.

* fix: some conflict errors (#3048)

Fixed some issues caused by git conflicts.

* improve: load player town and fix player badge escape string (#3055)

Simplified the town assignment logic when loading player data:
- If the town ID associated with the player is invalid, the system will
first attempt to assign the town "Thais". If "Thais" is unavailable, the
player is assigned the first valid town from the list.
- This change reduces the chain of conditional checks, making the logic
more readable and efficient, while ensuring a player is assigned to a
valid town whenever possible.

Fix for Escaping Strings in PlayerBadge:
- Added proper string escaping using `g_database().escapeString()` in
`PlayerBadge::getPlayersInfoByAccount()` to prevent SQL syntax errors
when player names contain special characters.
- This fix addresses issues with malformed queries that previously
resulted in SQL syntax errors.

* fix: prevent crash in condition light division (#3053)

Fix #3047 

Now min light level is always 1, prevent division by zero.

* fix: remove mystery box duplicated action (#3057)

* improve: optimize experience gain and loss calculations (#2905)

Optimized the experience gain and loss calculations in the
`onGainExperience` and `onLoseExperience` functions, adjusting the
application of bonuses like stamina, VIP, and boosted creatures. This
ensures more efficient performance and more accurate handling of player
experience management.

* fix: character cyclopedia item inspection imbuements (#3065)

This fixes the icons from the character item imbuements inspection cyclopedia.

* style: tryAddEvent to safeCall (#3045)

safeCall basically keeps calls safe when they are being executed
asynchronously, that is, if the calls inside safeCall are being executed
in a thread other than the dispatcher, they will simply be sent to that
thread, thus avoiding concurrency.

What I just wrote is already being done with tryAddEvent, but it is not
a very intuitive name, and it is visually polluted. In the safeCall
method, besides being short, you can simply send 'this' as a parameter
to the lambda, without having to fear that its execution will be done
when the reference no longer exists, because inside safeCall, there is a
reference check, if it has already been destroyed, it will simply not be
executed.

* improve: safecall (#3072)

Added check if creature was removed.

* improve: prevent crash in checkCreatures (#3073)

Apparently the creature can be destroyed while it is running in
checkCreatures, so let's increase the counter to ensure it still exists.

Note: It's had a rare crash while doing some testing.

* perf: remove unnecessary event callbacks (#3076)

Removed Lua callbacks from `MonsterType` of various monsters. These
callbacks were empty, which meant the functions were still being
"called" by the monsters without performing any action, creating a
significant performance bottleneck.

Removed the `onHear` event callback, which had a significant impact on
the server and was not used anywhere. It executed the `onHear` callback
for each spectator, causing an unnecessary overload without any real
benefit, especially as we have other methods to check for these events.

Additionally, the `monsterOnSpawn` event callback was removed and
replaced with `MonsterType::onSpawn`, which is much more efficient since
it only needs to be declared in the script for each monster that
actually uses it.

Finally, the way `setRewardBoss` was handled was improved. Previously,
it was executed in an `onSpawn` event callback, but now it is done
directly during the parsing of each monster script, marking them as
reward bosses at the time of script loading, improving efficiency.

* improve: add check to boosted boss name empty (#3081)

Checks if the boosted boss name is empty

* improve: lower boss name on boss lever system (#3070)

This ensures the integrity of the name during searches. If a name is
added with a different capitalization than the monster's actual name, it
can lead to conflicts, preventing the onDeath code from executing
properly.

* fix: review quests version 11 (#3049)

Fixing the PR #2938 levers and related parts. Since the original code
was quite extensive, perhaps some mechanics that should have been done
when pulling the lever were removed.

* fix: object variable renamed (#3082)

fixed the cobras console error, the problem was being caused because of
the object name handleCobraOnSpawn

* fix: creature teleport with dispatcher walk event (#3066)

Resolves bug implemented after: #2933

* feat: add new "soul cores" market category (#3092)

New category from 13.40
Uses with: https://github.com/Arch-Mina/Assets-Editor/pull/36

* improve: fix circular dependencies on iologindata.hpp (#3093)

* improve: fix circular dependencies on weapons.hpp (#3094)

* fix: speed and conditions (#3063)

This fixes the high speed bug that overflow the uint16_t because the
lack of checks and also fixes the conditions mysql issue when saving
conditions greater than 64KB.


Fixes #2712 
Fixes #2456

* fix: typo and missing lookfeet (#3054)

Missing lookFeet.
Default colours.
Fix typos.

* improve: spectators and map sector (#3062)

Improves the spectators to find monsters and npcs, adds excludeMaster
and excludePlayerMaster to filter monsters without masters. Added
vectors to cache the monsters and npcs in spectators and map sectors as
well.

* fix: house mailboxes (#3096)

Fixes the houses mailbox that were not sending parcels and consuming
them.

Fixes #2891

* cleanup: remove unnecessary inheritance from lua interface classes (#3046)

Fixed circular dependencies
Removed various unnecessary inheritance from lua interface
Removed legacy unused codes

* fix: remove empty if block and prevent use of pointer after erase (#3098)

This removes an empty `if` block that was originally used back when
pointer management was manual using raw pointers (*). At that time,
the 'if' block was intended to decrement the reference counter in a
manual garbage collection mechanism. Since the project now uses modern
smart pointers, this block has become obsolete and can be safely removed
without affecting functionality.

The change also prevents the use of the 'container' pointer after
erasing the iterator 'it' from the 'openContainers' map, which was
causing undefined behavior and potential crashes.

* improve: removed cache map dead code (#3086)

As per this PR: #2667

useCacheMap has been disabled, but the code is still there just for
decoration, so this PR will remove all that code.

* feat: add soul core items (#3099)

Add 660 Soulcore items, in preparation to further Soulpit Development.

* fix: freequests storages (#3044)

* fix: safe call add creatures on tile get/creation (#3090)

* fix: combat type out of index in ashes item (#3106)

Fixes #2874

* fix: remove bit_functions from vcxproj (#3108)

At some point, the bit_functions.cpp and bit_functions.h files were
removed from the project, but they continued to be referenced in the
Visual Studio .vcxproj file, causing an error when trying to compile
using it.

* fix: add source location to combatTypeToIndex (#3095)

* fix: wheel bonuses (#3058)

This fixes all vocations wheel spell and gem bonuses, const references
and refactors.

Fixes #3032 
Fixes #2150 
Fixes #2039

* fix: sending items to stash interrupted by items obtained from store (#2886)

• When send items from a container to the stash, the process is
interrupted when there are items obtained from the store.
• Fixed issue with sending items from the loot pouch to the stash

* fix: crash concurrent modification/casting in tile management (#3107)

This adds the implementation for dynamically determining the type of
tile (HouseTile, StaticTile, DynamicTile) when creating a new tile
object. The motivation is to correctly identify and assign specific tile
types, which enhances code readability and maintainability. The change
also ensures that houses have associated HouseTile objects for better
data integrity.

* refactor: move blessing bytes to cpp (#3064)

Moving bytes from modules to cpp.

* fix: teleport effect from "onUse" actions (#3109)

Fixed teleport effect from "onUse" actions and passed some pointers to const ref

* fix: transfer house crash (#3104)

This addresses an issue in the 'House::resetTransferItem function where
the 'transferItem' pointer was being set to 'nullptr' before being used
later in the function, leading to potential undefined behavior or
crashes. The solution involves reordering the operations to ensure that
'transferItem' is only set to 'nullptr' after all required operations
are completed. This change ensures that the object remains accessible
until all necessary manipulations are performed.

* improvement: enable custom duration and simplify expiration calculation (#3083)

Allows setting a custom ban duration and simplifies the expiration time
calculation.

* enhance and refactor: multiple scripts for better functionality (#3007)

1. Fixes a minor issue where, when emptying the balloons, they were
transformed into 255 instead of being reset to 1.
2. Adjusts the usage of the "bathtub" in datapacks, in addition to the
RLMap, ensuring better compatibility.
3. Makes minor aesthetic changes to enhance the code's readability.

Resolves #2923

* cleanup: simplify some account functions and fix console error (#3110)

Removes a duplicate function.
Fixed console error related to missing string.format.

* fix: disable ladder effect and add support for all ladders (#3114)

This PR updates the teleport action for ladders by disabling the effect
when using the ladder and modifying the logic to support all ladder IDs
dynamically.

1. The effect of moving up or down is now disabled when using the
ladder.
2. The script now automatically recognizes all ladder IDs, removing the
need for hardcoded values.

* fix: resolve nil index issue in destroy script callback (#3117)

Fixed an error in the item destruction script where calling
`ActionsLib.destroyItem` resulted in a `nil` reference. The function
call was adjusted to use `destroyItem` directly, ensuring the script
works correctly and avoids global index errors.

* fix: wheel spells bonuses (#3122)


This fixes the issue that some spells was sharing bonuses between all
other spells

* fix: blessings calculations (#3126)

Wrong blessing calculations

* fix: wands and rods chain damage (#3128)

This fixes the damage when chain system enabled for wands and rods.

Fixes #2472

* fix: ebb and flow boat summons teleport (#3125)


This fixes the ebb and flow boat teleport that was not teleporting
player summons

Fixes #2943

* fix: xp rates display (#3123)

This fixes the display xp rates with low level bonus and boost xp.

* fix: forge history (#3124)

This fixes the history forge that is crashing the server trying to
access an index of a empty vector.

Fixes #3121

* fix: sharpshooter not applying paralyze icon (#3119)

This commit aims to fix a problem that occurs when a player cast
sharpshooter.
The main behavior should be remove haste icon and apply paralyze,
counting on the speed decrease.

* perf: replace manual function name extraction with std::source_location (#3132)

Replaced the previous string concatenation approach for logging function
names with `std::source_location::current().function_name()`. This
change significantly improves performance by avoiding runtime string
operations. Instead of manually manipulating function signatures using
`methodName` to extract function names, `std::source_location` provides
this information directly in an efficient manner.

* feat: specific meal purchase option for hireling (#3105)

This update introduces a new feature for the hireling NPC, allowing
players to choose specific meals for 90,000 gold, aligning with the
latest global updates. The NPC now prompts players with options for a
"specific" or "surprise" meal, guiding them through the selection
process. If "specific" is chosen, players are presented with a list of
available dishes.

* fix: lua getNumber overflow with "MoveEvent::EquipItem" function (#3136)

Fixed overflow with "MoveEvent::EquipItem" and added imbuement shrine to canary temple

* fix: remove duplicate "update impact tracker" for elemental damage (#3137)

It's already send here:
https://github.com/opentibiabr/canary/blob/729387bc8b8a6171de32d936a6442cb285c9da42/src/game/game.cpp#L7375

* fix: quiver replacement logic and shield-weapon equip handling (#3138)

• Added logic to replace an existing quiver when equipping a new one,
ensuring proper unequip and feedback to the player.
• Refactored shield equip logic to properly handle scenarios where a
two-handed weapon is equipped in the left slot, preventing unnecessary
unequips.
• Improved equip flow to ensure consistent behavior for different weapon
and item types, avoiding conflicts between equipped items.

* fix: initialize totalCost correctly and refactor blessing purchase logic (#3142)

This fixes the initialization of the `totalCost` variable and
refactors the blessing purchase logic. Improvements include replacing
string concatenation with `string.format` for more efficient formatting,
as well as adjustments for better code clarity and readability. The code
is now more organized, and the calculation error has been fixed.

* fix: prevent teleportation (#3143)

This fixes an issue where the player was teleported even when a Lua
script was blocking the action.

* fix: item usage mechanics to obtain Phantasmal Jade (#3112)

This fixes the item usage mechanics for obtaining the
Phantasmal Jade mount.
It ensures that the correct number of items are used, and the mount is
granted when all requirements are met.
Additionally, it automates the registration of item IDs to simplify the
code and reduce redundancy.

Close #3100

* fix: boss lever check god access (#3141)

Check god access instead of normal, to ensure that tutors also count towards the cooldown

* fix: wrong loot items from bosses (#3148)

* fix: crash on try gem grade upgrade greater than 3 (#3151)

Fixes the crash when trying to upgrade gem to a grade greater than 3

* perf: optimize getInbox usage and shared pointer handling in loops (#3150)

This addresses performance issues by optimizing the use of shared
pointers and removing redundant calls. Specifically, the `getInbox` call
was removed from extensive loops to prevent unnecessary reference count
increments, which were causing CPU overhead. Additionally, shared
pointers used in recursive or iteration-heavy functions, such as the
`ContainerIterator`, were changed to `const&` where applicable, reducing
the impact of reference counting on performance.

* fix: console error related to wrong "monster" to "self" (#3166)

* fix: docker gha build workflow (#3167)

* fix: check creatures crash (#3168)

* perf: multithreading in updateTargetList in all events (#3074)

Previously, the multithreading of updateTargetList only worked for walk
events, now all requests to these methods will be executed async.

* refactor: split player death event handler into smaller functions (#3113)

This refactors the PlayerDeath event script to improve code
readability and maintainability. The original function has been split
into smaller, more focused functions, each handling a specific part of
the player death processing logic. This includes identifying the killer,
logging deaths in the database, sending messages to the guild channel,
and checking guild wars.

With this refactoring, the code is more modular and easier to
understand, making future modifications and maintenance more manageable.
The PlayerDeath event logic remains unchanged, ensuring the system
continues to function as expected.

Changes:
•. Split the onDeath function into smaller local functions.
•. Improved SQL query formatting using string.format for clarity and to
avoid repetitive code.
•. Renamed local variables to follow the camelCase convention.

* perf: onRemoveCreature->onCreatureLeave async (#3152)

the call to onCreatureLeave in Monster::onRemoveCreature will be called
asynchronously.

* fix: resolve nil value errors in handleGuildWar function (#3172)

I made corrections to the `death.lua` script to resolve nil value errors
in the `handleGuildWar` function. I added checks to ensure that both the
player and the killer are valid and that both belong to a guild before
proceeding with the guild war logic. This helps prevent failures when
one of the objects is undefined.

Fixes from: https://github.com/opentibiabr/canary/commit/3c98b4161cd9c25e57e61945fe6358d604242b27

* fix: packet interpretation parseSetOutfit for otcv8/old protocol (#3162)

Resolves #3155

* Compatibility with Basic CPUs (#3146)

Some servers or vps now come with modifications for basic cpu such as:
QEMU Virtual CPU version 2.5+, this function makes it possible to run
canary

* Improve: creature actions (#3084)

Some creature actions, such as checkCreatureAttack, checkCreatureWalk,
updateCreatureWalk, were processed based on the creature ID, as canary
works with smart pointer, we no longer have problems working with the
object reference, before it used the ID to maintain security, because at
the time of execution, the object could no longer exist.

* perf: onThink multithreading (#3075)

* improve: migration database update (#3071)

This improves the database migration process by removing the need to
manually define if more migrations are required with return values in
Lua scripts. The new approach automatically processes all migration
files based on their version, reducing complexity and making the update
process more robust. This change aims to streamline the database update
logic and eliminate manual steps previously required.

* fix: remove unsupported compiler flags for MSVC (#3173)

Resolves warnings issued during the Windows build
process with MSVC caused by unsupported compiler flags `(-march, -mtune,
-mno-avx, and -mno-sse4)`.

* fix: infinite loop in Zone:randomPosition when no valid tile exist (#3178)


This commit fixes an infinite loop issue in the `Zone:randomPosition`
function. When no valid positions (walkable tiles) exist in the zone,
the function would previously enter an infinite loop. The updated logic
now filters all positions upfront to identify walkable tiles, and if
none are found, the function returns `nil` with appropriate logging.
This change ensures better error handling and prevents server freezes
due to infinite loops.

* fix: position after try to cross bridge (#3175)


The problem was that the ladder action was executed first, followed
immediately by the teleportTo action, causing the Player to move above
the ladder with the possibility of crossing the bridge.

* enhance: Monster::getDanceStep code duplication (#2997)


Refactored the `getDanceStep` function to avoid code duplication by
introducing a helper function `tryAddDirection`. This change improves
code readability and maintainability by reducing repetitive logic.

* fix: hazard spawn initialization (#3184)

Fixes bugs introduced here:
https://github.com/opentibiabr/canary/pull/3076

By mistake I removed the onSpawn from the hazard and didn't realize it.

* fix: suppress get byte log (#3185)

Resolves #3153

This simple "suppress" the "getByte" log, some locations send "0" by
default, so we don't need to send log in these locations.

* fix: death call several times (#3186)


fix #3177

* fix: warning on decode lenght (#3188)

Resolves #3002

* fix: for lava tiles in entrance of The Pits of Inferno Quest (#3196)

Implements an alternative solution to handle lava
tiles in The Pits of Inferno Quest. The logic in register_actions.lua
has been modified to transform existing lava items (ID: 21477) into the
floor item (ID: 5815) using Tile:getItemById and Item:transform, instead
of relying on Game.createItem.
This addresses an issue where lava tiles in The Pits of Inferno Quest
were not behaving as expected
Resolves #3144

* fix: party shared experience (#3133)

This fixes the party shared experience that was not providing the correct amount of experience giving the unique vocations count and party size.

* feat: cyclopedia house auction (#3022)

* fix: damage console (#3203)

* fix: adjust character limit for player names (#3174)

* fix: lava lurker heals on fire damage (#3176)

* fix: add missing storage breaking the ice quest (#3201)

* feat: monsters and npcs rotten blood quest (#2686)

* fix: imbuement shrine and time guardian script errors (#2877)

* fix: problem with stack of items on the podium after server save (#2879)

* fix: distro rotten blood quest warnings (#3204)

* fix: balancing 13.40 (#3206)

* feat: add missing constants for client OS (#3179)

* fix: thorgrin callbacks (#3202)

* fix: prevent player corpses from being removed during tile cleaning (#3205)

* fix: preserve decimal precision for skill percentage calculation (#3207)

* fix: remove unnecessary function for data-canary (#2973)

* feat: create database backup on server shutdown (#3069)

This update introduces a refined automatic database backup feature
during the server shutdown process. The main improvements include:

1. Automatic Compression: The database backup is now always
compressed using gzip, reducing disk space usage.

2. Backup Management: The system organizes backup files into folders
named by date and automatically deletes backups older than 7 days. This
ensures that the backup storage remains manageable over time without
manual intervention.

The motivation behind these changes is to create a more efficient and
reliable way of managing database backups, ensuring dat…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants