Merge branch 'master' into 310

Conflicts:
	src/game/Player.cpp
	src/game/Player.h
	src/game/Unit.cpp
This commit is contained in:
tomrus88 2009-03-26 14:28:37 +03:00
commit 963aed5e0b
49 changed files with 1124 additions and 986 deletions

View file

@ -22,7 +22,7 @@
DROP TABLE IF EXISTS `db_version`;
CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`required_7503_01_mangos_command` bit(1) default NULL
`required_7536_01_mangos_spell_chain` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
--
@ -16186,6 +16186,13 @@ INSERT INTO spell_chain VALUES
(45361,45360,45357,5,0),
(45363,45361,45357,6,0),
/*------------------
-- (777) Mounts
------------------*/
(13819,0,13819,1,0),
(23214,13819,13819,2,33391),
(34769,0,34769,1,0),
(34767,34769,34769,2,33391),
/*------------------
--(780)Pet-ExoticChimaera
------------------*/
/*FroststormBreath*/

View file

@ -0,0 +1,9 @@
ALTER TABLE db_version CHANGE COLUMN required_7503_01_mangos_command required_7536_01_mangos_spell_chain bit;
DELETE FROM spell_chain WHERE spell_id in (13819,23214,34769,34767);
INSERT INTO `spell_chain` VALUES
(13819,0, 13819,1,0 ),
(23214,13819,13819,2,33391),
(34769,0, 34769,1,0 ),
(34767,34769,34769,2,33391);

View file

@ -201,6 +201,7 @@ pkgdata_DATA = \
7493_01_mangos_command.sql \
7495_01_mangos_mangos_string.sql \
7503_01_mangos_command.sql \
7536_01_mangos_spell_chain.sql \
README
## Additional files to include when running 'make dist'
@ -382,4 +383,5 @@ EXTRA_DIST = \
7493_01_mangos_command.sql \
7495_01_mangos_mangos_string.sql \
7503_01_mangos_command.sql \
7536_01_mangos_spell_chain.sql \
README

View file

@ -319,6 +319,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
MaNGOS::LocalizedPacketDo<MaNGOS::AchievementChatBuilder> say_do(say_builder);
guild->BroadcastWorker(say_do,GetPlayer());
}
if(achievement->flags & (ACHIEVEMENT_FLAG_REALM_FIRST_KILL|ACHIEVEMENT_FLAG_REALM_FIRST_REACH))
{
// broadcast realm first reached
@ -337,19 +338,20 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate();
MaNGOS::AchievementChatBuilder say_builder(*GetPlayer(), CHAT_MSG_GUILD_ACHIEVEMENT, LANG_ACHIEVEMENT_EARNED,achievement->ID);
MaNGOS::AchievementChatBuilder say_builder(*GetPlayer(), CHAT_MSG_ACHIEVEMENT, LANG_ACHIEVEMENT_EARNED,achievement->ID);
MaNGOS::LocalizedPacketDo<MaNGOS::AchievementChatBuilder> say_do(say_builder);
MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::AchievementChatBuilder> > say_worker(GetPlayer(),sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY),say_do);
TypeContainerVisitor<MaNGOS::PlayerDistWorker<MaNGOS::LocalizedPacketDo<MaNGOS::AchievementChatBuilder> >, WorldTypeMapContainer > message(say_worker);
CellLock<GridReadGuard> cell_lock(cell, p);
cell_lock->Visit(cell_lock, message, *GetPlayer()->GetMap());
}
WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8+4+8);
data.append(GetPlayer()->GetPackGUID());
data << uint32(achievement->ID);
data << uint32(secsToTimeBitFields(time(NULL)));
data << uint32(0);
GetPlayer()->SendMessageToSet(&data, true);
GetPlayer()->SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY), true);
}
void AchievementMgr::SendCriteriaUpdate(uint32 id, CriteriaProgress const* progress)
@ -365,7 +367,7 @@ void AchievementMgr::SendCriteriaUpdate(uint32 id, CriteriaProgress const* progr
data << uint32(secsToTimeBitFields(progress->date));
data << uint32(0); // timer 1
data << uint32(0); // timer 2
GetPlayer()->SendMessageToSet(&data, true);
GetPlayer()->SendDirectMessage(&data);
}
/**
@ -743,7 +745,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
if (miscvalue1 && miscvalue1 != achievementCriteria->gain_reputation.factionID)
continue;
int32 reputation = GetPlayer()->GetReputation(achievementCriteria->gain_reputation.factionID);
int32 reputation = GetPlayer()->GetReputationMgr().GetReputation(achievementCriteria->gain_reputation.factionID);
if (reputation > 0)
SetCriteriaProgress(achievementCriteria, reputation);
break;
@ -755,12 +757,12 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
continue;
uint32 counter = 0;
const FactionStateList factionStateList = GetPlayer()->GetFactionStateList();
FactionStateList const& factionStateList = GetPlayer()->GetReputationMgr().GetStateList();
for (FactionStateList::const_iterator iter = factionStateList.begin(); iter!= factionStateList.end(); ++iter)
{
if(GetPlayer()->ReputationToRank(iter->second.Standing) >= REP_EXALTED)
if(FactionEntry const *factionEntry = sFactionStore.LookupEntry(iter->second.ID))
if(ReputationMgr::ReputationToRank(iter->second.Standing + GetPlayer()->GetReputationMgr().GetBaseReputation(factionEntry)) >= REP_EXALTED)
++counter;
}
SetCriteriaProgress(achievementCriteria, counter);
break;
}
@ -1107,7 +1109,7 @@ AchievementCompletionState AchievementMgr::GetAchievementCompletionState(Achieve
void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry, uint32 changeValue, ProgressType ptype)
{
if((sLog.getLogFilter() & LOG_FILTER_ACHIEVEMENT_UPDATES)==0)
sLog.outDetail("AchievementMgr::SetCriteriaProgress(%u, %u) for (GUID:%u)", entry->ID, changeValue);
sLog.outDetail("AchievementMgr::SetCriteriaProgress(%u, %u) for (GUID:%u)", entry->ID, changeValue, m_player->GetGUIDLow());
CriteriaProgress *progress = NULL;
@ -1309,7 +1311,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaList()
}
sLog.outString();
sLog.outString(">> Loaded %u achievement criteria.",m_AchievementCriteriasByType->size());
sLog.outString(">> Loaded %lu achievement criteria.",(unsigned long)m_AchievementCriteriasByType->size());
}
@ -1338,7 +1340,7 @@ void AchievementGlobalMgr::LoadCompletedAchievements()
delete result;
sLog.outString();
sLog.outString(">> Loaded %u realm completed achievements.",m_allCompletedAchievements.size());
sLog.outString(">> Loaded %lu realm completed achievements.",(unsigned long)m_allCompletedAchievements.size());
}
void AchievementGlobalMgr::LoadRewards()
@ -1448,7 +1450,7 @@ void AchievementGlobalMgr::LoadRewards()
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u achievement reward locale strings", m_achievementRewardLocales.size() );
sLog.outString( ">> Loaded %lu achievement reward locale strings", (unsigned long)m_achievementRewardLocales.size() );
}
void AchievementGlobalMgr::LoadRewardLocales()
@ -1517,5 +1519,5 @@ void AchievementGlobalMgr::LoadRewardLocales()
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u achievement reward locale strings", m_achievementRewardLocales.size() );
sLog.outString( ">> Loaded %lu achievement reward locale strings", (unsigned long)m_achievementRewardLocales.size() );
}

View file

@ -493,7 +493,7 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
recv_data >> outbiddedCount;
if (recv_data.size() != (16 + outbiddedCount * 4 ))
{
sLog.outError("Client sent bad opcode!!! with count: %u and size : %d (mustbe: %d", outbiddedCount, recv_data.size(),(16 + outbiddedCount * 4 ));
sLog.outError("Client sent bad opcode!!! with count: %u and size : %lu (must be: %u)", outbiddedCount, (unsigned long)recv_data.size(),(16 + outbiddedCount * 4 ));
outbiddedCount = 0;
}

View file

@ -585,7 +585,7 @@ void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation,
if(!team) team = plr->GetTeam();
if(team == TeamID)
plr->ModifyFactionReputation(factionEntry, Reputation);
plr->GetReputationMgr().ModifyReputation(factionEntry, Reputation);
}
}

View file

@ -1176,7 +1176,7 @@ void BattleGroundMgr::Update(uint32 diff)
// skip updating battleground template
if( itr != m_BattleGrounds[i].end() )
++itr;
for(itr = m_BattleGrounds[i].begin(); itr != m_BattleGrounds[i].end(); itr = next)
for(; itr != m_BattleGrounds[i].end(); itr = next)
{
next = itr;
++next;

View file

@ -859,15 +859,7 @@ void WorldSession::HandleSetFactionAtWar( WorldPacket & recv_data )
recv_data >> repListID;
recv_data >> flag;
FactionStateList::iterator itr = GetPlayer()->m_factions.find(repListID);
if (itr == GetPlayer()->m_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;
GetPlayer()->SetFactionAtWar(&itr->second,flag);
GetPlayer()->GetReputationMgr().SetAtWar(repListID,flag);
}
//I think this function is never used :/ I dunno, but i guess this opcode not exists
@ -875,7 +867,7 @@ void WorldSession::HandleSetFactionCheat( WorldPacket & /*recv_data*/ )
{
//CHECK_PACKET_SIZE(recv_data,4+4);
//sLog.outDebug("WORLD SESSION: HandleSetFactionCheat");
sLog.outError("WORLD SESSION: HandleSetFactionCheat, not expected call, please report.");
/*
uint32 FactionID;
uint32 Standing;
@ -895,7 +887,7 @@ void WorldSession::HandleSetFactionCheat( WorldPacket & /*recv_data*/ )
}
}
*/
GetPlayer()->UpdateReputation();
GetPlayer()->GetReputationMgr().SendStates();
}
void WorldSession::HandleMeetingStoneInfo( WorldPacket & /*recv_data*/ )
@ -960,11 +952,7 @@ void WorldSession::HandleSetWatchedFactionInactiveOpcode(WorldPacket & recv_data
uint8 inactive;
recv_data >> replistid >> inactive;
FactionStateList::iterator itr = _player->m_factions.find(replistid);
if (itr == _player->m_factions.end())
return;
_player->SetFactionInactive(&itr->second, inactive);
_player->GetReputationMgr().SetInactive(replistid, inactive);
}
void WorldSession::HandleToggleHelmOpcode( WorldPacket & /*recv_data*/ )

View file

@ -118,7 +118,6 @@ ChatCommand * ChatHandler::getCommandTable()
{ "sendopcode", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSendOpcodeCommand, "", NULL },
{ "spawnvehicle", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSpawnVehicle, "", NULL },
{ "uws", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugUpdateWorldStateCommand, "", NULL },
{ "ps", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugPlaySound2Command, "", NULL },
{ "scn", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSendChannelNotifyCommand, "", NULL },
{ "scm", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSendChatMsgCommand, "", NULL },
{ "sps", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSendSetPhaseShiftCommand, "", NULL },

View file

@ -417,7 +417,6 @@ class ChatHandler
bool HandleDebugSellErrorCommand(const char* args);
bool HandleDebugBuyErrorCommand(const char* args);
bool HandleDebugUpdateWorldStateCommand(const char* args);
bool HandleDebugPlaySound2Command(const char* args);
bool HandleDebugSendChannelNotifyCommand(const char* args);
bool HandleDebugSendChatMsgCommand(const char* args);
bool HandleRenameCommand(const char * args);

View file

@ -596,7 +596,7 @@ void Guild::CreateRank(std::string name_,uint32 rights)
// name now can be used for encoding to DB
CharacterDatabase.escape_string(name_);
CharacterDatabase.PExecute( "INSERT INTO guild_rank (guildid,rid,rname,rights) VALUES ('%u', '%u', '%s', '%u')", Id, m_ranks.size(), name_.c_str(), rights );
CharacterDatabase.PExecute( "INSERT INTO guild_rank (guildid,rid,rname,rights) VALUES ('%u', '%u', '%s', '%u')", Id, (unsigned int)m_ranks.size(), name_.c_str(), rights );
}
void Guild::AddRank(const std::string& name_,uint32 rights, uint32 money)

View file

