void Channel::Say(ObjectGuid p, const char *what, uint32 lang, bool skipCheck) { if (!what) return; if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) lang = LANG_UNIVERSAL; uint32 sec = 0; PlayerPointer plr = GetPlayer(p); if (plr) sec = plr->GetSession()->GetSecurity(); if (!skipCheck && !IsOn(p)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, p); } else if (!skipCheck && m_players[p].IsMuted()) { WorldPacket data; MakeMuted(&data); SendToOne(&data, p); } else if (!skipCheck && m_moderate && !m_players[p].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, p); } else { uint32 messageLength = strlen(what) + 1; WorldPacket data(SMSG_MESSAGECHAT, 1 + 4 + 8 + 4 + m_name.size() + 1 + 8 + 4 + messageLength + 1); data << uint8(CHAT_MSG_CHANNEL); data << uint32(lang); data << m_name; data << uint32(0); data << ObjectGuid(p); data << uint32(messageLength); data << what; data << uint8(plr ? plr->chatTag() : 0); if (!skipCheck && plr && plr->GetSession()->GetAccountFlags() & ACCOUNT_FLAG_MUTED_FROM_PUBLIC_CHANNELS && plr->GetSession()->GetAccountMaxLevel() < sWorld.getConfig(CONFIG_UINT32_PUB_CHANS_MUTE_VANISH_LEVEL)) plr->GetSession()->SendPacket(&data); else SendToAll(&data, (!skipCheck && !m_players[p].IsModerator()) ? p : ObjectGuid()); } }
void InstanceMgr::ResetSavedInstances(PlayerPointer plr) { WorldPacket data(SMSG_INSTANCE_RESET, 4); Instance * in; InstanceMap::iterator itr; InstanceMap * instancemap; uint32 i; if(!plr->IsInWorld() || plr->GetMapMgr()->GetMapInfo()->type != INSTANCE_NULL) return; m_mapLock.Acquire(); for(i = 0; i < NUM_MAPS; ++i) { if(m_instances[i] != NULL) { instancemap = m_instances[i]; for(itr = instancemap->begin(); itr != instancemap->end();) { in = itr->second; ++itr; if ( in->m_mapInfo->type == INSTANCE_NONRAID && ( plr->GetLowGUID() == in->m_creatorGuid || ( plr->GetGroup() && plr->GetGroup()->GetID() == in->m_creatorGroup ))) { if(in->m_mapMgr && in->m_mapMgr->HasPlayers()) { plr->GetSession()->SystemMessage("Can't reset instance %u (%s) when there are still players inside!", in->m_instanceId, in->m_mapMgr->GetMapInfo()->name); continue; } // <mapid> has been reset. data << uint32(in->m_mapId); plr->GetSession()->SendPacket(&data); // reset groupinstanceid if(plr->GetGroup()) plr->GetGroup()->SetGroupInstanceID(0); // destroy the instance _DeleteInstance(in, true); } } } } m_mapLock.Release(); }
void Antispam::addMessage(const std::string& msg, uint32 type, PlayerPointer from, PlayerPointer to) { if (!m_enabled || from->isGameMaster()) return; if (from->getLevel() > m_restrictionLevel) return; uint8 chatType = getConvertedChatType(type); if (chatType == A_CHAT_TYPE_MAX) return; if (m_chatMask && (m_chatMask & (1 << chatType)) == 0) return; MessageBlock messageBlock; messageBlock.fromGuid = from->GetObjectGuid(); messageBlock.fromAccount = from->GetSession()->GetAccountId(); messageBlock.toGuid = (to && !m_mergeAllWhispers ? to->GetObjectGuid() : ObjectGuid()); messageBlock.msg = msg; messageBlock.type = chatType; messageBlock.count = 1; messageBlock.time = time(nullptr); m_messageQueue.push(messageBlock); }
void Channel::SetOwner(ObjectGuid guid, bool exclaim) { PlayerPointer newp = GetPlayer(guid); if (!newp) return; if (HasFlag(CHANNEL_FLAG_GENERAL) && newp->GetSession()->GetSecurity() < SEC_GAMEMASTER) return; if (m_ownerGuid) { // [] will re-add player after it possible removed PlayerList::iterator p_itr = m_players.find(m_ownerGuid); if (p_itr != m_players.end()) p_itr->second.SetOwner(false); } m_ownerGuid = guid; if (m_ownerGuid) { uint8 oldFlag = GetPlayerFlags(m_ownerGuid); m_players[m_ownerGuid].SetOwner(true); WorldPacket data; MakeModeChange(&data, m_ownerGuid, oldFlag); SendToAll(&data); if (exclaim) { MakeOwnerChanged(&data, m_ownerGuid); SendToAll(&data); } } }
void Channel::Password(ObjectGuid p, const char *pass) { uint32 sec = 0; PlayerPointer plr = GetPlayer(p); if (plr) sec = plr->GetSession()->GetSecurity(); if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, p); } else if (!m_players[p].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, p); } else { m_password = pass; WorldPacket data; MakePasswordChanged(&data, p); SendToAll(&data); } }
bool ChatHandler::CreateGuildCommand(const char* args, WorldSession *m_session) { if(!*args) return false; PlayerPointer ptarget = getSelectedChar(m_session); if(!ptarget) return false; if(strlen((char*)args)>75) { // send message to user char buf[256]; snprintf((char*)buf,256,"The name was too long by %i", (unsigned int)strlen((char*)args)-75); SystemMessage(m_session, buf); return true; } for (uint32 i = 0; i < strlen(args); i++) { if(!isalpha(args[i]) && args[i]!=' ') { SystemMessage(m_session, "Error, name can only contain chars A-Z and a-z."); return true; } } Charter tempCharter(0, ptarget->GetLowGUID(), CHARTER_TYPE_GUILD); tempCharter.SignatureCount=0; tempCharter.GuildName = string(args); Guild * pGuild = Guild::Create(); pGuild->CreateFromCharter(&tempCharter, ptarget->GetSession()); SystemMessage(m_session, "Guild created"); return true; }
void Channel::Moderate(ObjectGuid p) { uint32 sec = 0; PlayerPointer plr = GetPlayer(p); if (plr) sec = plr->GetSession()->GetSecurity(); if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, p); } else if (!m_players[p].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, p); } else { m_moderate = !m_moderate; WorldPacket data; if (m_moderate) MakeModerationOn(&data, p); else MakeModerationOff(&data, p); SendToAll(&data); } }
void Channel::KickOrBan(ObjectGuid good, const char *badname, bool ban) { AccountTypes sec = SEC_PLAYER; PlayerPointer gplr = GetPlayer(good); if (gplr) sec = gplr->GetSession()->GetSecurity(); if (!IsOn(good)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, good); } else if (!m_players[good].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, good); } else { Player *bad = sObjectMgr.GetPlayer(badname); if (bad == NULL || !IsOn(bad->GetObjectGuid())) { WorldPacket data; MakePlayerNotFound(&data, badname); SendToOne(&data, good); } else if (sec < SEC_GAMEMASTER && bad->GetObjectGuid() == m_ownerGuid && good != m_ownerGuid) { WorldPacket data; MakeNotOwner(&data); SendToOne(&data, good); } else { bool changeowner = (m_ownerGuid == bad->GetObjectGuid()); WorldPacket data; if (ban && !IsBanned(bad->GetObjectGuid())) { m_banned.insert(bad->GetObjectGuid()); MakePlayerBanned(&data, bad->GetObjectGuid(), good); } else MakePlayerKicked(&data, bad->GetObjectGuid(), good); SendToAll(&data); m_players.erase(bad->GetObjectGuid()); bad->LeftChannel(this); if (changeowner) { ObjectGuid newowner = !m_players.empty() ? good : ObjectGuid(); SetOwner(newowner); } } } }
void InstanceMgr::BuildSavedInstancesForPlayer(PlayerPointer plr) { WorldPacket data(4); Instance * in; InstanceMap::iterator itr; InstanceMap * instancemap; uint32 i; if(!plr->IsInWorld() || plr->GetMapMgr()->GetMapInfo()->type != INSTANCE_NULL) { m_mapLock.Acquire(); for(i = 0; i < NUM_MAPS; ++i) { if(m_instances[i] != NULL) { instancemap = m_instances[i]; for(itr = instancemap->begin(); itr != instancemap->end();) { in = itr->second; ++itr; if( PlayerOwnsInstance(in, plr) && in->m_mapInfo->type == INSTANCE_NONRAID ) { m_mapLock.Release(); data.SetOpcode(SMSG_UPDATE_LAST_INSTANCE); data << uint32(in->m_mapId); plr->GetSession()->SendPacket(&data); data.Initialize(SMSG_UPDATE_INSTANCE_OWNERSHIP); data << uint32(0x01); plr->GetSession()->SendPacket(&data); return; } } } } m_mapLock.Release(); } data.SetOpcode(SMSG_UPDATE_INSTANCE_OWNERSHIP); data << uint32(0x00); plr->GetSession()->SendPacket(&data); }
void WorldSession::HandleInviteToGuild(WorldPacket & recv_data) { CHECK_PACKET_SIZE(recv_data, 1); std::string inviteeName; recv_data >> inviteeName; PlayerPointer plyr = objmgr.GetPlayer( inviteeName.c_str() , false); Guild *pGuild = _player->m_playerInfo->guild; if(!plyr) { Guild::SendGuildCommandResult(this, GUILD_INVITE_S,inviteeName.c_str(),GUILD_PLAYER_NOT_FOUND); return; } else if(!pGuild) { Guild::SendGuildCommandResult(this, GUILD_CREATE_S,"",GUILD_PLAYER_NOT_IN_GUILD); return; } if( plyr->GetGuildId() ) { Guild::SendGuildCommandResult(this, GUILD_INVITE_S,plyr->GetName(),ALREADY_IN_GUILD); return; } else if( plyr->GetGuildInvitersGuid()) { Guild::SendGuildCommandResult(this, GUILD_INVITE_S,plyr->GetName(),ALREADY_INVITED_TO_GUILD); return; } else if(!_player->m_playerInfo->guildRank->CanPerformCommand(GR_RIGHT_INVITE)) { Guild::SendGuildCommandResult(this, GUILD_INVITE_S,"",GUILD_PERMISSIONS); return; } else if(plyr->GetTeam()!=_player->GetTeam() && _player->GetSession()->GetPermissionCount() == 0 && !sWorld.cross_faction_world) { Guild::SendGuildCommandResult(this, GUILD_INVITE_S,"",GUILD_NOT_ALLIED); return; } else if(pGuild->GetNumMembers() >= MAX_GUILD_MEMBERS) { // We can't handle >= 500 members, or WoW will #132. I don't have the proper error code, so just throw the internal one. Guild::SendGuildCommandResult(this, GUILD_INVITE_S,"",GUILD_INTERNAL); return; } Guild::SendGuildCommandResult(this, GUILD_INVITE_S,inviteeName.c_str(),GUILD_U_HAVE_INVITED); //41 WorldPacket data(SMSG_GUILD_INVITE, 100); data << _player->GetName(); data << pGuild->GetGuildName(); plyr->GetSession()->SendPacket(&data); plyr->SetGuildInvitersGuid( _player->GetLowGUID() ); }
bool ChatHandler::HandleAddHonorCommand(const char* args, WorldSession* m_session) { uint32 HonorAmount = args ? atol(args) : 1; PlayerPointer plr = getSelectedChar(m_session, true); if(plr == 0) return true; BlueSystemMessage(m_session, "Adding %u honor to player %s.", HonorAmount, plr->GetName()); GreenSystemMessage(plr->GetSession(), "You have had %u honor points added to your character.", HonorAmount); HonorHandler::AddHonorPointsToPlayer(plr, HonorAmount); return true; }
/////////////////////////////////////////////////////////////////////////////////////// ///This function handles CMSG_GROUP_DECLINE: ////////////////////////////////////////////////////////////////////////////////////// void WorldSession::HandleGroupDeclineOpcode( WorldPacket & recv_data ) { if(!_player->IsInWorld()) return; WorldPacket data(SMSG_GROUP_DECLINE, 100); PlayerPointer player = objmgr.GetPlayer(_player->GetInviter()); if(!player) return; data << GetPlayer()->GetName(); player->GetSession()->SendPacket( &data ); player->SetInviter(0); _player->SetInviter(0); }
void SendShowSignatures(Charter * c, uint64 i, PlayerPointer p) { WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, 100); data << i; data << (uint64)c->GetLeader(); data << c->GetID(); data << uint8(c->SignatureCount); for(uint32 i = 0; i < c->Slots; ++i) { if(c->Signatures[i] == 0) continue; data << uint64(c->Signatures[i]) << uint32(1); } data << uint8(0); p->GetSession()->SendPacket(&data); }
bool ChatHandler::HandleAddKillCommand(const char* args, WorldSession* m_session) { uint32 KillAmount = args ? atol(args) : 1; PlayerPointer plr = getSelectedChar(m_session, true); if(plr == 0) return true; BlueSystemMessage(m_session, "Adding %u kills to player %s.", KillAmount, plr->GetName()); GreenSystemMessage(plr->GetSession(), "You have had %u honor kills added to your character.", KillAmount); for(uint32 i = 0; i < KillAmount; ++i) HonorHandler::OnPlayerKilledUnit(plr, NULLPLR); return true; }
void MailSystem::DeliverMessage(MailMessage* message) { message->SaveToDB(); PlayerPointer plr = objmgr.GetPlayer((uint32)message->player_guid); if(plr != NULL) { plr->m_mailBox->AddMessage(message); if((uint32)UNIXTIME >= message->delivery_time) { uint32 v = 0; plr->GetSession()->OutPacket(SMSG_RECEIVED_MAIL, 4, &v); } } }
void Channel::SetOwner(ObjectGuid p, const char *newname) { PlayerPointer plr = GetPlayer(p); if (!plr.get()) return; uint32 sec = plr->GetSession()->GetSecurity(); if (!IsOn(p)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, p); return; } if (sec < SEC_GAMEMASTER && p != m_ownerGuid) { WorldPacket data; MakeNotOwner(&data); SendToOne(&data, p); return; } Player *newp = sObjectMgr.GetPlayer(newname); if (!newp || !IsOn(newp->GetObjectGuid())) { WorldPacket data; MakePlayerNotFound(&data, newname); SendToOne(&data, p); return; } if (newp->GetTeam() != plr->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) { WorldPacket data; MakePlayerNotFound(&data, newname); SendToOne(&data, p); return; } if (HasFlag(CHANNEL_FLAG_GENERAL) && newp->GetSession()->GetSecurity() < SEC_GAMEMASTER) return; m_players[newp->GetObjectGuid()].SetModerator(true); SetOwner(newp->GetObjectGuid()); }
void WorldSession::HandleCharterSign( WorldPacket & recv_data ) { uint64 item_guid; recv_data >> item_guid; if( !_player->IsInWorld() ) return; Charter * c = objmgr.GetCharterByItemGuid(item_guid); if(c == 0) return; if( _player->m_playerInfo->charterId[c->CharterType] != 0 ) { SendNotification("You cannot sign two charters of the same type."); return; } for(uint32 i = 0; i < 9; ++i) { if(c->Signatures[i] == _player->GetGUID()) { SendNotification("You have already signed that charter."); return; } } if(c->IsFull()) return; c->AddSignature(_player->GetLowGUID()); c->SaveToDB(); _player->m_playerInfo->charterId[c->CharterType] = c->GetID(); _player->SaveToDB(false); PlayerPointer l = _player->GetMapMgr()->GetPlayer(c->GetLeader()); if(l == 0) return; WorldPacket data(SMSG_PETITION_SIGN_RESULTS, 100); data << item_guid << _player->GetGUID() << uint32(0); l->GetSession()->SendPacket(&data); data.clear(); data << item_guid << (uint64)c->GetLeader() << uint32(0); SendPacket(&data); }
void Channel::Leave(ObjectGuid p, bool send) { if (!IsOn(p)) { if (send) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, p); } } else { PlayerPointer plr = GetPlayer(p); if (send) { WorldPacket data; MakeYouLeft(&data); SendToOne(&data, p); plr->LeftChannel(this); data.clear(); } bool changeowner = m_players[p].IsOwner(); m_players.erase(p); if (m_announce && (!plr.get() || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL))) { WorldPacket data; MakeLeft(&data, p); SendToAll(&data); } LeaveNotify(p); if (changeowner) { ObjectGuid newowner = !m_players.empty() ? m_players.begin()->second.player : ObjectGuid(); SetOwner(newowner); } } }
void WorldSession::HandleGuildDecline(WorldPacket & recv_data) { WorldPacket data; PlayerPointer plyr = GetPlayer(); if(!plyr) return; PlayerPointer inviter = objmgr.GetPlayer( plyr->GetGuildInvitersGuid() ); plyr->UnSetGuildInvitersGuid(); if(!inviter) return; data.Initialize(SMSG_GUILD_DECLINE); data << plyr->GetName(); inviter->GetSession()->SendPacket(&data); }
void InstanceMgr::PlayerLeftGroup(Group * pGroup, PlayerPointer pPlayer) { // does this group own any instances? we have to kick the player out of those instances. Instance * in; InstanceMap::iterator itr; InstanceMap * instancemap; WorldPacket data(SMSG_RAID_GROUP_ONLY, 8); uint32 i; m_mapLock.Acquire(); for(i = 0; i < NUM_MAPS; ++i) { instancemap = m_instances[i]; if(instancemap) { for(itr = instancemap->begin(); itr != instancemap->end();) { in = itr->second; ++itr; if(PlayerOwnsInstance(in,pPlayer)) { // better make sure we're actually in that instance.. :P if(!pPlayer->raidgrouponlysent && pPlayer->GetInstanceID() == (int32)in->m_instanceId) { data << uint32(60000) << uint32(1); pPlayer->GetSession()->SendPacket(&data); pPlayer->raidgrouponlysent=true; sEventMgr.AddEvent(pPlayer, &Player::EjectFromInstance, EVENT_PLAYER_EJECT_FROM_INSTANCE, 60000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT); m_mapLock.Release(); return; } } } } } m_mapLock.Release(); }
void GossipSelectOption(ObjectPointer pObject, PlayerPointer plr, uint32 Id, uint32 IntId, const char * Code) { if( !plr ) return; CreaturePointer pCreature = NULLCREATURE; pCreature = pObject->IsCreature() ? TO_CREATURE( pObject ) : NULLCREATURE; if( !pCreature ) return; if( IntId == 3 ) { plr->GetSession()->SendInventoryList(pCreature); return; } uint32 CastSpellID = IntId == 1 ? 32430 : 32431; if( CastSpellID != 0 ) if( !plr->HasAura( CastSpellID ) ) pCreature->CastSpell(plr,CastSpellID,true); return; }
void InstanceMgr::BuildRaidSavedInstancesForPlayer(PlayerPointer plr) { WorldPacket data(SMSG_RAID_INSTANCE_INFO, 200); Instance * in; InstanceMap::iterator itr; InstanceMap * instancemap; uint32 i; uint32 counter = 0; data << counter; m_mapLock.Acquire(); for(i = 0; i < NUM_MAPS; ++i) { if(m_instances[i] != NULL) { instancemap = m_instances[i]; for(itr = instancemap->begin(); itr != instancemap->end();) { in = itr->second; ++itr; uint8 poinst = PlayerOwnsInstance(in, plr); if( poinst >= OWNER_CHECK_OK ) { data << in->m_mapId; data << uint32(in->m_expiration - UNIXTIME); data << in->m_instanceId; data << in->m_difficulty; ++counter; } } } } m_mapLock.Release(); *(uint32*)&data.contents()[0] = counter; plr->GetSession()->SendPacket(&data); }
void Channel::UnBan(ObjectGuid good, const char *badname) { uint32 sec = 0; PlayerPointer gplr = GetPlayer(good); if (gplr) sec = gplr->GetSession()->GetSecurity(); if (!IsOn(good)) { WorldPacket data; MakeNotMember(&data); SendToOne(&data, good); } else if (!m_players[good].IsModerator() && sec < SEC_GAMEMASTER) { WorldPacket data; MakeNotModerator(&data); SendToOne(&data, good); } else { Player *bad = sObjectMgr.GetPlayer(badname); if (bad == NULL || !IsBanned(bad->GetObjectGuid())) { WorldPacket data; MakePlayerNotFound(&data, badname); SendToOne(&data, good); } else { m_banned.erase(bad->GetObjectGuid()); WorldPacket data; MakePlayerUnbanned(&data, bad->GetObjectGuid(), good); SendToAll(&data); } } }
void HonorHandler::OnPlayerKilledUnit( PlayerPointer pPlayer, UnitPointer pVictim ) { if( pVictim == NULL || pPlayer == NULL || !pVictim->IsPlayer() || !pPlayer->IsPlayer() ) return; if( TO_PLAYER( pVictim )->m_honorless ) return; if( pVictim->IsPlayer() ) { if( pPlayer->m_bg ) { if( TO_PLAYER( pVictim )->m_bgTeam == pPlayer->m_bgTeam ) return; // patch 2.4, players killed >50 times in battlegrounds won't be worth honor for the rest of that bg if( TO_PLAYER(pVictim)->m_bgScore.Deaths >= 50 ) return; } else { if( pPlayer->GetTeam() == TO_PLAYER( pVictim )->GetTeam() ) return; } } // Calculate points int32 Points = CalculateHonorPointsForKill(pPlayer, pVictim); if( Points > 0 ) { if( pPlayer->m_bg ) { // hackfix for battlegrounds (since the gorups there are disabled, we need to do this manually) vector<PlayerPointer > toadd; uint32 t = pPlayer->m_bgTeam; toadd.reserve(15); // shouldnt have more than this pPlayer->m_bg->Lock(); set<PlayerPointer > * s = &pPlayer->m_bg->m_players[t]; for(set<PlayerPointer >::iterator itr = s->begin(); itr != s->end(); ++itr) { if((*itr) == pPlayer || (*itr)->isInRange(pPlayer,40.0f)) toadd.push_back(*itr); } if( toadd.size() > 0 ) { uint32 pts = Points / (uint32)toadd.size(); for(vector<PlayerPointer >::iterator vtr = toadd.begin(); vtr != toadd.end(); ++vtr) { AddHonorPointsToPlayer(*vtr, pts); (*vtr)->GetAchievementInterface()->HandleAchievementCriteriaHonorableKill(); (*vtr)->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillClass( pVictim->getClass() ); (*vtr)->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillRace( pVictim->getRace() ); (*vtr)->m_killsToday++; (*vtr)->m_killsLifetime++; pPlayer->m_bg->HookOnHK(*vtr); if(pVictim) { // Send PVP credit WorldPacket data(SMSG_PVP_CREDIT, 12); uint32 pvppoints = pts * 10; data << pvppoints << pVictim->GetGUID() << uint32(TO_PLAYER(pVictim)->GetPVPRank()); (*vtr)->GetSession()->SendPacket(&data); } } } pPlayer->m_bg->Unlock(); } else if(pPlayer->GetGroup()) { Group *pGroup = pPlayer->GetGroup(); PlayerPointer gPlayer = NULLPLR; int32 GroupPoints; pGroup->Lock(); GroupPoints = (Points / (pGroup->MemberCount() ? pGroup->MemberCount() : 1)); GroupMembersSet::iterator gitr; for(uint32 k = 0; k < pGroup->GetSubGroupCount(); k++) { for(gitr = pGroup->GetSubGroup(k)->GetGroupMembersBegin(); gitr != pGroup->GetSubGroup(k)->GetGroupMembersEnd(); ++gitr) { gPlayer = (*gitr)->m_loggedInPlayer; if(gPlayer && (gPlayer == pPlayer || gPlayer->isInRange(pPlayer,100.0f))) // visible range { gPlayer->GetAchievementInterface()->HandleAchievementCriteriaHonorableKill(); gPlayer->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillClass( pVictim->getClass() ); gPlayer->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillRace( pVictim->getRace() ); gPlayer->m_killsToday++; gPlayer->m_killsLifetime++; if(gPlayer->m_bg) gPlayer->m_bg->HookOnHK(gPlayer); sHookInterface.OnHonorableKill(gPlayer, TO_PLAYER(pVictim)); AddHonorPointsToPlayer(gPlayer, GroupPoints); if(pVictim) { // Send PVP credit WorldPacket data(SMSG_PVP_CREDIT, 12); uint32 pvppoints = GroupPoints * 10; data << pvppoints << pVictim->GetGUID() << uint32(TO_PLAYER(pVictim)->GetPVPRank()); gPlayer->GetSession()->SendPacket(&data); } //patch by emsy // If we are in Halaa if(pPlayer->GetZoneId() == 3518) { // Add Halaa Battle Token SpellEntry * pvp_token_spell = dbcSpell.LookupEntry(gPlayer->GetTeam()? 33004 : 33005); gPlayer->CastSpell(gPlayer, pvp_token_spell, true); } // If we are in Hellfire Peninsula if(pPlayer->GetZoneId() == 3483) { // Add Mark of Thrallmar/Honor Hold SpellEntry * pvp_token_spell = dbcSpell.LookupEntry(gPlayer->GetTeam()? 32158 : 32155); gPlayer->CastSpell(gPlayer, pvp_token_spell, true); } } } } pGroup->Unlock(); } else { pPlayer->GetAchievementInterface()->HandleAchievementCriteriaHonorableKill(); pPlayer->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillClass( pVictim->getClass() ); pPlayer->GetAchievementInterface()->HandleAchievementCriteriaHonorableKillRace( pVictim->getRace() ); pPlayer->m_killsToday++; pPlayer->m_killsLifetime++; AddHonorPointsToPlayer(pPlayer, Points); if(pPlayer->m_bg) pPlayer->m_bg->HookOnHK(pPlayer); sHookInterface.OnHonorableKill(pPlayer, TO_PLAYER(pVictim)); if(pVictim) { // Send PVP credit WorldPacket data(SMSG_PVP_CREDIT, 12); uint32 pvppoints = Points * 10; data << pvppoints << pVictim->GetGUID() << uint32(TO_PLAYER(pVictim)->GetPVPRank()); pPlayer->GetSession()->SendPacket(&data); } //patch by emsy // If we are in Halaa if(pPlayer->GetZoneId() == 3518) { // Add Halaa Battle Token SpellEntry * halaa_spell = dbcSpell.LookupEntry(pPlayer->GetTeam()? 33004 : 33005); pPlayer->CastSpell(pPlayer, halaa_spell, true); } } } }
void WorldSession::HandleAcceptTrade(WorldPacket & recv_data) { if(!_player->IsInWorld() || _player->mTradeTarget == 0) return; uint32 TradeStatus = TRADE_STATUS_ACCEPTED; PlayerPointer pTarget = _player->GetTradeTarget(); if(pTarget == NULL || !pTarget->IsInWorld()) TradeStatus = TRADE_STATUS_PLAYER_NOT_FOUND; // Tell the other player we're green. if(pTarget->m_session && pTarget->m_session->GetSocket()) pTarget->m_session->SendTradeStatus(TradeStatus); _player->mTradeStatus = TradeStatus; //Both sides accepted? Let's trade! if(_player->mTradeStatus == TRADE_STATUS_ACCEPTED && pTarget->mTradeStatus == TRADE_STATUS_ACCEPTED) { // Ready! uint32 ItemCount = 0; uint32 TargetItemCount = 0; ItemPointer pItem; // Count items on both sides, check if bags are empty. for(uint32 Index = 0; Index < 6; ++Index) { if(_player->mTradeItems[Index] != NULL) { pItem = _player->mTradeItems[Index]; if( pItem != NULL && pItem->IsContainer() && TO_CONTAINER(pItem)->HasItems()) { sCheatLog.writefromsession(this, "%s involved in bag-trick trade with %s", _player->GetName(),pTarget->GetName()); _player->GetItemInterface()->BuildInventoryChangeError( pItem, NULLITEM, INV_ERR_CANT_TRADE_EQUIP_BAGS); TradeStatus = TRADE_STATUS_CANCELLED; break; } else ++ItemCount; } if(pTarget->mTradeItems[Index] != NULL) { pItem = pTarget->mTradeItems[Index]; if( pItem != NULL && pItem->IsContainer() && TO_CONTAINER(pItem)->HasItems() ) { sCheatLog.writefromsession(this, "%s involved in bag-trick trade with %s.", pTarget->GetName(),_player->GetName()); pTarget->GetItemInterface()->BuildInventoryChangeError( pItem, NULLITEM, INV_ERR_CANT_TRADE_EQUIP_BAGS); TradeStatus = TRADE_STATUS_CANCELLED; break; } else ++TargetItemCount; } } //Do we have something to trade? if( ItemCount == 0 && TargetItemCount == 0 && _player->mTradeGold == 0 && pTarget->mTradeGold == 0 ) TradeStatus = TRADE_STATUS_CANCELLED; //Do we have enough free slots on both sides? else if((_player->m_ItemInterface->CalculateFreeSlots(NULL) + ItemCount) < TargetItemCount || (pTarget->m_ItemInterface->CalculateFreeSlots(NULL) + TargetItemCount) < ItemCount ) TradeStatus = TRADE_STATUS_CANCELLED; //Everything still ok? else if(TradeStatus == TRADE_STATUS_ACCEPTED) { uint64 Guid; //Swapp 6 itemslots (7th will not trade) for(uint32 Index = 0; Index < 6; ++Index) { Guid = _player->mTradeItems[Index] ? _player->mTradeItems[Index]->GetGUID() : 0; if(Guid != 0) { if( _player->mTradeItems[Index]->IsSoulbound()) _player->GetItemInterface()->BuildInventoryChangeError( _player->mTradeItems[Index], NULLITEM, INV_ERR_CANNOT_TRADE_THAT); else { //Remove from player pItem = _player->m_ItemInterface->SafeRemoveAndRetreiveItemByGuidRemoveStats(Guid, true); //and add to pTarget if(pItem != NULL) { pItem->SetOwner(pTarget); if( !pTarget->m_ItemInterface->AddItemToFreeSlot(pItem) ) { pItem->Destructor(); pItem = NULLITEM; } } if(GetPermissionCount()>0 || pTarget->GetSession()->GetPermissionCount()>0) sGMLog.writefromsession(this, "trade item %s with %s (soulbound = %d)", _player->mTradeItems[Index]->GetProto()->Name1, pTarget->GetName()); } } Guid = pTarget->mTradeItems[Index] ? pTarget->mTradeItems[Index]->GetGUID() : 0; if(Guid != 0) { if( pTarget->mTradeItems[Index]->IsSoulbound()) pTarget->GetItemInterface()->BuildInventoryChangeError( pTarget->mTradeItems[Index], NULLITEM, INV_ERR_CANNOT_TRADE_THAT); else { //Remove from pTarget pItem = pTarget->m_ItemInterface->SafeRemoveAndRetreiveItemByGuidRemoveStats(Guid, true); //and add to initiator if(pItem != NULL) { pItem->SetOwner(_player); if( !_player->m_ItemInterface->AddItemToFreeSlot(pItem) ) { pItem->Destructor(); pItem = NULLITEM; } } if(GetPermissionCount()>0 || pTarget->GetSession()->GetPermissionCount()>0) sGMLog.writefromsession(this, "trade item %s with %s", pTarget->mTradeItems[Index]->GetProto()->Name1, _player->GetName()); } } } // Trade Gold if(_player->mTradeGold) { pTarget->ModUnsigned32Value(PLAYER_FIELD_COINAGE, _player->mTradeGold); _player->ModUnsigned32Value(PLAYER_FIELD_COINAGE, -(int32)_player->mTradeGold); } if(pTarget->mTradeGold) { _player->ModUnsigned32Value(PLAYER_FIELD_COINAGE, pTarget->mTradeGold); pTarget->ModUnsigned32Value(PLAYER_FIELD_COINAGE, -(int32)pTarget->mTradeGold); } pTarget->SaveToDB(false); _player->SaveToDB(false); TradeStatus = TRADE_STATUS_COMPLETE; } SendTradeStatus(TradeStatus); if(pTarget->m_session && pTarget->m_session->GetSocket()) pTarget->m_session->SendTradeStatus(TradeStatus); // Reset Trade Vars _player->ResetTradeVariables(); pTarget->ResetTradeVariables(); } }
int32 Item::AddEnchantment( EnchantEntry* Enchantment, uint32 Duration, bool Perm /* = false */, bool apply /* = true */, bool RemoveAtLogout /* = false */, uint32 Slot_, uint32 RandomSuffix ) { int32 Slot = Slot_; m_isDirty = true; /* if(Perm) { if(Slot_) { Slot=Slot_; } else { Slot = FindFreeEnchantSlot(Enchantment); } } else { if(Enchantment->EnchantGroups > 1) // replaceable temp enchants { Slot = 1; RemoveEnchantment(1); } else { Slot = FindFreeEnchantSlot(Enchantment);*/ /* Slot = Enchantment->type ? 3 : 0; //that's 's code for(uint32 Index = ITEM_FIELD_ENCHANTMENT_09; Index < ITEM_FIELD_ENCHANTMENT_32; Index += 3) { if(m_uint32Values[Index] == 0) break;; ++Slot; } //Slot = FindFreeEnchantSlot(Enchantment); // reach max of temp enchants if(Slot >= 11) return -1; */ /*} } */ // Create the enchantment struct. EnchantmentInstance Instance; Instance.ApplyTime = UNIXTIME; Instance.BonusApplied = false; Instance.Slot = Slot; Instance.Enchantment = Enchantment; Instance.Duration = Duration; Instance.RemoveAtLogout = RemoveAtLogout; Instance.RandomSuffix = RandomSuffix; // Set the enchantment in the item fields. uint32 EnchantBase = Slot * 3 + ITEM_FIELD_ENCHANTMENT_1_1; SetUInt32Value( EnchantBase, Enchantment->Id ); SetUInt32Value( EnchantBase + 1, (uint32)Instance.ApplyTime ); SetUInt32Value( EnchantBase + 2, 0 ); // charges // Add it to our map. Enchantments[Slot] = Instance; if( m_owner == NULL ) return Slot; PlayerPointer owner = m_owner; // Add the removal event. if( Duration ) { sEventMgr.AddEvent( item_shared_from_this(), &Item::RemoveEnchantment, uint32(Slot), EVENT_REMOVE_ENCHANTMENT1 + Slot, Duration * 1000, 1, 0 ); } // No need to send the log packet, if the owner isn't in world (we're still loading) if( !owner->IsInWorld() ) return Slot; if( apply ) { WorldPacket EnchantLog( SMSG_ENCHANTMENTLOG, 25 ); EnchantLog << m_owner->GetGUID(); EnchantLog << m_owner->GetGUID(); EnchantLog << m_uint32Values[OBJECT_FIELD_ENTRY]; EnchantLog << Enchantment->Id; EnchantLog << uint8(0); owner->GetSession()->SendPacket( &EnchantLog ); if( owner->GetTradeTarget() ) { owner->SendTradeUpdate(); } /* Only apply the enchantment bonus if we're equipped */ uint8 slot = m_owner->GetItemInterface()->GetInventorySlotByGuid( GetGUID() ); if( slot > EQUIPMENT_SLOT_START && slot < EQUIPMENT_SLOT_END ) ApplyEnchantmentBonus( Slot, APPLY ); } owner->SaveToDB(false); return Slot; }
void InnkeeperGossip::GossipSelectOption(ObjectPointer pObject, PlayerPointer Plr, uint32 Id, uint32 IntId, const char * Code) { CreaturePointer pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?(TO_CREATURE(pObject)):NULLCREATURE; if(pCreature==NULLCREATURE) return; switch(IntId) { case 1: // VENDOR Plr->GetSession()->SendInventoryList(pCreature); break; case 2: // BINDER Plr->GetSession()->SendInnkeeperBind(pCreature); break; case 3: // WHAT CAN I DO ? // Prepare second menu GossipMenu *Menu; objmgr.CreateGossipMenuForPlayer(&Menu, pCreature->GetGUID(), 1853, Plr); Menu->AddItem(5, "Make this inn your home.", 2); Menu->SendTo(Plr); break; case 4: // EVENT OF HALLOWEEN if(!Plr->HasAura(SPELL_TRICK_OR_TREATED)) { pCreature->CastSpell(Plr, SPELL_TRICK_OR_TREATED, true); // either trick or treat, 50% chance if(rand()%2) { Plr->CastSpell(Plr, SPELL_TREAT, true); } else { int32 trickspell=0; switch (rand()%9) { case 0: trickspell=24753; // cannot cast, random 30sec break; case 1: trickspell=24713; // lepper gnome costume break; case 2: if(Plr->getGender() == 0){ trickspell=24735; // male ghost costume }else{ trickspell=24736; // female ghostcostume } break; case 3: if(Plr->getGender() == 0){ trickspell=24711; // male ninja costume }else{ trickspell=24710; // female ninja costume } break; case 4: if(Plr->getGender() == 0){ trickspell=24708; // male pirate costume }else{ trickspell=24709; // female pirate costume } break; case 5: trickspell=24723; // skeleton costume break; } pCreature->CastSpell(Plr, trickspell, true); } } Plr->Gossip_Complete(); break; } }
void ClusterInterface::RequestTransfer(PlayerPointer plr, uint32 MapId, uint32 InstanceId, LocationVector & vec) { WorldPacket data(ICMSG_TELEPORT_REQUEST, 32); data << plr->GetSession()->GetSocket()->GetSessionId() << MapId << InstanceId << vec << vec.o; SendPacket(&data); }
void Channel::Join(ObjectGuid p, const char *pass) { WorldPacket data; if (IsOn(p)) { if (!IsConstant()) // non send error message for built-in channels { MakePlayerAlreadyMember(&data, p); SendToOne(&data, p); } return; } if (IsBanned(p)) { MakeBanned(&data); SendToOne(&data, p); return; } if (m_password.length() > 0 && strcmp(pass, m_password.c_str())) { MakeWrongPassword(&data); SendToOne(&data, p); return; } PlayerPointer plr = GetPlayer(p); if (m_securityLevel && (!plr.get() || plr->GetSession()->GetSecurity() < m_securityLevel)) { MakeWrongPassword(&data); SendToOne(&data, p); return; } if (plr && plr->ToPlayer()) { if (plr->GetGuildId() && (GetFlags() == 0x38)) return; plr->ToPlayer()->JoinedChannel(this); } if (m_announce && (!plr.get() || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL))) { MakeJoined(&data, p); SendToAll(&data); } data.clear(); PlayerInfo& pinfo = m_players[p]; pinfo.player = p; pinfo.flags = 0; MakeYouJoined(&data); SendToOne(&data, p); JoinNotify(p); // if no owner first logged will become if (HasFlag(CHANNEL_FLAG_CUSTOM) && !IsConstant() && !m_ownerGuid) { SetOwner(p, (m_players.size() > 1 ? true : false)); m_players[p].SetModerator(true); } }
void Channel::SendToOne(WorldPacket *data, ObjectGuid who) { PlayerPointer plr = GetPlayer(who); if (plr) plr->GetSession()->SendPacket(data); }