Cache highest arena team/guild ids. Some code clean up.

This commit is contained in:
hunuza 2008-11-05 16:58:57 +01:00
parent 88b1974df6
commit 90828fa699
23 changed files with 183 additions and 160 deletions

View file

@ -57,13 +57,7 @@ bool ArenaTeam::create(uint64 captainGuid, uint32 type, std::string ArenaTeamNam
Name = ArenaTeamName; Name = ArenaTeamName;
Type = type; Type = type;
QueryResult *result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team"); Id = objmgr.GenerateArenaTeamId();
if( result )
{
Id = (*result)[0].GetUInt32()+1;
delete result;
}
else Id = 1;
// ArenaTeamName already assigned to ArenaTeam::name, use it to encode string for DB // ArenaTeamName already assigned to ArenaTeam::name, use it to encode string for DB
CharacterDatabase.escape_string(ArenaTeamName); CharacterDatabase.escape_string(ArenaTeamName);

View file

@ -673,7 +673,7 @@ void BattleGround::Reset()
m_PlayerScores.clear(); m_PlayerScores.clear();
// reset BGSubclass // reset BGSubclass
this->ResetBGSubclass(); ResetBGSubclass();
} }
void BattleGround::StartBattleGround() void BattleGround::StartBattleGround()
@ -1033,7 +1033,7 @@ bool BattleGround::AddSpiritGuide(uint32 type, float x, float y, float z, float
if(!pCreature) if(!pCreature)
{ {
sLog.outError("Can't create Spirit guide. BattleGround not created!"); sLog.outError("Can't create Spirit guide. BattleGround not created!");
this->EndNow(); EndNow();
return false; return false;
} }

View file

@ -133,10 +133,10 @@ void BattleGroundEY::Update(time_t diff)
/*I used this order of calls, because although we will check if one player is in gameobject's distance 2 times /*I used this order of calls, because although we will check if one player is in gameobject's distance 2 times
but we can count of players on current point in CheckSomeoneLeftPoint but we can count of players on current point in CheckSomeoneLeftPoint
*/ */
this->CheckSomeoneJoinedPoint(); CheckSomeoneJoinedPoint();
//check if player left point //check if player left point
this->CheckSomeoneLeftPoint(); CheckSomeoneLeftPoint();
this->UpdatePointStatuses(); UpdatePointStatuses();
m_TowerCapCheckTimer = BG_EY_FPOINTS_TICK_TIME; m_TowerCapCheckTimer = BG_EY_FPOINTS_TICK_TIME;
} }
} }
@ -221,7 +221,7 @@ void BattleGroundEY::CheckSomeoneLeftPoint()
{ {
m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]); m_PlayersNearPoint[EY_POINTS_MAX].push_back(m_PlayersNearPoint[i][j]);
m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j); m_PlayersNearPoint[i].erase(m_PlayersNearPoint[i].begin() + j);
this->UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_DONT_SHOW, plr); UpdateWorldStateForPlayer(PROGRESS_BAR_SHOW, BG_EY_PROGRESS_BAR_DONT_SHOW, plr);
} }
else else
{ {
@ -264,17 +264,17 @@ void BattleGroundEY::UpdatePointStatuses()
Player *plr = objmgr.GetPlayer(m_PlayersNearPoint[point][i]); Player *plr = objmgr.GetPlayer(m_PlayersNearPoint[point][i]);
if (plr) if (plr)
{ {
this->UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[point], plr); UpdateWorldStateForPlayer(PROGRESS_BAR_STATUS, m_PointBarStatus[point], plr);
//if point owner changed we must evoke event! //if point owner changed we must evoke event!
if (pointOwnerTeamId != m_PointOwnedByTeam[point]) if (pointOwnerTeamId != m_PointOwnedByTeam[point])
{ {
//point was uncontrolled and player is from team which captured point //point was uncontrolled and player is from team which captured point
if (m_PointState[point] == EY_POINT_STATE_UNCONTROLLED && plr->GetTeam() == pointOwnerTeamId) if (m_PointState[point] == EY_POINT_STATE_UNCONTROLLED && plr->GetTeam() == pointOwnerTeamId)
this->EventTeamCapturedPoint(plr, point); EventTeamCapturedPoint(plr, point);
//point was under control and player isn't from team which controlled it //point was under control and player isn't from team which controlled it
if (m_PointState[point] == EY_POINT_UNDER_CONTROL && plr->GetTeam() != m_PointOwnedByTeam[point]) if (m_PointState[point] == EY_POINT_UNDER_CONTROL && plr->GetTeam() != m_PointOwnedByTeam[point])
this->EventTeamLostPoint(plr, point); EventTeamLostPoint(plr, point);
} }
} }
} }
@ -350,7 +350,7 @@ void BattleGroundEY::RemovePlayer(Player *plr, uint64 guid)
if(m_FlagKeeper == guid) if(m_FlagKeeper == guid)
{ {
if(plr) if(plr)
this->EventPlayerDroppedFlag(plr); EventPlayerDroppedFlag(plr);
else else
{ {
SetFlagPicker(0); SetFlagPicker(0);
@ -610,7 +610,7 @@ void BattleGroundEY::EventPlayerDroppedFlag(Player *Source)
void BattleGroundEY::EventPlayerClickedOnFlag(Player *Source, GameObject* target_obj) void BattleGroundEY::EventPlayerClickedOnFlag(Player *Source, GameObject* target_obj)
{ {
if(GetStatus() != STATUS_IN_PROGRESS || this->IsFlagPickedup() || !Source->IsWithinDistInMap(target_obj, 10)) if(GetStatus() != STATUS_IN_PROGRESS || IsFlagPickedup() || !Source->IsWithinDistInMap(target_obj, 10))
return; return;
const char *message; const char *message;
@ -750,7 +750,7 @@ void BattleGroundEY::EventTeamCapturedPoint(Player *Source, uint32 Point)
void BattleGroundEY::EventPlayerCapturedFlag(Player *Source, uint32 BgObjectType) void BattleGroundEY::EventPlayerCapturedFlag(Player *Source, uint32 BgObjectType)
{ {
if(GetStatus() != STATUS_IN_PROGRESS || this->GetFlagPickerGUID() != Source->GetGUID()) if(GetStatus() != STATUS_IN_PROGRESS || GetFlagPickerGUID() != Source->GetGUID())
return; return;
uint8 type = 0; uint8 type = 0;

View file

@ -80,7 +80,7 @@ void BattleGroundQueue::AddPlayer(Player *plr, uint32 bgTypeId)
else else
++m_QueuedPlayers[queue_id].Horde; ++m_QueuedPlayers[queue_id].Horde;
this->Update(bgTypeId, queue_id); Update(bgTypeId, queue_id);
if( sWorld.getConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE) ) if( sWorld.getConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE) )
{ {
@ -183,7 +183,7 @@ void BattleGroundQueue::Update(uint32 bgTypeId, uint32 queue_id)
} }
//if no players in queue ... do nothing //if no players in queue ... do nothing
if (this->m_QueuedPlayers[queue_id].Alliance == 0 && this->m_QueuedPlayers[queue_id].Horde == 0) if (m_QueuedPlayers[queue_id].Alliance == 0 && m_QueuedPlayers[queue_id].Horde == 0)
return; return;
//battleground with free slot for player should be always the last in this queue //battleground with free slot for player should be always the last in this queue
@ -625,7 +625,7 @@ void BattleGroundMgr::BuildPlayerJoinedBattleGroundPacket(WorldPacket *data, Pla
void BattleGroundMgr::InvitePlayer(Player* plr, uint32 bgInstanceGUID) void BattleGroundMgr::InvitePlayer(Player* plr, uint32 bgInstanceGUID)
{ {
// set invited player counters: // set invited player counters:
BattleGround* bg = this->GetBattleGround(bgInstanceGUID); BattleGround* bg = GetBattleGround(bgInstanceGUID);
if(!bg) if(!bg)
return; return;

View file

@ -217,7 +217,7 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT);
if(Source->GetTeam() == ALLIANCE) if(Source->GetTeam() == ALLIANCE)
{ {
if (!this->IsHordeFlagPickedup()) if (!IsHordeFlagPickedup())
return; return;
SetHordeFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time SetHordeFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
// horde flag in base (but not respawned yet) // horde flag in base (but not respawned yet)
@ -234,7 +234,7 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source)
} }
else else
{ {
if (!this->IsAllianceFlagPickedup()) if (!IsAllianceFlagPickedup())
return; return;
SetAllianceFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time SetAllianceFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
// alliance flag in base (but not respawned yet) // alliance flag in base (but not respawned yet)
@ -293,7 +293,7 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player *Source)
if(Source->GetTeam() == ALLIANCE) if(Source->GetTeam() == ALLIANCE)
{ {
if(!this->IsHordeFlagPickedup()) if(!IsHordeFlagPickedup())
return; return;
if(GetHordeFlagPickerGUID() == Source->GetGUID()) if(GetHordeFlagPickerGUID() == Source->GetGUID())
{ {
@ -308,7 +308,7 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player *Source)
} }
else else
{ {
if(!this->IsAllianceFlagPickedup()) if(!IsAllianceFlagPickedup())
return; return;
if(GetAllianceFlagPickerGUID() == Source->GetGUID()) if(GetAllianceFlagPickerGUID() == Source->GetGUID())
{ {
@ -349,8 +349,8 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target
uint8 type = 0; uint8 type = 0;
//alliance flag picked up from base //alliance flag picked up from base
if(Source->GetTeam() == HORDE && this->GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE if(Source->GetTeam() == HORDE && GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_BASE
&& this->m_BgObjects[BG_WS_OBJECT_A_FLAG] == target_obj->GetGUID()) && m_BgObjects[BG_WS_OBJECT_A_FLAG] == target_obj->GetGUID())
{ {
message = GetMangosString(LANG_BG_WS_PICKEDUP_AF); message = GetMangosString(LANG_BG_WS_PICKEDUP_AF);
type = CHAT_MSG_BG_SYSTEM_HORDE; type = CHAT_MSG_BG_SYSTEM_HORDE;
@ -365,8 +365,8 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target
} }
//horde flag picked up from base //horde flag picked up from base
if (Source->GetTeam() == ALLIANCE && this->GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_BASE if (Source->GetTeam() == ALLIANCE && GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_BASE
&& this->m_BgObjects[BG_WS_OBJECT_H_FLAG] == target_obj->GetGUID()) && m_BgObjects[BG_WS_OBJECT_H_FLAG] == target_obj->GetGUID())
{ {
message = GetMangosString(LANG_BG_WS_PICKEDUP_HF); message = GetMangosString(LANG_BG_WS_PICKEDUP_HF);
type = CHAT_MSG_BG_SYSTEM_ALLIANCE; type = CHAT_MSG_BG_SYSTEM_ALLIANCE;
@ -381,7 +381,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target
} }
//Alliance flag on ground(not in base) (returned or picked up again from ground!) //Alliance flag on ground(not in base) (returned or picked up again from ground!)
if(this->GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10)) if(GetFlagState(ALLIANCE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10))
{ {
if(Source->GetTeam() == ALLIANCE) if(Source->GetTeam() == ALLIANCE)
{ {
@ -410,7 +410,7 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player *Source, GameObject* target
} }
//Horde flag on ground(not in base) (returned or picked up again) //Horde flag on ground(not in base) (returned or picked up again)
if(this->GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10)) if(GetFlagState(HORDE) == BG_WS_FLAG_STATE_ON_GROUND && Source->IsWithinDistInMap(target_obj, 10))
{ {
if(Source->GetTeam() == HORDE) if(Source->GetTeam() == HORDE)
{ {
@ -455,22 +455,22 @@ void BattleGroundWS::RemovePlayer(Player *plr, uint64 guid)
if(!plr) if(!plr)
{ {
sLog.outError("BattleGroundWS: Removing offline player who has the FLAG!!"); sLog.outError("BattleGroundWS: Removing offline player who has the FLAG!!");
this->SetAllianceFlagPicker(0); SetAllianceFlagPicker(0);
this->RespawnFlag(ALLIANCE, false); RespawnFlag(ALLIANCE, false);
} }
else else
this->EventPlayerDroppedFlag(plr); EventPlayerDroppedFlag(plr);
} }
if(IsHordeFlagPickedup() && m_FlagKeepers[BG_TEAM_HORDE] == guid) if(IsHordeFlagPickedup() && m_FlagKeepers[BG_TEAM_HORDE] == guid)
{ {
if(!plr) if(!plr)
{ {
sLog.outError("BattleGroundWS: Removing offline player who has the FLAG!!"); sLog.outError("BattleGroundWS: Removing offline player who has the FLAG!!");
this->SetHordeFlagPicker(0); SetHordeFlagPicker(0);
this->RespawnFlag(HORDE, false); RespawnFlag(HORDE, false);
} }
else else
this->EventPlayerDroppedFlag(plr); EventPlayerDroppedFlag(plr);
} }
} }

View file

@ -119,7 +119,7 @@ struct MANGOS_DLL_DECL Cell
Cell& operator=(const Cell &cell) Cell& operator=(const Cell &cell)
{ {
this->data.All = cell.data.All; data.All = cell.data.All;
return *this; return *this;
} }
@ -154,7 +154,7 @@ struct MANGOS_DLL_DECL CellLock
operator const Cell &(void) const { return i_cell; } operator const Cell &(void) const { return i_cell; }
CellLock<T>& operator=(const CellLock<T> &cell) CellLock<T>& operator=(const CellLock<T> &cell)
{ {
this->~CellLock(); ~CellLock();
new (this) CellLock<T>(cell); new (this) CellLock<T>(cell);
return *this; return *this;
} }

View file

@ -407,7 +407,7 @@ void GameObject::Update(uint32 /*p_time*/)
//burning flags in some battlegrounds, if you find better condition, just add it //burning flags in some battlegrounds, if you find better condition, just add it
if (GetGoAnimProgress() > 0) if (GetGoAnimProgress() > 0)
{ {
SendObjectDeSpawnAnim(this->GetGUID()); SendObjectDeSpawnAnim(GetGUID());
//reset flags //reset flags
SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags); SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags);
} }

View file

@ -1305,7 +1305,7 @@ void Group::UpdateLooterGuid( Creature* creature, bool ifneed )
void Roll::targetObjectBuildLink() void Roll::targetObjectBuildLink()
{ {
// called from link() // called from link()
this->getTarget()->addLootValidatorRef(this); getTarget()->addLootValidatorRef(this);
} }
void Group::SetDifficulty(uint8 difficulty) void Group::SetDifficulty(uint8 difficulty)

View file

@ -69,13 +69,7 @@ bool Guild::create(uint64 lGuid, std::string gname)
guildbank_money = 0; guildbank_money = 0;
purchased_tabs = 0; purchased_tabs = 0;
QueryResult *result = CharacterDatabase.Query( "SELECT MAX(guildid) FROM guild" ); Id = objmgr.GenerateGuildId();
if( result )
{
Id = (*result)[0].GetUInt32()+1;
delete result;
}
else Id = 1;
// gname already assigned to Guild::name, use it to encode string for DB // gname already assigned to Guild::name, use it to encode string for DB
CharacterDatabase.escape_string(gname); CharacterDatabase.escape_string(gname);
@ -410,18 +404,16 @@ void Guild::LoadPlayerStatsByGuid(uint64 guid)
void Guild::SetLeader(uint64 guid) void Guild::SetLeader(uint64 guid)
{ {
leaderGuid = guid; leaderGuid = guid;
this->ChangeRank(guid, GR_GUILDMASTER); ChangeRank(guid, GR_GUILDMASTER);
CharacterDatabase.PExecute("UPDATE guild SET leaderguid='%u' WHERE guildid='%u'", GUID_LOPART(guid), Id); CharacterDatabase.PExecute("UPDATE guild SET leaderguid='%u' WHERE guildid='%u'", GUID_LOPART(guid), Id);
} }
void Guild::DelMember(uint64 guid, bool isDisbanding) void Guild::DelMember(uint64 guid, bool isDisbanding)
{ {
if(this->leaderGuid == guid && !isDisbanding) if(leaderGuid == guid && !isDisbanding)
{ {
std::ostringstream ss; QueryResult *result = CharacterDatabase.PQuery("SELECT guid FROM guild_member WHERE guildid='%u' AND guid != '%u' ORDER BY rank ASC LIMIT 1", Id, GUID_LOPART(leaderGuid));
ss<<"SELECT guid FROM guild_member WHERE guildid='"<<Id<<"' AND guid!='"<<this->leaderGuid<<"' ORDER BY rank ASC LIMIT 1";
QueryResult *result = CharacterDatabase.Query( ss.str().c_str() );
if( result ) if( result )
{ {
uint64 newLeaderGUID; uint64 newLeaderGUID;
@ -431,7 +423,7 @@ void Guild::DelMember(uint64 guid, bool isDisbanding)
newLeaderGUID = (*result)[0].GetUInt64(); newLeaderGUID = (*result)[0].GetUInt64();
delete result; delete result;
this->SetLeader(newLeaderGUID); SetLeader(newLeaderGUID);
newLeader = objmgr.GetPlayer(newLeaderGUID); newLeader = objmgr.GetPlayer(newLeaderGUID);
if(newLeader) if(newLeader)
@ -453,20 +445,20 @@ void Guild::DelMember(uint64 guid, bool isDisbanding)
data << (uint8)2; data << (uint8)2;
data << oldLeaderName; data << oldLeaderName;
data << newLeaderName; data << newLeaderName;
this->BroadcastPacket(&data); BroadcastPacket(&data);
data.Initialize(SMSG_GUILD_EVENT, (1+1+oldLeaderName.size()+1)); data.Initialize(SMSG_GUILD_EVENT, (1+1+oldLeaderName.size()+1));
data << (uint8)GE_LEFT; data << (uint8)GE_LEFT;
data << (uint8)1; data << (uint8)1;
data << oldLeaderName; data << oldLeaderName;
this->BroadcastPacket(&data); BroadcastPacket(&data);
} }
sLog.outDebug( "WORLD: Sent (SMSG_GUILD_EVENT)" ); sLog.outDebug( "WORLD: Sent (SMSG_GUILD_EVENT)" );
} }
else else
{ {
this->Disband(); Disband();
return; return;
} }
} }
@ -662,7 +654,7 @@ void Guild::Disband()
{ {
WorldPacket data(SMSG_GUILD_EVENT, 1); WorldPacket data(SMSG_GUILD_EVENT, 1);
data << (uint8)GE_DISBANDED; data << (uint8)GE_DISBANDED;
this->BroadcastPacket(&data); BroadcastPacket(&data);
while (!members.empty()) while (!members.empty())
{ {
@ -762,11 +754,11 @@ void Guild::Query(WorldSession *session)
void Guild::SetEmblem(uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor, uint32 backgroundColor) void Guild::SetEmblem(uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor, uint32 backgroundColor)
{ {
this->EmblemStyle = emblemStyle; EmblemStyle = emblemStyle;
this->EmblemColor = emblemColor; EmblemColor = emblemColor;
this->BorderStyle = borderStyle; BorderStyle = borderStyle;
this->BorderColor = borderColor; BorderColor = borderColor;
this->BackgroundColor = backgroundColor; BackgroundColor = backgroundColor;
CharacterDatabase.PExecute("UPDATE guild SET EmblemStyle=%u, EmblemColor=%u, BorderStyle=%u, BorderColor=%u, BackgroundColor=%u WHERE guildid = %u", EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor, Id); CharacterDatabase.PExecute("UPDATE guild SET EmblemStyle=%u, EmblemColor=%u, BorderStyle=%u, BorderColor=%u, BackgroundColor=%u WHERE guildid = %u", EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor, Id);
} }
@ -1950,7 +1942,7 @@ void Guild::SendGuildBankTabText(WorldSession *session, uint8 TabId)
bool GuildItemPosCount::isContainedIn(GuildItemPosCountVec const &vec) const bool GuildItemPosCount::isContainedIn(GuildItemPosCountVec const &vec) const
{ {
for(GuildItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr) for(GuildItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr)
if(itr->slot == this->slot) if(itr->slot == slot)
return true; return true;
return false; return false;

View file

@ -347,7 +347,7 @@ void WorldSession::HandleGuildPromoteOpcode(WorldPacket& recvPacket)
SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS); SendGuildCommandResult(GUILD_INVITE_S, "", GUILD_PERMISSIONS);
return; return;
} }
else if((plRankId-1) == 0 || (plRankId-1) < this->GetPlayer()->GetRank()) else if((plRankId-1) == 0 || (plRankId-1) < GetPlayer()->GetRank())
return; return;
if(plRankId < 1) if(plRankId < 1)
@ -434,7 +434,7 @@ void WorldSession::HandleGuildDemoteOpcode(WorldPacket& recvPacket)
return; return;
} }
if((plRankId+1) >= guild->GetNrRanks() || plRankId <= this->GetPlayer()->GetRank()) if((plRankId+1) >= guild->GetNrRanks() || plRankId <= GetPlayer()->GetRank())
return; return;
guild->ChangeRank(plGuid, (plRankId+1)); guild->ChangeRank(plGuid, (plRankId+1));

View file

@ -418,7 +418,7 @@ Map::LoadGrid(const Cell& cell, bool no_unload)
bool Map::Add(Player *player) bool Map::Add(Player *player)
{ {
player->SetInstanceId(this->GetInstanceId()); player->SetInstanceId(GetInstanceId());
// update player state for other player and visa-versa // update player state for other player and visa-versa
CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY());

View file

@ -355,7 +355,7 @@ void ObjectMgr::SendAuctionWonMail( AuctionEntry *auction )
sLog.outDebug( "AuctionWon body string : %s", msgAuctionWonBody.str().c_str() ); sLog.outDebug( "AuctionWon body string : %s", msgAuctionWonBody.str().c_str() );
//prepare mail data... : //prepare mail data... :
uint32 itemTextId = this->CreateItemText( msgAuctionWonBody.str() ); uint32 itemTextId = CreateItemText( msgAuctionWonBody.str() );
// set owner to bidder (to prevent delete item with sender char deleting) // set owner to bidder (to prevent delete item with sender char deleting)
// owner in `data` will set at mail receive and item extracting // owner in `data` will set at mail receive and item extracting
@ -406,7 +406,7 @@ void ObjectMgr::SendAuctionSalePendingMail( AuctionEntry * auction )
sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str()); sLog.outDebug("AuctionSalePending body string : %s", msgAuctionSalePendingBody.str().c_str());
uint32 itemTextId = this->CreateItemText( msgAuctionSalePendingBody.str() ); uint32 itemTextId = CreateItemText( msgAuctionSalePendingBody.str() );
WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSalePendingSubject.str(), itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_AUCTION); WorldSession::SendMailTo(owner, MAIL_AUCTION, MAIL_STATIONERY_AUCTION, auction->location, auction->owner, msgAuctionSalePendingSubject.str(), itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_AUCTION);
} }
@ -438,7 +438,7 @@ void ObjectMgr::SendAuctionSuccessfulMail( AuctionEntry * auction )
sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str()); sLog.outDebug("AuctionSuccessful body string : %s", auctionSuccessfulBody.str().c_str());
uint32 itemTextId = this->CreateItemText( auctionSuccessfulBody.str() ); uint32 itemTextId = CreateItemText( auctionSuccessfulBody.str() );
uint32 profit = auction->bid + auction->deposit - auctionCut; uint32 profit = auction->bid + auction->deposit - auctionCut;
@ -1418,7 +1418,7 @@ void ObjectMgr::LoadAuctions()
aItem->deposit = fields[10].GetUInt32(); aItem->deposit = fields[10].GetUInt32();
aItem->location = fields[11].GetUInt8(); aItem->location = fields[11].GetUInt8();
//check if sold item exists //check if sold item exists
if ( this->GetAItem( aItem->item_guidlow ) ) if ( GetAItem( aItem->item_guidlow ) )
{ {
GetAuctionsMap( aItem->location )->AddAuction(aItem); GetAuctionsMap( aItem->location )->AddAuction(aItem);
} }
@ -5016,13 +5016,8 @@ void ObjectMgr::SetHighestGuids()
delete result; delete result;
} }
result = CharacterDatabase.Query( "SELECT MAX(id) FROM character_pet" ); // pet guids are not saved to DB, set to 0 (pet guid != pet id)
if( result ) m_hiPetGuid = 0;
{
m_hiPetGuid = (*result)[0].GetUInt32()+1;
delete result;
}
result = CharacterDatabase.Query( "SELECT MAX(guid) FROM item_instance" ); result = CharacterDatabase.Query( "SELECT MAX(guid) FROM item_instance" );
if( result ) if( result )
@ -5085,6 +5080,44 @@ void ObjectMgr::SetHighestGuids()
delete result; delete result;
} }
result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team");
if (result)
{
m_arenaTeamId = (*result)[0].GetUInt32()+1;
delete result;
}
result = CharacterDatabase.Query( "SELECT MAX(guildid) FROM guild" );
if (result)
{
m_guildId = (*result)[0].GetUInt32()+1;
delete result;
}
}
uint32 ObjectMgr::GenerateArenaTeamId()
{
++m_arenaTeamId;
if(m_arenaTeamId>=0xFFFFFFFF)
{
sLog.outError("Arena team ids overflow!! Can't continue, shuting down server. ");
sWorld.m_stopEvent = true;
}
return m_arenaTeamId;
}
uint32 ObjectMgr::GenerateGuildId()
{
++m_guildId;
if(m_guildId>=0xFFFFFFFF)
{
sLog.outError("Guild ids overflow!! Can't continue, shuting down server. ");
sWorld.m_stopEvent = true;
}
return m_guildId;
} }
uint32 ObjectMgr::GenerateAuctionID() uint32 ObjectMgr::GenerateAuctionID()

View file

@ -569,6 +569,8 @@ class ObjectMgr
uint32 GenerateMailID(); uint32 GenerateMailID();
uint32 GenerateItemTextID(); uint32 GenerateItemTextID();
uint32 GeneratePetNumber(); uint32 GeneratePetNumber();
uint32 GenerateArenaTeamId();
uint32 GenerateGuildId();
uint32 CreateItemText(std::string text); uint32 CreateItemText(std::string text);
std::string GetItemText( uint32 id ) std::string GetItemText( uint32 id )
@ -758,6 +760,8 @@ class ObjectMgr
uint32 m_auctionid; uint32 m_auctionid;
uint32 m_mailid; uint32 m_mailid;
uint32 m_ItemTextId; uint32 m_ItemTextId;
uint32 m_arenaTeamId;
uint32 m_guildId;
uint32 m_hiCharGuid; uint32 m_hiCharGuid;
uint32 m_hiCreatureGuid; uint32 m_hiCreatureGuid;

View file

@ -1476,7 +1476,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// The player was ported to another map and looses the duel immediatly. // The player was ported to another map and looses the duel immediatly.
// We have to perform this check before the teleport, otherwise the // We have to perform this check before the teleport, otherwise the
// ObjectAccessor won't find the flag. // ObjectAccessor won't find the flag.
if (duel && this->GetMapId()!=mapid) if (duel && GetMapId()!=mapid)
{ {
GameObject* obj = ObjectAccessor::GetGameObject(*this, GetUInt64Value(PLAYER_DUEL_ARBITER)); GameObject* obj = ObjectAccessor::GetGameObject(*this, GetUInt64Value(PLAYER_DUEL_ARBITER));
if (obj) if (obj)
@ -1486,7 +1486,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// reset movement flags at teleport, because player will continue move with these flags after teleport // reset movement flags at teleport, because player will continue move with these flags after teleport
SetUnitMovementFlags(0); SetUnitMovementFlags(0);
if ((this->GetMapId() == mapid) && (!m_transport)) if ((GetMapId() == mapid) && (!m_transport))
{ {
// prepare zone change detect // prepare zone change detect
uint32 old_zone = GetZoneId(); uint32 old_zone = GetZoneId();
@ -6779,7 +6779,7 @@ void Player::CastItemCombatSpell(Item *item,Unit* Target, WeaponAttackType attTy
} }
if (roll_chance_f(chance)) if (roll_chance_f(chance))
this->CastSpell(Target, spellInfo->Id, true, item); CastSpell(Target, spellInfo->Id, true, item);
} }
// item combat enchantments // item combat enchantments
@ -18133,7 +18133,7 @@ void Player::SetCanBlock( bool value )
bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const
{ {
for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr) for(ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end();++itr)
if(itr->pos == this->pos) if(itr->pos == pos)
return true; return true;
return false; return false;

View file

@ -1507,8 +1507,8 @@ class MANGOS_DLL_SPEC Player : public Unit
void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); } void RemoveFromGroup() { RemoveFromGroup(GetGroup(),GetGUID()); }
void SendUpdateToOutOfRangeGroupMembers(); void SendUpdateToOutOfRangeGroupMembers();
void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, this->GetGUID()); } void SetInGuild(uint32 GuildId) { SetUInt32Value(PLAYER_GUILDID, GuildId); Player::SetUInt32ValueInDB(PLAYER_GUILDID, GuildId, GetGUID()); }
void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, this->GetGUID()); } void SetRank(uint32 rankId){ SetUInt32Value(PLAYER_GUILDRANK, rankId); Player::SetUInt32ValueInDB(PLAYER_GUILDRANK, rankId, GetGUID()); }
void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; }
uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); } uint32 GetGuildId() { return GetUInt32Value(PLAYER_GUILDID); }
static uint32 GetGuildIdFromDB(uint64 guid); static uint32 GetGuildIdFromDB(uint64 guid);
@ -1521,7 +1521,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot) void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot)
{ {
SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId); SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId);
SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, this->GetGUID()); SetUInt32ValueInDB(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6), ArenaTeamId, GetGUID());
} }
uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); } uint32 GetArenaTeamId(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * 6)); }
static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot); static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot);