@ -1971,35 +1971,6 @@ bool ChatHandler::HandleWhispersCommand(const char* args)
return false;
}
//Play sound
bool ChatHandler::HandleDebugPlaySoundCommand(const char* args)
{
// USAGE: .debug playsound #soundid
// #soundid - ID decimal number from SoundEntries.dbc (1st column)
// this file have about 5000 sounds.
// In this realization only caller can hear this sound.
if( *args )
{
uint32 dwSoundId = atoi((char*)args);
if( !sSoundEntriesStore.LookupEntry(dwSoundId) )
{
PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId);
SetSentErrorMessage(true);
return false;
}
WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8);
data << uint32(dwSoundId) << m_session->GetPlayer()->GetGUID();
m_session->SendPacket(&data);
PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId);
return true;
}
return false;
}
//Save all players in the world
bool ChatHandler::HandleSaveAllCommand(const char* /*args*/)
{

View file

@ -887,14 +887,7 @@ bool ChatHandler::HandleLookupFactionCommand(const char* args)
FactionEntry const *factionEntry = sFactionStore.LookupEntry (id);
if (factionEntry)
{
FactionState const* repState = NULL;
if(target)
{
FactionStateList::const_iterator repItr = target->m_factions.find (factionEntry->reputationListID);
if(repItr != target->m_factions.end())
repState = &repItr->second;
}
FactionState const* repState = target ? target->GetReputationMgr().GetState(factionEntry) : NULL;
int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale();
std::string name = factionEntry->name[loc];
@ -930,10 +923,10 @@ bool ChatHandler::HandleLookupFactionCommand(const char* args)
if (repState) // and then target!=NULL also
{
ReputationRank rank = target->GetReputationRank(factionEntry);
ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry);
std::string rankName = GetMangosString(ReputationRankStrIndex[rank]);
ss << " " << rankName << "|h|r (" << target->GetReputation(factionEntry) << ")";
ss << " " << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ")";
if(repState->Flags & FACTION_FLAG_VISIBLE)
ss << GetMangosString(LANG_FACTION_VISIBLE);
@ -1020,9 +1013,9 @@ bool ChatHandler::HandleModifyRepCommand(const char * args)
if (deltaTxt)
{
int32 delta = atoi(deltaTxt);
if ((delta < 0) || (delta > Player::ReputationRank_Length[r] -1))
if ((delta < 0) || (delta > ReputationMgr::PointsInRank[r] -1))
{
PSendSysMessage(LANG_COMMAND_FACTION_DELTA, (Player::ReputationRank_Length[r]-1));
PSendSysMessage(LANG_COMMAND_FACTION_DELTA, (ReputationMgr::PointsInRank[r]-1));
SetSentErrorMessage(true);
return false;
}
@ -1030,7 +1023,7 @@ bool ChatHandler::HandleModifyRepCommand(const char * args)
}
break;
}
amount += Player::ReputationRank_Length[r];
amount += ReputationMgr::PointsInRank[r];
}
if (r >= MAX_REPUTATION_RANK)
{
@ -1056,8 +1049,9 @@ bool ChatHandler::HandleModifyRepCommand(const char * args)
return false;
}
target->SetFactionReputation(factionEntry,amount);
PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[m_session->GetSessionDbcLocale()], factionId, GetNameLink(target).c_str(), target->GetReputation(factionId));
target->GetReputationMgr().SetReputation(factionEntry,amount);
PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[m_session->GetSessionDbcLocale()], factionId,
GetNameLink(target).c_str(), target->GetReputationMgr().GetReputation(factionEntry));
return true;
}
@ -2298,14 +2292,16 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
return false;
}
for(FactionStateList::const_iterator itr = target->m_factions.begin(); itr != target->m_factions.end(); ++itr)
FactionStateList const& targetFSL = target->GetReputationMgr().GetStateList();
for(FactionStateList::const_iterator itr = targetFSL.begin(); itr != targetFSL.end(); ++itr)
{
FactionEntry const *factionEntry = sFactionStore.LookupEntry(itr->second.ID);
char const* factionName = factionEntry ? factionEntry->name[m_session->GetSessionDbcLocale()] : "#Not found#";
ReputationRank rank = target->GetReputationRank(factionEntry);
ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry);
std::string rankName = GetMangosString(ReputationRankStrIndex[rank]);
std::ostringstream ss;
ss << itr->second.ID << ": |cffffffff|Hfaction:" << itr->second.ID << "|h[" << factionName << "]|h|r " << rankName << "|h|r (" << target->GetReputation(factionEntry) << ")";
ss << itr->second.ID << ": |cffffffff|Hfaction:" << itr->second.ID << "|h[" << factionName << "]|h|r " << rankName << "|h|r ("
<< target->GetReputationMgr().GetReputation(factionEntry) << ")";
if(itr->second.Flags & FACTION_FLAG_VISIBLE)
ss << GetMangosString(LANG_FACTION_VISIBLE);
@ -4310,6 +4306,13 @@ bool ChatHandler::LookupPlayerSearchCommand(QueryResult* result, int32 limit)
delete result;
if(i==0) // empty accounts only
{
PSendSysMessage(LANG_NO_PLAYERS_FOUND);
SetSentErrorMessage(true);
return false;
}
return true;
}

View file

@ -5015,12 +5015,10 @@ bool ChatHandler::HandleQuestComplete(const char* args)
if(uint32 repFaction = pQuest->GetRepObjectiveFaction())
{
uint32 repValue = pQuest->GetRepObjectiveValue();
uint32 curRep = player->GetReputation(repFaction);
uint32 curRep = player->GetReputationMgr().GetReputation(repFaction);
if(curRep < repValue)
{
FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction);
player->SetFactionReputation(factionEntry,repValue);
}
if(FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction))
player->GetReputationMgr().SetReputation(factionEntry,repValue);
}
// If the quest requires money

View file

@ -478,7 +478,7 @@ void WorldSession::HandleLootMasterGiveOpcode( WorldPacket & recv_data )
if (slotid > pLoot->items.size())
{
sLog.outDebug("AutoLootItem: Player %s might be using a hack! (slot %d, size %d)",GetPlayer()->GetName(), slotid, pLoot->items.size());
sLog.outDebug("AutoLootItem: Player %s might be using a hack! (slot %d, size %lu)",GetPlayer()->GetName(), slotid, (unsigned long)pLoot->items.size());
return;
}

View file

@ -166,7 +166,7 @@ void LootStore::LoadLootTable()
Verify(); // Checks validity of the loot store
sLog.outString();
sLog.outString( ">> Loaded %u loot definitions (%d templates)", count, m_LootTemplates.size());
sLog.outString( ">> Loaded %u loot definitions (%lu templates)", count, (unsigned long)m_LootTemplates.size());
}
else
{

View file

@ -214,6 +214,8 @@ libmangosgame_a_SOURCES = \
RandomMovementGenerator.h \
ReactorAI.cpp \
ReactorAI.h \
ReputationMgr.cpp \
ReputationMgr.h \
ScriptCalls.cpp \
ScriptCalls.h \
SharedDefines.h \

View file

@ -1737,8 +1737,8 @@ bool Map::CheckGridIntegrity(Creature* c, bool moved) const
Cell xy_cell(xy_val);
if(xy_cell != cur_cell)
{
sLog.outError("%s (GUID: %u) X: %f Y: %f (%s) in grid[%u,%u]cell[%u,%u] instead grid[%u,%u]cell[%u,%u]",
(c->GetTypeId()==TYPEID_PLAYER ? "Player" : "Creature"),c->GetGUIDLow(),
sLog.outError("Creature (GUIDLow: %u) X: %f Y: %f (%s) in grid[%u,%u]cell[%u,%u] instead grid[%u,%u]cell[%u,%u]",
c->GetGUIDLow(),
c->GetPositionX(),c->GetPositionY(),(moved ? "final" : "original"),
cur_cell.GridX(), cur_cell.GridY(), cur_cell.CellX(), cur_cell.CellY(),
xy_cell.GridX(), xy_cell.GridY(), xy_cell.CellX(), xy_cell.CellY());

View file

@ -405,7 +405,8 @@ void WorldSession::HandleSetTargetOpcode( WorldPacket & recv_data )
if(!unit)
return;
_player->SetFactionVisibleForFactionTemplateId(unit->getFaction());
if(FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction()))
_player->GetReputationMgr().SetVisible(factionTemplateEntry);
}
void WorldSession::HandleSetSelectionOpcode( WorldPacket & recv_data )
@ -422,7 +423,8 @@ void WorldSession::HandleSetSelectionOpcode( WorldPacket & recv_data )
if(!unit)
return;
_player->SetFactionVisibleForFactionTemplateId(unit->getFaction());
if(FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction()))
_player->GetReputationMgr().SetVisible(factionTemplateEntry);
}
void WorldSession::HandleStandStateChangeOpcode( WorldPacket & recv_data )

View file

@ -190,6 +190,9 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
if (!MaNGOS::IsValidMapCoord(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o))
return;
Unit *mover = _player->m_mover;
Player *plMover = mover->GetTypeId()==TYPEID_PLAYER ? (Player*)mover : NULL;
/* handle special cases */
if (movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT)
{
@ -203,24 +206,24 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
return;
// if we boarded a transport, add us to it
if (!GetPlayer()->m_transport)
if (plMover && !plMover->m_transport)
{
// elevators also cause the client to send MOVEMENTFLAG_ONTRANSPORT - just unmount if the guid can be found in the transport list
for (MapManager::TransportSet::iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter)
{
if ((*iter)->GetGUID() == movementInfo.t_guid)
{
GetPlayer()->m_transport = (*iter);
(*iter)->AddPassenger(GetPlayer());
plMover->m_transport = (*iter);
(*iter)->AddPassenger(plMover);
break;
}
}
}
}
else if (GetPlayer()->m_transport) // if we were on a transport, leave
else if (plMover && plMover->m_transport) // if we were on a transport, leave
{
GetPlayer()->m_transport->RemovePassenger(GetPlayer());
GetPlayer()->m_transport = NULL;
plMover->m_transport->RemovePassenger(plMover);
plMover->m_transport = NULL;
movementInfo.t_x = 0.0f;
movementInfo.t_y = 0.0f;
movementInfo.t_z = 0.0f;
@ -230,58 +233,40 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
}
// fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map).
if (opcode == MSG_MOVE_FALL_LAND && !GetPlayer()->isInFlight())
GetPlayer()->HandleFall(movementInfo);
if (opcode == MSG_MOVE_FALL_LAND && plMover && !plMover->isInFlight())
plMover->HandleFall(movementInfo);
if(((movementInfo.flags & MOVEMENTFLAG_SWIMMING) != 0) != GetPlayer()->IsInWater())
if (plMover && ((movementInfo.flags & MOVEMENTFLAG_SWIMMING) != 0) != plMover->IsInWater())
{
// now client not include swimming flag in case jumping under water
GetPlayer()->SetInWater( !GetPlayer()->IsInWater() || GetPlayer()->GetBaseMap()->IsUnderWater(movementInfo.x, movementInfo.y, movementInfo.z) );
plMover->SetInWater( !plMover->IsInWater() || plMover->GetBaseMap()->IsUnderWater(movementInfo.x, movementInfo.y, movementInfo.z) );
}
/*----------------------*/
/* process position-change */
Unit *mover = _player->m_mover;
recv_data.put<uint32>(6, getMSTime()); // fix time, offset flags(4) + unk(2)
WorldPacket data(recv_data.GetOpcode(), (mover->GetPackGUID().size()+recv_data.size()));
data.append(_player->m_mover->GetPackGUID()); // use mover guid
data.append(mover->GetPackGUID()); // use mover guid
data.append(recv_data.contents(), recv_data.size());
GetPlayer()->SendMessageToSet(&data, false);
if(!_player->GetCharmGUID()) // nothing is charmed
if(plMover) // nothing is charmed, or player charmed
{
_player->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
_player->m_movementInfo = movementInfo;
_player->SetUnitMovementFlags(movementInfo.flags);
}
else
{
if(mover->GetTypeId() != TYPEID_PLAYER) // unit, creature, pet, vehicle...
{
if(Map *map = mover->GetMap())
map->CreatureRelocation((Creature*)mover, movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
mover->SetUnitMovementFlags(movementInfo.flags);
}
else // player
{
((Player*)mover)->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
((Player*)mover)->m_movementInfo = movementInfo;
((Player*)mover)->SetUnitMovementFlags(movementInfo.flags);
}
}
plMover->SetPosition(movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
plMover->m_movementInfo = movementInfo;
plMover->SetUnitMovementFlags(movementInfo.flags);
if (GetPlayer()->m_lastFallTime >= movementInfo.fallTime || GetPlayer()->m_lastFallZ <=movementInfo.z || recv_data.GetOpcode() == MSG_MOVE_FALL_LAND)
GetPlayer()->SetFallInformation(movementInfo.fallTime, movementInfo.z);
plMover->UpdateFallInformationIfNeed(movementInfo,recv_data.GetOpcode());
if(GetPlayer()->isMovingOrTurning())
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
if(plMover->isMovingOrTurning())
plMover->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
if(movementInfo.z < -500.0f)
{
if(GetPlayer()->InBattleGround()
&& GetPlayer()->GetBattleGround()
&& GetPlayer()->GetBattleGround()->HandlePlayerUnderMap(_player))
if(plMover->InBattleGround()
&& plMover->GetBattleGround()
&& plMover->GetBattleGround()->HandlePlayerUnderMap(_player))
{
// do nothing, the handle already did if returned true
}
@ -290,20 +275,27 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
// NOTE: this is actually called many times while falling
// even after the player has been teleported away
// TODO: discard movement packets after the player is rooted
if(GetPlayer()->isAlive())
if(plMover->isAlive())
{
GetPlayer()->EnvironmentalDamage(GetPlayer()->GetGUID(),DAMAGE_FALL_TO_VOID, GetPlayer()->GetMaxHealth());
plMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, GetPlayer()->GetMaxHealth());
// change the death state to CORPSE to prevent the death timer from
// starting in the next player update
GetPlayer()->KillPlayer();
GetPlayer()->BuildPlayerRepop();
plMover->KillPlayer();
plMover->BuildPlayerRepop();
}
// cancel the death timer here if started
GetPlayer()->RepopAtGraveyard();
plMover->RepopAtGraveyard();
}
}
}
else // creature charmed
{
if(Map *map = mover->GetMap())
map->CreatureRelocation((Creature*)mover, movementInfo.x, movementInfo.y, movementInfo.z, movementInfo.o);
mover->SetUnitMovementFlags(movementInfo.flags);
}
}
void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recv_data)
{

View file

@ -1708,3 +1708,24 @@ void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
if(update && IsInWorld())
ObjectAccessor::UpdateObjectVisibility(this);
}
void WorldObject::PlayDistanceSound( uint32 sound_id, Player* target /*= NULL*/ )
{
WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8);
data << uint32(sound_id);
data << GetGUID();
if (target)
target->SendDirectMessage( &data );
else
SendMessageToSet( &data, true );
}
void WorldObject::PlayDirectSound( uint32 sound_id, Player* target /*= NULL*/ )
{
WorldPacket data(SMSG_PLAY_SOUND, 4);
data << uint32(sound_id);
if (target)
target->SendDirectMessage( &data );
else
SendMessageToSet( &data, true );
}

View file

@ -458,6 +458,9 @@ class MANGOS_DLL_SPEC WorldObject : public Object
void MonsterWhisper(int32 textId, uint64 receiver, bool IsBossWhisper = false);
void BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const* text, uint32 language, char const* name, uint64 TargetGuid) const;
void PlayDistanceSound(uint32 sound_id, Player* target = NULL);
void PlayDirectSound(uint32 sound_id, Player* target = NULL);
void SendObjectDeSpawnAnim(uint64 guid);
virtual void SaveRespawnTime() {}

View file

