Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas authored Sep 16, 2023
2 parents c5736af + 3becf02 commit a7906c5
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 19 deletions.
3 changes: 0 additions & 3 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1654,9 +1654,6 @@ void Player::onCreatureAppear(Creature* creature, bool isLogin) {
}
}

// Reload bestiary tracker
refreshBestiaryMonsterTracker();

g_game().checkPlayersRecord();
IOLoginData::updateOnlineStatus(guid, true);
if (getLevel() < g_configManager().getNumber(ADVENTURERSBLESSING_LEVEL)) {
Expand Down
4 changes: 2 additions & 2 deletions src/creatures/players/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ class Player final : public Creature, public Cylinder, public Bankable {
}
}

void refreshBestiaryMonsterTracker() const {
refreshCyclopediaMonsterTracker(getCyclopediaMonsterTrackerSet(false), false);
void refreshCyclopediaMonsterTracker(bool isBoss = false) const {
refreshCyclopediaMonsterTracker(getCyclopediaMonsterTrackerSet(isBoss), isBoss);
}

void refreshCyclopediaMonsterTracker(const phmap::parallel_flat_hash_set<std::shared_ptr<MonsterType>> &trackerList, bool isBoss) const {
Expand Down
1 change: 1 addition & 0 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9087,6 +9087,7 @@ void Game::playerRotatePodium(uint32_t playerId, const Position &pos, uint8_t st
// We retrieve the outfit information to be able to rotate the podium of renown in the new direction
Outfit_t newOutfit;
newOutfit.lookType = InternalGame::getCustomAttributeValue<uint16_t>(item, "LookType");
newOutfit.lookAddons = InternalGame::getCustomAttributeValue<uint8_t>(item, "LookAddons");
newOutfit.lookHead = InternalGame::getCustomAttributeValue<uint8_t>(item, "LookHead");
newOutfit.lookBody = InternalGame::getCustomAttributeValue<uint8_t>(item, "LookBody");
newOutfit.lookLegs = InternalGame::getCustomAttributeValue<uint8_t>(item, "LookLegs");
Expand Down
10 changes: 3 additions & 7 deletions src/io/functions/iologindata_load_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void IOLoginDataLoad::loadPlayerBlessings(Player* player, DBResult_ptr result) {
}
}

void IOLoginDataLoad::loadPlayerConditions(const Player* player, DBResult_ptr result) {
void IOLoginDataLoad::loadPlayerConditions(Player* player, DBResult_ptr result) {
if (!result || !player) {
g_logger().warn("[IOLoginData::loadPlayer] - Player or Result nullptr: {}", __FUNCTION__);
return;
Expand All @@ -230,14 +230,10 @@ void IOLoginDataLoad::loadPlayerConditions(const Player* player, DBResult_ptr re
PropStream propStream;
propStream.init(attr, attrSize);

std::list<std::unique_ptr<Condition>> conditionList;
Condition* condition = Condition::createCondition(propStream);
while (condition) {
std::unique_ptr<Condition> uniqueCondition(condition);
if (uniqueCondition->unserialize(propStream)) {
conditionList.push_front(std::move(uniqueCondition));
} else {
uniqueCondition.release(); // Release memory ownership
if (condition->unserialize(propStream)) {
player->storedConditionList.push_front(condition);
}
condition = Condition::createCondition(propStream);
}
Expand Down
2 changes: 1 addition & 1 deletion src/io/functions/iologindata_load_player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class IOLoginDataLoad : public IOLoginData {
static bool preLoadPlayer(Player* player, const std::string &name);
static void loadPlayerExperience(Player* player, DBResult_ptr result);
static void loadPlayerBlessings(Player* player, DBResult_ptr result);
static void loadPlayerConditions(const Player* player, DBResult_ptr result);
static void loadPlayerConditions(Player* player, DBResult_ptr result);
static void loadPlayerDefaultOutfit(Player* player, DBResult_ptr result);
static void loadPlayerSkullSystem(Player* player, DBResult_ptr result);
static void loadPlayerSkill(Player* player, DBResult_ptr result);
Expand Down
1 change: 1 addition & 0 deletions src/io/io_bosstiary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ void IOBosstiary::addBosstiaryKill(Player* player, const std::shared_ptr<Monster

auto oldBossLevel = getBossCurrentLevel(player, bossId);
player->addBestiaryKillCount(bossId, amount);
player->refreshCyclopediaMonsterTracker(true);
auto newBossLevel = getBossCurrentLevel(player, bossId);
if (oldBossLevel == newBossLevel) {
return;
Expand Down
8 changes: 2 additions & 6 deletions src/io/iobestiary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,8 @@ void IOBestiary::addBestiaryKill(Player* player, const std::shared_ptr<MonsterTy
}
}

const auto &trackerUnorderedSet = player->getCyclopediaMonsterTrackerSet(false);
for (const auto mType : trackerUnorderedSet) {
if (raceid == mType->info.raceid) {
player->refreshCyclopediaMonsterTracker(trackerUnorderedSet, false);
}
}
// Reload bestiary tracker
player->refreshCyclopediaMonsterTracker();
}

charmRune_t IOBestiary::getCharmFromTarget(Player* player, const std::shared_ptr<MonsterType> mtype) {
Expand Down
14 changes: 14 additions & 0 deletions src/lua/functions/items/item_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,20 @@ int ItemFunctions::luaItemIsInsideDepot(lua_State* L) {
return 1;
}

int ItemFunctions::luaItemIsContainer(lua_State* L) {
// item:isContainer()
const auto item = getUserdata<const Item>(L, 1);
if (!item) {
reportErrorFunc(getErrorDesc(LUA_ERROR_ITEM_NOT_FOUND));
pushBoolean(L, false);
return 1;
}

const auto &it = Item::items[item->getID()];
pushBoolean(L, it.isContainer());
return 1;
}

int ItemFunctions::luaItemGetTier(lua_State* L) {
// item:getTier()
const Item* item = getUserdata<Item>(L, 1);
Expand Down
2 changes: 2 additions & 0 deletions src/lua/functions/items/item_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class ItemFunctions final : LuaScriptInterface {
registerMethod(L, "Item", "setDuration", ItemFunctions::luaItemSetDuration);

registerMethod(L, "Item", "isInsideDepot", ItemFunctions::luaItemIsInsideDepot);
registerMethod(L, "Item", "isContainer", ItemFunctions::luaItemIsContainer);

registerMethod(L, "Item", "getTier", ItemFunctions::luaItemGetTier);
registerMethod(L, "Item", "setTier", ItemFunctions::luaItemSetTier);
Expand Down Expand Up @@ -145,6 +146,7 @@ class ItemFunctions final : LuaScriptInterface {
static int luaItemSetDuration(lua_State* L);

static int luaItemIsInsideDepot(lua_State* L);
static int luaItemIsContainer(lua_State* L);

static int luaItemGetTier(lua_State* L);
static int luaItemSetTier(lua_State* L);
Expand Down

0 comments on commit a7906c5

Please sign in to comment.