View file

@ -3142,7 +3142,7 @@ void Spell::TriggerSpell()
{ {
for(TriggerSpells::iterator si=m_TriggerSpells.begin(); si!=m_TriggerSpells.end(); ++si) for(TriggerSpells::iterator si=m_TriggerSpells.begin(); si!=m_TriggerSpells.end(); ++si)
{ {
Spell* spell = new Spell(m_caster, (*si), true, m_originalCasterGUID, this->m_selfContainer); Spell* spell = new Spell(m_caster, (*si), true, m_originalCasterGUID, m_selfContainer);
spell->prepare(&m_targets); // use original spell original targets spell->prepare(&m_targets); // use original spell original targets
} }
} }

View file

@ -2228,7 +2228,7 @@ void Spell::EffectSendEvent(uint32 EffectIndex)
case 23333: // Pickup Horde Flag case 23333: // Pickup Horde Flag
/*do not uncomment . /*do not uncomment .
if(bg->GetTypeID()==BATTLEGROUND_WS) if(bg->GetTypeID()==BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
sLog.outDebug("Send Event Horde Flag Picked Up"); sLog.outDebug("Send Event Horde Flag Picked Up");
break; break;
/* not used : /* not used :
@ -2241,7 +2241,7 @@ void Spell::EffectSendEvent(uint32 EffectIndex)
case 23335: // Pickup Alliance Flag 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 /*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) if(bg->GetTypeID()==BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
sLog.outDebug("Send Event Alliance Flag Picked Up"); sLog.outDebug("Send Event Alliance Flag Picked Up");
break; break;
/* not used : /* not used :
@ -2252,18 +2252,18 @@ void Spell::EffectSendEvent(uint32 EffectIndex)
break; break;
case 23385: // Alliance Flag Returns case 23385: // Alliance Flag Returns
if(bg->GetTypeID()==BATTLEGROUND_WS) if(bg->GetTypeID()==BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
sLog.outDebug("Alliance Flag Returned"); sLog.outDebug("Alliance Flag Returned");
break; break;
case 23386: // Horde Flag Returns case 23386: // Horde Flag Returns
if(bg->GetTypeID()==BATTLEGROUND_WS) if(bg->GetTypeID()==BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
sLog.outDebug("Horde Flag Returned"); sLog.outDebug("Horde Flag Returned");
break;*/ break;*/
case 34976: case 34976:
/* /*
if(bg->GetTypeID()==BATTLEGROUND_EY) if(bg->GetTypeID()==BATTLEGROUND_EY)
bg->EventPlayerClickedOnFlag((Player*)m_caster, this->gameObjTarget); bg->EventPlayerClickedOnFlag((Player*)m_caster, gameObjTarget);
*/ */
break; break;
default: default:
@ -3685,13 +3685,13 @@ void Spell::EffectAddHonor(uint32 /*i*/)
if(unitTarget->GetTypeId() != TYPEID_PLAYER) if(unitTarget->GetTypeId() != TYPEID_PLAYER)
return; return;
sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, this->damage, ((Player*)unitTarget)->GetGUIDLow()); sLog.outDebug("SpellEffect::AddHonor called for spell_id %u , that rewards %d honor points to player: %u", m_spellInfo->Id, damage, ((Player*)unitTarget)->GetGUIDLow());
// TODO: find formula for honor reward based on player's level! // TODO: find formula for honor reward based on player's level!
// now fixed only for level 70 players: // now fixed only for level 70 players:
if (((Player*)unitTarget)->getLevel() == 70) if (((Player*)unitTarget)->getLevel() == 70)
((Player*)unitTarget)->RewardHonor(NULL, 1, this->damage); ((Player*)unitTarget)->RewardHonor(NULL, 1, damage);
} }
void Spell::EffectTradeSkill(uint32 /*i*/) void Spell::EffectTradeSkill(uint32 /*i*/)