@ -79,13 +79,11 @@ ObjectAccessor::GetNPCIfCanInteractWith(Player const &player, uint64 guid, uint3
return NULL;
// not unfriendly
FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(unit->getFaction());
if(factionTemplate)
{
FactionEntry const* faction = sFactionStore.LookupEntry(factionTemplate->faction);
if( faction && faction->reputationListID >= 0 && player.GetReputationRank(faction) <= REP_UNFRIENDLY)
if(FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(unit->getFaction()))
if(factionTemplate->faction)
if(FactionEntry const* faction = sFactionStore.LookupEntry(factionTemplate->faction))
if(faction->reputationListID >= 0 && player.GetReputationMgr().GetRank(faction) <= REP_UNFRIENDLY)
return NULL;
}
// not too far
if(!unit->IsWithinDistInMap(&player,INTERACTION_DISTANCE))

View file

@ -323,7 +323,7 @@ void ObjectMgr::LoadCreatureLocales()
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u creature locale strings", mCreatureLocaleMap.size() );
sLog.outString( ">> Loaded %lu creature locale strings", (unsigned long)mCreatureLocaleMap.size() );
}
void ObjectMgr::LoadNpcOptionLocales()
@ -391,7 +391,7 @@ void ObjectMgr::LoadNpcOptionLocales()
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u npc_option locale strings", mNpcOptionLocaleMap.size() );
sLog.outString( ">> Loaded %lu npc_option locale strings", (unsigned long)mNpcOptionLocaleMap.size() );
}
void ObjectMgr::LoadPointOfInterestLocales()
@ -442,7 +442,7 @@ void ObjectMgr::LoadPointOfInterestLocales()
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u points_of_interest locale strings", mPointOfInterestLocaleMap.size() );
sLog.outString( ">> Loaded %lu points_of_interest locale strings", (unsigned long)mPointOfInterestLocaleMap.size() );
}
struct SQLCreatureLoader : public SQLStorageLoaderBase<SQLCreatureLoader>
@ -982,7 +982,7 @@ void ObjectMgr::LoadCreatures()
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u creatures", mCreatureDataMap.size() );
sLog.outString( ">> Loaded %lu creatures", (unsigned long)mCreatureDataMap.size() );
}
void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data)
@ -1109,7 +1109,7 @@ void ObjectMgr::LoadGameobjects()
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u gameobjects", mGameObjectDataMap.size());
sLog.outString( ">> Loaded %lu gameobjects", (unsigned long)mGameObjectDataMap.size());
}
void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data)
@ -1182,7 +1182,7 @@ void ObjectMgr::LoadCreatureRespawnTimes()
delete result;
sLog.outString( ">> Loaded %u creature respawn times", mCreatureRespawnTimes.size() );
sLog.outString( ">> Loaded %lu creature respawn times", (unsigned long)mCreatureRespawnTimes.size() );
sLog.outString();
}
@ -1224,7 +1224,7 @@ void ObjectMgr::LoadGameobjectRespawnTimes()
delete result;
sLog.outString( ">> Loaded %u gameobject respawn times", mGORespawnTimes.size() );
sLog.outString( ">> Loaded %lu gameobject respawn times", (unsigned long)mGORespawnTimes.size() );
sLog.outString();
}
@ -1369,7 +1369,7 @@ void ObjectMgr::LoadItemLocales()
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u Item locale strings", mItemLocaleMap.size() );
sLog.outString( ">> Loaded %lu Item locale strings", (unsigned long)mItemLocaleMap.size() );
}
struct SQLItemLoader : public SQLStorageLoaderBase<SQLItemLoader>
@ -1719,13 +1719,13 @@ void ObjectMgr::LoadItemPrototypes()
if(proto->BagFamily)
{
// check bits
for(uint32 i = 0; i < sizeof(proto->BagFamily)*8; ++i)
for(uint32 j = 0; j < sizeof(proto->BagFamily)*8; ++j)
{
uint32 mask = 1 << i;
uint32 mask = 1 << j;
if((proto->BagFamily & mask)==0)
continue;
ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(i+1);
ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j+1);
if(!bf)
{
sLog.outErrorDb("Item (Entry: %u) has bag family bit set not listed in ItemBagFamily.dbc, remove bit",i);
@ -2986,10 +2986,10 @@ void ObjectMgr::LoadQuests()
// no changes, quest can't be done for this requirement
}
if(qinfo->RequiredMinRepValue && qinfo->RequiredMinRepValue > Player::Reputation_Cap)
if(qinfo->RequiredMinRepValue && qinfo->RequiredMinRepValue > ReputationMgr::Reputation_Cap)
{
sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but max reputation is %u, quest can't be done.",
qinfo->GetQuestId(),qinfo->RequiredMinRepValue,Player::Reputation_Cap);
qinfo->GetQuestId(),qinfo->RequiredMinRepValue,ReputationMgr::Reputation_Cap);
// no changes, quest can't be done for this requirement
}
@ -3412,7 +3412,7 @@ void ObjectMgr::LoadQuests()
}
sLog.outString();
sLog.outString( ">> Loaded %u quests definitions", mQuestTemplates.size() );
sLog.outString( ">> Loaded %lu quests definitions", (unsigned long)mQuestTemplates.size() );
}
void ObjectMgr::LoadQuestLocales()
@ -3548,7 +3548,7 @@ void ObjectMgr::LoadQuestLocales()
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u Quest locale strings", mQuestLocaleMap.size() );
sLog.outString( ">> Loaded %lu Quest locale strings", (unsigned long)mQuestLocaleMap.size() );
}
void ObjectMgr::LoadPetCreateSpells()
@ -4098,7 +4098,7 @@ void ObjectMgr::LoadPageTextLocales()
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u PageText locale strings", mPageTextLocaleMap.size() );
sLog.outString( ">> Loaded %lu PageText locale strings", (unsigned long)mPageTextLocaleMap.size() );
}
struct SQLInstanceLoader : public SQLStorageLoaderBase<SQLInstanceLoader>
@ -4293,7 +4293,7 @@ void ObjectMgr::LoadNpcTextLocales()
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u NpcText locale strings", mNpcTextLocaleMap.size() );
sLog.outString( ">> Loaded %lu NpcText locale strings", (unsigned long)mNpcTextLocaleMap.size() );
}
//not very fast function but it is called only once a day, or on starting-up
@ -5379,7 +5379,7 @@ void ObjectMgr::LoadGameObjectLocales()
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u gameobject locale strings", mGameObjectLocaleMap.size() );
sLog.outString( ">> Loaded %lu gameobject locale strings", (unsigned long)mGameObjectLocaleMap.size() );
}
struct SQLGameObjectLoader : public SQLStorageLoaderBase<SQLGameObjectLoader>
@ -6609,7 +6609,7 @@ bool PlayerCondition::Meets(Player const * player) const
case CONDITION_REPUTATION_RANK:
{
FactionEntry const* faction = sFactionStore.LookupEntry(value1);
return faction && player->GetReputationRank(faction) >= value2;
return faction && player->GetReputationMgr().GetRank(faction) >= value2;
}
case CONDITION_TEAM:
return player->GetTeam() == value1;

View file

