Skip to content

Commit

Permalink
Fix black and red squares behaviors (mehah#902)
Browse files Browse the repository at this point in the history
* Fix squares:
- Set black squares color to 1 instead of 0 so it's not treated as alpha
- Fix creaturesMark logic so red squares don't disappear when attacking and black squares show when attacked
  • Loading branch information
OTArchive authored Oct 6, 2024
1 parent 38801cb commit 3ca46d4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/client/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ void Creature::setShieldTexture(const std::string& filename, bool blink)
void Creature::addTimedSquare(uint8_t color)
{
m_showTimedSquare = true;
m_timedSquareColor = Color::from8bit(color);
m_timedSquareColor = Color::from8bit(color != 0 ? color : 1);

// schedule removal
const auto self = static_self_cast<Creature>();
Expand Down
67 changes: 32 additions & 35 deletions src/client/protocolgameparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ void ProtocolGame::parseStoreTransactionHistory(const InputMessagePtr& msg) cons
msg->getU32();
const uint32_t time = msg->getU32();
msg->getU8();
const uint32_t amount = (UINT32_MAX -msg->getU32());
const uint32_t amount = (UINT32_MAX - msg->getU32());
msg->getU8();
const auto& productName = msg->getString();
msg->getU8();
Expand Down Expand Up @@ -1437,7 +1437,7 @@ void ProtocolGame::parseContainerRemoveItem(const InputMessagePtr& msg)
g_game.processContainerRemoveItem(containerId, slot, lastItem);
}

void ProtocolGame::parseBosstiaryInfo(const InputMessagePtr& msg)
void ProtocolGame::parseBosstiaryInfo(const InputMessagePtr& msg)
{
const uint16_t bosstiaryRaceLast = msg->getU16();
std::vector<BosstiaryData> bossData;
Expand Down Expand Up @@ -2651,7 +2651,7 @@ void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg) const
const auto& shaderName = msg->getString();
shaderList.emplace_back(shaderId, shaderName);
}
}
}

g_game.processOpenOutfitWindow(currentOutfit, outfitList, mountList, wingList, auraList, effectList, shaderList);
}
Expand Down Expand Up @@ -2809,7 +2809,7 @@ void ProtocolGame::parseBestiaryMonsterData(const InputMessagePtr& msg)
if (data.currentLevel > 1) {
data.charmValue = msg->getU16();
data.attackMode = msg->getU8();
msg->getU8();
msg->getU8();
data.maxHealth = msg->getU32();
data.experience = msg->getU32();
data.speed = msg->getU16();
Expand Down Expand Up @@ -2847,7 +2847,7 @@ void ProtocolGame::parseBestiaryCharmsData(const InputMessagePtr& msg)
BestiaryCharmsData charmData;
charmData.points = msg->getU32();

const uint8_t charmsAmount = msg->getU8();
const uint8_t charmsAmount = msg->getU8();
for (auto i = 0; i < charmsAmount; ++i) {
CharmData charm;
charm.id = msg->getU8();
Expand All @@ -2864,17 +2864,17 @@ void ProtocolGame::parseBestiaryCharmsData(const InputMessagePtr& msg)
const bool asigned = static_cast<bool>(msg->getU8());
if (asigned) {
charm.asignedStatus = asigned;
charm.raceId = msg->getU16();
charm.removeRuneCost = msg->getU32();
charm.raceId = msg->getU16();
charm.removeRuneCost = msg->getU32();
}
} else {
msg->getU8();
msg->getU8();
}

charmData.charms.emplace_back(charm);
}

msg->getU8();
msg->getU8();

