diff --git a/Source/Contents/Actors/GameActor.cpp b/Source/Contents/Actors/GameActor.cpp index 6185b01c1..46e30454f 100644 --- a/Source/Contents/Actors/GameActor.cpp +++ b/Source/Contents/Actors/GameActor.cpp @@ -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(g_modeMgr.GetGameMode())->ActorName(targetAid); + std::string attackerName = static_cast(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(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(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(notice), 0xFFFF, 16, 0, 0); + } + + if (std::strlen(partyNotice) != 0) { + g_windowMgr.SendNotice(UIM_PUSHINTOCHATHISTORY, reinterpret_cast(partyNotice), 0xC8C8FF, 17, 0, 0); + } + } + + ActorDamageMessage& message = *it; + this->SendMsg( + nullptr, message.action, message.action >> 31, reinterpret_cast(&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(g_modeMgr.GetGameMode())->ActorName(targetAid); - std::string attackerName = static_cast(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(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(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(notice), 0xFFFF, 16, 0, 0); - } - - if (std::strlen(partyNotice) != 0) { - g_windowMgr.SendNotice(UIM_PUSHINTOCHATHISTORY, reinterpret_cast(partyNotice), 0xC8C8FF, 17, 0, 0); - } - } - - ActorDamageMessage& message = *it; - this->SendMsg( - nullptr, message.action, message.action >> 31, reinterpret_cast(&message.targetAid), 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0); - it = this->willBeAttackedList.erase(it); } }