本文整理汇总了C++中SetAtWar函数的典型用法代码示例。如果您正苦于以下问题:C++ SetAtWar函数的具体用法?C++ SetAtWar怎么用?C++ SetAtWar使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetAtWar函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetVisible
bool ReputationMgr::SwitchReputation(uint32 faction1Id, uint32 faction2Id)
{
FactionEntry const *faction1Entry = sFactionStore.LookupEntry(faction1Id);
FactionEntry const *faction2Entry = sFactionStore.LookupEntry(faction2Id);
if (!faction1Entry || !faction2Entry)
return false;
FactionStateList::iterator itr1 = m_factions.find(faction1Entry->reputationListID);
FactionStateList::iterator itr2 = m_factions.find(faction2Entry->reputationListID);
if (itr1 != m_factions.end() && itr2 != m_factions.end())
{
int32 temp = itr1->second.Standing;
itr1->second.Standing = itr2->second.Standing;
itr2->second.Standing = temp;
itr1->second.needSend = true;
itr1->second.needSave = true;
itr2->second.needSend = true;
itr2->second.needSave = true;
SetVisible(&itr1->second);
SetVisible(&itr2->second);
if (ReputationToRank(itr1->second.Standing) <= REP_HOSTILE)
SetAtWar(&itr1->second, true);
if (ReputationToRank(itr2->second.Standing) <= REP_HOSTILE)
SetAtWar(&itr2->second, true);
m_player->ReputationChanged(faction1Entry);
m_player->ReputationChanged(faction2Entry);
return true;
}
return false;
}
示例2: Initialize
void ReputationMgr::LoadFromDB(PreparedQueryResult result)
{
// Set initial reputations (so everything is nifty before DB data load)
Initialize();
//QueryResult* result = CharacterDatabase.PQuery("SELECT faction, standing, flags FROM character_reputation WHERE guid = '%u'", GetGUIDLow());
if (result)
{
do
{
Field* fields = result->Fetch();
FactionEntry const* factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt16());
if (factionEntry && (factionEntry->reputationListID >= 0))
{
FactionState* faction = &_factions[factionEntry->reputationListID];
// update standing to current
faction->Standing = fields[1].GetInt32();
// update counters
int32 BaseRep = GetBaseReputation(factionEntry);
ReputationRank old_rank = ReputationToRank(BaseRep);
ReputationRank new_rank = ReputationToRank(BaseRep + faction->Standing);
UpdateRankCounters(old_rank, new_rank);
uint32 dbFactionFlags = fields[2].GetUInt16();
if (dbFactionFlags & FACTION_FLAG_VISIBLE)
SetVisible(faction); // have internal checks for forced invisibility
if (dbFactionFlags & FACTION_FLAG_INACTIVE)
SetInactive(faction, true); // have internal checks for visibility requirement
if (dbFactionFlags & FACTION_FLAG_AT_WAR) // DB at war
SetAtWar(faction, true); // have internal checks for FACTION_FLAG_PEACE_FORCED
else // DB not at war
{
// allow remove if visible (and then not FACTION_FLAG_INVISIBLE_FORCED or FACTION_FLAG_HIDDEN)
if (faction->Flags & FACTION_FLAG_VISIBLE)
SetAtWar(faction, false); // have internal checks for FACTION_FLAG_PEACE_FORCED
}
// set atWar for hostile
if (GetRank(factionEntry) <= REP_HOSTILE)
SetAtWar(faction, true);
// reset changed flag if values similar to saved in DB
if (faction->Flags == dbFactionFlags)
{
faction->needSend = false;
faction->needSave = false;
}
}
}
while (result->NextRow());
}
}
示例3: GetBaseReputation
bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
{
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
if (itr != m_factions.end())
{
FactionState& faction = itr->second;
int32 BaseRep = GetBaseReputation(factionEntry);
if (incremental)
standing += faction.Standing + BaseRep;
if (standing > Reputation_Cap)
standing = Reputation_Cap;
else if (standing < Reputation_Bottom)
standing = Reputation_Bottom;
faction.Standing = standing - BaseRep;
faction.needSend = true;
faction.needSave = true;
SetVisible(&faction);
if (ReputationToRank(standing) <= REP_HOSTILE)
SetAtWar(&itr->second, true);
m_player->ReputationChanged(factionEntry);
return true;
}
return false;
}
示例4: GetBaseReputation
bool ReputationMgr::ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing)
{
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
if (itr != m_factions.end())
{
int32 BaseRep = GetBaseReputation(factionEntry);
int32 new_rep = BaseRep + itr->second.Standing + standing;
if (new_rep > Reputation_Cap)
new_rep = Reputation_Cap;
else
if (new_rep < Reputation_Bottom)
new_rep = Reputation_Bottom;
if (ReputationToRank(new_rep) <= REP_HOSTILE)
SetAtWar(&itr->second, true);
itr->second.Standing = new_rep - BaseRep;
itr->second.Changed = true;
SetVisible(&itr->second);
SendState(&itr->second);
m_player->ReputationChanged(factionEntry);
return true;
}
return false;
}
示例5: GetBaseReputation
bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry,
int32 standing, bool incremental) {
FactionStateList::iterator itr = m_factions.find(
factionEntry->reputationListID);
if (itr != m_factions.end()) {
int32 BaseRep = GetBaseReputation(factionEntry);
if (incremental) {
// int32 *= float cause one point loss?
standing = int32(
floor(
(float) standing
* sWorld->getRate(RATE_REPUTATION_GAIN)
+ 0.5));
standing += itr->second.Standing + BaseRep;
}
if (standing > Reputation_Cap)
standing = Reputation_Cap;
else if (standing < Reputation_Bottom)
standing = Reputation_Bottom;
ReputationRank old_rank = ReputationToRank(
itr->second.Standing + BaseRep);
ReputationRank new_rank = ReputationToRank(standing);
itr->second.Standing = standing - BaseRep;
itr->second.needSend = true;
itr->second.needSave = true;
SetVisible(&itr->second);
if (new_rank <= REP_HOSTILE)
SetAtWar(&itr->second, true);
UpdateRankCounters(old_rank, new_rank);
m_player->ReputationChanged(factionEntry);
m_player->GetAchievementMgr().UpdateAchievementCriteria(
ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS, factionEntry->ID);
m_player->GetAchievementMgr().UpdateAchievementCriteria(
ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, factionEntry->ID);
m_player->GetAchievementMgr().UpdateAchievementCriteria(
ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION,
factionEntry->ID);
m_player->GetAchievementMgr().UpdateAchievementCriteria(
ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION,
factionEntry->ID);
m_player->GetAchievementMgr().UpdateAchievementCriteria(
ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION,
factionEntry->ID);
return true;
}
return false;
}
示例6: SetAtWar
void ReputationMgr::SetAtWar(RepListID repListID, bool on)
{
FactionStateList::iterator itr = _factions.find(repListID);
if (itr == _factions.end())
return;
// always invisible or hidden faction can't change war state
if (itr->second.Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN))
return;
SetAtWar(&itr->second, on);
}
示例7: GetBaseReputation
bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing, bool incremental)
{
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
if (itr != m_factions.end())
{
FactionState &faction = itr->second;
int32 BaseRep = GetBaseReputation(factionEntry);
if (incremental)
standing += faction.Standing + BaseRep;
if (standing > Reputation_Cap)
standing = Reputation_Cap;
else if (standing < Reputation_Bottom)
standing = Reputation_Bottom;
ReputationRank old_rank = ReputationToRank(faction.Standing + BaseRep);
ReputationRank new_rank = ReputationToRank(standing);
faction.Standing = standing - BaseRep;
faction.needSend = true;
faction.needSave = true;
SetVisible(&faction);
if (new_rank <= REP_HOSTILE)
SetAtWar(&faction, true);
UpdateRankCounters(old_rank, new_rank);
m_player->ReputationChanged(factionEntry);
AchievementMgr &achievementManager = m_player->GetAchievementMgr();
achievementManager.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS, factionEntry->ID);
achievementManager.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, factionEntry->ID);
achievementManager.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, factionEntry->ID);
achievementManager.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION, factionEntry->ID);
achievementManager.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION, factionEntry->ID);
if (new_rank > old_rank)
return true;
}
return false;
}
示例8: Initialize
void ReputationMgr::LoadFromDB(QueryResult* result)
{
// Set initial reputations (so everything is nifty before DB data load)
Initialize();
// QueryResult *result = CharacterDatabase.PQuery("SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'",GetGUIDLow());
if (result)
{
do
{
Field* fields = result->Fetch();
FactionEntry const* factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt32());
if (factionEntry && factionEntry->HasReputation())
{
FactionState* faction = &m_factions[factionEntry->reputationListID];
// update standing to current
faction->Standing = int32(fields[1].GetUInt32());
uint32 dbFactionFlags = fields[2].GetUInt32();
if (dbFactionFlags & FACTION_FLAG_VISIBLE)
SetVisible(faction); // have internal checks for forced invisibility
if (dbFactionFlags & FACTION_FLAG_INACTIVE)
SetInactive(faction, true); // have internal checks for visibility requirement
if (dbFactionFlags & FACTION_FLAG_AT_WAR) // DB at war
SetAtWar(faction, true); // have internal checks for FACTION_FLAG_PEACE_FORCED
else // DB not at war
{
// allow remove if visible (and then not FACTION_FLAG_INVISIBLE_FORCED or FACTION_FLAG_HIDDEN)
if (faction->Flags & FACTION_FLAG_VISIBLE)
SetAtWar(faction, false); // have internal checks for FACTION_FLAG_PEACE_FORCED
}
// set atWar for hostile
ForcedReactions::const_iterator forceItr = m_forcedReactions.find(factionEntry->ID);
if (forceItr != m_forcedReactions.end())
{
if (forceItr->second <= REP_HOSTILE)
SetAtWar(faction, true);
}
else if (GetRank(factionEntry) <= REP_HOSTILE)
SetAtWar(faction, true);
// reset changed flag if values similar to saved in DB
if (faction->Flags == dbFactionFlags)
{
faction->needSend = false;
faction->needSave = false;
}
}
}
while (result->NextRow());
delete result;
}
}