View file

@ -35,7 +35,7 @@ Totem::Totem() : Creature()
void Totem::Update( uint32 time ) void Totem::Update( uint32 time )
{ {
Unit *owner = GetOwner(); Unit *owner = GetOwner();
if (!owner || !owner->isAlive() || !this->isAlive()) if (!owner || !owner->isAlive() || !isAlive())
{ {
UnSummon(); // remove self UnSummon(); // remove self
return; return;
@ -89,7 +89,7 @@ void Totem::UnSummon()
CombatStop(); CombatStop();
RemoveAurasDueToSpell(GetSpell()); RemoveAurasDueToSpell(GetSpell());
Unit *owner = this->GetOwner(); Unit *owner = GetOwner();
if (owner) if (owner)
{ {
// clear owenr's totem slot // clear owenr's totem slot
@ -130,11 +130,11 @@ void Totem::SetOwner(uint64 guid)
{ {
SetUInt64Value(UNIT_FIELD_SUMMONEDBY, guid); SetUInt64Value(UNIT_FIELD_SUMMONEDBY, guid);
SetUInt64Value(UNIT_FIELD_CREATEDBY, guid); SetUInt64Value(UNIT_FIELD_CREATEDBY, guid);
Unit *owner = this->GetOwner(); Unit *owner = GetOwner();
if (owner) if (owner)
{ {
this->setFaction(owner->getFaction()); setFaction(owner->getFaction());
this->SetLevel(owner->getLevel()); SetLevel(owner->getLevel());
} }
} }

View file

@ -464,7 +464,7 @@ bool Transport::AddPassenger(Player* passenger)
{ {
if (m_passengers.find(passenger) == m_passengers.end()) if (m_passengers.find(passenger) == m_passengers.end())
{ {
sLog.outDetail("Player %s boarded transport %s.", passenger->GetName(), this->m_name.c_str()); sLog.outDetail("Player %s boarded transport %s.", passenger->GetName(), m_name.c_str());
m_passengers.insert(passenger); m_passengers.insert(passenger);
} }
return true; return true;
@ -474,7 +474,7 @@ bool Transport::RemovePassenger(Player* passenger)
{ {
if (m_passengers.find(passenger) != m_passengers.end()) if (m_passengers.find(passenger) != m_passengers.end())
{ {
sLog.outDetail("Player %s removed from transport %s.", passenger->GetName(), this->m_name.c_str()); sLog.outDetail("Player %s removed from transport %s.", passenger->GetName(), m_name.c_str());
m_passengers.erase(passenger); m_passengers.erase(passenger);
} }
return true; return true;
@ -498,7 +498,7 @@ void Transport::Update(uint32 /*p_time*/)
} }
else else
{ {
//MapManager::Instance().GetMap(m_curr->second.mapid)->GameobjectRelocation((GameObject *)this, m_curr->second.x, m_curr->second.y, m_curr->second.z, this->m_orientation); //MapManager::Instance().GetMap(m_curr->second.mapid)->GameobjectRelocation((GameObject *)this, m_curr->second.x, m_curr->second.y, m_curr->second.z, m_orientation);
Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z); Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z);
} }
@ -514,13 +514,13 @@ void Transport::Update(uint32 /*p_time*/)
m_nextNodeTime = m_curr->first; m_nextNodeTime = m_curr->first;
if (m_curr == m_WayPoints.begin() && (sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES)==0) if (m_curr == m_WayPoints.begin() && (sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES)==0)
sLog.outDetail(" ************ BEGIN ************** %s", this->m_name.c_str()); sLog.outDetail(" ************ BEGIN ************** %s", m_name.c_str());
// MapManager::Instance().GetMap(m_curr->second.mapid)->Add(&this); // -> // ->Add(t); // MapManager::Instance().GetMap(m_curr->second.mapid)->Add(&this); // -> // ->Add(t);
//MapManager::Instance().GetMap(m_curr->second.mapid)->Remove((GameObject *)this, false); // -> // ->Add(t); //MapManager::Instance().GetMap(m_curr->second.mapid)->Remove((GameObject *)this, false); // -> // ->Add(t);
//MapManager::Instance().GetMap(m_curr->second.mapid)->Add((GameObject *)this); // -> // ->Add(t); //MapManager::Instance().GetMap(m_curr->second.mapid)->Add((GameObject *)this); // -> // ->Add(t);
if ((sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES)==0) if ((sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES)==0)
sLog.outDetail("%s moved to %f %f %f %d", this->m_name.c_str(), m_curr->second.x, m_curr->second.y, m_curr->second.z, m_curr->second.mapid); sLog.outDetail("%s moved to %f %f %f %d", m_name.c_str(), m_curr->second.x, m_curr->second.y, m_curr->second.z, m_curr->second.mapid);
} }
} }

View file

@ -37,7 +37,7 @@ struct MANGOS_DLL_DECL Traveller
Traveller(const Traveller &obj) : i_traveller(obj) {} Traveller(const Traveller &obj) : i_traveller(obj) {}
Traveller& operator=(const Traveller &obj) Traveller& operator=(const Traveller &obj)
{ {
this->~Traveller(); ~Traveller();
new (this) Traveller(obj); new (this) Traveller(obj);
return *this; return *this;
} }

View file

@ -1374,7 +1374,7 @@ uint32 Unit::SpellNonMeleeDamageLog(Unit *pVictim, uint32 spellID, uint32 damage
{ {
if(!this || !pVictim) if(!this || !pVictim)
return 0; return 0;
if(!this->isAlive() || !pVictim->isAlive()) if(!isAlive() || !pVictim->isAlive())
return 0; return 0;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID); SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID);
@ -8076,7 +8076,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage,WeaponAttackType attT
int32 TakenFlatBenefit = 0; int32 TakenFlatBenefit = 0;
// ..done (for creature type by mask) in taken // ..done (for creature type by mask) in taken
AuraList const& mDamageDoneCreature = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); AuraList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE);
for(AuraList::const_iterator i = mDamageDoneCreature.begin();i != mDamageDoneCreature.end(); ++i) for(AuraList::const_iterator i = mDamageDoneCreature.begin();i != mDamageDoneCreature.end(); ++i)
if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue))
DoneFlatBenefit += (*i)->GetModifier()->m_amount; DoneFlatBenefit += (*i)->GetModifier()->m_amount;
@ -8144,7 +8144,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage,WeaponAttackType attT
// SPELL_AURA_MOD_DAMAGE_PERCENT_DONE included in weapon damage // SPELL_AURA_MOD_DAMAGE_PERCENT_DONE included in weapon damage
// SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT included in weapon damage // SPELL_AURA_MOD_OFFHAND_DAMAGE_PCT included in weapon damage
AuraList const& mDamageDoneVersus = this->GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS);
for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i) for(AuraList::const_iterator i = mDamageDoneVersus.begin();i != mDamageDoneVersus.end(); ++i)
if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) if(creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue))
DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f;
@ -8684,7 +8684,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList)
//Visible distance is modified by //Visible distance is modified by
//-Level Diff (every level diff = 1.0f in visible distance) //-Level Diff (every level diff = 1.0f in visible distance)
visibleDistance += int32(u->getLevelForTarget(this)) - int32(this->getLevelForTarget(u)); visibleDistance += int32(u->getLevelForTarget(this)) - int32(getLevelForTarget(u));
//This allows to check talent tree and will add addition stealth dependent on used points) //This allows to check talent tree and will add addition stealth dependent on used points)
int32 stealthMod = GetTotalAuraModifier(SPELL_AURA_MOD_STEALTH_LEVEL); int32 stealthMod = GetTotalAuraModifier(SPELL_AURA_MOD_STEALTH_LEVEL);
@ -10830,9 +10830,9 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
return NULL; return NULL;
} }
pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, this->GetGUID()); pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID());
pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, this->GetGUID()); pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, GetGUID());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,this->getFaction()); pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE,getFaction());
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id); pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id);
if(!pet->InitStatsForLevel(creatureTarget->getLevel())) if(!pet->InitStatsForLevel(creatureTarget->getLevel()))

