Skip to content

Commit

Permalink
Merge branch 'feature/badge-system' of https://github.com/elsongabrie…
Browse files Browse the repository at this point in the history
…l/canary into feature/title-system
  • Loading branch information
elsongabriel committed May 4, 2024
2 parents af280e0 + 681b79e commit 9a8c6dc
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 22 deletions.
4 changes: 2 additions & 2 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ resetSessionsOnStartup = false
-- Misc.
-- NOTE: experienceDisplayRates: set to false to ignore exp rate or true to include exp rate
-- NOTE: disableLegacyRaids: set to true to disable legacy XML raids
-- NOTE: combatChainDelay: set to minimum 50 miliseconds
allowChangeOutfit = true
toggleMountInProtectionZone = false
freePremium = false
Expand Down Expand Up @@ -430,7 +429,8 @@ maxElementalResistance = 200
maxDamageReflection = 200

-- Chain system
toggleChainSystem = true
-- NOTE: combatChainDelay: set to minimum 50 miliseconds
toggleChainSystem = false
combatChainDelay = 50
combatChainTargets = 5
combatChainSkillFormulaAxe = 0.9
Expand Down
2 changes: 1 addition & 1 deletion src/canary_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void CanaryServer::loadModules() {
g_game().loadBoostedCreature();
g_ioBosstiary().loadBoostedBoss();
g_ioprey().initializeTaskHuntOptions();
g_game().getCyclopediaStatistics();
g_game().logCyclopediaStats();
}