@ -261,11 +261,9 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi)
//== Player ====================================================
const int32 Player::ReputationRank_Length[MAX_REPUTATION_RANK] = {36000, 3000, 3000, 3000, 6000, 12000, 21000, 1000};
UpdateMask Player::updateVisualBits;
Player::Player (WorldSession *session): Unit(), m_achievementMgr(this)
Player::Player (WorldSession *session): Unit(), m_achievementMgr(this), m_reputationMgr(this)
{
m_transport = 0;
@ -447,7 +445,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this)
//Default movement to run mode
m_unit_movement_flags = 0;
m_mover = NULL;
m_mover = this;
m_miniPet = 0;
m_bgAfkReportedTimer = 0;
@ -455,6 +453,9 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this)
m_declinedname = NULL;
m_runes = NULL;
m_lastFallTime = 0;
m_lastFallZ = 0;
}
Player::~Player ()
@ -822,7 +823,7 @@ void Player::StopMirrorTimer(MirrorTimerType Type)
GetSession()->SendPacket( &data );
}
void Player::EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage)
void Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
{
if(!isAlive() || isGameMaster())
return;
@ -838,11 +839,11 @@ void Player::EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 da
damage-=absorb+resist;
WorldPacket data(SMSG_ENVIRONMENTALDAMAGELOG, (21));
data << (uint64)guid;
data << (uint8)(type!=DAMAGE_FALL_TO_VOID ? type : DAMAGE_FALL);
data << (uint32)damage;
data << (uint32)absorb; // absorb
data << (uint32)resist; // resist
data << uint64(GetGUID());
data << uint8(type!=DAMAGE_FALL_TO_VOID ? type : DAMAGE_FALL);
data << uint32(damage);
data << uint32(absorb);
data << uint32(resist);
SendMessageToSet(&data, true);
DealDamage(this, damage, NULL, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
@ -921,7 +922,7 @@ void Player::HandleDrowning(uint32 time_diff)
// Calculate and deal damage
// TODO: Check this formula
uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel()-1);
EnvironmentalDamage(GetGUID(), DAMAGE_DROWNING, damage);
EnvironmentalDamage(DAMAGE_DROWNING, damage);
}
else if (!(m_MirrorTimerFlagsLast & UNDERWATER_INWATER)) // Update time in client if need
SendMirrorTimer(BREATH_TIMER, getMaxTimer(BREATH_TIMER), m_MirrorTimer[BREATH_TIMER], -1);
@ -957,7 +958,7 @@ void Player::HandleDrowning(uint32 time_diff)
if (isAlive()) // Calculate and deal damage
{
uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel()-1);
EnvironmentalDamage(GetGUID(), DAMAGE_EXHAUSTED, damage);
EnvironmentalDamage(DAMAGE_EXHAUSTED, damage);
}
else if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) // Teleport ghost to graveyard
RepopAtGraveyard();
@ -991,9 +992,9 @@ void Player::HandleDrowning(uint32 time_diff)
// TODO: Check this formula
uint32 damage = urand(600, 700);
if (m_MirrorTimerFlags&UNDERWATER_INLAVA)
EnvironmentalDamage(GetGUID(), DAMAGE_LAVA, damage);
EnvironmentalDamage(DAMAGE_LAVA, damage);
else
EnvironmentalDamage(GetGUID(), DAMAGE_SLIME, damage);
EnvironmentalDamage(DAMAGE_SLIME, damage);
}
}
}
@ -5586,439 +5587,27 @@ void Player::setFactionForRace(uint8 race)
setFaction( getFactionForRace(race) );
}
void Player::UpdateReputation() const
{
sLog.outDetail( "WORLD: Player::UpdateReputation" );
for(FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
{
SendFactionState(&(itr->second));
}
}
void Player::SendFactionState(FactionState const* faction) const
{
if(faction->Flags & FACTION_FLAG_VISIBLE) //If faction is visible then update it
{
WorldPacket data(SMSG_SET_FACTION_STANDING, (16)); // last check 2.4.0
data << (float) 0; // unk 2.4.0
data << (uint8) 0; // wotlk 8634
data << (uint32) 1; // count
// for
data << (uint32) faction->ReputationListID;
data << (uint32) faction->Standing;
// end for
GetSession()->SendPacket(&data);
}
}
void Player::SendInitialReputations()
{
WorldPacket data(SMSG_INITIALIZE_FACTIONS, (4+128*5));
data << uint32 (0x00000080);
RepListID a = 0;
for (FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
{
// fill in absent fields
for (; a != itr->first; a++)
{
data << uint8 (0x00);
data << uint32 (0x00000000);
}
// fill in encountered data
data << uint8 (itr->second.Flags);
data << uint32 (itr->second.Standing);
++a;
}
// fill in absent fields
for (; a != 128; a++)
{
data << uint8 (0x00);
data << uint32 (0x00000000);
}
GetSession()->SendPacket(&data);
}
FactionState const* Player::GetFactionState( FactionEntry const* factionEntry) const
{
FactionStateList::const_iterator itr = m_factions.find(factionEntry->reputationListID);
if (itr != m_factions.end())
return &itr->second;
return NULL;
}
void Player::SetFactionAtWar(FactionState* faction, bool atWar)
{
// not allow declare war to own faction
if(atWar && (faction->Flags & FACTION_FLAG_PEACE_FORCED) )
return;
// already set
if(((faction->Flags & FACTION_FLAG_AT_WAR) != 0) == atWar)
return;
if( atWar )
faction->Flags |= FACTION_FLAG_AT_WAR;
else
faction->Flags &= ~FACTION_FLAG_AT_WAR;
faction->Changed = true;
}
void Player::SetFactionInactive(FactionState* faction, bool inactive)
{
// always invisible or hidden faction can't be inactive
if(inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE) ) )
return;
// already set
if(((faction->Flags & FACTION_FLAG_INACTIVE) != 0) == inactive)
return;
if(inactive)
faction->Flags |= FACTION_FLAG_INACTIVE;
else
faction->Flags &= ~FACTION_FLAG_INACTIVE;
faction->Changed = true;
}
void Player::SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId)
{
FactionTemplateEntry const*factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId);
if(!factionTemplateEntry)
return;
if(factionTemplateEntry->faction)
SetFactionVisibleForFactionId(factionTemplateEntry->faction);
}
void Player::SetFactionVisibleForFactionId(uint32 FactionId)
{
FactionEntry const *factionEntry = sFactionStore.LookupEntry(FactionId);
if(!factionEntry)
return;
if(factionEntry->reputationListID < 0)
return;
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
if (itr == m_factions.end())
return;
SetFactionVisible(&itr->second);
}
void Player::SetFactionVisible(FactionState* faction)
{
// always invisible or hidden faction can't be make visible
if(faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN))
return;
// already set
if(faction->Flags & FACTION_FLAG_VISIBLE)
return;
faction->Flags |= FACTION_FLAG_VISIBLE;
faction->Changed = true;
if(!m_session->PlayerLoading())
{
// make faction visible in reputation list at client
WorldPacket data(SMSG_SET_FACTION_VISIBLE, 4);
data << faction->ReputationListID;
GetSession()->SendPacket(&data);
}
}
void Player::SetInitialFactions()
{
for(unsigned int i = 1; i < sFactionStore.GetNumRows(); i++)
{
FactionEntry const *factionEntry = sFactionStore.LookupEntry(i);
if( factionEntry && (factionEntry->reputationListID >= 0))
{
FactionState newFaction;
newFaction.ID = factionEntry->ID;
newFaction.ReputationListID = factionEntry->reputationListID;
newFaction.Standing = 0;
newFaction.Flags = GetDefaultReputationFlags(factionEntry);
newFaction.Changed = true;
m_factions[newFaction.ReputationListID] = newFaction;
}
}
}
uint32 Player::GetDefaultReputationFlags(const FactionEntry *factionEntry) const
{
if (!factionEntry)
return 0;
uint32 raceMask = getRaceMask();
uint32 classMask = getClassMask();
for (int i=0; i < 4; i++)
{
if( (factionEntry->BaseRepRaceMask[i] & raceMask) &&
(factionEntry->BaseRepClassMask[i]==0 ||
(factionEntry->BaseRepClassMask[i] & classMask) ) )
return factionEntry->ReputationFlags[i];
}
return 0;
}
int32 Player::GetBaseReputation(const FactionEntry *factionEntry) const
{
if (!factionEntry)
return 0;
uint32 raceMask = getRaceMask();
uint32 classMask = getClassMask();
for (int i=0; i < 4; i++)
{
if( (factionEntry->BaseRepRaceMask[i] & raceMask) &&
(factionEntry->BaseRepClassMask[i]==0 ||
(factionEntry->BaseRepClassMask[i] & classMask) ) )
return factionEntry->BaseRepValue[i];
}
// in faction.dbc exist factions with (RepListId >=0, listed in character reputation list) with all BaseRepRaceMask[i]==0
return 0;
}
int32 Player::GetReputation(uint32 faction_id) const
{
FactionEntry const *factionEntry = sFactionStore.LookupEntry(faction_id);
if (!factionEntry)
{
sLog.outError("Player::GetReputation: Can't get reputation of %s for unknown faction (faction template id) #%u.",GetName(), faction_id);
return 0;
}
return GetReputation(factionEntry);
}
int32 Player::GetReputation(const FactionEntry *factionEntry) const
{
// Faction without recorded reputation. Just ignore.
if(!factionEntry)
return 0;
FactionStateList::const_iterator itr = m_factions.find(factionEntry->reputationListID);
if (itr != m_factions.end())
return GetBaseReputation(factionEntry) + itr->second.Standing;
return 0;
}
ReputationRank Player::GetReputationRank(uint32 faction) const
{
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction);
if(!factionEntry)
return MIN_REPUTATION_RANK;
return GetReputationRank(factionEntry);
}
ReputationRank Player::ReputationToRank(int32 standing) const
{
int32 Limit = Reputation_Cap + 1;
for (int i = MAX_REPUTATION_RANK-1; i >= MIN_REPUTATION_RANK; --i)
{
Limit -= ReputationRank_Length[i];
if (standing >= Limit )
return ReputationRank(i);
}
return MIN_REPUTATION_RANK;
}
ReputationRank Player::GetReputationRank(const FactionEntry *factionEntry) const
{
int32 Reputation = GetReputation(factionEntry);
return ReputationToRank(Reputation);
}
ReputationRank Player::GetBaseReputationRank(const FactionEntry *factionEntry) const
{
int32 Reputation = GetBaseReputation(factionEntry);
return ReputationToRank(Reputation);
}
bool Player::ModifyFactionReputation(uint32 FactionTemplateId, int32 DeltaReputation)
{
FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId);
if(!factionTemplateEntry)
{
sLog.outError("Player::ModifyFactionReputation: Can't update reputation of %s for unknown faction (faction template id) #%u.", GetName(), FactionTemplateId);
return false;
}
FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction);
// Faction without recorded reputation. Just ignore.
if(!factionEntry)
return false;
return ModifyFactionReputation(factionEntry, DeltaReputation);
}
bool Player::ModifyFactionReputation(FactionEntry const* factionEntry, int32 standing)
{
SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID);
if (flist)
{
bool res = false;
for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr)
{
FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr);
if(factionEntryCalc)
res = ModifyOneFactionReputation(factionEntryCalc, standing);
}
return res;
}
else
return ModifyOneFactionReputation(factionEntry, standing);
}
bool Player::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)
SetFactionAtWar(&itr->second,true);
itr->second.Standing = new_rep - BaseRep;
itr->second.Changed = true;
SetFactionVisible(&itr->second);
for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i )
{
if(uint32 questid = GetQuestSlotQuestId(i))
{
Quest const* qInfo = objmgr.GetQuestTemplate(questid);
if( qInfo && qInfo->GetRepObjectiveFaction() == factionEntry->ID )
{
QuestStatusData& q_status = mQuestStatus[questid];
if( q_status.m_status == QUEST_STATUS_INCOMPLETE )
{
if(GetReputation(factionEntry) >= qInfo->GetRepObjectiveValue())
if ( CanCompleteQuest( questid ) )
CompleteQuest( questid );
}
else if( q_status.m_status == QUEST_STATUS_COMPLETE )
{
if(GetReputation(factionEntry) < qInfo->GetRepObjectiveValue())
IncompleteQuest( questid );
}
}
}
}
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION,factionEntry->ID);
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION,factionEntry->ID);
SendFactionState(&(itr->second));
return true;
}
return false;
}
bool Player::SetFactionReputation(uint32 FactionTemplateId, int32 standing)
{
FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(FactionTemplateId);
if(!factionTemplateEntry)
{
sLog.outError("Player::SetFactionReputation: Can't set reputation of %s for unknown faction (faction template id) #%u.", GetName(), FactionTemplateId);
return false;
}
FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction);
// Faction without recorded reputation. Just ignore.
if(!factionEntry)
return false;
return SetFactionReputation(factionEntry, standing);
}
bool Player::SetFactionReputation(FactionEntry const* factionEntry, int32 standing)
{
SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID);
if (flist)
{
bool res = false;
for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr)
{
FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr);
if(factionEntryCalc)
res = SetOneFactionReputation(factionEntryCalc, standing);
}
return res;
}
else
return SetOneFactionReputation(factionEntry, standing);
}
bool Player::SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing)
{
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
if (itr != m_factions.end())
{
if (standing > Reputation_Cap)
standing = Reputation_Cap;
else
if (standing < Reputation_Bottom)
standing = Reputation_Bottom;
int32 BaseRep = GetBaseReputation(factionEntry);
itr->second.Standing = standing - BaseRep;
itr->second.Changed = true;
SetFactionVisible(&itr->second);
if(ReputationToRank(standing) <= REP_HOSTILE)
SetFactionAtWar(&itr->second,true);
SendFactionState(&(itr->second));
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION,factionEntry->ID);
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION,factionEntry->ID);
return true;
}
return false;
return GetReputationMgr().GetRank(factionEntry);
}
//Calculate total reputation percent player gain with quest/creature level
int32 Player::CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest)
{
int32 percent = 100;
float percent = 100.0f;
float rate = for_quest ? sWorld.getRate(RATE_REPUTATION_LOWLEVEL_QUEST) : sWorld.getRate(RATE_REPUTATION_LOWLEVEL_KILL);
if(rate != 1.0f && creatureOrQuestLevel <= MaNGOS::XP::GetGrayLevel(getLevel()))
percent *= rate;
int32 repMod = GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN);
percent += rep > 0 ? repMod : -repMod;
if(percent <=0)
if(percent <= 0.0f)
return 0;
return int32(sWorld.getRate(RATE_REPUTATION_GAIN)*rep*percent/100);
@ -6040,16 +5629,16 @@ void Player::RewardReputation(Unit *pVictim, float rate)
int32 donerep1 = CalculateReputationGain(pVictim->getLevel(),Rep->repvalue1,false);
donerep1 = int32(donerep1*rate);
FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1);
uint32 current_reputation_rank1 = GetReputationRank(factionEntry1);
uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1);
if(factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1)
ModifyFactionReputation(factionEntry1, donerep1);
GetReputationMgr().ModifyReputation(factionEntry1, donerep1);
// Wiki: Team factions value divided by 2
if(Rep->is_teamaward1)
{
FactionEntry const *team1_factionEntry = sFactionStore.LookupEntry(factionEntry1->team);
if(team1_factionEntry)
ModifyFactionReputation(team1_factionEntry, donerep1 / 2);
GetReputationMgr().ModifyReputation(team1_factionEntry, donerep1 / 2);
}
}
@ -6058,16 +5647,16 @@ void Player::RewardReputation(Unit *pVictim, float rate)
int32 donerep2 = CalculateReputationGain(pVictim->getLevel(),Rep->repvalue2,false);
donerep2 = int32(donerep2*rate);
FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2);
uint32 current_reputation_rank2 = GetReputationRank(factionEntry2);
uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2);
if(factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2)
ModifyFactionReputation(factionEntry2, donerep2);
GetReputationMgr().ModifyReputation(factionEntry2, donerep2);
// Wiki: Team factions value divided by 2
if(Rep->is_teamaward2)
{
FactionEntry const *team2_factionEntry = sFactionStore.LookupEntry(factionEntry2->team);
if(team2_factionEntry)
ModifyFactionReputation(team2_factionEntry, donerep2 / 2);
GetReputationMgr().ModifyReputation(team2_factionEntry, donerep2 / 2);
}
}
}
@ -6083,7 +5672,7 @@ void Player::RewardReputation(Quest const *pQuest)
int32 rep = CalculateReputationGain(GetQuestLevel(pQuest),pQuest->RewRepValue[i],true);
FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i]);
if(factionEntry)
ModifyFactionReputation(factionEntry, rep);
GetReputationMgr().ModifyReputation(factionEntry, rep);
}
}
@ -10283,7 +9872,7 @@ uint8 Player::CanUseAmmo( uint32 item ) const
}
if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) )
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
/*if( GetReputation() < pProto->RequiredReputation )
/*if( GetReputationMgr().GetReputation() < pProto->RequiredReputation )
return EQUIP_ERR_CANT_EQUIP_REPUTATION;
*/
if( getLevel() < pProto->RequiredLevel )
@ -12454,7 +12043,7 @@ bool Player::CanCompleteQuest( uint32 quest_id )
}
uint32 repFacId = qInfo->GetRepObjectiveFaction();
if ( repFacId && GetReputation(repFacId) < qInfo->GetRepObjectiveValue() )
if ( repFacId && GetReputationMgr().GetReputation(repFacId) < qInfo->GetRepObjectiveValue() )
return false;
return true;
@ -12588,7 +12177,8 @@ void Player::AddQuest( Quest const *pQuest, Object *questGiver )
AdjustQuestReqItemCount( pQuest, questStatusData );
if( pQuest->GetRepObjectiveFaction() )
SetFactionVisibleForFactionId(pQuest->GetRepObjectiveFaction());
if(FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->GetRepObjectiveFaction()))
GetReputationMgr().SetVisible(factionEntry);
uint32 qtime = 0;
if( pQuest->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) )
@ -13081,7 +12671,7 @@ bool Player::SatisfyQuestRace( Quest const* qInfo, bool msg )
bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg )
{
uint32 fIdMin = qInfo->GetRequiredMinRepFaction(); //Min required rep
if(fIdMin && GetReputation(fIdMin) < qInfo->GetRequiredMinRepValue())
if(fIdMin && GetReputationMgr().GetReputation(fIdMin) < qInfo->GetRequiredMinRepValue())
{
if( msg )
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
@ -13089,7 +12679,7 @@ bool Player::SatisfyQuestReputation( Quest const* qInfo, bool msg )
}
uint32 fIdMax = qInfo->GetRequiredMaxRepFaction(); //Max required rep
if(fIdMax && GetReputation(fIdMax) >= qInfo->GetRequiredMaxRepValue())
if(fIdMax && GetReputationMgr().GetReputation(fIdMax) >= qInfo->GetRequiredMaxRepValue())
{
if( msg )
SendCanTakeQuestResponse( INVALIDREASON_DONT_HAVE_REQ );
@ -13733,6 +13323,34 @@ void Player::MoneyChanged( uint32 count )
}
}
void Player::ReputationChanged(FactionEntry const* factionEntry )
{
for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i )
{
if(uint32 questid = GetQuestSlotQuestId(i))
{
if(Quest const* qInfo = objmgr.GetQuestTemplate(questid))
{
if(qInfo->GetRepObjectiveFaction() == factionEntry->ID )
{
QuestStatusData& q_status = mQuestStatus[questid];
if( q_status.m_status == QUEST_STATUS_INCOMPLETE )
{
if(GetReputationMgr().GetReputation(factionEntry) >= qInfo->GetRepObjectiveValue())
if ( CanCompleteQuest( questid ) )
CompleteQuest( questid );
}
else if( q_status.m_status == QUEST_STATUS_COMPLETE )
{
if(GetReputationMgr().GetReputation(factionEntry) < qInfo->GetRepObjectiveValue())
IncompleteQuest( questid );
}
}
}
}
}
}
bool Player::HasQuestForItem( uint32 itemid ) const
{
for( int i = 0; i < MAX_QUEST_LOG_SIZE; ++i )
@ -14179,7 +13797,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
//Need to call it to initialize m_team (m_team can be calculated from m_race)
//Other way is to saves m_team into characters table.
setFactionForRace(m_race);
SetCharm(0);
SetCharm(NULL);
m_class = fields[5].GetUInt8();
@ -14513,7 +14131,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
learnDefaultSpells();
// must be before inventory (some items required reputation check)
_LoadReputation(holder->GetResult(PLAYER_LOGIN_QUERY_LOADREPUTATION));
m_reputationMgr.LoadFromDB(holder->GetResult(PLAYER_LOGIN_QUERY_LOADREPUTATION));
_LoadInventory(holder->GetResult(PLAYER_LOGIN_QUERY_LOADINVENTORY), time_diff);
@ -15260,61 +14878,6 @@ void Player::_LoadDailyQuestStatus(QueryResult *result)
m_DailyQuestChanged = false;
}
void Player::_LoadReputation(QueryResult *result)
{
m_factions.clear();
// Set initial reputations (so everything is nifty before DB data load)
SetInitialFactions();
//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->reputationListID >= 0))
{
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 )
SetFactionVisible(faction); // have internal checks for forced invisibility
if( dbFactionFlags & FACTION_FLAG_INACTIVE)
SetFactionInactive(faction,true); // have internal checks for visibility requirement
if( dbFactionFlags & FACTION_FLAG_AT_WAR ) // DB at war
SetFactionAtWar(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 )
SetFactionAtWar(faction,false); // have internal checks for FACTION_FLAG_PEACE_FORCED
}
// set atWar for hostile
if(GetReputationRank(factionEntry) <= REP_HOSTILE)
SetFactionAtWar(faction,true);
// reset changed flag if values similar to saved in DB
if(faction->Flags==dbFactionFlags)
faction->Changed = false;
}
}
while( result->NextRow() );
delete result;
}
}
void Player::_LoadSpells(QueryResult *result)
{
//QueryResult *result = CharacterDatabase.PQuery("SELECT spell,active,disabled FROM character_spell WHERE guid = '%u'",GetGUIDLow());
@ -15776,7 +15339,8 @@ void Player::SaveToDB()
_SaveSpellCooldowns();
_SaveActions();
_SaveAuras();
_SaveReputation();
m_achievementMgr.SaveToDB();
m_reputationMgr.SaveToDB();
_SaveEquipmentSets();
GetSession()->SaveTutorialsData(); // changed only while character in game
@ -15792,7 +15356,6 @@ void Player::SaveToDB()
// save pet (hunter pet level and experience and all type pets health/mana).
if(Pet* pet = GetPet())
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
m_achievementMgr.SaveToDB();
}
// fast save function for item/money cheating preventing - save only inventory and money state
@ -16056,19 +15619,6 @@ void Player::_SaveDailyQuestStatus()
GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx),uint64(m_lastDailyQuestTime));
}
void Player::_SaveReputation()
{
for(FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
{
if (itr->second.Changed)
{
CharacterDatabase.PExecute("DELETE FROM character_reputation WHERE guid = '%u' AND faction='%u'", GetGUIDLow(), itr->second.ID);
CharacterDatabase.PExecute("INSERT INTO character_reputation (guid,faction,standing,flags) VALUES ('%u', '%u', '%i', '%u')", GetGUIDLow(), itr->second.ID, itr->second.Standing, itr->second.Flags);
itr->second.Changed = false;
}
}
}
void Player::_SaveSpells()
{
for (PlayerSpellMap::iterator itr = m_spells.begin(), next = m_spells.begin(); itr != m_spells.end();)
@ -16308,16 +15858,6 @@ void Player::SendAutoRepeatCancel()
GetSession()->SendPacket( &data );
}
void Player::PlaySound(uint32 Sound, bool OnlySelf)
{
WorldPacket data(SMSG_PLAY_SOUND, 4);
data << Sound;
if (OnlySelf)
GetSession()->SendPacket( &data );
else
SendMessageToSet( &data, true );
}
void Player::SendExplorationExperience(uint32 Area, uint32 Experience)
{
WorldPacket data( SMSG_EXPLORATION_EXPERIENCE, 8 );
@ -18223,7 +17763,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
GetSession()->SendPacket(&data);
SendInitialActionButtons();
SendInitialReputations();
m_reputationMgr.SendInitialReputations();
m_achievementMgr.SendAllAchievementData();
// update zone
@ -18742,6 +18282,7 @@ void Player::SummonIfPossible(bool agree)
}
// drop flag at summon
// this code can be reached only when GM is summoning player who carries flag, because player should be immune to summoning spells when he carries flag
if(BattleGround *bg = GetBattleGround())
bg->EventPlayerDroppedFlag(this);
@ -19388,6 +18929,7 @@ bool Player::CanUseBattleGroundObject()
return ( //InBattleGround() && // in battleground - not need, check in other cases
//!IsMounted() && - not correct, player is dismounted when he clicks on flag
//i'm not sure if these two are correct, because invisible players should get visible when they click on flag
!isTotalImmune() && // not totally immune
!HasStealthAura() && // not stealthed
!HasInvisibilityAura() && // not invisible
!HasAura(SPELL_RECENTLY_DROPPED_FLAG, 0) && // can't pickup
@ -19555,6 +19097,20 @@ void Player::ExitVehicle(Vehicle *vehicle)
CastSpell(this, 45472, true); // Parachute
}
bool Player::isTotalImmune()
{
AuraList const& immune = GetAurasByType(SPELL_AURA_SCHOOL_IMMUNITY);
uint32 immuneMask = 0;
for(AuraList::const_iterator itr = immune.begin(); itr != immune.end(); ++itr)
{
immuneMask |= (*itr)->GetModifier()->m_miscvalue;
if( immuneMask & SPELL_SCHOOL_MASK_ALL ) // total immunity
return true;
}
return false;
}
bool Player::HasTitle(uint32 bitIndex)
{
if (bitIndex > 128)
@ -19865,7 +19421,7 @@ void Player::HandleFall(MovementInfo const& movementInfo)
if (GetDummyAura(43621))
damage = GetMaxHealth()/2;
EnvironmentalDamage(GetGUID(), DAMAGE_FALL, damage);
EnvironmentalDamage(DAMAGE_FALL, damage);
// recheck alive, might have died of EnvironmentalDamage
if (isAlive())
@ -20143,6 +19699,12 @@ void Player::UpdateKnownCurrencies(uint32 itemId, bool apply)
}
}
void Player::UpdateFallInformationIfNeed( MovementInfo const& minfo,uint16 opcode )
{
if (m_lastFallTime >= minfo.fallTime || m_lastFallZ <=minfo.z || opcode == MSG_MOVE_FALL_LAND)
SetFallInformation(minfo.fallTime, minfo.z);
}
void Player::BuildPlayerTalentsInfoData(WorldPacket *data)
{
*data << uint32(GetFreeTalentPoints()); // unspentTalentPoints

View file

@ -34,6 +34,7 @@
#include "MapReference.h"
#include "Util.h" // for Tokens typedef
#include "AchievementMgr.h"
#include "ReputationMgr.h"
#include "BattleGround.h"
#include<string>
@ -49,7 +50,6 @@ class Transport;
class UpdateMask;
class SpellCastTargets;
class PlayerSocial;
class AchievementMgr;
class Vehicle;
typedef std::deque<Mail*> PlayerMails;
@ -272,31 +272,6 @@ struct Runes
}
};
enum FactionFlags
{
FACTION_FLAG_VISIBLE = 0x01, // makes visible in client (set or can be set at interaction with target of this faction)
FACTION_FLAG_AT_WAR = 0x02, // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation
FACTION_FLAG_HIDDEN = 0x04, // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client)
FACTION_FLAG_INVISIBLE_FORCED = 0x08, // always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions
FACTION_FLAG_PEACE_FORCED = 0x10, // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions
FACTION_FLAG_INACTIVE = 0x20, // player controlled, state stored in characters.data ( CMSG_SET_FACTION_INACTIVE )
FACTION_FLAG_RIVAL = 0x40 // flag for the two competing outland factions
};
typedef uint32 RepListID;
struct FactionState
{
uint32 ID;
RepListID ReputationListID;
uint32 Flags;
int32 Standing;
bool Changed;
};
typedef std::map<RepListID,FactionState> FactionStateList;
typedef std::map<uint32,ReputationRank> ForcedReactions;
typedef std::set<uint64> GuardianPetList;
struct EnchantDuration
@ -1234,6 +1209,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void CastedCreatureOrGO( uint32 entry, uint64 guid, uint32 spell_id );
void TalkedToCreature( uint32 entry, uint64 guid );
void MoneyChanged( uint32 value );
void ReputationChanged(FactionEntry const* factionEntry );
bool HasQuestForItem( uint32 itemid ) const;
bool HasQuestForGO(int32 GOId) const;
void UpdateForQuestsGO();
@ -1611,8 +1587,6 @@ class MANGOS_DLL_SPEC Player : public Unit
void SendDelayResponse(const uint32);
void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP);
//Low Level Packets
void PlaySound(uint32 Sound, bool OnlySelf);
//notifiers
void SendAttackSwingCantAttack();
void SendAttackSwingCancelAttack();
@ -1701,39 +1675,12 @@ class MANGOS_DLL_SPEC Player : public Unit
bool RewardPlayerAndGroupAtKill(Unit* pVictim);
bool isHonorOrXPTarget(Unit* pVictim);
FactionStateList m_factions;
ForcedReactions m_forcedReactions;
FactionStateList const& GetFactionStateList() { return m_factions; }
uint32 GetDefaultReputationFlags(const FactionEntry *factionEntry) const;
int32 GetBaseReputation(const FactionEntry *factionEntry) const;
int32 GetReputation(uint32 faction_id) const;
int32 GetReputation(const FactionEntry *factionEntry) const;
ReputationRank GetReputationRank(uint32 faction) const;
ReputationRank GetReputationRank(const FactionEntry *factionEntry) const;
ReputationRank GetBaseReputationRank(const FactionEntry *factionEntry) const;
ReputationRank ReputationToRank(int32 standing) const;
const static int32 ReputationRank_Length[MAX_REPUTATION_RANK];
const static int32 Reputation_Cap = 42999;
const static int32 Reputation_Bottom = -42000;
bool ModifyFactionReputation(uint32 FactionTemplateId, int32 DeltaReputation);
bool ModifyFactionReputation(FactionEntry const* factionEntry, int32 standing);
bool ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing);
bool SetFactionReputation(uint32 FactionTemplateId, int32 standing);
bool SetFactionReputation(FactionEntry const* factionEntry, int32 standing);
bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing);
int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest);
ReputationMgr& GetReputationMgr() { return m_reputationMgr; }
ReputationMgr const& GetReputationMgr() const { return m_reputationMgr; }
ReputationRank GetReputationRank(uint32 faction_id) const;
void RewardReputation(Unit *pVictim, float rate);
void RewardReputation(Quest const *pQuest);
void SetInitialFactions();
void UpdateReputation() const;
void SendFactionState(FactionState const* faction) const;
void SendInitialReputations();
FactionState const* GetFactionState( FactionEntry const* factionEntry) const;
void SetFactionAtWar(FactionState* faction, bool atWar);
void SetFactionInactive(FactionState* faction, bool inactive);
void SetFactionVisible(FactionState* faction);
void SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId);
void SetFactionVisibleForFactionId(uint32 FactionId);
void UpdateSkillsForLevel();
void UpdateSkillsToMaxSkillsForLevel(); // for .levelup
void ModifySkillBonus(uint32 skillid,int32 val, bool talent);
@ -1926,6 +1873,7 @@ class MANGOS_DLL_SPEC Player : public Unit
bool GetBGAccessByLevel(BattleGroundTypeId bgTypeId) const;
bool CanUseBattleGroundObject();
bool isTotalImmune();
bool CanCaptureTowerPoint();
/*********************************************************/
@ -1941,7 +1889,7 @@ class MANGOS_DLL_SPEC Player : public Unit
/*** ENVIROMENTAL SYSTEM ***/
/*********************************************************/
void EnvironmentalDamage(uint64 guid, EnviromentalDamage type, uint32 damage);
void EnvironmentalDamage(EnviromentalDamage type, uint32 damage);
/*********************************************************/
/*** FLOOD FILTER SYSTEM ***/
@ -1955,8 +1903,7 @@ class MANGOS_DLL_SPEC Player : public Unit
/*** VARIOUS SYSTEMS ***/
/*********************************************************/
MovementInfo m_movementInfo;
uint32 m_lastFallTime;
float m_lastFallZ;
void UpdateFallInformationIfNeed(MovementInfo const& minfo,uint16 opcode);
Unit *m_mover;
void SetFallInformation(uint32 time, float z)
{
@ -2164,7 +2111,6 @@ class MANGOS_DLL_SPEC Player : public Unit
void _LoadQuestStatus(QueryResult *result);
void _LoadDailyQuestStatus(QueryResult *result);
void _LoadGroup(QueryResult *result);
void _LoadReputation(QueryResult *result);
void _LoadSkills();
void _LoadSpells(QueryResult *result);
void _LoadFriendList(QueryResult *result);
@ -2183,7 +2129,6 @@ class MANGOS_DLL_SPEC Player : public Unit
void _SaveMail();
void _SaveQuestStatus();
void _SaveDailyQuestStatus();
void _SaveReputation();
void _SaveSpells();
void _SaveEquipmentSets();
@ -2198,10 +2143,6 @@ class MANGOS_DLL_SPEC Player : public Unit
void StopMirrorTimer(MirrorTimerType Type);
void HandleDrowning(uint32 time_diff);
int32 getMaxTimer(MirrorTimerType timer);
int32 m_MirrorTimer[MAX_TIMERS];
uint8 m_MirrorTimerFlags;
uint8 m_MirrorTimerFlagsLast;
bool m_isInWater;
/*********************************************************/
/*** HONOR SYSTEM ***/
@ -2350,7 +2291,6 @@ class MANGOS_DLL_SPEC Player : public Unit
DeclinedName *m_declinedname;
Runes *m_runes;
AchievementMgr m_achievementMgr;
EquipmentSets m_EquipmentSets;
private:
// internal common parts for CanStore/StoreItem functions
@ -2358,12 +2298,24 @@ class MANGOS_DLL_SPEC Player : public Unit
uint8 _CanStoreItem_InBag( uint8 bag, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot ) const;
uint8 _CanStoreItem_InInventorySlots( uint8 slot_begin, uint8 slot_end, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot ) const;
Item* _StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, bool update );
void UpdateKnownCurrencies(uint32 itemId, bool apply);
void UpdateKnownCurrencies(uint32 itemId, bool apply);
int32 CalculateReputationGain(uint32 creatureOrQuestLevel, int32 rep, bool for_quest);
void AdjustQuestReqItemCount( Quest const* pQuest, QuestStatusData& questStatusData );
GridReference<Player> m_gridRef;
MapReference m_mapRef;
uint32 m_lastFallTime;
float m_lastFallZ;
int32 m_MirrorTimer[MAX_TIMERS];
uint8 m_MirrorTimerFlags;
uint8 m_MirrorTimerFlagsLast;
bool m_isInWater;
AchievementMgr m_achievementMgr;
ReputationMgr m_reputationMgr;
};
void AddItemsSetItem(Player*player,Item *item);

