*Merge.
--HG-- branch : trunk
This commit is contained in:
commit
d6b09015d6
7 files changed
+84
-46
No files matched your search
+44
-32
@@ -7382,28 +7382,34 @@ bool Unit::IsHostileTo(Unit const* unit) const
|
||||
if(tester->GetTypeId()==TYPEID_PLAYER)
|
||||
{
|
||||
// forced reaction
|
||||
ForcedReactions::const_iterator forceItr = ((Player*)tester)->m_forcedReactions.find(target_faction->faction);
|
||||
if(forceItr!=((Player*)tester)->m_forcedReactions.end())
|
||||
return forceItr->second <= REP_HOSTILE;
|
||||
if(target_faction->faction)
|
||||
{
|
||||
ForcedReactions::const_iterator forceItr = ((Player*)tester)->m_forcedReactions.find(target_faction->faction);
|
||||
if(forceItr!=((Player*)tester)->m_forcedReactions.end())
|
||||
return forceItr->second <= REP_HOSTILE;
|
||||
|
||||
// if faction have reputation then hostile state for tester at 100% dependent from at_war state
|
||||
if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction))
|
||||
if(raw_target_faction->reputationListID >=0)
|
||||
if(FactionState const* factionState = ((Player*)tester)->GetFactionState(raw_target_faction))
|
||||
return (factionState->Flags & FACTION_FLAG_AT_WAR);
|
||||
// if faction have reputation then hostile state for tester at 100% dependent from at_war state
|
||||
if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction))
|
||||
if(raw_target_faction->reputationListID >=0)
|
||||
if(FactionState const* factionState = ((Player*)tester)->GetFactionState(raw_target_faction))
|
||||
return (factionState->Flags & FACTION_FLAG_AT_WAR);
|
||||
}
|
||||
}
|
||||
// CvP forced reaction and reputation case
|
||||
else if(target->GetTypeId()==TYPEID_PLAYER)
|
||||
{
|
||||
// forced reaction
|
||||
ForcedReactions::const_iterator forceItr = ((Player const*)target)->m_forcedReactions.find(tester_faction->faction);
|
||||
if(forceItr!=((Player const*)target)->m_forcedReactions.end())
|
||||
return forceItr->second <= REP_HOSTILE;
|
||||
if(tester_faction->faction)
|
||||
{
|
||||
ForcedReactions::const_iterator forceItr = ((Player const*)target)->m_forcedReactions.find(tester_faction->faction);
|
||||
if(forceItr!=((Player const*)target)->m_forcedReactions.end())
|
||||
return forceItr->second <= REP_HOSTILE;
|
||||
|
||||
// apply reputation state
|
||||
FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction);
|
||||
if(raw_tester_faction && raw_tester_faction->reputationListID >=0 )
|
||||
return ((Player const*)target)->GetReputationRank(raw_tester_faction) <= REP_HOSTILE;
|
||||
// apply reputation state
|
||||
FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction);
|
||||
if(raw_tester_faction && raw_tester_faction->reputationListID >=0 )
|
||||
return ((Player const*)target)->GetReputationRank(raw_tester_faction) <= REP_HOSTILE;
|
||||
}
|
||||
}
|
||||
|
||||
// common faction based case (CvC,PvC,CvP)
|
||||
@@ -7491,28 +7497,34 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
|
||||
if(tester->GetTypeId()==TYPEID_PLAYER)
|
||||
{
|
||||
// forced reaction
|
||||
ForcedReactions::const_iterator forceItr = ((Player const*)tester)->m_forcedReactions.find(target_faction->faction);
|
||||
if(forceItr!=((Player const*)tester)->m_forcedReactions.end())
|
||||
return forceItr->second >= REP_FRIENDLY;
|
||||
if(target_faction->faction)
|
||||
{
|
||||
ForcedReactions::const_iterator forceItr = ((Player const*)tester)->m_forcedReactions.find(target_faction->faction);
|
||||
if(forceItr!=((Player const*)tester)->m_forcedReactions.end())
|
||||
return forceItr->second >= REP_FRIENDLY;
|
||||
|
||||
// if faction have reputation then friendly state for tester at 100% dependent from at_war state
|
||||
if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction))
|
||||
if(raw_target_faction->reputationListID >=0)
|
||||
if(FactionState const* FactionState = ((Player*)tester)->GetFactionState(raw_target_faction))
|
||||
return !(FactionState->Flags & FACTION_FLAG_AT_WAR);
|
||||
// if faction have reputation then friendly state for tester at 100% dependent from at_war state
|
||||
if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction))
|
||||
if(raw_target_faction->reputationListID >=0)
|
||||
if(FactionState const* FactionState = ((Player*)tester)->GetFactionState(raw_target_faction))
|
||||
return !(FactionState->Flags & FACTION_FLAG_AT_WAR);
|
||||
}
|
||||
}
|
||||
// CvP forced reaction and reputation case
|
||||
else if(target->GetTypeId()==TYPEID_PLAYER)
|
||||
{
|
||||
// forced reaction
|
||||
ForcedReactions::const_iterator forceItr = ((Player const*)target)->m_forcedReactions.find(tester_faction->faction);
|
||||
if(forceItr!=((Player const*)target)->m_forcedReactions.end())
|
||||
return forceItr->second >= REP_FRIENDLY;
|
||||
if(tester_faction->faction)
|
||||
{
|
||||
ForcedReactions::const_iterator forceItr = ((Player const*)target)->m_forcedReactions.find(tester_faction->faction);
|
||||
if(forceItr!=((Player const*)target)->m_forcedReactions.end())
|
||||
return forceItr->second >= REP_FRIENDLY;
|
||||
|
||||
// apply reputation state
|
||||
if(FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
|
||||
if(raw_tester_faction->reputationListID >=0 )
|
||||
return ((Player const*)target)->GetReputationRank(raw_tester_faction) >= REP_FRIENDLY;
|
||||
// apply reputation state
|
||||
if(FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction))
|
||||
if(raw_tester_faction->reputationListID >=0 )
|
||||
return ((Player const*)target)->GetReputationRank(raw_tester_faction) >= REP_FRIENDLY;
|
||||
}
|
||||
}
|
||||
|
||||
// common faction based case (CvC,PvC,CvP)
|
||||
@@ -7522,7 +7534,7 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
|
||||
bool Unit::IsHostileToPlayers() const
|
||||
{
|
||||
FactionTemplateEntry const* my_faction = getFactionTemplateEntry();
|
||||
if(!my_faction)
|
||||
if(!my_faction || !my_faction->faction)
|
||||
return false;
|
||||
|
||||
FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction);
|
||||
@@ -7535,7 +7547,7 @@ bool Unit::IsHostileToPlayers() const
|
||||
bool Unit::IsNeutralToAll() const
|
||||
{
|
||||
FactionTemplateEntry const* my_faction = getFactionTemplateEntry();
|
||||
if(!my_faction)
|
||||
if(!my_faction || !my_faction->faction)
|
||||
return true;
|
||||
|
||||
FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction);
|
||||
|
||||
Reference in new issue
Block a user