Skip to content

Commit

Permalink
Merge branch 'main' into dudantas/fix-container-iterator-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas committed Sep 30, 2024
2 parents b2e79e2 + e938b75 commit 5523237
Show file tree
Hide file tree
Showing 207 changed files with 1,278 additions and 1,063 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@ option(RUN_TESTS_AFTER_BUILD "Run tests when building" OFF) # By default, tests
# *****************************************************************************
add_subdirectory(src)

if(BUILD_TESTS)
if(BUILD_TESTS OR PACKAGE_TESTS)
add_subdirectory(tests)
endif()
4 changes: 1 addition & 3 deletions cmake/modules/CanaryLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ add_subdirectory(utils)
target_sources(${PROJECT_NAME}_lib PRIVATE canary_server.cpp)

# Add public pre compiler header to lib, to pass down to related targets
if (NOT SPEED_UP_BUILD_UNITY)
target_precompile_headers(${PROJECT_NAME}_lib PUBLIC pch.hpp)
endif()
target_precompile_headers(${PROJECT_NAME}_lib PUBLIC pch.hpp)

if(NOT SPEED_UP_BUILD_UNITY AND USE_PRECOMPILED_HEADERS)
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC -DUSE_PRECOMPILED_HEADERS)
Expand Down
2 changes: 0 additions & 2 deletions src/account/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "account/account.hpp"

#include "account/account_repository_db.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/account/account_repository.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "account/account_repository.hpp"

#include "lib/di/container.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/account/account_repository_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "account/account_repository_db.hpp"

#include "database/database.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/canary_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "canary_server.hpp"

#include "declarations.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "config/configmanager.hpp"
#include "lib/di/container.hpp"
#include "game/game.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/appearance/mounts/mounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/appearance/mounts/mounts.hpp"
#include "game/game.hpp"
#include "utils/pugicast.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/appearance/outfit/outfit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/appearance/outfit/outfit.hpp"
#include "utils/pugicast.hpp"
#include "utils/tools.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "declarations.hpp"
#include "creatures/combat/combat.hpp"
#include "lua/creature/events.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/combat/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/combat/condition.hpp"
#include "game/game.hpp"
#include "game/scheduling/dispatcher.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/combat/spells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/combat/combat.hpp"
#include "creatures/combat/spells.hpp"
#include "creatures/monsters/monster.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/creature.hpp"
#include "declarations.hpp"
#include "game/scheduling/dispatcher.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/interactions/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/interactions/chat.hpp"
#include "game/game.hpp"
#include "utils/pugicast.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/monsters/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/monsters/monster.hpp"
#include "creatures/combat/spells.hpp"
#include "creatures/players/wheel/player_wheel.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/monsters/monsters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/monsters/monsters.hpp"