480
src/game/ReputationMgr.cpp Normal file
View file

@ -0,0 +1,480 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ReputationMgr.h"
#include "Database/DBCStores.h"
#include "Player.h"
#include "WorldPacket.h"
const int32 ReputationMgr::PointsInRank[MAX_REPUTATION_RANK] = {36000, 3000, 3000, 3000, 6000, 12000, 21000, 1000};
ReputationRank ReputationMgr::ReputationToRank(int32 standing)
{
int32 limit = Reputation_Cap + 1;
for (int i = MAX_REPUTATION_RANK-1; i >= MIN_REPUTATION_RANK; --i)
{
limit -= PointsInRank[i];
if (standing >= limit )
return ReputationRank(i);
}
return MIN_REPUTATION_RANK;
}
int32 ReputationMgr::GetReputation(uint32 faction_id) const
{
FactionEntry const *factionEntry = sFactionStore.LookupEntry(faction_id);
if (!factionEntry)
{
sLog.outError("ReputationMgr::GetReputation: Can't get reputation of %s for unknown faction (faction id) #%u.",m_player->GetName(), faction_id);
return 0;
}
return GetReputation(factionEntry);
}
int32 ReputationMgr::GetBaseReputation(FactionEntry const* factionEntry) const
{
if (!factionEntry)
return 0;
uint32 raceMask = m_player->getRaceMask();
uint32 classMask = m_player->getClassMask();
for (int i=0; i < 4; i++)
{
if( (factionEntry->BaseRepRaceMask[i] & raceMask) &&
(factionEntry->BaseRepClassMask[i]==0 ||
(factionEntry->BaseRepClassMask[i] & classMask) ) )
return factionEntry->BaseRepValue[i];
}
// in faction.dbc exist factions with (RepListId >=0, listed in character reputation list) with all BaseRepRaceMask[i]==0
return 0;
}
int32 ReputationMgr::GetReputation(FactionEntry const* factionEntry) const
{
// Faction without recorded reputation. Just ignore.
if(!factionEntry)
return 0;
if(FactionState const* state = GetState(factionEntry))
return GetBaseReputation(factionEntry) + state->Standing;
return 0;
}
ReputationRank ReputationMgr::GetRank(FactionEntry const* factionEntry) const
{
int32 reputation = GetReputation(factionEntry);
return ReputationToRank(reputation);
}
ReputationRank ReputationMgr::GetBaseRank(FactionEntry const* factionEntry) const
{
int32 reputation = GetBaseReputation(factionEntry);
return ReputationToRank(reputation);
}
void ReputationMgr::ApplyForceReaction( uint32 faction_id,ReputationRank rank,bool apply )
{
if(apply)
m_forcedReactions[faction_id] = rank;
else
m_forcedReactions.erase(faction_id);
}
uint32 ReputationMgr::GetDefaultStateFlags(FactionEntry const* factionEntry) const
{
if (!factionEntry)
return 0;
uint32 raceMask = m_player->getRaceMask();
uint32 classMask = m_player->getClassMask();
for (int i=0; i < 4; i++)
{
if( (factionEntry->BaseRepRaceMask[i] & raceMask) &&
(factionEntry->BaseRepClassMask[i]==0 ||
(factionEntry->BaseRepClassMask[i] & classMask) ) )
return factionEntry->ReputationFlags[i];
}
return 0;
}
void ReputationMgr::SendForceReactions()
{
WorldPacket data;
data.Initialize(SMSG_SET_FORCED_REACTIONS, 4+m_forcedReactions.size()*(4+4));
data << uint32(m_forcedReactions.size());
for(ForcedReactions::const_iterator itr = m_forcedReactions.begin(); itr != m_forcedReactions.end(); ++itr)
{
data << uint32(itr->first); // faction_id (Faction.dbc)
data << uint32(itr->second); // reputation rank
}
m_player->SendDirectMessage(&data);
}
void ReputationMgr::SendState(FactionState const* faction) const
{
if(faction->Flags & FACTION_FLAG_VISIBLE) //If faction is visible then update it
{
WorldPacket data(SMSG_SET_FACTION_STANDING, (16)); // last check 2.4.0
data << (float) 0; // unk 2.4.0
data << (uint8) 0; // wotlk 8634
data << (uint32) 1; // count
// for
data << (uint32) faction->ReputationListID;
data << (uint32) faction->Standing;
// end for
m_player->SendDirectMessage(&data);
}
}
void ReputationMgr::SendInitialReputations()
{
WorldPacket data(SMSG_INITIALIZE_FACTIONS, (4+128*5));
data << uint32 (0x00000080);
RepListID a = 0;
for (FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
{
// fill in absent fields
for (; a != itr->first; a++)
{
data << uint8 (0x00);
data << uint32 (0x00000000);
}
// fill in encountered data
data << uint8 (itr->second.Flags);
data << uint32 (itr->second.Standing);
++a;
}
// fill in absent fields
for (; a != 128; a++)
{
data << uint8 (0x00);
data << uint32 (0x00000000);
}
m_player->SendDirectMessage(&data);
}
void ReputationMgr::SendStates() const
{
for(FactionStateList::const_iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
SendState(&(itr->second));
}
void ReputationMgr::SendVisible(FactionState const* faction) const
{
if(m_player->GetSession()->PlayerLoading())
return;
// make faction visible in reputation list at client
WorldPacket data(SMSG_SET_FACTION_VISIBLE, 4);
data << faction->ReputationListID;
m_player->SendDirectMessage(&data);
}
void ReputationMgr::Initilize()
{
m_factions.clear();
for(unsigned int i = 1; i < sFactionStore.GetNumRows(); i++)
{
FactionEntry const *factionEntry = sFactionStore.LookupEntry(i);
if( factionEntry && (factionEntry->reputationListID >= 0))
{
FactionState newFaction;
newFaction.ID = factionEntry->ID;
newFaction.ReputationListID = factionEntry->reputationListID;
newFaction.Standing = 0;
newFaction.Flags = GetDefaultStateFlags(factionEntry);
newFaction.Changed = true;
m_factions[newFaction.ReputationListID] = newFaction;
}
}
}
bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standing)
{
SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID);
if (flist)
{
bool res = false;
for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr)
{
FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr);
if(factionEntryCalc)
res = SetOneFactionReputation(factionEntryCalc, standing);
}
return res;
}
else
return SetOneFactionReputation(factionEntry, standing);
}
bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing)
{
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
if (itr != m_factions.end())
{
if (standing > Reputation_Cap)
standing = Reputation_Cap;
else
if (standing < Reputation_Bottom)
standing = Reputation_Bottom;
int32 BaseRep = GetBaseReputation(factionEntry);
itr->second.Standing = standing - BaseRep;
itr->second.Changed = true;
SetVisible(&itr->second);
if(ReputationToRank(standing) <= REP_HOSTILE)
SetAtWar(&itr->second,true);
SendState(&itr->second);
m_player->ReputationChanged(factionEntry);
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION,factionEntry->ID);
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION,factionEntry->ID);
return true;
}
return false;
}
bool ReputationMgr::ModifyReputation(FactionEntry const* factionEntry, int32 standing)
{
SimpleFactionsList const* flist = GetFactionTeamList(factionEntry->ID);
if (flist)
{
bool res = false;
for (SimpleFactionsList::const_iterator itr = flist->begin();itr != flist->end();++itr)
{
FactionEntry const *factionEntryCalc = sFactionStore.LookupEntry(*itr);
if(factionEntryCalc)
res = ModifyOneFactionReputation(factionEntryCalc, standing);
}
return res;
}
else
return ModifyOneFactionReputation(factionEntry, standing);
}
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);
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION,factionEntry->ID);
m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION,factionEntry->ID);
return true;
}
return false;
}
void ReputationMgr::SetVisible(FactionTemplateEntry const*factionTemplateEntry)
{
if(!factionTemplateEntry->faction)
return;
if(FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction))
SetVisible(factionEntry);
}
void ReputationMgr::SetVisible(FactionEntry const *factionEntry)
{
if(factionEntry->reputationListID < 0)
return;
FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID);
if (itr == m_factions.end())
return;
SetVisible(&itr->second);
}
void ReputationMgr::SetVisible(FactionState* faction)
{
// always invisible or hidden faction can't be make visible
if(faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN))
return;
// already set
if(faction->Flags & FACTION_FLAG_VISIBLE)
return;
faction->Flags |= FACTION_FLAG_VISIBLE;
faction->Changed = true;
SendVisible(faction);
}
void ReputationMgr::SetAtWar( RepListID repListID, bool on )
{
FactionStateList::iterator itr = m_factions.find(repListID);
if (itr == m_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);
}
void ReputationMgr::SetAtWar(FactionState* faction, bool atWar)
{
// not allow declare war to own faction
if(atWar && (faction->Flags & FACTION_FLAG_PEACE_FORCED) )
return;
// already set
if(((faction->Flags & FACTION_FLAG_AT_WAR) != 0) == atWar)
return;
if( atWar )
faction->Flags |= FACTION_FLAG_AT_WAR;
else
faction->Flags &= ~FACTION_FLAG_AT_WAR;
faction->Changed = true;
}
void ReputationMgr::SetInactive( RepListID repListID, bool on )
{
FactionStateList::iterator itr = m_factions.find(repListID);
if (itr == m_factions.end())
return;
SetInactive(&itr->second,on);
}
void ReputationMgr::SetInactive(FactionState* faction, bool inactive)
{
// always invisible or hidden faction can't be inactive
if(inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE) ) )
return;
// already set
if(((faction->Flags & FACTION_FLAG_INACTIVE) != 0) == inactive)
return;
if(inactive)
faction->Flags |= FACTION_FLAG_INACTIVE;
else
faction->Flags &= ~FACTION_FLAG_INACTIVE;
faction->Changed = true;
}
void ReputationMgr::LoadFromDB(QueryResult *result)
{
// Set initial reputations (so everything is nifty before DB data load)
Initilize();
//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->reputationListID >= 0))
{
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
if(GetRank(factionEntry) <= REP_HOSTILE)
SetAtWar(faction,true);
// reset changed flag if values similar to saved in DB
if(faction->Flags==dbFactionFlags)
faction->Changed = false;
}
}
while( result->NextRow() );
delete result;
}
}
void ReputationMgr::SaveToDB()
{
CharacterDatabase.BeginTransaction();
for(FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
{
if (itr->second.Changed)
{
CharacterDatabase.PExecute("DELETE FROM character_reputation WHERE guid = '%u' AND faction='%u'", m_player->GetGUIDLow(), itr->second.ID);
CharacterDatabase.PExecute("INSERT INTO character_reputation (guid,faction,standing,flags) VALUES ('%u', '%u', '%i', '%u')", m_player->GetGUIDLow(), itr->second.ID, itr->second.Standing, itr->second.Flags);
itr->second.Changed = false;
}
}
CharacterDatabase.CommitTransaction();
}

129
src/game/ReputationMgr.h Normal file
View file

@ -0,0 +1,129 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __MANGOS_REPUTATION_MGR_H
#define __MANGOS_REPUTATION_MGR_H
#include "Common.h"
#include "SharedDefines.h"
#include "Database/DBCStructure.h"
#include <map>
enum FactionFlags
{
FACTION_FLAG_VISIBLE = 0x01, // makes visible in client (set or can be set at interaction with target of this faction)
FACTION_FLAG_AT_WAR = 0x02, // enable AtWar-button in client. player controlled (except opposition team always war state), Flag only set on initial creation
FACTION_FLAG_HIDDEN = 0x04, // hidden faction from reputation pane in client (player can gain reputation, but this update not sent to client)
FACTION_FLAG_INVISIBLE_FORCED = 0x08, // always overwrite FACTION_FLAG_VISIBLE and hide faction in rep.list, used for hide opposite team factions
FACTION_FLAG_PEACE_FORCED = 0x10, // always overwrite FACTION_FLAG_AT_WAR, used for prevent war with own team factions
FACTION_FLAG_INACTIVE = 0x20, // player controlled, state stored in characters.data ( CMSG_SET_FACTION_INACTIVE )
FACTION_FLAG_RIVAL = 0x40 // flag for the two competing outland factions
};
typedef uint32 RepListID;
struct FactionState
{
uint32 ID;
RepListID ReputationListID;
uint32 Flags;
int32 Standing;
bool Changed;
};
typedef std::map<RepListID,FactionState> FactionStateList;
typedef std::pair<FactionStateList::const_iterator,FactionStateList::const_iterator> FactionStateListPair;
typedef std::map<uint32,ReputationRank> ForcedReactions;
class Player;
class QueryResult;
class ReputationMgr
{
public: // constructors and global modifiers
explicit ReputationMgr(Player* owner) : m_player(owner) {}
~ReputationMgr() {}
void SaveToDB();
void LoadFromDB(QueryResult *result);
public: // statics
static const int32 PointsInRank[MAX_REPUTATION_RANK];
static const int32 Reputation_Cap = 42999;
static const int32 Reputation_Bottom = -42000;
static ReputationRank ReputationToRank(int32 standing);
public: // accessors
FactionStateList const& GetStateList() const { return m_factions; }
FactionState const* GetState(FactionEntry const* factionEntry) const
{
return factionEntry->reputationListID >= 0 ? GetState(factionEntry->reputationListID) : NULL;
}
FactionState const* GetState(RepListID id) const
{
FactionStateList::const_iterator repItr = m_factions.find (id);
return repItr != m_factions.end() ? &repItr->second : NULL;
}
int32 GetReputation(uint32 faction_id) const;
int32 GetReputation(FactionEntry const* factionEntry) const;
int32 GetBaseReputation(FactionEntry const* factionEntry) const;
ReputationRank GetRank(FactionEntry const* factionEntry) const;
ReputationRank GetBaseRank(FactionEntry const* factionEntry) const;
ReputationRank const* GetForcedRankIfAny(FactionTemplateEntry const* factionTemplateEntry) const
{
ForcedReactions::const_iterator forceItr = m_forcedReactions.find(factionTemplateEntry->faction);
return forceItr != m_forcedReactions.end() ? &forceItr->second : NULL;
}
public: // modifiers
bool SetReputation(FactionEntry const* factionEntry, int32 standing);
bool ModifyReputation(FactionEntry const* factionEntry, int32 standing);
void SetVisible(FactionTemplateEntry const* factionTemplateEntry);
void SetVisible(FactionEntry const* factionEntry);
void SetAtWar(RepListID repListID, bool on);
void SetInactive(RepListID repListID, bool on);
void ApplyForceReaction(uint32 faction_id,ReputationRank rank,bool apply);
public: // senders
void SendInitialReputations();
void SendForceReactions();
void SendState(FactionState const* faction) const;
void SendStates() const;
private: // internal helper functions
void Initilize();
uint32 GetDefaultStateFlags(const FactionEntry *factionEntry) const;
bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing);
bool ModifyOneFactionReputation(FactionEntry const* factionEntry, int32 standing);
void SetVisible(FactionState* faction);
void SetAtWar(FactionState* faction, bool atWar);
void SetInactive(FactionState* faction, bool inactive);
void SendVisible(FactionState const* faction) const;
private:
Player* m_player;
FactionStateList m_factions;
ForcedReactions m_forcedReactions;
};
#endif

