-
-
Notifications
You must be signed in to change notification settings - Fork 741
fix: concurrency crash on item attributes #3304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lamonato29
approved these changes
Jan 30, 2025
|
vllworldbuilding
pushed a commit
to vllworldbuilding/canary
that referenced
this pull request
Mar 3, 2025
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.
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 <phac@cin.ufpe.br> * 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 <146901121+valdzera@users.noreply.github.com> * 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 <146901121+valdzera@users.noreply.github.com> * 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 <146901121+valdzera@users.noreply.github.com> * fix: add ui exhausted to imbuement apply/clear (opentibiabr#3455) * feat: features OTCR natively in canary (opentibiabr#3061) Client modification: Feature improvements per mehah/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 <eduardo.dantas@hotmail.com.br> * 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. <168607226+kaleohanopahala@users.noreply.github.com> Co-authored-by: Pedro Cruz <phac@cin.ufpe.br> Co-authored-by: Eduardo Dantas <eduardo.dantas@hotmail.com.br> Co-authored-by: Felipe Paluco <87909998+FelipePaluco@users.noreply.github.com> Co-authored-by: murilo09 <78226931+murilo09@users.noreply.github.com> Co-authored-by: Marco <marcomoa@hotmail.com> Co-authored-by: Renato Machado <mehahx@gmail.com> Co-authored-by: Paulo Henrique Lisboa <phlinho10@gmail.com> Co-authored-by: HT Cesta <58153179+htc16@users.noreply.github.com> Co-authored-by: Felipe Muniz <felipemuniznet@gmail.com> Co-authored-by: Luan Luciano <luanluciano@outlook.com> Co-authored-by: valdzera <146901121+valdzera@users.noreply.github.com> Co-authored-by: kokekanon <114332266+kokekanon@users.noreply.github.com> Co-authored-by: odisk777 <65802862+odisk777@users.noreply.github.com> Co-authored-by: Felipe Pessoa <pessoa.93@hotmail.com> Co-authored-by: Jean Carlo de Souza <jeanifpr@gmail.com> Co-authored-by: pudimtibia <royalpudim@gmail.com> Co-authored-by: Filipe Arruda <66535966+arrudaqs@users.noreply.github.com> Co-authored-by: Elson Costa <elsongabriel@hotmail.com> Co-authored-by: mdbeng <37564938+mdbeng@users.noreply.github.com> Co-authored-by: Sorairei <79299476+Sorairei@users.noreply.github.com> Co-authored-by: feliphechaves <40308692+feliphechaves@users.noreply.github.com> Co-authored-by: Samuel Gomes <samuelbfgomes@gmail.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: aphirotx <patrickctris91@gmail.com> Co-authored-by: Jonyrewind <jonyrewind@gmail.com> Co-authored-by: Guilherme <guilherme.vrsantana@gmail.com> Co-authored-by: Aerwix <26527255+Aerwix@users.noreply.github.com> Co-authored-by: bdzicc <52944047+bdzicc@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR refactors the
Attributes
class by replacingstd::shared_ptr<std::string>
withstd::string
in thevalue
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.Fix this crash: update_door.log
Behaviour
Actual
If an attribute stored a
std::shared_ptr<std::string>
, there were cases where the reference was lost or improperly accessed, leading to crashes when trying to retrieve the string.Expected
Attributes now store
std::string
directly, preventing dangling pointers and reducing overhead related to shared pointer allocation and dereferencing.Type of change
How Has This Been Tested
Checklist