void CanaryServer::modulesLoadHelper(bool loaded, std::string moduleName) {
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ bool Creature::dropCorpse(std::shared_ptr<Creature> lastHitCreature, std::shared
auto monster = getMonster();
if (monster && !monster->isRewardBoss()) {
std::ostringstream lootMessage;
auto collorMessage = player->getProtocolVersion() < 1200 || player->getOperatingSystem() >= CLIENTOS_OTCLIENT_LINUX;
auto collorMessage = player->getProtocolVersion() > 1200 && player->getOperatingSystem() < CLIENTOS_OTCLIENT_LINUX;
lootMessage << "Loot of " << getNameDescription() << ": " << corpseContainer->getContentDescription(collorMessage) << ".";
auto suffix = corpseContainer->getAttribute<std::string>(ItemAttribute_t::LOOTMESSAGE_SUFFIX);
if (!suffix.empty()) {
Expand Down
4 changes: 2 additions & 2 deletions src/creatures/players/cyclopedia/player_badge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ bool PlayerBadge::add(uint8_t id, uint32_t timestamp /* = 0*/) {
return false;
}

const Badge &badge = g_game().getBadgeByIdOrName(id);
const Badge &badge = g_game().getBadgeById(id);
if (badge.m_id == 0) {
return false;
}
Expand Down Expand Up @@ -86,7 +86,7 @@ void PlayerBadge::loadUnlockedBadges() {
const auto &unlockedBadges = getUnlockedKV()->keys();
g_logger().debug("[{}] - Loading unlocked badges: {}", __FUNCTION__, unlockedBadges.size());
for (const auto &badgeName : unlockedBadges) {
const Badge &badge = g_game().getBadgeByIdOrName(0, badgeName);
const Badge &badge = g_game().getBadgeByName(badgeName);
if (badge.m_id == 0) {
g_logger().error("[{}] - Badge {} not found.", __FUNCTION__, badgeName);
continue;
Expand Down
31 changes: 25 additions & 6 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3296,7 +3296,13 @@ void Game::playerEquipItem(uint32_t playerId, uint16_t itemId, bool hasTier /* =
} else {
const int32_t &slotPosition = equipItem->getSlotPosition();
// Checks if a two-handed item is being equipped in the left slot when the right slot is already occupied and move to backpack
if (slotPosition & SLOTP_LEFT && rightItem && (slotPosition & SLOTP_TWO_HAND)) {
if (
(slotPosition & SLOTP_LEFT)
&& (slotPosition & SLOTP_TWO_HAND)
&& rightItem
&& !(it.weaponType == WEAPON_DISTANCE)
&& !rightItem->isQuiver()
) {
ret = internalCollectManagedItems(player, rightItem, getObjectCategory(rightItem), false);
}

Expand Down Expand Up @@ -10637,7 +10643,7 @@ std::map<uint16_t, Achievement> Game::getAchievements() {
return m_achievements;
}

void Game::getCyclopediaStatistics() {
void Game::logCyclopediaStats() {
g_logger().info("Loaded {} badges from Badge System", m_badges.size());
g_logger().info("Loaded {} titles from Title system", m_titles.size());
}
Expand All @@ -10646,12 +10652,25 @@ std::unordered_set<Badge> Game::getBadges() {
return m_badges;
}

Badge Game::getBadgeByIdOrName(uint8_t id, const std::string &name /*= ""*/) {
if (id == 0 && name.empty()) {
Badge Game::getBadgeById(uint8_t id) {
if (id == 0) {
return {};
}
auto it = std::find_if(m_badges.begin(), m_badges.end(), [id](const Badge &b) {
return b.m_id == id;
});
if (it != m_badges.end()) {
return *it;
}
return {};
}

Badge Game::getBadgeByName(const std::string &name) {
if (name.empty()) {
return {};
}
auto it = std::find_if(m_badges.begin(), m_badges.end(), [id, name](const Badge &b) {
return id != 0 ? b.m_id == id : b.m_name == name;
auto it = std::find_if(m_badges.begin(), m_badges.end(), [name](const Badge &b) {
return b.m_name == name;
});
if (it != m_badges.end()) {
return *it;
Expand Down
5 changes: 3 additions & 2 deletions src/game/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Game {

void forceRemoveCondition(uint32_t creatureId, ConditionType_t type, ConditionId_t conditionId);

void getCyclopediaStatistics();
void logCyclopediaStats();

/**
* Load the main map
Expand Down Expand Up @@ -724,7 +724,8 @@ class Game {
std::map<uint16_t, Achievement> getAchievements();

std::unordered_set<Badge> getBadges();
Badge getBadgeByIdOrName(uint8_t id, const std::string &name = "");
Badge getBadgeById(uint8_t id);
Badge getBadgeByName(const std::string &name);

std::unordered_set<Title> getTitles();
Title getTitleByIdOrName(uint8_t id, const std::string &name = "");
Expand Down
14 changes: 6 additions & 8 deletions src/server/network/protocol/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4164,19 +4164,19 @@ void ProtocolGame::sendTextMessage(const TextMessage &message) {
break;
}
case MESSAGE_MARKET: {
internalType = MESSAGE_GAME_HIGHLIGHT;
internalType = MESSAGE_EVENT_ADVANCE;
break;
}
case MESSAGE_MANA: {
internalType = MESSAGE_THANK_YOU;
internalType = MESSAGE_HEALED;
break;
}
case MESSAGE_BEYOND_LAST: {
internalType = MESSAGE_LOOT;
break;
}
case MESSAGE_ATTENTION: {
internalType = MESSAGE_DAMAGE_DEALT;
internalType = MESSAGE_EVENT_ADVANCE;
break;
}
case MESSAGE_BOOSTED_CREATURE: {
Expand Down Expand Up @@ -4219,11 +4219,9 @@ void ProtocolGame::sendTextMessage(const TextMessage &message) {
}
case MESSAGE_HEALED:
case MESSAGE_HEALED_OTHERS: {
if (!oldProtocol) {
msg.addPosition(message.position);
msg.add<uint32_t>(message.primary.value);
msg.addByte(message.primary.color);
}
msg.addPosition(message.position);
msg.add<uint32_t>(message.primary.value);
msg.addByte(message.primary.color);
break;
}
case MESSAGE_EXPERIENCE:
Expand Down

0 comments on commit 9a8c6dc

Please sign in to comment.