View file

@ -296,7 +296,7 @@ enum ItemQualities
#define SPELL_ATTR_EX2_UNK18 0x00040000 // 18 Only Revive pet - possible req dead pet
#define SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT 0x00080000 // 19 does not necessarly need shapeshift
#define SPELL_ATTR_EX2_UNK20 0x00100000 // 20
#define SPELL_ATTR_EX2_UNK21 0x00200000 // 21
#define SPELL_ATTR_EX2_DAMAGE_REDUCED_SHIELD 0x00200000 // 21 for ice blocks, pala immunity buffs, priest absorb shields, but used also for other spells -> not sure!
#define SPELL_ATTR_EX2_UNK22 0x00400000 // 22
#define SPELL_ATTR_EX2_UNK23 0x00800000 // 23 Only mage Arcane Concentration have this flag
#define SPELL_ATTR_EX2_UNK24 0x01000000 // 24

View file

@ -4630,7 +4630,7 @@ SpellCastResult Spell::CheckCasterAuras() const
prevented_reason = SPELL_FAILED_PACIFIED;
// Attr must make flag drop spell totally immune from all effects
if(prevented_reason)
if(prevented_reason != SPELL_CAST_OK)
{
if(school_immune || mechanic_immune || dispel_immune)
{

View file

@ -2051,8 +2051,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
m_target->CastSpell(m_target, 51581, true, NULL, this);
return;
case 43873: // Headless Horseman Laugh
if(caster->GetTypeId() == TYPEID_PLAYER)
((Player*)caster)->PlaySound(11965, false);
m_target->PlayDistanceSound(11965);
return;
case 46354: // Blood Elf Illusion
if(caster)
@ -2923,20 +2922,8 @@ void Aura::HandleForceReaction(bool apply, bool Real)
uint32 faction_id = m_modifier.m_miscvalue;
uint32 faction_rank = m_modifier.m_amount;
if(apply)
player->m_forcedReactions[faction_id] = ReputationRank(faction_rank);
else
player->m_forcedReactions.erase(faction_id);
WorldPacket data;
data.Initialize(SMSG_SET_FORCED_REACTIONS, 4+player->m_forcedReactions.size()*(4+4));
data << uint32(player->m_forcedReactions.size());
for(ForcedReactions::const_iterator itr = player->m_forcedReactions.begin(); itr != player->m_forcedReactions.end(); ++itr)
{
data << uint32(itr->first); // faction_id (Faction.dbc)
data << uint32(itr->second); // reputation rank
}
player->SendDirectMessage(&data);
player->GetReputationMgr().ApplyForceReaction(faction_id,ReputationRank(faction_rank),apply);
player->GetReputationMgr().SendForceReactions();
}
void Aura::HandleAuraModSkill(bool apply, bool Real)
@ -3066,8 +3053,15 @@ void Aura::HandleModPossess(bool apply, bool Real)
{
m_target->SetCharmerGUID(GetCasterGUID());
m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,caster->getFaction());
caster->SetCharm(m_target);
if(caster->GetTypeId() == TYPEID_PLAYER)
{
((Player*)caster)->SetFarSightGUID(m_target->GetGUID());
((Player*)caster)->SetClientControl(m_target, 1);
}
m_target->CombatStop();
m_target->DeleteThreatList();
if(m_target->GetTypeId() == TYPEID_UNIT)
@ -3096,15 +3090,19 @@ void Aura::HandleModPossess(bool apply, bool Real)
m_target->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,cinfo->faction_A);
}
caster->SetCharm(0);
caster->SetCharm(NULL);
if(caster->GetTypeId() == TYPEID_PLAYER)
{
((Player*)caster)->SetFarSightGUID(0);
((Player*)caster)->SetClientControl(m_target,0);
WorldPacket data(SMSG_PET_SPELLS, 8+4);
data << uint64(0);
data << uint32(0);
((Player*)caster)->GetSession()->SendPacket(&data);
}
if(m_target->GetTypeId() == TYPEID_UNIT)
{
((Creature*)m_target)->AIM_Initialize();
@ -3113,8 +3111,6 @@ void Aura::HandleModPossess(bool apply, bool Real)
((Creature*)m_target)->AI()->AttackStart(caster);
}
}
if(caster->GetTypeId() == TYPEID_PLAYER)
((Player*)caster)->SetFarSightGUID(apply ? m_target->GetGUID() : 0);
}
void Aura::HandleModPossessPet(bool apply, bool Real)
@ -3252,7 +3248,7 @@ void Aura::HandleModCharm(bool apply, bool Real)
}
}
caster->SetCharm(0);
caster->SetCharm(NULL);
if(caster->GetTypeId() == TYPEID_PLAYER)
{
@ -3312,6 +3308,7 @@ void Aura::HandleFeignDeath(bool apply, bool Real)
m_target->addUnitState(UNIT_STAT_DIED);
m_target->CombatStop();
m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
// prevent interrupt message
if(m_caster_guid==m_target->GetGUID() && m_target->m_currentSpells[CURRENT_GENERIC_SPELL])
@ -3494,9 +3491,7 @@ void Aura::HandleModStealth(bool apply, bool Real)
if(apply)
{
// drop flag at stealth in bg
if(Real && m_target->GetTypeId()==TYPEID_PLAYER && ((Player*)m_target)->InBattleGround())
if(BattleGround *bg = ((Player*)m_target)->GetBattleGround())
bg->EventPlayerDroppedFlag((Player*)m_target);
m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
// only at real aura add
if(Real)
@ -3561,15 +3556,13 @@ void Aura::HandleInvisibility(bool apply, bool Real)
{
m_target->m_invisibilityMask |= (1 << m_modifier.m_miscvalue);
m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
if(Real && m_target->GetTypeId()==TYPEID_PLAYER)
{
// apply glow vision
m_target->SetFlag(PLAYER_FIELD_BYTES2,PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW);
// drop flag at invisible in bg
if(((Player*)m_target)->InBattleGround())
if(BattleGround *bg = ((Player*)m_target)->GetBattleGround())
bg->EventPlayerDroppedFlag((Player*)m_target);
}
// apply only if not in GM invisibility and not stealth
@ -4016,44 +4009,15 @@ void Aura::HandleModMechanicImmunity(bool apply, bool Real)
}
}
//this method is called whenever we add / remove aura which gives m_target some imunity to some spell effect
void Aura::HandleAuraModEffectImmunity(bool apply, bool Real)
{
if(!apply)
// when removing flag aura, handle flag drop
if( !apply && m_target->GetTypeId() == TYPEID_PLAYER
&& (GetSpellProto()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION) )
{
if(m_target->GetTypeId() == TYPEID_PLAYER)
{
if(((Player*)m_target)->InBattleGround())
{
BattleGround *bg = ((Player*)m_target)->GetBattleGround();
if(bg)
{
switch(bg->GetTypeID())
{
case BATTLEGROUND_AV:
{
break;
}
case BATTLEGROUND_WS:
{
// Warsong Flag, horde // Silverwing Flag, alliance
if(GetId() == 23333 || GetId() == 23335)
if( BattleGround *bg = ((Player*)m_target)->GetBattleGround() )
bg->EventPlayerDroppedFlag(((Player*)m_target));
break;
}
case BATTLEGROUND_AB:
{
break;
}
case BATTLEGROUND_EY:
{
if(GetId() == 34976)
bg->EventPlayerDroppedFlag(((Player*)m_target));
break;
}
}
}
}
}
}
m_target->ApplySpellImmune(GetId(),IMMUNITY_EFFECT,m_modifier.m_miscvalue,apply);
@ -4083,9 +4047,15 @@ void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real)
{
m_target->ApplySpellImmune(GetId(),IMMUNITY_SCHOOL,m_modifier.m_miscvalue,apply);
if(Real && apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)
{
if(IsPositiveSpell(GetId())) //Only positive immunity removes auras
// remove all flag auras (they are positive, but they must be removed when you are immune)
if( this->GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
&& this->GetSpellProto()->AttributesEx2 & SPELL_ATTR_EX2_DAMAGE_REDUCED_SHIELD )
m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
// TODO: optimalize this cycle - use RemoveAurasWithInterruptFlags call or something else
if( Real && apply
&& GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY
&& IsPositiveSpell(GetId()) ) //Only positive immunity removes auras
{
uint32 school_mask = m_modifier.m_miscvalue;
Unit::AuraMap& Auras = m_target->GetAuras();
@ -4107,7 +4077,6 @@ void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real)
}
}
}
}
if( Real && GetSpellProto()->Mechanic == MECHANIC_BANISH )
{
if( apply )
@ -5565,8 +5534,10 @@ void Aura::HandleAuraRetainComboPoints(bool apply, bool Real)
void Aura::HandleModUnattackable( bool Apply, bool Real )
{
if(Real && Apply)
{
m_target->CombatStop();
m_target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION);
}
m_target->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE,Apply);
}