View file

@ -81,7 +81,7 @@ m_Seed (static_cast<uint32> (rand32 ())),
m_OverSpeedPings (0), m_OverSpeedPings (0),
m_LastPingTime (ACE_Time_Value::zero) m_LastPingTime (ACE_Time_Value::zero)
{ {
this->reference_counting_policy ().value (ACE_Event_Handler::Reference_Counting_Policy::ENABLED); reference_counting_policy ().value (ACE_Event_Handler::Reference_Counting_Policy::ENABLED);
} }
WorldSocket::~WorldSocket (void) WorldSocket::~WorldSocket (void)
@ -92,9 +92,9 @@ WorldSocket::~WorldSocket (void)
if (m_OutBuffer) if (m_OutBuffer)
m_OutBuffer->release (); m_OutBuffer->release ();
this->closing_ = true; closing_ = true;
this->peer ().close (); peer ().close ();
WorldPacket* pct; WorldPacket* pct;
while (m_PacketQueue.dequeue_head (pct) == 0) while (m_PacketQueue.dequeue_head (pct) == 0)
@ -103,7 +103,7 @@ WorldSocket::~WorldSocket (void)
bool WorldSocket::IsClosed (void) const bool WorldSocket::IsClosed (void) const
{ {
return this->closing_; return closing_;
} }
void WorldSocket::CloseSocket (void) void WorldSocket::CloseSocket (void)
@ -111,12 +111,12 @@ void WorldSocket::CloseSocket (void)
{ {
ACE_GUARD (LockType, Guard, m_OutBufferLock); ACE_GUARD (LockType, Guard, m_OutBufferLock);
if (this->closing_) if (closing_)
return; return;
this->closing_ = true; closing_ = true;
this->peer ().close_writer (); peer ().close_writer ();
} }
{ {
@ -135,7 +135,7 @@ int WorldSocket::SendPacket (const WorldPacket& pct)
{ {
ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1); ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1);
if (this->closing_) if (closing_)
return -1; return -1;
// Dump outgoing packet. // Dump outgoing packet.
@ -180,12 +180,12 @@ int WorldSocket::SendPacket (const WorldPacket& pct)
long WorldSocket::AddReference (void) long WorldSocket::AddReference (void)
{ {
return static_cast<long> (this->add_reference ()); return static_cast<long> (add_reference ());
} }
long WorldSocket::RemoveReference (void) long WorldSocket::RemoveReference (void)
{ {
return static_cast<long> (this->remove_reference ()); return static_cast<long> (remove_reference ());
} }
int WorldSocket::open (void *a) int WorldSocket::open (void *a)
@ -210,7 +210,7 @@ int WorldSocket::open (void *a)
// Store peer address. // Store peer address.
ACE_INET_Addr remote_addr; ACE_INET_Addr remote_addr;
if (this->peer ().get_remote_addr (remote_addr) == -1) if (peer ().get_remote_addr (remote_addr) == -1)
{ {
sLog.outError ("WorldSocket::open: peer ().get_remote_addr errno = %s", ACE_OS::strerror (errno)); sLog.outError ("WorldSocket::open: peer ().get_remote_addr errno = %s", ACE_OS::strerror (errno));
return -1; return -1;
@ -226,42 +226,42 @@ int WorldSocket::open (void *a)
return -1; return -1;
// Register with ACE Reactor // Register with ACE Reactor
if (this->reactor ()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1) if (reactor ()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1)
{ {
sLog.outError ("WorldSocket::open: unable to register client handler errno = %s", ACE_OS::strerror (errno)); sLog.outError ("WorldSocket::open: unable to register client handler errno = %s", ACE_OS::strerror (errno));
return -1; return -1;
} }
// reactor takes care of the socket from now on // reactor takes care of the socket from now on
this->remove_reference (); remove_reference ();
return 0; return 0;
} }
int WorldSocket::close (int) int WorldSocket::close (int)
{ {
this->shutdown (); shutdown ();
this->closing_ = true; closing_ = true;
this->remove_reference (); remove_reference ();
return 0; return 0;
} }
int WorldSocket::handle_input (ACE_HANDLE) int WorldSocket::handle_input (ACE_HANDLE)
{ {
if (this->closing_) if (closing_)
return -1; return -1;
switch (this->handle_input_missing_data ()) switch (handle_input_missing_data ())
{ {
case -1 : case -1 :
{ {
if ((errno == EWOULDBLOCK) || if ((errno == EWOULDBLOCK) ||
(errno == EAGAIN)) (errno == EAGAIN))
{ {
return this->Update (); // interesting line ,isnt it ? return Update (); // interesting line ,isnt it ?
} }
DEBUG_LOG ("WorldSocket::handle_input: Peer error closing connection errno = %s", ACE_OS::strerror (errno)); DEBUG_LOG ("WorldSocket::handle_input: Peer error closing connection errno = %s", ACE_OS::strerror (errno));
@ -279,7 +279,7 @@ int WorldSocket::handle_input (ACE_HANDLE)
case 1: case 1:
return 1; return 1;
default: default:
return this->Update (); // another interesting line ;) return Update (); // another interesting line ;)
} }
ACE_NOTREACHED(return -1); ACE_NOTREACHED(return -1);
@ -289,18 +289,18 @@ int WorldSocket::handle_output (ACE_HANDLE)
{ {
ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1); ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1);
if (this->closing_) if (closing_)
return -1; return -1;
const size_t send_len = m_OutBuffer->length (); const size_t send_len = m_OutBuffer->length ();
if (send_len == 0) if (send_len == 0)
return this->cancel_wakeup_output (Guard); return cancel_wakeup_output (Guard);
#ifdef MSG_NOSIGNAL #ifdef MSG_NOSIGNAL
ssize_t n = this->peer ().send (m_OutBuffer->rd_ptr (), send_len, MSG_NOSIGNAL); ssize_t n = peer ().send (m_OutBuffer->rd_ptr (), send_len, MSG_NOSIGNAL);
#else #else
ssize_t n = this->peer ().send (m_OutBuffer->rd_ptr (), send_len); ssize_t n = peer ().send (m_OutBuffer->rd_ptr (), send_len);
#endif // MSG_NOSIGNAL #endif // MSG_NOSIGNAL
if (n == 0) if (n == 0)
@ -308,7 +308,7 @@ int WorldSocket::handle_output (ACE_HANDLE)
else if (n == -1) else if (n == -1)
{ {
if (errno == EWOULDBLOCK || errno == EAGAIN) if (errno == EWOULDBLOCK || errno == EAGAIN)
return this->schedule_wakeup_output (Guard); return schedule_wakeup_output (Guard);
return -1; return -1;
} }
@ -319,16 +319,16 @@ int WorldSocket::handle_output (ACE_HANDLE)
// move the data to the base of the buffer // move the data to the base of the buffer
m_OutBuffer->crunch (); m_OutBuffer->crunch ();
return this->schedule_wakeup_output (Guard); return schedule_wakeup_output (Guard);
} }
else //now n == send_len else //now n == send_len
{ {
m_OutBuffer->reset (); m_OutBuffer->reset ();
if (!iFlushPacketQueue ()) if (!iFlushPacketQueue ())
return this->cancel_wakeup_output (Guard); return cancel_wakeup_output (Guard);
else else
return this->schedule_wakeup_output (Guard); return schedule_wakeup_output (Guard);
} }
ACE_NOTREACHED (return 0); ACE_NOTREACHED (return 0);
@ -340,10 +340,10 @@ int WorldSocket::handle_close (ACE_HANDLE h, ACE_Reactor_Mask)
{ {
ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1); ACE_GUARD_RETURN (LockType, Guard, m_OutBufferLock, -1);
this->closing_ = true; closing_ = true;
if (h == ACE_INVALID_HANDLE) if (h == ACE_INVALID_HANDLE)
this->peer ().close_writer (); peer ().close_writer ();
} }
// Critical section // Critical section
@ -358,13 +358,13 @@ int WorldSocket::handle_close (ACE_HANDLE h, ACE_Reactor_Mask)
int WorldSocket::Update (void) int WorldSocket::Update (void)
{ {
if (this->closing_) if (closing_)
return -1; return -1;
if (m_OutActive || m_OutBuffer->length () == 0) if (m_OutActive || m_OutBuffer->length () == 0)
return 0; return 0;
return this->handle_output (this->get_handle ()); return handle_output (get_handle ());
} }
int WorldSocket::handle_input_header (void) int WorldSocket::handle_input_header (void)
@ -416,7 +416,7 @@ int WorldSocket::handle_input_payload (void)
ACE_ASSERT (m_Header.space () == 0); ACE_ASSERT (m_Header.space () == 0);
ACE_ASSERT (m_RecvWPct != NULL); ACE_ASSERT (m_RecvWPct != NULL);
const int ret = this->ProcessIncoming (m_RecvWPct); const int ret = ProcessIncoming (m_RecvWPct);
m_RecvPct.base (NULL, 0); m_RecvPct.base (NULL, 0);
m_RecvPct.reset (); m_RecvPct.reset ();
@ -448,7 +448,7 @@ int WorldSocket::handle_input_missing_data (void)
const size_t recv_size = message_block.space (); const size_t recv_size = message_block.space ();
const ssize_t n = this->peer ().recv (message_block.wr_ptr (), const ssize_t n = peer ().recv (message_block.wr_ptr (),
recv_size); recv_size);
if (n <= 0) if (n <= 0)
@ -474,7 +474,7 @@ int WorldSocket::handle_input_missing_data (void)
} }
//we just recieved nice new header //we just recieved nice new header
if (this->handle_input_header () == -1) if (handle_input_header () == -1)
{ {
ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN)); ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN));
return -1; return -1;
@ -509,7 +509,7 @@ int WorldSocket::handle_input_missing_data (void)
} }
//just recieved fresh new payload //just recieved fresh new payload
if (this->handle_input_payload () == -1) if (handle_input_payload () == -1)
{ {
ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN)); ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN));
return -1; return -1;
@ -528,7 +528,7 @@ int WorldSocket::cancel_wakeup_output (GuardType& g)
g.release (); g.release ();
if (this->reactor ()->cancel_wakeup if (reactor ()->cancel_wakeup
(this, ACE_Event_Handler::WRITE_MASK) == -1) (this, ACE_Event_Handler::WRITE_MASK) == -1)
{ {
// would be good to store errno from reactor with errno guard // would be good to store errno from reactor with errno guard
@ -548,7 +548,7 @@ int WorldSocket::schedule_wakeup_output (GuardType& g)
g.release (); g.release ();
if (this->reactor ()->schedule_wakeup if (reactor ()->schedule_wakeup
(this, ACE_Event_Handler::WRITE_MASK) == -1) (this, ACE_Event_Handler::WRITE_MASK) == -1)
{ {
sLog.outError ("WorldSocket::schedule_wakeup_output"); sLog.outError ("WorldSocket::schedule_wakeup_output");
@ -567,7 +567,7 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
const ACE_UINT16 opcode = new_pct->GetOpcode (); const ACE_UINT16 opcode = new_pct->GetOpcode ();
if (this->closing_) if (closing_)
return -1; return -1;
// dump recieved packet // dump recieved packet
@ -853,7 +853,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
return -1; return -1;
} }
std::string address = this->GetRemoteAddress (); std::string address = GetRemoteAddress ();
DEBUG_LOG ("WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.", DEBUG_LOG ("WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.",
account.c_str (), account.c_str (),
@ -878,7 +878,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
// In case needed sometime the second arg is in microseconds 1 000 000 = 1 sec // In case needed sometime the second arg is in microseconds 1 000 000 = 1 sec
ACE_OS::sleep (ACE_Time_Value (0, 10000)); ACE_OS::sleep (ACE_Time_Value (0, 10000));
sWorld.AddSession (this->m_Session); sWorld.AddSession (m_Session);
// Create and send the Addon packet // Create and send the Addon packet
if (sAddOnHandler.BuildAddonPacket (&recvPacket, &SendAddonPacked)) if (sAddOnHandler.BuildAddonPacket (&recvPacket, &SendAddonPacked))
@ -946,14 +946,14 @@ int WorldSocket::HandlePing (WorldPacket& recvPacket)
sLog.outError ("WorldSocket::HandlePing: peer sent CMSG_PING, " sLog.outError ("WorldSocket::HandlePing: peer sent CMSG_PING, "
"but is not authenticated or got recently kicked," "but is not authenticated or got recently kicked,"
" adress = %s", " adress = %s",
this->GetRemoteAddress ().c_str ()); GetRemoteAddress ().c_str ());
return -1; return -1;
} }
} }
WorldPacket packet (SMSG_PONG, 4); WorldPacket packet (SMSG_PONG, 4);
packet << ping; packet << ping;
return this->SendPacket (packet); return SendPacket (packet);
} }
int WorldSocket::iSendPacket (const WorldPacket& pct) int WorldSocket::iSendPacket (const WorldPacket& pct)

