-
-
Notifications
You must be signed in to change notification settings - Fork 632
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
fix: crash when removing items during iteration with ContainerIterator #2901
Conversation
4ae2f7e
to
137c8fd
Compare
ef32935
to
56822e5
Compare
I've installed this on 100+ server that goes into infinite |
There is a server with 100+ users testing for over 5 days, and so far no issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and working.
d062854
to
4e5b724
Compare
c4245f5
to
0f25cff
Compare
185db07
to
a2514d3
Compare
925f1be
to
439b49b
Compare
Quality Gate passedIssues Measures |
commit 89b3073 Author: murilo09 <78226931+murilo09@users.noreply.github.com> 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 <eduardo.dantas@hotmail.com.br> 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 <daniel15042014@hotmail.com> 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 <eduardo.dantas@hotmail.com.br> commit 469e09a Author: Pedro Cruz <phac@cin.ufpe.br> 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 <eduardo.dantas@hotmail.com.br> 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 <mehah@users.noreply.github.com> commit 6f9754f Author: Renato Machado <mehahx@gmail.com> 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 <78324439+aokisama@users.noreply.github.com> 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 <eduardo.dantas@hotmail.com.br> 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 <marcomoa@hotmail.com> 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 <marcomoa@hotmail.com> 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 <eduardo.dantas@hotmail.com.br> 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 <eduardo.dantas@hotmail.com.br> 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 <marcomoa@hotmail.com> 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 <130802152+LeoPetryx@users.noreply.github.com> 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 <eduardo.dantas@hotmail.com.br> 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 <royalpudim@gmail.com> 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 <pessoacarlos98@gmail.com> 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 <41605307+LeoTKBR@users.noreply.github.com> 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. <168607226+kaleohanopahala@users.noreply.github.com> 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 <pessoacarlos98@gmail.com> 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 <royalpudim@gmail.com> 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 <87909998+FelipePaluco@users.noreply.github.com> 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 <87909998+FelipePaluco@users.noreply.github.com> 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 <daniel15042014@hotmail.com> Date: Sun Oct 13 00:54:20 2024 -0300 update: gha build (opentibiabr#2641) commit c4786c4 Author: Beats <daniel15042014@hotmail.com> Date: Sat Oct 12 19:29:22 2024 -0300 perf: build cmake (opentibiabr#2972) commit 34baa0a Author: Leilani A. <168607226+kaleohanopahala@users.noreply.github.com> 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 <eduardo.dantas@hotmail.com.br> 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 <130802152+PetryNotak@users.noreply.github.com> 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 <marcomoa@hotmail.com> 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 <eduardo.dantas@hotmail.com.br> 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 <eduardo.dantas@hotmail.com.br> 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 <eduardo.dantas@hotmail.com.br> Date: Wed Oct 9 18:15:14 2024 -0300 improve: remove qodana and fix eventcallback error (opentibiabr#2958) commit aff5014 Author: Eduardo Dantas <eduardo.dantas@hotmail.com.br> Date: Wed Oct 9 17:47:56 2024 -0300 ci/cd: remove qodana (opentibiabr#2957) commit c229548 Author: Eduardo Dantas <eduardo.dantas@hotmail.com.br> Date: Wed Oct 9 17:42:13 2024 -0300 fix: eventcallback crash (pointer uninitialized) (opentibiabr#2956) commit 90e205d Author: Eduardo Dantas <eduardo.dantas@hotmail.com.br> 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 <eduardo.dantas@hotmail.com.br> 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 <eduardo.dantas@hotmail.com.br> Date: Wed Oct 9 15:52:53 2024 -0300 fix: sonarcloud check (opentibiabr#2954) commit 01e9a81 Author: Eduardo Dantas <eduardo.dantas@hotmail.com.br> Date: Wed Oct 9 14:59:32 2024 -0300 fix: sonarcloud (opentibiabr#2953) commit da92674 Author: Leonardo <130802152+PetryNotak@users.noreply.github.com> 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 <eduardo.dantas@hotmail.com.br> 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 <eduardo.dantas@hotmail.com.br> 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 <eduardo.dantas@hotmail.com.br> 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 <roberto.f@hotmail.com.br> Date: Wed Oct 2 20:13:23 2024 -0300 fix: stamina green delay (opentibiabr#2884) commit 1d921ae Author: kokekanon <114332266+kokekanon@users.noreply.github.com> Date: Wed Oct 2 20:12:55 2024 -0300 fix: colored text loot in OTC 13.40 (opentibiabr#2929) commit b503adb Author: HT Cesta <58153179+htc16@users.noreply.github.com> Date: Wed Oct 2 20:12:07 2024 -0300 fix: quests from version 10 revised (opentibiabr#2855) commit e938b75 Author: Eduardo Dantas <eduardo.dantas@hotmail.com.br> 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 <eduardo.dantas@hotmail.com.br> 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 <eduardo.dantas@hotmail.com.br> 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 <eduardo.dantas@hotmail.com.br> 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 <eduardo.dantas@hotmail.com.br> Date: Fri Sep 27 23:46:00 2024 -0300 fix: convergence wrong price calculation (opentibiabr#2918) Resolves opentibiabr#2523 commit 11bd3a6 Author: Eduardo Dantas <eduardo.dantas@hotmail.com.br> Date: Tue Sep 24 21:37:48 2024 -0300 fix: forge correct slots (opentibiabr#2850) Resolves opentibiabr#2718 commit 4bc7a5c Author: Eduardo Dantas <eduardo.dantas@hotmail.com.br> 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 <eduardo.dantas@hotmail.com.br> 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 <luanluciano@outlook.com> 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 <luanluciano@outlook.com> 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 <marcomoa@hotmail.com> 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 <marcomoa@hotmail.com> 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 <eduardo.dantas@hotmail.com.br> 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 <pessoacarlos98@gmail.com> 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 <eduardo.dantas@hotmail.com.br> Date: Wed Sep 18 22:51:17 2024 -0300 fix: qodana linter (opentibiabr#2902) commit b3b19a6 Author: Pedro Cruz <phac@cin.ufpe.br> 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 <luanluciano@outlook.com> Date: Sat Sep 14 15:59:58 2024 -0300 fix: field doesn`t display the condition (opentibiabr#2882) commit 687aba5 Author: Eduardo Dantas <eduardo.dantas@hotmail.com.br> 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 <eduardo.dantas@hotmail.com.br> 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 <phac@cin.ufpe.br> commit a9e4875 Author: Paulo Henrique Lisboa <phlinho10@gmail.com> Date: Wed Sep 11 11:10:25 2024 -0300 fix: wild growth (opentibiabr#2885) commit b330a33 Author: Karin <pessoacarlos98@gmail.com> 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 <andreoam@gmail.com> Date: Fri Sep 6 10:35:31 2024 -0300 fix: container:addItem missing return (opentibiabr#2857) commit d4b1b61 Author: Eduardo Dantas <eduardo.dantas@hotmail.com.br> Date: Thu Sep 5 21:16:38 2024 -0300 fix: remove bakragore icons talkaction (opentibiabr#2828) commit 8056ca6 Author: Majesty <32709570+majestyotbr@users.noreply.github.com> Date: Thu Aug 29 19:45:55 2024 -0300 fix: datapacks tools actions (opentibiabr#2851) commit a154773 Author: Majesty <32709570+majestyotbr@users.noreply.github.com> Date: Thu Aug 29 09:00:26 2024 -0300 fix: data-canary errors and warnings (opentibiabr#2844) commit 0d924e8 Author: Majesty <32709570+majestyotbr@users.noreply.github.com> 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 <63259115+hecmo94@users.noreply.github.com> commit 0f8929d Author: Majesty <32709570+majestyotbr@users.noreply.github.com> 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. <168607226+kaleohanopahala@users.noreply.github.com>
Description
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.
Behaviour
Actual
Removing items from a container during iteration causes a crash due to invalidated iterators.
Example: During an event or action that removes items while iterating, the server crashes.
Expected
Items can be safely removed from a container during iteration without causing a crash.
The iteration continues correctly, and the application remains stable.
Type of change
How Has This Been Tested
We conducted tests to verify that the crash no longer occurs when items are removed during iteration:
Test A: Used a command (!container) that iterates over a player's backpack and removes items during iteration. Confirmed that no crash occurs and all items are removed safely.
Test the command before this implementation, it will crash. This can happen in various contexts, for example, during the reading of the "itemlist" in a loop, and the player removes an item from the container being read, it will cause a crash because it invalidates all iterators.
After implementing the fix, the crash will no longer occur with the command above, and it likely won't happen in other scenarios either.
NOTE: In the code, the "container->removeItem(item)" function will disrupt the iterator's count, but it will neither crash nor cause any errors. This happens because the iterator becomes unreliable when the container is modified during iteration. However, it effectively prevents a crash, which is our primary objective. If you want to test only the amount of items scanned, comment out the "removeItem.
Checklist
Fixes this crash:
crash-container-iterator.log