View file

@ -300,7 +300,7 @@ void Spell::EffectEnvirinmentalDMG(uint32 i)
m_caster->SendSpellNonMeleeDamageLog(m_caster, m_spellInfo->Id, damage, GetSpellSchoolMask(m_spellInfo), absorb, resist, false, 0, false);
if(m_caster->GetTypeId() == TYPEID_PLAYER)
((Player*)m_caster)->EnvironmentalDamage(m_caster->GetGUID(),DAMAGE_FIRE,damage);
((Player*)m_caster)->EnvironmentalDamage(DAMAGE_FIRE,damage);
}
void Spell::EffectSchoolDMG(uint32 effect_idx)
@ -2372,60 +2372,9 @@ void Spell::EffectPowerDrain(uint32 i)
void Spell::EffectSendEvent(uint32 EffectIndex)
{
if (m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->InBattleGround())
{
BattleGround* bg = ((Player *)m_caster)->GetBattleGround();
if(bg && bg->GetStatus() == STATUS_IN_PROGRESS)
{
switch(m_spellInfo->Id)
{
case 23333: // Pickup Horde Flag
/*do not uncomment .
if(bg->GetTypeID()==BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
sLog.outDebug("Send Event Horde Flag Picked Up");
break;
/* not used :
case 23334: // Drop Horde Flag
if(bg->GetTypeID()==BATTLEGROUND_WS)
bg->EventPlayerDroppedFlag((Player*)m_caster);
sLog.outDebug("Drop Horde Flag");
break;
*/
case 23335: // Pickup Alliance Flag
/*do not uncomment ... (it will cause crash, because of null targetobject!) anyway this is a bad way to call that event, because it would cause recursion
if(bg->GetTypeID()==BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
sLog.outDebug("Send Event Alliance Flag Picked Up");
break;
/* not used :
case 23336: // Drop Alliance Flag
if(bg->GetTypeID()==BATTLEGROUND_WS)
bg->EventPlayerDroppedFlag((Player*)m_caster);
sLog.outDebug("Drop Alliance Flag");
break;
case 23385: // Alliance Flag Returns
if(bg->GetTypeID()==BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
sLog.outDebug("Alliance Flag Returned");
break;
case 23386: // Horde Flag Returns
if(bg->GetTypeID()==BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
sLog.outDebug("Horde Flag Returned");
break;*/
case 34976:
/*
if(bg->GetTypeID()==BATTLEGROUND_EY)
bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
we do not handle a flag dropping or clicking on flag in battleground by sendevent system
*/
break;
default:
sLog.outDebug("Unknown spellid %u in BG event", m_spellInfo->Id);
break;
}
}
}
sLog.outDebug("Spell ScriptStart %u for spellid %u in EffectSendEvent ", m_spellInfo->EffectMiscValue[EffectIndex], m_spellInfo->Id);
sWorld.ScriptsStart(sEventScripts, m_spellInfo->EffectMiscValue[EffectIndex], m_caster, focusObject);
}
@ -5812,7 +5761,7 @@ void Spell::EffectReputation(uint32 i)
if(!factionEntry)
return;
_player->ModifyFactionReputation(factionEntry,rep_change);
_player->GetReputationMgr().ModifyReputation(factionEntry,rep_change);
}
void Spell::EffectQuestComplete(uint32 i)

View file

@ -56,7 +56,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
return;
}
sLog.outDetail("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, cast_count: %u, spellid: %u, Item: %u, glyphIndex: %u, unk_flags: %u, data length = %i", bagIndex, slot, cast_count, spellid, pItem->GetEntry(), glyphIndex, unk_flags, recvPacket.size());
sLog.outDetail("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, cast_count: %u, spellid: %u, Item: %u, glyphIndex: %u, unk_flags: %u, data length = %i", bagIndex, slot, cast_count, spellid, pItem->GetEntry(), glyphIndex, unk_flags, (uint32)recvPacket.size());
ItemPrototype const *proto = pItem->GetProto();
if(!proto)
@ -135,7 +135,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
{
CHECK_PACKET_SIZE(recvPacket,1+1);
sLog.outDetail("WORLD: CMSG_OPEN_ITEM packet, data length = %i",recvPacket.size());
sLog.outDetail("WORLD: CMSG_OPEN_ITEM packet, data length = %i",(uint32)recvPacket.size());
Player* pUser = _player;
uint8 bagIndex, slot;
@ -247,7 +247,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
recvPacket >> unk_flags; // flags (if 0x02 - some additional data are received)
sLog.outDebug("WORLD: got cast spell packet, spellId - %u, cast_count: %u, unk_flags %u, data length = %i",
spellId, cast_count, unk_flags, recvPacket.size());
spellId, cast_count, unk_flags, (uint32)recvPacket.size());
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId );

View file

@ -298,10 +298,6 @@ bool IsPositiveEffect(uint32 spellId, uint32 effIndex)
switch(spellId)
{
case 23333: // BG spell
case 23335: // BG spell
case 34976: // BG spell
return true;
case 28441: // not positive dummy spell
case 37675: // Chaos Blast
return false;

View file

@ -409,7 +409,7 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
uint32 timer = t;
// sLog.outDetail(" Generated %d waypoints, total time %u.", m_WayPoints.size(), timer);
// sLog.outDetail(" Generated %lu waypoints, total time %u.", (unsigned long)m_WayPoints.size(), timer);
m_curr = m_WayPoints.begin();
m_curr = GetNextWayPoint();

View file

@ -6956,14 +6956,12 @@ bool Unit::IsHostileTo(Unit const* unit) const
// forced reaction
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(ReputationRank const* force =((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction))
return *force <= 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))
if(FactionState const* factionState = ((Player*)tester)->GetReputationMgr().GetState(raw_target_faction))
return (factionState->Flags & FACTION_FLAG_AT_WAR);
}
}
@ -6973,14 +6971,13 @@ bool Unit::IsHostileTo(Unit const* unit) const
// forced reaction
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;
if(ReputationRank const* force = ((Player*)target)->GetReputationMgr().GetForcedRankIfAny(tester_faction))
return *force <= 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;
return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) <= REP_HOSTILE;
}
}
@ -7071,15 +7068,13 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
// forced reaction
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(ReputationRank const* force =((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction))
return *force >= 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(FactionState const* factionState = ((Player*)tester)->GetReputationMgr().GetState(raw_target_faction))
return !(factionState->Flags & FACTION_FLAG_AT_WAR);
}
}
// CvP forced reaction and reputation case
@ -7088,14 +7083,13 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
// forced reaction
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;
if(ReputationRank const* force =((Player*)target)->GetReputationMgr().GetForcedRankIfAny(tester_faction))
return *force >= 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;
return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY;
}
}
@ -7360,7 +7354,7 @@ Unit* Unit::GetCharm() const
return pet;
sLog.outError("Unit::GetCharm: Charmed creature %u not exist.",GUID_LOPART(charm_guid));
const_cast<Unit*>(this)->SetCharm(0);
const_cast<Unit*>(this)->SetCharm(NULL);
}
return NULL;
@ -8233,6 +8227,9 @@ bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo)
return true;
}
//TODO add spellEffect immunity checks!, player with flag in bg is imune to imunity buffs from other friendly players!
//SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_EFFECT];
SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_DISPEL];
for(SpellImmuneList::const_iterator itr = dispelList.begin(); itr != dispelList.end(); ++itr)
if(itr->type == spellInfo->Dispel)

View file

@ -75,7 +75,7 @@ enum SpellAuraInterruptFlags
AURA_INTERRUPT_FLAG_MOUNTING = 0x00020000, // 17 removed by mounting
AURA_INTERRUPT_FLAG_NOT_SEATED = 0x00040000, // 18 removed by standing up
AURA_INTERRUPT_FLAG_CHANGE_MAP = 0x00080000, // 19 leaving map/getting teleported
AURA_INTERRUPT_FLAG_IMMUNE_OR_STEALTH = 0x00100000, // 20 removed when player on himself casts immunity spell or vanish?
AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION = 0x00100000, // 20 removed by auras that make you invulnerable, or make other to loose selection on you
AURA_INTERRUPT_FLAG_UNK21 = 0x00200000, // 21
AURA_INTERRUPT_FLAG_UNK22 = 0x00400000, // 22
AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT = 0x00800000, // 23 removed by entering pvp combat

View file

@ -472,6 +472,8 @@ void World::LoadConfigSettings(bool reload)
rate_values[RATE_XP_QUEST] = sConfig.GetFloatDefault("Rate.XP.Quest", 1.0f);
rate_values[RATE_XP_EXPLORE] = sConfig.GetFloatDefault("Rate.XP.Explore", 1.0f);
rate_values[RATE_REPUTATION_GAIN] = sConfig.GetFloatDefault("Rate.Reputation.Gain", 1.0f);
rate_values[RATE_REPUTATION_LOWLEVEL_KILL] = sConfig.GetFloatDefault("Rate.Reputation.LowLevel.Kill", 1.0f);
rate_values[RATE_REPUTATION_LOWLEVEL_QUEST] = sConfig.GetFloatDefault("Rate.Reputation.LowLevel.Quest", 1.0f);
rate_values[RATE_CREATURE_NORMAL_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Normal.Damage", 1.0f);
rate_values[RATE_CREATURE_ELITE_ELITE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.Elite.Damage", 1.0f);
rate_values[RATE_CREATURE_ELITE_RAREELITE_DAMAGE] = sConfig.GetFloatDefault("Rate.Creature.Elite.RAREELITE.Damage", 1.0f);
@ -2239,6 +2241,47 @@ void World::ScriptsProcess()
break;
}
case SCRIPT_COMMAND_PLAY_SOUND:
{
if(!source)
{
sLog.outError("SCRIPT_COMMAND_PLAY_SOUND call for NULL creature.");
break;
}
WorldObject* pSource = dynamic_cast<WorldObject*>(source);
if(!pSource)
{
sLog.outError("SCRIPT_COMMAND_PLAY_SOUND call for non-world object (TypeId: %u), skipping.",source->GetTypeId());
break;
}
// bitmask: 0/1=anyone/target, 0/2=with distance dependent
Player* pTarget = NULL;
if(step.script->datalong2 & 1)
{
if(!target)
{
sLog.outError("SCRIPT_COMMAND_PLAY_SOUND in targeted mode call for NULL target.");
break;
}
if(target->GetTypeId()!=TYPEID_PLAYER)
{
sLog.outError("SCRIPT_COMMAND_PLAY_SOUND in targeted mode call for non-player (TypeId: %u), skipping.",target->GetTypeId());
break;
}
pTarget = (Player*)target;
}
// bitmask: 0/1=anyone/target, 0/2=with distance dependent
if(step.script->datalong2 & 2)
pSource->PlayDistanceSound(step.script->datalong,pTarget);
else
pSource->PlayDirectSound(step.script->datalong,pTarget);
break;
}
default:
sLog.outError("Unknown script command %u called.",step.script->command);
break;

View file

@ -223,6 +223,8 @@ enum Rates
RATE_XP_QUEST,
RATE_XP_EXPLORE,
RATE_REPUTATION_GAIN,
RATE_REPUTATION_LOWLEVEL_KILL,
RATE_REPUTATION_LOWLEVEL_QUEST,
RATE_CREATURE_NORMAL_HP,
RATE_CREATURE_ELITE_ELITE_HP,
RATE_CREATURE_ELITE_RAREELITE_HP,
@ -322,6 +324,7 @@ enum RealmZone
#define SCRIPT_COMMAND_ACTIVATE_OBJECT 13 // source = unit, target=GO
#define SCRIPT_COMMAND_REMOVE_AURA 14 // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id
#define SCRIPT_COMMAND_CAST_SPELL 15 // source/target cast spell at target/source (script->datalong2: 0: s->t 1: s->s 2: t->t 3: t->s
#define SCRIPT_COMMAND_PLAY_SOUND 16 // source = any object, target=any/player, datalong (sound_id), datalong2 (bitmask: 0/1=anyone/target, 0/2=with distance dependent, so 1|2 = 3 is target with distance dependent)
/// Storage class for commands issued for delayed execution
struct CliCommandHolder

View file

@ -213,13 +213,41 @@ bool ChatHandler::HandleDebugUpdateWorldStateCommand(const char* args)
return true;
}
bool ChatHandler::HandleDebugPlaySound2Command(const char* args)
//Play sound
bool ChatHandler::HandleDebugPlaySoundCommand(const char* args)
{
if(!args)
// USAGE: .debug playsound #soundid
// #soundid - ID decimal number from SoundEntries.dbc (1st column)
if( !*args )
{
SendSysMessage(LANG_BAD_VALUE);
SetSentErrorMessage(true);
return false;
}
uint32 soundid = atoi(args);
m_session->GetPlayer()->PlaySound(soundid, false);
uint32 dwSoundId = atoi((char*)args);
if(!sSoundEntriesStore.LookupEntry(dwSoundId))
{
PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId);
SetSentErrorMessage(true);
return false;
}
Unit* unit = getSelectedUnit();
if(!unit)
{
SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
SetSentErrorMessage(true);
return false;
}
if(m_session->GetPlayer()->GetSelection())
unit->PlayDistanceSound(dwSoundId,m_session->GetPlayer());
else
unit->PlayDirectSound(dwSoundId,m_session->GetPlayer());
PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId);
return true;
}

View file

@ -1004,6 +1004,14 @@ Visibility.Distance.Grey.Object = 10
# Reputation Gain rate
# Default: 1
#
# Rate.Reputation.LowLevel.Kill
# Reputation Gain form low level kill (grey creture)
# Default: 1
#
# Rate.Reputation.LowLevel.Quest
# Reputation Gain rate
# Default: 1
#
# Rate.InstanceResetTime
# Multiplier for the number of days in between global raid/heroic instance resets.
# Default: 1
@ -1096,6 +1104,9 @@ Rate.Mining.Amount = 1
Rate.Mining.Next = 1
Rate.Talent = 1
Rate.Reputation.Gain = 1
Rate.Reputation.LowLevel.Kill = 1
Rate.Reputation.LowLevel.Quest = 1
Rate.InstanceResetTime = 1
SkillGain.Crafting = 1
SkillGain.Defense = 1

View file

@ -338,7 +338,7 @@ class ByteBuffer
if(!sLog.IsOutDebug()) // optimize disabled debug output
return;
sLog.outDebug("STORAGE_SIZE: %u", size() );
sLog.outDebug("STORAGE_SIZE: %lu", (unsigned long)size() );
for(uint32 i = 0; i < size(); i++)
sLog.outDebugInLine("%u - ", read<uint8>(i) );
sLog.outDebug(" ");
@ -349,7 +349,7 @@ class ByteBuffer
if(!sLog.IsOutDebug()) // optimize disabled debug output
return;
sLog.outDebug("STORAGE_SIZE: %u", size() );
sLog.outDebug("STORAGE_SIZE: %lu", (unsigned long)size() );
for(uint32 i = 0; i < size(); i++)
sLog.outDebugInLine("%c", read<uint8>(i) );
sLog.outDebug(" ");
@ -361,7 +361,7 @@ class ByteBuffer
return;
uint32 j = 1, k = 1;
sLog.outDebug("STORAGE_SIZE: %u", size() );
sLog.outDebug("STORAGE_SIZE: %lu", (unsigned long)size() );
if(sLog.IsIncludeTime())
sLog.outDebugInLine(" ");
@ -420,7 +420,7 @@ class ByteBuffer
protected:
bool PrintPosError(bool add, size_t pos, size_t esize) const
{
sLog.outError("ERROR: Attempt %s in ByteBuffer (pos: %u size: %u) value with size: %u",(add ? "put" : "get"),pos, size(), esize);
sLog.outError("ERROR: Attempt %s in ByteBuffer (pos: %lu size: %lu) value with size: %lu",(add ? "put" : "get"),(unsigned long)pos, (unsigned long)size(), (unsigned long)esize);
// assert must fail after function call
return false;

View file

@ -88,7 +88,6 @@ enum AchievementCriteriaTypes
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST = 14,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND= 15,
ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP= 16,
// TODO: this can be both arena and total deaths. Where is this difference in the dbc?
ACHIEVEMENT_CRITERIA_TYPE_DEATH= 17,
ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON = 18,
ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID = 19,

View file

@ -457,7 +457,7 @@ void LoadDBCStores(const std::string& dataPath)
for(std::list<std::string>::iterator i = bad_dbc_files.begin(); i != bad_dbc_files.end(); ++i)
str += *i + "\n";
sLog.outError("\nSome required *.dbc files (%u from %d) not found or not compatible:\n%s",bad_dbc_files.size(),DBCFilesCount,str.c_str());
sLog.outError("\nSome required *.dbc files (%u from %d) not found or not compatible:\n%s",(uint32)bad_dbc_files.size(),DBCFilesCount,str.c_str());
exit(1);
}

View file

@ -95,7 +95,7 @@ bool SqlQueryHolder::SetQuery(size_t index, const char *sql)
{
if(m_queries.size() <= index)
{
sLog.outError("Query index (%u) out of range (size: %u) for query: %s",index,m_queries.size(),sql);
sLog.outError("Query index (%u) out of range (size: %u) for query: %s",index,(uint32)m_queries.size(),sql);
return false;
}

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "7517"
#define REVISION_NR "7542"
#endif // __REVISION_NR_H__

View file

@ -720,6 +720,12 @@
<File
RelativePath="..\..\src\game\ReactorAI.h">
</File>
<File
RelativePath="..\..\src\game\ReputationMgr.cpp">
</File>
<File
RelativePath="..\..\src\game\ReputationMgr.h">
</File>
<File
RelativePath="..\..\src\game\SocialMgr.cpp">
</File>

View file

@ -1134,6 +1134,14 @@
RelativePath="..\..\src\game\ReactorAI.h"
>
</File>
<File
RelativePath="..\..\src\game\ReputationMgr.cpp"
>
</File>
<File
RelativePath="..\..\src\game\ReputationMgr.h"
>
</File>
<File
RelativePath="..\..\src\game\SocialMgr.cpp"
>

View file

@ -1136,6 +1136,14 @@
RelativePath="..\..\src\game\ReactorAI.h"
>
</File>
<File
RelativePath="..\..\src\game\ReputationMgr.cpp"
>
</File>
<File
RelativePath="..\..\src\game\ReputationMgr.h"
>
</File>
<File
RelativePath="..\..\src\game\SocialMgr.cpp"
>