Decompile fn_21099 (CGameActor::ProcessDamageMessages)

Batch #17660 by eAthena: 0 byte-identical, 1 confirmed by peer review.

- fn_21099 CGameActor::ProcessDamageMessages: logic confirmed by peer review

Peer-reviewed-by: Yommy, cremane, bibinir
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
ragnarok-clanker 2026-11-12 01:55:11 +00:00
commit fb357b4915

View file

@ -48,70 +48,69 @@ static vector3d& operator+=(vector3d& target, const vector3d& offset) {
// FUNCTION: fn_21099
void CGameActor::ProcessDamageMessages() {
for (auto it = this->willBeAttackedList.begin(); it != this->willBeAttackedList.end();) {
if (timeGetTime() < it->time) {
if (timeGetTime() >= it->time) {
if (it->damage > 0) {
const std::uint32_t targetAid = it->targetAid;
const std::uint32_t attackerAid = it->attackerAid;
char partyNotice[500];
char notice[500];
notice[0] = '\0';
partyNotice[0] = '\0';
std::string targetName = static_cast<CGameMode*>(g_modeMgr.GetGameMode())->ActorName(targetAid);
std::string attackerName = static_cast<CGameMode*>(g_modeMgr.GetGameMode())->ActorName(attackerAid);
std::size_t position = targetName.find('#');
if (position != std::string::npos) {
targetName.resize(position);
}
position = attackerName.find('#');
if (position != std::string::npos) {
attackerName.resize(position);
}
if (targetName.empty()) {
const CActorNameCard& card = static_cast<CGameMode*>(g_modeMgr.GetGameMode())->LookupNameCard(targetAid);
targetName.assign(card.displayName.empty() ? std::string(LookupMessage(MSI_WHO_IS)) : card.displayName);
}
if (attackerName.empty()) {
const CActorNameCard& card = static_cast<CGameMode*>(g_modeMgr.GetGameMode())->LookupNameCard(attackerAid);
attackerName.assign(card.displayName.empty() ? std::string(LookupMessage(MSI_WHO_IS)) : card.displayName);
}
if (IsPlayerJob(this->GetEffectiveJob(-1))) {
if (g_session.m_aid == targetAid) {
std::sprintf(notice, LookupMessage(MSI_I_RECEIVED_DAMAGE), attackerName.c_str(), it->damage);
} else if (g_session.IsPartyMember(targetAid, true)) {
std::sprintf(partyNotice, LookupMessage(MSI_PARTY_RECEIVED_DAMAGE), targetName.c_str(), attackerName.c_str(), it->damage);
}
} else {
if (g_session.m_aid == attackerAid) {
std::sprintf(notice, LookupMessage(MSI_I_GAVE_DAMAGE), targetName.c_str(), it->damage);
} else if (g_session.IsPartyMember(attackerAid, true)) {
std::sprintf(partyNotice, LookupMessage(MSI_PARTY_GAVE_DAMAGE), attackerName.c_str(), targetName.c_str(), it->damage);
}
}
if (std::strlen(notice) != 0) {
g_windowMgr.SendNotice(UIM_PUSHINTOCHATHISTORY, reinterpret_cast<std::intptr_t>(notice), 0xFFFF, 16, 0, 0);
}
if (std::strlen(partyNotice) != 0) {
g_windowMgr.SendNotice(UIM_PUSHINTOCHATHISTORY, reinterpret_cast<std::intptr_t>(partyNotice), 0xC8C8FF, 17, 0, 0);
}
}
ActorDamageMessage& message = *it;
this->SendMsg(
nullptr, message.action, message.action >> 31, reinterpret_cast<int>(&message.targetAid), 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0);
it = this->willBeAttackedList.erase(it);
} else {
++it;
continue;
}
if (it->damage > 0) {
const std::uint32_t targetAid = it->targetAid;
const std::uint32_t attackerAid = it->attackerAid;
char partyNotice[500];
char notice[500];
notice[0] = '\0';
partyNotice[0] = '\0';
std::string targetName = static_cast<CGameMode*>(g_modeMgr.GetGameMode())->ActorName(targetAid);
std::string attackerName = static_cast<CGameMode*>(g_modeMgr.GetGameMode())->ActorName(attackerAid);
std::size_t position = targetName.find('#');
if (position != std::string::npos) {
targetName.resize(position);
}
position = attackerName.find('#');
if (position != std::string::npos) {
attackerName.resize(position);
}
if (targetName.empty()) {
const CActorNameCard& card = static_cast<CGameMode*>(g_modeMgr.GetGameMode())->LookupNameCard(targetAid);
targetName.assign(card.displayName.empty() ? std::string(LookupMessage(MSI_WHO_IS)) : card.displayName);
}
if (attackerName.empty()) {
const CActorNameCard& card = static_cast<CGameMode*>(g_modeMgr.GetGameMode())->LookupNameCard(attackerAid);
attackerName.assign(card.displayName.empty() ? std::string(LookupMessage(MSI_WHO_IS)) : card.displayName);
}
if (IsPlayerJob(this->GetEffectiveJob(-1))) {
if (g_session.m_aid == targetAid) {
std::sprintf(notice, LookupMessage(MSI_I_RECEIVED_DAMAGE), attackerName.c_str(), it->damage);
} else if (g_session.IsPartyMember(targetAid, true)) {
std::sprintf(partyNotice, LookupMessage(MSI_PARTY_RECEIVED_DAMAGE), targetName.c_str(), attackerName.c_str(), it->damage);
}
} else {
if (g_session.m_aid == attackerAid) {
std::sprintf(notice, LookupMessage(MSI_I_GAVE_DAMAGE), targetName.c_str(), it->damage);
} else if (g_session.IsPartyMember(attackerAid, true)) {
std::sprintf(partyNotice, LookupMessage(MSI_PARTY_GAVE_DAMAGE), attackerName.c_str(), targetName.c_str(), it->damage);
}
}
if (std::strlen(notice) != 0) {
g_windowMgr.SendNotice(UIM_PUSHINTOCHATHISTORY, reinterpret_cast<std::intptr_t>(notice), 0xFFFF, 16, 0, 0);
}
if (std::strlen(partyNotice) != 0) {
g_windowMgr.SendNotice(UIM_PUSHINTOCHATHISTORY, reinterpret_cast<std::intptr_t>(partyNotice), 0xC8C8FF, 17, 0, 0);
}
}
ActorDamageMessage& message = *it;
this->SendMsg(
nullptr, message.action, message.action >> 31, reinterpret_cast<int>(&message.targetAid), 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0);
it = this->willBeAttackedList.erase(it);
}
}