const uint16_t finishedMonstersSize = msg->getU16();
for (auto i = 0; i < finishedMonstersSize; ++i) {
Expand Down Expand Up @@ -3041,27 +3041,24 @@ void ProtocolGame::parseChangeMapAwareRange(const InputMessagePtr& msg)

void ProtocolGame::parseCreaturesMark(const InputMessagePtr& msg)
{
const uint8_t len = g_game.getClientVersion() >= 1035 ? 1 : msg->getU8();
for (auto i = 0; i < len; ++i) {
const uint32_t creatureId = msg->getU32();
const bool isPermanent = static_cast<bool>(msg->getU8());
const uint8_t markType = msg->getU8();
const uint32_t creatureId = msg->getU32();
const bool isPermanent = g_game.getClientVersion() >= 1076 ? msg->getU8() == 0 : false;
const uint8_t markType = msg->getU8();

const auto& creature = g_map.getCreatureById(creatureId);
if (!creature) {
g_logger.traceError(stdext::format("ProtocolGame::parseTrappers: could not get creature with id %d", creatureId));
continue;
}
const auto& creature = g_map.getCreatureById(creatureId);
if (!creature) {
g_logger.traceError(stdext::format("ProtocolGame::parseTrappers: could not get creature with id %d", creatureId));
return;
}

if (isPermanent) {
if (markType == 0xff) {
creature->hideStaticSquare();
} else {
creature->showStaticSquare(Color::from8bit(markType));
}
if (isPermanent) {
if (markType == 0xff) {
creature->hideStaticSquare();
} else {
creature->addTimedSquare(markType);
creature->showStaticSquare(Color::from8bit(markType != 0 ? markType : 1));
}
} else {
creature->addTimedSquare(markType);
}
}

Expand Down Expand Up @@ -3821,7 +3818,7 @@ void ProtocolGame::parsePartyAnalyzer(const InputMessagePtr& msg)
msg->getU64(); // healing
}

const bool hasNamesBool =static_cast<bool>( msg->getU8());
const bool hasNamesBool = static_cast<bool>(msg->getU8());
if (hasNamesBool) {
const uint8_t membersNameSize = msg->getU8();
for (auto i = 0; i < membersNameSize; ++i) {
Expand Down Expand Up @@ -4155,10 +4152,10 @@ void ProtocolGame::parseCyclopediaCharacterInfo(const InputMessagePtr& msg)
case Otc::CYCLOPEDIA_CHARACTERINFO_RECENTDEATHS:
{
CyclopediaCharacterRecentDeaths data;
msg->getU16();
msg->getU16();
msg->getU16();

const uint16_t entriesCount = msg->getU16();
const uint16_t entriesCount = msg->getU16();
for (auto i = 0; i < entriesCount; ++i) {
RecentDeathEntry entry;
entry.timestamp = msg->getU32();
Expand All @@ -4172,10 +4169,10 @@ void ProtocolGame::parseCyclopediaCharacterInfo(const InputMessagePtr& msg)
case Otc::CYCLOPEDIA_CHARACTERINFO_RECENTPVPKILLS:
{
CyclopediaCharacterRecentPvPKills data;
msg->getU16();
msg->getU16();
msg->getU16();

const uint16_t entriesCount = msg->getU16();
const uint16_t entriesCount = msg->getU16();
for (auto i = 0; i < entriesCount; ++i) {
RecentPvPKillEntry entry;
entry.timestamp = msg->getU32();
Expand Down Expand Up @@ -4347,8 +4344,8 @@ void ProtocolGame::parseCyclopediaCharacterInfo(const InputMessagePtr& msg)
}
case Otc::CYCLOPEDIA_CHARACTERINFO_STORESUMMARY:
{
const uint32_t xpBoostTime = msg->getU32();
const uint32_t dailyRewardXpBoostTime = msg->getU32();
const uint32_t xpBoostTime = msg->getU32();
const uint32_t dailyRewardXpBoostTime = msg->getU32();

std::vector<std::tuple<std::string, uint8_t>> blessings;
const uint8_t blessingCount = msg->getU8();
Expand Down Expand Up @@ -4406,7 +4403,7 @@ void ProtocolGame::parseCyclopediaCharacterInfo(const InputMessagePtr& msg)
const auto& badgeName = msg->getString();
badgesVector.emplace_back(badgeId, badgeName);
}

g_game.processCyclopediaCharacterGeneralStatsBadge(showAccountInformation, playerOnline, playerPremium, loyaltyTitle, badgesVector);
break;
}
Expand Down Expand Up @@ -4767,7 +4764,7 @@ void ProtocolGame::parseImbuementWindow(const InputMessagePtr& msg)
const uint8_t firstByte = msg->getU8();
if (firstByte == 0x01) {
Imbuement imbuement = getImbuementInfo(msg);
const uint32_t duration = msg->getU32();
const uint32_t duration = msg->getU32();
const uint32_t removalCost = msg->getU32();
activeSlots[i] = std::make_tuple(imbuement, duration, removalCost);
}
Expand Down

0 comments on commit 3ca46d4

Please sign in to comment.