#include "creatures/combat/spells.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/monsters/spawns/spawn_monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/monsters/spawns/spawn_monster.hpp"
#include "game/game.hpp"
#include "creatures/monsters/monster.hpp"
Expand Down
14 changes: 7 additions & 7 deletions src/creatures/monsters/spawns/spawn_monster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ class SpawnMonster {

// moveable
SpawnMonster(SpawnMonster &&rhs) noexcept :
spawnMonsterMap(std::move(rhs.spawnMonsterMap)),
spawnedMonsterMap(std::move(rhs.spawnedMonsterMap)),
checkSpawnMonsterEvent(rhs.checkSpawnMonsterEvent), centerPos(rhs.centerPos), radius(rhs.radius), interval(rhs.interval) { }
spawnMonsterMap(std::move(rhs.spawnMonsterMap)),
centerPos(rhs.centerPos),
radius(rhs.radius),
interval(rhs.interval),
checkSpawnMonsterEvent(rhs.checkSpawnMonsterEvent) { }

SpawnMonster &operator=(SpawnMonster &&rhs) noexcept {
if (this != &rhs) {
Expand Down Expand Up @@ -77,15 +80,12 @@ class SpawnMonster {
void setMonsterVariant(const std::string &variant);

private:
// map of the spawned creatures
// The map of the spawned creatures
std::map<uint32_t, std::shared_ptr<Monster>> spawnedMonsterMap;

// map of creatures in the spawn
// The map of creatures in the spawn
std::map<uint32_t, spawnBlock_t> spawnMonsterMap;

Position centerPos;
int32_t radius;

uint32_t interval = 30000;
uint32_t checkSpawnMonsterEvent = 0;

Expand Down
9 changes: 7 additions & 2 deletions src/creatures/npcs/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/npcs/npc.hpp"
#include "creatures/npcs/npcs.hpp"
#include "declarations.hpp"
Expand Down Expand Up @@ -387,6 +385,13 @@ void Npc::onPlayerSellItem(std::shared_ptr<Player> player, uint16_t itemId, uint
continue;
}

if (const auto &container = item->getContainer()) {
if (container->size() > 0) {
player->sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must empty the container before selling it.");
continue;
}
}

if (parent && item->getParent() != parent) {
continue;
}
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/npcs/npcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "declarations.hpp"
#include "creatures/combat/combat.hpp"
#include "lua/scripts/lua_environment.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/npcs/spawns/spawn_npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/npcs/spawns/spawn_npc.hpp"
#include "creatures/npcs/npc.hpp"
#include "game/game.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/players/achievement/player_achievement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "player_achievement.hpp"

#include "creatures/players/player.hpp"
Expand Down
4 changes: 1 addition & 3 deletions src/creatures/players/cyclopedia/player_badge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "player_badge.hpp"

#include "creatures/players/player.hpp"
Expand Down Expand Up @@ -116,7 +114,7 @@ bool PlayerBadge::loyalty(uint8_t amount) {
}

bool PlayerBadge::accountAllLevel(uint8_t amount) {
const auto &players = g_game().getPlayersByAccount(m_player.getAccount(), true);
auto players = g_game().getPlayersByAccount(m_player.getAccount(), true);
uint16_t total = std::accumulate(players.begin(), players.end(), 0, [](uint16_t sum, const std::shared_ptr<Player> &player) {
return sum + player->getLevel();
});
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/players/cyclopedia/player_cyclopedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "player_cyclopedia.hpp"

#include "database/databasetasks.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/players/cyclopedia/player_title.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "player_title.hpp"

#include "creatures/players/player.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/players/grouping/familiars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/players/grouping/familiars.hpp"
#include "lib/di/container.hpp"
#include "config/configmanager.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/players/grouping/groups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "config/configmanager.hpp"
#include "game/game.hpp"
#include "creatures/players/grouping/groups.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/players/grouping/guild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/players/grouping/guild.hpp"
#include "game/game.hpp"

Expand Down
2 changes: 0 additions & 2 deletions src/creatures/players/grouping/party.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

#include <utility>

#include "pch.hpp"

#include "creatures/players/grouping/party.hpp"
#include "game/game.hpp"
#include "lua/creature/events.hpp"
Expand Down
1 change: 0 additions & 1 deletion src/creatures/players/imbuements/imbuements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"
#include "creatures/players/imbuements/imbuements.hpp"
#include "lua/creature/events.hpp"
#include "utils/pugicast.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/players/management/ban.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/players/management/ban.hpp"
#include "database/database.hpp"
#include "database/databasetasks.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/players/management/waitlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/players/management/waitlist.hpp"
#include "game/game.hpp"

Expand Down
16 changes: 11 additions & 5 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/combat/combat.hpp"
#include "creatures/interactions/chat.hpp"
#include "creatures/monsters/monster.hpp"
Expand Down Expand Up @@ -4120,6 +4118,12 @@ std::map<uint32_t, uint32_t> &Player::getAllItemTypeCount(std::map<uint32_t, uin

std::map<uint16_t, uint16_t> &Player::getAllSaleItemIdAndCount(std::map<uint16_t, uint16_t> &countMap) const {
for (const auto &item : getAllInventoryItems(false, true)) {
if (const auto &container = item->getContainer()) {
if (container->size() > 0) {
continue;
}
}

countMap[item->getID()] += item->getItemCount();
}

Expand Down Expand Up @@ -5569,7 +5573,7 @@ int32_t Player::getMagicShieldCapacityPercent(bool useCharges) const {

double_t Player::getReflectPercent(CombatType_t combat, bool useCharges) const {
double_t result = reflectPercent[combatTypeToIndex(combat)];
for (const auto item : getEquippedItems()) {
for (const auto &item : getEquippedItems()) {
const ItemType &itemType = Item::items[item->getID()];
if (!itemType.abilities) {
continue;
Expand Down Expand Up @@ -6200,7 +6204,9 @@ void Player::sendIcons() {
// Remove the last icon so that Bakragore's is added
auto iconSet = getClientIcons();
if (iconSet.size() >= 9 && iconBakragore != IconBakragore::None) {
iconSet.erase(std::prev(iconSet.end()));
std::vector<PlayerIcon> tempVector(iconSet.begin(), iconSet.end());
tempVector.pop_back();
iconSet = std::unordered_set<PlayerIcon>(tempVector.begin(), tempVector.end());
}

client->sendIcons(iconSet, iconBakragore);
Expand Down Expand Up @@ -7213,7 +7219,7 @@ void Player::forgeFuseItems(ForgeAction_t actionType, uint16_t firstItemId, uint
}

for (const auto &[mapTier, mapPrice] : itemClassification->tiers) {
if (mapTier == firstForgingItem->getTier()) {
if (mapTier == firstForgingItem->getTier() + 1) {
cost = mapPrice.convergenceFusionPrice;
break;
}
Expand Down
2 changes: 0 additions & 2 deletions src/creatures/players/storages/storages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Website: https://docs.opentibiabr.com/
*/

#include "pch.hpp"

#include "creatures/players/storages/storages.hpp"

#include "config/configmanager.hpp"
Expand Down
Loading

0 comments on commit 5523237

Please sign in to comment.