View file

@ -79,8 +79,8 @@ class ReactorRunnable : protected ACE_Task_Base
virtual ~ReactorRunnable () virtual ~ReactorRunnable ()
{ {
this->Stop (); Stop ();
this->Wait (); Wait ();
if (m_Reactor) if (m_Reactor)
delete m_Reactor; delete m_Reactor;
@ -96,7 +96,7 @@ class ReactorRunnable : protected ACE_Task_Base
if (m_ThreadId != -1) if (m_ThreadId != -1)
return -1; return -1;
return (m_ThreadId = this->activate ()); return (m_ThreadId = activate ());
} }
void Wait () { ACE_Task_Base::wait (); } void Wait () { ACE_Task_Base::wait (); }
@ -278,7 +278,7 @@ WorldSocketMgr::StartNetwork (ACE_UINT16 port, const char* address)
if (!sLog.IsOutDebug ()) if (!sLog.IsOutDebug ())
ACE_Log_Msg::instance ()->priority_mask (LM_ERROR, ACE_Log_Msg::PROCESS); ACE_Log_Msg::instance ()->priority_mask (LM_ERROR, ACE_Log_Msg::PROCESS);
if (this->StartReactiveIO (port, address) == -1) if (StartReactiveIO (port, address) == -1)
return -1; return -1;
return 0; return 0;
@ -301,7 +301,7 @@ WorldSocketMgr::StopNetwork ()
m_NetThreads[i].Stop (); m_NetThreads[i].Stop ();
} }
this->Wait (); Wait ();
} }
void void