示例#1
0
    public static Obj TryAddObj(Net.p_obj ObjInfo)
    {
        var pos = Common.GetLocalPos(ObjInfo.Pos);
        Obj Obj;

        if (ObjMgr.Objs.ContainsKey(ObjInfo.Id))
        {
            Obj = ObjMgr.Objs[ObjInfo.Id];
        }
        else
        {
            Obj = ObjMgr.NewObj(pos, ObjInfo.Type, ObjInfo.Id);
            Obj.Init();
        }

        if (ObjInfo.Pos.X != 0 && ObjInfo.Pos.Y != 0)
        {
            Obj.GPose = pos;
        }
        if (!ObjInfo.Name.Equals(""))
        {
            Obj.SetName(ObjInfo.Name);
        }

        if (ObjInfo.Status == (int)(ObjStatus.NONE) && Obj.HasStatus(ObjStatus.MOVE))
        {
            Obj.DoStopMove();
        }
        else if (ObjInfo.Status == (int)ObjStatus.MOVE)
        {
            Obj.SetSpeed(ObjInfo.Speed);
            Obj.DoMove((ObjDirection)ObjInfo.Direction);
        }
        return(Obj);
    }
示例#2
0
        public void SetLevel(uint NewLevel)
        {
            uint oldLevel = GetLevel();

            Level = NewLevel;

            /*
             * // Find all guild perks to learn
             * std::vector<uint32> perksToLearn;
             * for (uint32 i = 0; i < sGuildPerkSpellsStore.GetNumRows(); ++i)
             *  if (GuildPerkSpellsEntry const* entry = sGuildPerkSpellsStore.LookupEntry(i))
             * if (entry->Level > oldLevel && entry->Level <= GetLevel())
             *  perksToLearn.push_back(entry->SpellId);
             */
            // Notify all online players that guild level changed and learn perks
            Player pl;

            foreach (var member in MemberList)
            {
                pl = ObjMgr.FindPlayer(member.CharGuid);
                if (pl != null)
                {
                    pl.SetGuildLevel(GetLevel());
                    //for (size_t i = 0; i < perksToLearn.size(); ++i)
                    //pl->learnSpell(perksToLearn[i], true);
                }
            }

            //GetNewsLog().AddNewEvent(GUILD_NEWS_LEVEL_UP, time(NULL), 0, 0, _level);
            //GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_GUILD_LEVEL, GetLevel(), 0, NULL, source);
        }
示例#3
0
        public static void HandleNameQueryRequest(ref PacketReader packet, ref WorldSession session)
        {
            ulong guid    = packet.ReadUInt64();
            uint  realmId = packet.ReadUInt32();//Sometimes it reads 0?  maybe not realmid?

            Player pl = ObjMgr.FindPlayer(guid);

            if (pl == null)
            {
                return;
            }

            PacketWriter writer = new PacketWriter(Opcodes.SMSG_NameQueryResponse);

            writer.WritePackedGuid(guid);
            writer.WriteUInt8(0);//result?
            writer.WriteCString(pl.GetName());
            writer.WriteUInt32(WorldConfig.RealmId);
            writer.WriteUInt8(pl.getRace());
            writer.WriteUInt8(pl.getGender());
            writer.WriteUInt8(pl.getClass());
            writer.WriteUInt8(0);

            session.Send(writer);
        }
示例#4
0
        public static bool HandleModifyMoneyCommand(string[] args, CommandGroup handler)
        {
            if (args.Count() < 1)
                return false;

            Player target = handler.getSelectedPlayer();
            if (target == null)
                return handler.SendErrorMessage(CypherStrings.NoCharSelected);

            // check online security
            if (handler.HasLowerSecurity(target, 0))
                return false;

            long addmoney;
            long.TryParse(args[0], out addmoney);

            long moneyuser = (long)target.GetMoney();

            if (addmoney < 0)
            {
                ulong newmoney = (ulong)(moneyuser + addmoney);

                Log.outDebug(ObjMgr.GetCypherString(CypherStrings.CurrentMoney), moneyuser, addmoney, newmoney);
                if (newmoney <= 0)
                {
                    handler.SendSysMessage(CypherStrings.YouTakeAllMoney, handler.GetNameLink(target));
                    if (handler.needReportToTarget(target))
                       ChatHandler.SendSysMessage(target, CypherStrings.YoursAllMoneyGone, handler.GetNameLink());

                    target.SetMoney(0);
                }
                else
                {
                    if (newmoney > PlayerConst.MaxMoneyAmount)
                        newmoney = PlayerConst.MaxMoneyAmount;

                    handler.SendSysMessage(CypherStrings.YouTakeMoney, Math.Abs(addmoney), handler.GetNameLink(target));
                    if (handler.needReportToTarget(target))
                        ChatHandler.SendSysMessage(target, CypherStrings.YoursMoneyTaken, handler.GetNameLink(), Math.Abs(addmoney));
                    target.SetMoney(newmoney);
                }
            }
            else
            {
                handler.SendSysMessage( CypherStrings.YouGiveMoney, addmoney, handler.GetNameLink(target));
                if (handler.needReportToTarget(target))
                    ChatHandler.SendSysMessage(target, CypherStrings.YoursMoneyGiven, handler.GetNameLink(), addmoney);

                if (addmoney >= PlayerConst.MaxMoneyAmount)
                    target.SetMoney(PlayerConst.MaxMoneyAmount);
                else
                    target.ModifyMoney(addmoney);
            }

            Log.outDebug(ObjMgr.GetCypherString(CypherStrings.NewMoney), moneyuser, addmoney, target.GetMoney());
            return true;
        }
示例#5
0
 public void BroadcastPacket(PacketWriter writer)
 {
     foreach (Member member in MemberList)
     {
         Player pl = ObjMgr.FindPlayer(member.CharGuid);
         if (pl != null)
         {
             pl.GetSession().Send(writer);
         }
     }
 }
示例#6
0
 public bool extractPlayerTarget(string arg, out Player player)
 {
     if (arg.Contains("\"") || !Regex.IsMatch(arg, @"\d"))
     {
         player = ObjMgr.FindPlayerByName(arg);
     }
     else
     {
         player = getSelectedPlayer();// session.GetPlayer().GetSelection<Player>();
     }
     return(player != null);
 }
示例#7
0
        public bool SendSysMessage(CypherStrings str, params object[] args)
        {
            string input   = ObjMgr.GetCypherString(str);
            string pattern = @"%(\d+(\.\d+)?)?(d|f|s|u)";

            int    count  = 0;
            string result = Regex.Replace(input, pattern, m =>
            {
                return(String.Concat("{", count++, "}"));
            });

            return(SendSysMessage(result, args));
        }
示例#8
0
 void initTerrain()
 {
     m_terrains = new Obj[Config.TerrainArrayX * Config.TerrainArrayY];
     for (int x = -Config.TerrainArrayX / 2; x < Config.TerrainArrayX / 2; x++)
     {
         for (int z = -Config.TerrainArrayY / 2; z < Config.TerrainArrayY / 2; z++)
         {
             int i = x + Config.TerrainArrayX / 2, j = z + Config.TerrainArrayY / 2;
             Obj terrain = ObjMgr.NewObj(new Vector3(x * Config.TerrainMeshX + MapCenterPos.x, 0, z * Config.TerrainMeshY + MapCenterPos.z), T_Obj.T_TERRAIN.GenObjType(), i * Config.TerrainArrayY + j + 1000000);
             terrain.Init();
             m_terrains[i * Config.TerrainArrayY + j] = terrain;
         }
     }
 }
示例#9
0
    // Use this for initialization
    void Start()
    {
        for (int x = 0; x < 10; x++)
        {
            //Instantiate(Map.Instance.ObjPrefab,new Vector3(x,1,1), Quaternion.identity);
            testobj = ObjMgr.NewObj(new Vector3(x, 0, 0), T_Obj.T_NPC.T_TestNPC.GenObjType(), 1);
            testobj.Init();
        }
        //testobj = ObjMgr.NewObj(new Vector3(122, 117, 115), T_Obj.NPC().TestNPC().GenObjType(), 1);
        // testobj.Init();
        //testobj.Light();

        // var testobj1 = ObjMgr.NewObj(new Vector3(1, 1, 2), T_Obj.NPC().TestNPC().GenObjType(), 2);
        //testobj1.Init();
        // testobj1.Light();
    }
示例#10
0
    /// <summary>
    /// 完成游戏对象的初始化工作
    /// </summary>
    private void InitObj()
    {
        base.Init("logic/GameManager");
        //初始化稳固的游戏对象
        ObjMgr.InitStableObj();

        //初始化固定脚本的游戏对象
        object[] os = CallMethod("CreateObj");
        foreach (object o in os)
        {
            ObjMgr.CreateObjByBundle((string)o);
        }

        //在lua中初始化动态地游戏对象
        CallMethod("InitObj");
    }
示例#11
0
        void Update(Unit caster)
        {
            ObjectTarget = ObjectTargetGUID != 0 ? ((ObjectTargetGUID == caster.GetGUIDLow()) ? caster : ObjMgr.GetObject <WorldObject>(caster, ObjectTargetGUID)) : null;

            ItemTarget = null;
            if (caster is Player)
            {
                Player player = caster.ToPlayer();
                if (Convert.ToBoolean(TargetMask & SpellCastTargetFlags.Item))
                {
                    ItemTarget = player.GetItemByGuid(ItemTargetGUID);
                }
                else if (Convert.ToBoolean(TargetMask & SpellCastTargetFlags.TradeItem))
                {
                    //if (ItemTargetGUID == (uint)TradeSlots.NONTRADED) // here it is not guid but slot. Also prevents hacking slots
                    //if (TradeData* pTrade = player->GetTradeData())
                    //ItemTarget = pTrade->GetTraderData()->GetItem(TradeSlots.NONTRADED);
                }

                if (ItemTarget != null)
                {
                    ItemTargetEntry = ItemTarget.GetEntry();
                }
            }

            // update positions by transport move
            if (HasSrc() && Src.TransportGUID != 0)
            {
                WorldObject transport = ObjMgr.GetObject <WorldObject>(caster, Src.TransportGUID);
                if (transport != null)
                {
                    Src.Position.Relocate(transport.Position);
                    Src.Position.RelocateOffset(Src.TransportOffset);
                }
            }

            if (HasDst() && Dst.TransportGUID != 0)
            {
                WorldObject transport = ObjMgr.GetObject <WorldObject>(caster, Dst.TransportGUID);
                if (transport != null)
                {
                    Dst.Position.Relocate(transport.Position);
                    Dst.Position.RelocateOffset(Dst.TransportOffset);
                }
            }
        }
示例#12
0
        public static void HandleRequestCharCreate(ref PacketReader packet, ref WorldSession session)
        {
            PacketWriter writer = new PacketWriter(Opcodes.SMSG_CharCreate);

            Player newChar = new Player(ref session);

            //newChar.GetMotionMaster()->Initialize();
            if (!newChar.Create(ObjMgr.GenerateLowGuid(HighGuidType.Player), ref packet))
            {
                // Player not create (race/class/etc problem?)
                writer.WriteUInt8((byte)ResponseCodes.CharCreateError);
                session.Send(writer);
                return;
            }

            //if ((haveSameRace && skipCinematics == 1) || skipCinematics == 2)
            //newChar.setCinematic(1);                          // not show intro

            newChar.atLoginFlags = AtLoginFlags.LoginFirst;               // First login

            // Player created, save it now
            newChar.SaveToDB(true);
            //createInfo->CharCount += 1;

            //PreparedStatement stmt = DB.Realms.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS_BY_REALM);
            //stmt->setUInt32(0, GetAccountId());
            //stmt->setUInt32(1, realmID);
            //trans->Append(stmt);

            //stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_REALM_CHARACTERS);
            //stmt->setUInt32(0, createInfo->CharCount);
            //stmt->setUInt32(1, GetAccountId());
            //stmt->setUInt32(2, realmID);
            //trans->Append(stmt);

            // Success
            writer.WriteUInt8((byte)ResponseCodes.CharCreateSuccess);
            session.Send(writer);

            //std::string IP_str = GetRemoteAddress();
            //sLog->outInfo(LOG_FILTER_CHARACTER, "Account: %d (IP: %s) Create Character:[%s] (GUID: %u)", GetAccountId(), IP_str.c_str(), createInfo->Name.c_str(), newChar.GetGUIDLow());
            //sScriptMgr->OnPlayerCreate(&newChar);
            //sWorld->AddCharacterNameData(newChar.GetGUIDLow(), std::string(newChar.GetName()), newChar.getGender(), newChar.getRace(), newChar.getClass(), newChar.getLevel());
        }
示例#13
0
        bool HasLowerSecurityAccount(WorldSession target, uint target_account, bool strong = false)
        {
            uint target_sec;

            // allow everything from console and RA console
            if (session == null)
            {
                return(false);
            }

            // ignore only for non-players for non strong checks (when allow apply command at least to same sec level)
            if (!ObjMgr.IsPlayerAccount(session.GetSecurity()) && !strong)// && !sWorld->getBoolConfig(CONFIG_GM_LOWER_SECURITY))
            {
                return(false);
            }

            if (target != null)
            {
                target_sec = (uint)target.GetSecurity();
            }
            else if (target_account != 0)
            {
                target_sec = AcctMgr.GetSecurity(target_account);
            }
            else
            {
                return(true);                                        // caller must report error for (target == NULL && target_account == 0)
            }
            AccountTypes target_ac_sec = (AccountTypes)target_sec;

            if (session.GetSecurity() < target_ac_sec || (strong && session.GetSecurity() <= target_ac_sec))
            {
                SendSysMessage(CypherStrings.YoursSecurityIsLow);
                SetSentErrorMessage(true);
                return(true);
            }
            return(false);
        }
示例#14
0
        public bool HasLowerSecurity(Player target, ulong guid, bool strong = false)
        {
            WorldSession target_session = null;
            uint         target_account = 0;

            if (target != null)
            {
                target_session = target.GetSession();
            }
            else if (guid != 0)
            {
                target_account = ObjMgr.GetPlayerAccountIdByGUID(guid);
            }

            if (target_session == null && target_account == 0)
            {
                SendSysMessage(CypherStrings.PlayerNotFound);
                SetSentErrorMessage(true);
                return(true);
            }

            return(HasLowerSecurityAccount(target_session, target_account, strong));
        }
示例#15
0
        static void SendListInventory(ulong vendorGuid, ref WorldSession session)
        {
            Log.outDebug("WORLD: Sent SMSG_LIST_INVENTORY");

            Player pl = session.GetPlayer();

            Creature vendor = pl.GetNPCIfCanInteractWith(vendorGuid, NPCFlags.Vendor);

            if (vendor == null)
            {
                Log.outDebug("WORLD: SendListInventory - Unit (GUID: %u) not found or you can not interact with him.", ObjectGuid.GuidLowPart(vendorGuid));
                session.GetPlayer().SendSellError(SellResult.CantFindVendor, null, 0);
                return;
            }

            // remove fake death
            //if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
            //GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);

            // Stop the npc if moving
            //if (vendor.HasUnitState(UNIT_STATE_MOVING))
            //vendor->StopMoving();

            VendorItemData vendorItems  = vendor.GetVendorItems();
            int            rawItemCount = vendorItems != null?vendorItems.GetItemCount() : 0;

            List <bool>  enablers  = new List <bool>();
            PacketWriter itemsData = new PacketWriter();

            float  discountMod = session.GetPlayer().GetReputationPriceDiscount(vendor);
            ushort count       = 0;

            for (ushort slot = 0; slot < rawItemCount; ++slot)
            {
                VendorItem vendorItem = vendorItems.GetItem(slot);
                if (vendorItem == null)
                {
                    continue;
                }

                if (vendorItem.Type == (byte)ItemVendorType.Item)
                {
                    ItemTemplate itemTemplate = ObjMgr.GetItemTemplate(vendorItem.item);
                    if (itemTemplate == null)
                    {
                        continue;
                    }

                    uint leftInStock = vendorItem.maxcount == 0 ? 0xFFFFFFFF : vendor.GetVendorItemCurrentCount(vendorItem);
                    if (!pl.isGameMaster()) // ignore conditions if GM on
                    {
                        // Respect allowed class
                        if (!Convert.ToBoolean(itemTemplate.AllowableClass & pl.getClassMask()) && itemTemplate.Bonding == ItemBondingType.PickedUp)
                        {
                            continue;
                        }

                        // Only display items in vendor lists for the team the player is on
                        if ((Convert.ToBoolean(itemTemplate.Flags2 & ItemFlags2.HordeOnly) && pl.GetTeam() == Team.Alliance) ||
                            (Convert.ToBoolean(itemTemplate.Flags2 & ItemFlags2.AllianceOnly) && pl.GetTeam() == Team.Horde))
                        {
                            continue;
                        }

                        // Items sold out are not displayed in list
                        if (leftInStock == 0)
                        {
                            continue;
                        }
                    }

                    int price = vendorItem.IsGoldRequired(itemTemplate) ? (int)(Math.Floor(itemTemplate.BuyPrice * discountMod)) : 0;

                    //int priceMod = pl.GetTotalAuraModifier(SPELL_AURA_MOD_VENDOR_ITEMS_PRICES)
                    //if (priceMod != 0)
                    //price -= CalculatePctN(price, priceMod);

                    itemsData.WriteUInt32(count++ + 1);        // client expects counting to start at 1
                    itemsData.WriteUInt32(itemTemplate.MaxDurability);

                    if (vendorItem.ExtendedCost != 0)
                    {
                        enablers.Add(false);
                        itemsData.WriteUInt32(vendorItem.ExtendedCost);
                    }
                    else
                    {
                        enablers.Add(true);
                    }
                    enablers.Add(true);                 // unk bit

                    itemsData.WriteUInt32(vendorItem.item);
                    itemsData.WriteUInt32(vendorItem.Type);     // 1 is items, 2 is currency
                    itemsData.WriteUInt32(price);
                    itemsData.WriteUInt32(itemTemplate.DisplayInfoID);
                    // if (!unk "enabler") data << uint32(something);
                    itemsData.WriteUInt32(leftInStock);
                    itemsData.WriteUInt32(itemTemplate.BuyCount);
                }
                else if (vendorItem.Type == (byte)ItemVendorType.Currency)
                {
                    CurrencyTypesEntry currencyTemplate = DBCStorage.CurrencyTypesStorage.LookupByKey(vendorItem.item);
                    if (currencyTemplate == null)
                    {
                        continue;
                    }

                    if (vendorItem.ExtendedCost == 0)
                    {
                        continue; // there's no price defined for currencies, only extendedcost is used
                    }
                    uint precision = (uint)(Convert.ToBoolean(currencyTemplate.Flags & (uint)CurrencyFlags.HighPrecision) ? 100 : 1);

                    itemsData.WriteUInt32(count++ + 1);        // client expects counting to start at 1
                    itemsData.WriteUInt32(0);                  // max durability

                    if (vendorItem.ExtendedCost != 0)
                    {
                        enablers.Add(false);
                        itemsData.WriteUInt32(vendorItem.ExtendedCost);
                    }
                    else
                    {
                        enablers.Add(true);
                    }

                    enablers.Add(true);                    // unk bit

                    itemsData.WriteUInt32(vendorItem.item);
                    itemsData.WriteUInt32(vendorItem.Type);    // 1 is items, 2 is currency
                    itemsData.WriteUInt32(0);                  // price, only seen currency types that have Extended cost
                    itemsData.WriteUInt32(0);                  // displayId
                    // if (!unk "enabler") data << uint32(something);
                    itemsData.WriteInt32(-1);
                    itemsData.WriteUInt32(vendorItem.maxcount * precision);
                }
                // else error
            }

            ObjectGuid guid = new ObjectGuid(vendorGuid);

            PacketWriter data = new PacketWriter(Opcodes.SMSG_ListInventory);

            data.WriteBit(guid[1]);
            data.WriteBit(guid[0]);

            data.WriteBits(count, 21); // item count

            data.WriteBit(guid[3]);
            data.WriteBit(guid[6]);
            data.WriteBit(guid[5]);
            data.WriteBit(guid[2]);
            data.WriteBit(guid[7]);

            foreach (var itr in enablers)
            {
                data.WriteBit(itr);
            }

            data.WriteBit(guid[4]);

            data.BitFlush();
            data.WriteBytes(itemsData);

            data.WriteByteSeq(guid[5]);
            data.WriteByteSeq(guid[4]);
            data.WriteByteSeq(guid[1]);
            data.WriteByteSeq(guid[0]);
            data.WriteByteSeq(guid[6]);

            data.WriteUInt8(count == 0); // unk byte, item count 0: 1, item count != 0: 0 or some "random" value below 300

            data.WriteByteSeq(guid[2]);
            data.WriteByteSeq(guid[3]);
            data.WriteByteSeq(guid[7]);

            session.Send(data);
        }
示例#16
0
        public static void SendSysMessage(WorldSession session, CypherStrings message, params object[] args)
        {
            string msg = string.Format(ObjMgr.GetCypherString(message), args);

            SendChatMessage(session, ChatMsg.System, Language.Universal, msg);
        }
示例#17
0
 public static void SendSysMessage(WorldObject obj, CypherStrings message, params object[] args)
 {
     SendSysMessage(obj.GetSession(), ObjMgr.GetCypherString(message), args);
 }
示例#18
0
        public static void HandleChatMessage(ref PacketReader packet, ref WorldSession session)
        {
            ChatMsg type;

            switch (packet.Opcode)
            {
            case Opcodes.CMSG_MessageChatGuild:
                type = ChatMsg.Guild;
                break;

            case Opcodes.CMSG_MessageChatOfficer:
                type = ChatMsg.Officer;
                break;

            case Opcodes.CMSG_MessageChatParty:
                type = ChatMsg.Party;
                break;

            case Opcodes.CMSG_MessageChatWhisper:
                type = ChatMsg.Whisper;
                break;

            case Opcodes.CMSG_MessageChatYell:
                type = ChatMsg.Yell;
                break;

            case Opcodes.CMSG_MessageChatSay:
            default:
                type = ChatMsg.Say;
                break;
            }

            if (type >= ChatMsg.Max)
            {
                Log.outError("CHAT: Wrong message type received: {0}", type);
                return;
            }
            Player sender = session.GetPlayer();

            Language lang;

            if (type != ChatMsg.Emote && type != ChatMsg.Afk && type != ChatMsg.Dnd)
            {
                lang = (Language)packet.ReadUInt32();

                /*
                 * // prevent talking at unknown language (cheating)
                 * LanguageDesc const* langDesc = GetLanguageDescByID(lang);
                 * if (!langDesc)
                 * {
                 *  SendNotification(LANG_UNKNOWN_LANGUAGE);
                 *  recvData.rfinish();
                 *  return;
                 * }
                 *
                 * if (langDesc->skill_id != 0 && !sender->HasSkill(langDesc->skill_id))
                 * {
                 *  // also check SPELL_AURA_COMPREHEND_LANGUAGE (client offers option to speak in that language)
                 *  Unit::AuraEffectList const& langAuras = sender->GetAuraEffectsByType(SPELL_AURA_COMPREHEND_LANGUAGE);
                 *  bool foundAura = false;
                 *  for (Unit::AuraEffectList::const_iterator i = langAuras.begin(); i != langAuras.end(); ++i)
                 *  {
                 *      if ((*i)->GetMiscValue() == int32(lang))
                 *      {
                 *          foundAura = true;
                 *          break;
                 *      }
                 *  }
                 *  if (!foundAura)
                 *  {
                 *      SendNotification(LANG_NOT_LEARNED_LANGUAGE);
                 *      recvData.rfinish();
                 *      return;
                 *  }
                 * }
                 */
                if (lang == Language.Addon)
                {
                    //if (sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
                    {
                        //std::string msg = "";
                        //recvData >> msg;

                        //if (msg.empty())
                        //return;

                        // sScriptMgr->OnPlayerChat(sender, uint32(CHAT_MSG_ADDON), lang, msg);
                    }

                    // Disabled addon channel?
                    //if (!sWorld->getBoolConfig(CONFIG_ADDON_CHANNEL))
                    //return;
                }
                // LANG_ADDON should not be changed nor be affected by flood control
                else
                {
                    // send in universal language if player in .gm on mode (ignore spell effects)
                    if (sender.isGameMaster())
                    {
                        lang = Language.Universal;
                    }

                    /*
                     * else
                     * {
                     * // send in universal language in two side iteration allowed mode
                     * //if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT))
                     * //lang = LANG_UNIVERSAL;
                     * //else
                     * //{
                     * switch (type)
                     * {
                     *  case CHAT_MSG_PARTY:
                     *  case CHAT_MSG_PARTY_LEADER:
                     *  case CHAT_MSG_RAID:
                     *  case CHAT_MSG_RAID_LEADER:
                     *  case CHAT_MSG_RAID_WARNING:
                     *  // allow two side chat at group channel if two side group allowed
                     *  if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
                     *      lang = LANG_UNIVERSAL;
                     *      break;
                     *  case CHAT_MSG_GUILD:
                     *  case CHAT_MSG_OFFICER:
                     *  // allow two side chat at guild channel if two side guild allowed
                     *  if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD))
                     *      lang = LANG_UNIVERSAL;
                     *  break;
                     * }
                     *
                     *
                     * // but overwrite it by SPELL_AURA_MOD_LANGUAGE auras (only single case used)
                     * Unit::AuraEffectList const& ModLangAuras = sender->GetAuraEffectsByType(SPELL_AURA_MOD_LANGUAGE);
                     * if (!ModLangAuras.empty())
                     * lang = ModLangAuras.front()->GetMiscValue();
                     * }
                     *
                     * //if (!sender->CanSpeak())
                     * {
                     * //std::string timeStr = secsToTimeString(m_muteTime - time(NULL));
                     * //SendNotification(GetCypherString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str());
                     * //recvData.rfinish(); // Prevent warnings
                     * //return;
                     * }
                     */
                }
            }
            else
            {
                lang = Language.Universal;
            }

            //if (sender->HasAura(1852) && type != CHAT_MSG_WHISPER)
            {
                //recvData.rfinish();
                //SendNotification(GetCypherString(LANG_GM_SILENCE), sender->GetName());
                //return;
            }
            uint   textLength     = 0;
            uint   receiverLength = 0;
            string to             = string.Empty;
            string channel        = string.Empty;
            string msg            = string.Empty;
            bool   ignoreChecks   = false;

            switch (type)
            {
            case ChatMsg.Say:
            case ChatMsg.Emote:
            case ChatMsg.Yell:
            case ChatMsg.Party:
            case ChatMsg.Guild:
            case ChatMsg.Officer:
            case ChatMsg.Raid:
            case ChatMsg.Raid_Warning:
            case ChatMsg.Battleground:
                textLength = packet.GetBits <uint>(9);
                msg        = packet.ReadString(textLength);
                break;

            case ChatMsg.Whisper:
                receiverLength = packet.GetBits <uint>(10);
                textLength     = packet.GetBits <uint>(9);
                to             = packet.ReadString(receiverLength);
                msg            = packet.ReadString(textLength);
                break;

            case ChatMsg.Channel:
                receiverLength = packet.GetBits <uint>(10);
                textLength     = packet.GetBits <uint>(9);
                msg            = packet.ReadString(textLength);
                channel        = packet.ReadString(receiverLength);
                break;

            case ChatMsg.Afk:
            case ChatMsg.Dnd:
                textLength   = packet.GetBits <uint>(9);
                msg          = packet.ReadString(textLength);
                ignoreChecks = true;
                break;
            }
            if (!ignoreChecks)
            {
                if (msg == string.Empty)
                {
                    return;
                }

                if (CommandManager.TryParse(msg, session))
                {
                    return;
                }

                if (msg == string.Empty)
                {
                    return;
                }
            }

            switch (type)
            {
            case ChatMsg.Say:
            case ChatMsg.Emote:
            case ChatMsg.Yell:
                //if (sender->getLevel() < sWorld->getIntConfig(CONFIG_CHAT_SAY_LEVEL_REQ))
            {
                //SendNotification(GetCypherString(LANG_SAY_REQ), sWorld->getIntConfig(CONFIG_CHAT_SAY_LEVEL_REQ));
                //return;
            }

                if (type == ChatMsg.Say)
                {
                    sender.Say(msg, lang);
                }
                //else if (type == ChatMsg.EMOTE)
                //sender.TextEmote(msg);
                else if (type == ChatMsg.Yell)
                {
                    sender.Yell(msg, lang);
                }
                break;

            case ChatMsg.Whisper:
                //if (sender->getLevel() < sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ))
            {
                //SendNotification(GetCypherString(LANG_WHISPER_REQ), sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ));
                //return;
            }

                //if (!normalizePlayerName(to))
                {
                    //SendPlayerNotFoundNotice(to);
                    //break;
                }

                Player receiver         = ObjMgr.FindPlayerByName(to);
                bool   senderIsPlayer   = ObjMgr.IsPlayerAccount(session.GetSecurity());
                bool   receiverIsPlayer = ObjMgr.IsPlayerAccount(receiver != null ? receiver.GetSession().GetSecurity() : AccountTypes.Player);
                if (receiver == null || (senderIsPlayer && !receiverIsPlayer))        // && !receiver.isAcceptWhispers() && !receiver.IsInWhisperWhiteList(sender->GetGUID())))todo fixme
                {
                    SendPlayerNotFoundNotice(session, to);
                    return;
                }

                //if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT) && senderIsPlayer && receiverIsPlayer)
                //if (GetPlayer()->GetTeam() != receiver->GetTeam())
                {
                    //SendWrongFactionNotice();
                    //return;
                }

                //if (GetPlayer()->HasAura(1852) && !receiver->isGameMaster())
                {
                    //SendNotification(GetCypherString(LANG_GM_SILENCE), GetPlayer()->GetName());
                    //return;
                }

                // If player is a Gamemaster and doesn't accept whisper, we auto-whitelist every player that the Gamemaster is talking to
                //if (!senderIsPlayer && !sender->isAcceptWhispers() && !sender->IsInWhisperWhiteList(receiver->GetGUID()))
                //sender->AddWhisperWhiteList(receiver->GetGUID());

                session.GetPlayer().Whisper(msg, lang, receiver.GetGUID());
                break;

            /*
             * case ChatMsg.Party:
             * case ChatMsg.PartyLEADER:
             * {
             *  // if player is in battleground, he cannot say to battleground members by /p
             *  Group* group = GetPlayer()->GetOriginalGroup();
             *  if (!group)
             *  {
             *      group = _player->GetGroup();
             *      if (!group || group->isBGGroup())
             *          return;
             *  }
             *
             *  if (group->IsLeader(GetPlayer()->GetGUID()))
             *      type = CHAT_MSG_PARTY_LEADER;
             *
             *  sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
             *
             *  WorldPacket data;
             *  ChatHandler::FillMessageData(&data, this, uint8(type), lang, NULL, 0, msg.c_str(), NULL);
             *  group->BroadcastPacket(&data, false, group->GetMemberGroup(GetPlayer()->GetGUID()));
             * } break;
             * case CHAT_MSG_GUILD:
             * {
             *  if (GetPlayer()->GetGuildId())
             *  {
             *      if (Guild* guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildId()))
             *      {
             *          sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, guild);
             *
             *          guild->BroadcastToGuild(this, false, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
             *      }
             *  }
             * } break;
             * case CHAT_MSG_OFFICER:
             * {
             *  if (GetPlayer()->GetGuildId())
             *  {
             *      if (Guild* guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildId()))
             *      {
             *          sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, guild);
             *
             *          guild->BroadcastToGuild(this, true, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
             *      }
             *  }
             * } break;
             * case CHAT_MSG_RAID:
             * case CHAT_MSG_RAID_LEADER:
             * {
             *  // if player is in battleground, he cannot say to battleground members by /ra
             *  Group* group = GetPlayer()->GetOriginalGroup();
             *  if (!group)
             *  {
             *      group = GetPlayer()->GetGroup();
             *      if (!group || group->isBGGroup() || !group->isRaidGroup())
             *          return;
             *  }
             *
             *  if (group->IsLeader(GetPlayer()->GetGUID()))
             *      type = CHAT_MSG_RAID_LEADER;
             *
             *  sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
             *
             *  WorldPacket data;
             *  ChatHandler::FillMessageData(&data, this, uint8(type), lang, "", 0, msg.c_str(), NULL);
             *  group->BroadcastPacket(&data, false);
             * } break;
             * case CHAT_MSG_RAID_WARNING:
             * {
             *  Group* group = GetPlayer()->GetGroup();
             *  if (!group || !group->isRaidGroup() || !(group->IsLeader(GetPlayer()->GetGUID()) || group->IsAssistant(GetPlayer()->GetGUID())) || group->isBGGroup())
             *      return;
             *
             *  sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
             *
             *  WorldPacket data;
             *  //in battleground, raid warning is sent only to players in battleground - code is ok
             *  ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID_WARNING, lang, "", 0, msg.c_str(), NULL);
             *  group->BroadcastPacket(&data, false);
             * } break;
             * case CHAT_MSG_BATTLEGROUND:
             * case CHAT_MSG_BATTLEGROUND_LEADER:
             * {
             *  // battleground raid is always in Player->GetGroup(), never in GetOriginalGroup()
             *  Group* group = GetPlayer()->GetGroup();
             *  if (!group || !group->isBGGroup())
             *      return;
             *
             *  if (group->IsLeader(GetPlayer()->GetGUID()))
             *      type = CHAT_MSG_BATTLEGROUND_LEADER;
             *
             *  sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
             *
             *  WorldPacket data;
             *  ChatHandler::FillMessageData(&data, this, uint8(type), lang, "", 0, msg.c_str(), NULL);
             *  group->BroadcastPacket(&data, false);
             * } break;
             * case CHAT_MSG_CHANNEL:
             * {
             *  if (AccountMgr::IsPlayerAccount(GetSecurity()))
             *  {
             *      if (_player->getLevel() < sWorld->getIntConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ))
             *      {
             *          SendNotification(GetCypherString(LANG_CHANNEL_REQ), sWorld->getIntConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ));
             *          return;
             *      }
             *  }
             *
             *  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
             *  {
             *
             *      if (Channel* chn = cMgr->GetChannel(channel, _player))
             *      {
             *          sScriptMgr->OnPlayerChat(_player, type, lang, msg, chn);
             *
             *          chn->Say(_player->GetGUID(), msg.c_str(), lang);
             *      }
             *  }
             * } break;
             * case CHAT_MSG_AFK:
             * {
             *  if ((msg.empty() || !_player->isAFK()) && !_player->isInCombat())
             *  {
             *      if (!_player->isAFK())
             *      {
             *          if (msg.empty())
             *              msg  = GetCypherString(LANG_PLAYER_AFK_DEFAULT);
             *          _player->afkMsg = msg;
             *      }
             *
             *      sScriptMgr->OnPlayerChat(_player, type, lang, msg);
             *
             *      _player->ToggleAFK();
             *      if (_player->isAFK() && _player->isDND())
             *          _player->ToggleDND();
             *  }
             * } break;
             * case CHAT_MSG_DND:
             * {
             *  if (msg.empty() || !_player->isDND())
             *  {
             *      if (!_player->isDND())
             *      {
             *          if (msg.empty())
             *              msg = GetCypherString(LANG_PLAYER_DND_DEFAULT);
             *          _player->dndMsg = msg;
             *      }
             *
             *      sScriptMgr->OnPlayerChat(_player, type, lang, msg);
             *
             *      _player->ToggleDND();
             *      if (_player->isDND() && _player->isAFK())
             *          _player->ToggleAFK();
             *  }
             * } break;
             */
            default:
                Log.outError("CHAT: unknown message type {0}, lang: {1}", type, lang);
                break;
            }
        }
示例#19
0
            //same here
            public override bool Fallback(string[] @params = null, CommandGroup cmd = null)
            {
                if (@params == null || cmd == null || @params.Count() < 2)
                {
                    return(false);
                }

                uint objectId;

                uint.TryParse(@params[0], out objectId);

                if (objectId == 0)
                {
                    return(false);
                }

                uint spawntimeSecs;

                uint.TryParse(@params[1], out spawntimeSecs);

                GameObjectTemplate objectInfo = ObjMgr.GetGameObjectTemplate(objectId);

                if (objectInfo == null)
                {
                    cmd.SendErrorMessage(CypherStrings.GameobjectNotExist, objectId);
                    return(false);
                }

                //if (objectInfo.displayId != 0 && !DBCStorage.sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId))
                {
                    // report to DB errors log as in loading case
                    //sLog->outError(LOG_FILTER_SQL, "Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", objectId, objectInfo->type, objectInfo->displayId);
                    //handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, objectId);
                    //return false;
                }

                Player player = cmd.GetSession().GetPlayer();
                float  x      = player.GetPositionX();
                float  y      = player.GetPositionY();
                float  z      = player.GetPositionZ();
                float  o      = player.GetOrientation();
                Map    map    = player.GetMap();

                GameObject obj     = new GameObject();
                uint       guidLow = ObjMgr.GenerateLowGuid(HighGuidType.GameObject);

                if (!obj.Create(guidLow, objectInfo.entry, map, 1 /*player.GetPhaseMgr().GetPhaseMaskForSpawn()*/, x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GameObjectState.Ready))
                {
                    return(false);
                }

                //if (spawntimeSecs != 0)
                {
                    //obj.SetRespawnTime(spawntimeSecs);
                }

                // fill the gameobject data and save to the db
                obj.SaveToDB(map.GetId(), (byte)(1 << (int)map.GetSpawnMode()), 1);//player.GetPhaseMgr().GetPhaseMaskForSpawn());

                // this will generate a new guid if the object is in an instance
                if (!obj.LoadGameObjectFromDB(guidLow, map))
                {
                    return(false);
                }

                // TODO: is it really necessary to add both the real and DB table guid here ?
                ObjMgr.AddGameObjectToGrid(guidLow, ObjMgr.GetGOData(guidLow));
                cmd.SendSysMessage(CypherStrings.GameobjectAdd, objectId, objectInfo.name, guidLow, x, y, z);
                return(true);
            }
示例#20
0
文件: Spell.cs 项目: ovr/CypherCore
        public Spell(Unit caster, SpellInfo info, TriggerCastFlags triggerFlags, ulong originalCasterGUID = 0, bool skipCheck = false)
        {
            m_spellInfo  = SpellMgr.GetSpellForDifficultyFromSpell(info, caster);
            m_caster     = Convert.ToBoolean(info.AttributesEx6 & SpellAttr6.CastByCharmer) ? null : caster;//&& caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster
            m_spellValue = new SpellValue(m_spellInfo);

            m_customError   = SpellCustomErrors.None;
            m_skipCheck     = skipCheck;
            m_selfContainer = null;
            m_referencedFromCurrentSpell = false;
            m_executedCurrently          = false;
            m_needComboPoints            = m_spellInfo.NeedsComboPoints();
            m_comboPointGain             = 0;
            m_delayStart         = 0;
            m_delayAtDamageCount = 0;

            m_applyMultiplierMask = 0;
            m_auraScaleMask       = 0;

            // Get data for type of attack
            switch (m_spellInfo.DmgClass)
            {
            case SpellDmgClass.Melee:
                if (Convert.ToBoolean(m_spellInfo.AttributesEx3 & SpellAttr3.ReqOffhand))
                {
                    m_attackType = WeaponAttackType.OffAttack;
                }
                else
                {
                    m_attackType = WeaponAttackType.BaseAttack;
                }
                break;

            case SpellDmgClass.Ranged:
                m_attackType = m_spellInfo.IsRangedWeaponSpell() ? WeaponAttackType.RangedAttack : WeaponAttackType.BaseAttack;
                break;

            default:
                // Wands
                if (Convert.ToBoolean(m_spellInfo.AttributesEx2 & SpellAttr2.AutorepeatFlag))
                {
                    m_attackType = WeaponAttackType.RangedAttack;
                }
                else
                {
                    m_attackType = WeaponAttackType.BaseAttack;
                }
                break;
            }

            m_spellSchoolMask = info.GetSchoolMask();           // Can be override for some spell (wand shoot for example)

            if (m_attackType == WeaponAttackType.RangedAttack)
            {
                if ((m_caster.getClassMask() & SharedConst.ClassMaskWandUsers) != 0 && m_caster.GetTypeId() == ObjectType.Player)
                {
                    Item pItem = m_caster.ToPlayer().GetWeaponForAttack(WeaponAttackType.RangedAttack);
                    //if (pItem != null)
                    //m_spellSchoolMask = (SpellSchoolMask)(1 << (int)pItem.ItemInfo.ItemSparse.DamageType);
                }
            }

            if (originalCasterGUID != 0)
            {
                m_originalCasterGUID = originalCasterGUID;
            }
            else
            {
                m_originalCasterGUID = m_caster.GetGUID();
            }

            if (m_originalCasterGUID == m_caster.GetGUID())
            {
                m_originalCaster = m_caster;
            }
            else
            {
                m_originalCaster = ObjMgr.GetObject <Unit>(m_caster, m_originalCasterGUID);
                if (m_originalCaster != null && !m_originalCaster.IsInWorld)
                {
                    m_originalCaster = null;
                }
            }

            m_spellState        = SpellState.None;
            _triggeredCastFlags = triggerFlags;
            if (Convert.ToBoolean(info.AttributesEx4 & SpellAttr4.Triggered))
            {
                _triggeredCastFlags = TriggerCastFlags.FullMask;
            }

            m_CastItem     = null;
            m_castItemGUID = 0;

            unitTarget     = null;
            itemTarget     = null;
            gameObjTarget  = null;
            focusObject    = null;
            m_cast_count   = 0;
            m_glyphIndex   = 0;
            m_preCastSpell = 0;
            //m_triggeredByAuraSpell  = null;
            //m_spellAura = null;

            //Auto Shot & Shoot (wand)
            m_autoRepeat = m_spellInfo.IsAutoRepeatRangedSpell();

            m_runesState = 0;
            m_powerCost  = 0;                                       // setup to correct value in Spell::prepare, must not be used before.
            m_casttime   = 0;                                       // setup to correct value in Spell::prepare, must not be used before.
            m_timer      = 0;                                       // will set to castime in prepare

            //m_channelTargetEffectMask = 0;

            // Determine if spell can be reflected back to the caster
            // Patch 1.2 notes: Spell Reflection no longer reflects abilities
            m_canReflect = m_spellInfo.DmgClass == SpellDmgClass.Magic && !Convert.ToBoolean(m_spellInfo.Attributes & SpellAttr0.Ability) &&
                           !Convert.ToBoolean(m_spellInfo.AttributesEx & SpellAttr1.CantBeReflected) && !Convert.ToBoolean(m_spellInfo.Attributes & SpellAttr0.UnaffectedByInvulnerability) &&
                           !m_spellInfo.IsPassive() && !m_spellInfo.IsPositive();

            CleanupTargetList();

            for (var i = 0; i < SharedConst.MaxSpellEffects; ++i)
            {
                m_destTargets[i] = new SpellDestination(m_caster);
            }
        }
示例#21
0
        public static void HandleTrainerList(ref PacketReader packet, ref WorldSession session)
        {
            ulong  guid = packet.ReadUInt64();
            string str  = ObjMgr.GetCypherString(CypherStrings.NpcTrainerHello);

            Creature unit = session.GetPlayer().GetNPCIfCanInteractWith(guid, NPCFlags.Trainer);

            if (unit == null)
            {
                Log.outDebug("WORLD: SendTrainerList - Unit (GUID: {0}) not found or you can not interact with him.", ObjectGuid.GuidLowPart(guid));
                return;
            }

            // remove fake death
            //if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
            //GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);

            // trainer list loaded at check;
            if (!unit.isTrainerOf(session.GetPlayer(), true))
            {
                return;
            }

            CreatureTemplate ci = unit.GetCreatureTemplate();

            if (ci == null)
            {
                Log.outDebug("WORLD: SendTrainerList - (GUID: {0}) NO CREATUREINFO!", ObjectGuid.GuidLowPart(guid));
                return;
            }
            TrainerSpellData trainer_spells = unit.GetTrainerSpells();

            if (trainer_spells == null)
            {
                Log.outDebug("WORLD: SendTrainerList - Training spells not found for creature (GUID: {0} Entry: {1})", ObjectGuid.GuidLowPart(guid), unit.GetEntry());
                return;
            }
            PacketWriter data = new PacketWriter(Opcodes.SMSG_TrainerList);

            data.WriteUInt64(guid);
            data.WriteUInt32(trainer_spells.trainerType);
            data.WriteUInt32(133);

            int count_pos = data.wpos();

            data.WriteUInt32(trainer_spells.spellList.Count);

            // reputation discount
            float fDiscountMod           = session.GetPlayer().GetReputationPriceDiscount(unit);
            bool  can_learn_primary_prof = session.GetPlayer().GetFreePrimaryProfessionPoints() > 0;

            uint count = 0;

            foreach (var spell in trainer_spells.spellList.Values)
            {
                bool valid = true;
                bool primary_prof_first_rank = false;
                for (var i = 0; i < 3; ++i)
                {
                    if (spell.learnedSpell[i] == 0)
                    {
                        continue;
                    }
                    if (!session.GetPlayer().IsSpellFitByClassAndRace(spell.learnedSpell[i]))
                    {
                        valid = false;
                        break;
                    }
                    SpellInfo spellentry = SpellMgr.GetSpellInfo(spell.learnedSpell[i]);
                    if (spellentry.IsPrimaryProfessionFirstRank())
                    {
                        primary_prof_first_rank = true;
                    }
                }
                if (!valid)
                {
                    continue;
                }

                TrainerSpellState state = session.GetPlayer().GetTrainerSpellState(spell);
                data.WriteUInt32(spell.spellId);                      // learned spell (or cast-spell in profession case)
                data.WriteUInt8((byte)(state == TrainerSpellState.GreenDisabled ? TrainerSpellState.Green : state));
                data.WriteUInt32((uint)Math.Floor(spell.spellCost * fDiscountMod));

                data.WriteUInt8((byte)spell.reqLevel);
                data.WriteUInt32(spell.reqSkill);
                data.WriteUInt32(spell.reqSkillValue);
                //prev + req or req + 0
                var maxReq = 0;
                for (var i = 0; i < 3; ++i)
                {
                    if (spell.learnedSpell[i] == 0)
                    {
                        continue;
                    }
                    uint prevSpellId = SpellMgr.GetPrevSpellInChain(spell.learnedSpell[i]);
                    if (prevSpellId != 0)
                    {
                        data.WriteUInt32(prevSpellId);
                        maxReq++;
                    }
                    if (maxReq == 2)
                    {
                        break;
                    }

                    //SpellsRequiringSpellMapBounds spellsRequired = sSpellMgr->GetSpellsRequiredForSpellBounds(tSpell->learnedSpell[i]);
                    //for (SpellsRequiringSpellMap::const_iterator itr2 = spellsRequired.first; itr2 != spellsRequired.second && maxReq < 3; ++itr2)
                    {
                        //data.WriteUInt32(itr2->second);
                        //++maxReq;
                    }
                    //if (maxReq == 2)
                    //break;
                }
                while (maxReq < 2)
                {
                    data.WriteUInt32(0);
                    maxReq++;
                }

                data.WriteInt32(primary_prof_first_rank && can_learn_primary_prof ? 1 : 0);
                count++;
            }
            data.WriteCString(str);
            data.Replace <uint>(count_pos, count);
            session.Send(data);
        }
示例#22
0
        //Members
        public bool AddMember(UInt64 plGuid, int rankId = -1)
        {
            Player pl = ObjMgr.FindPlayer(plGuid);

            if (pl == null || pl.GuildGuid != 0)
            {
                return(false);
            }

            //remove all signs from petitions

            if (rankId == -1)
            {
                rankId = GetLowestRank();
            }

            Member member = new Member()
            {
                CharGuid           = new ObjectGuid(pl.GetGUIDLow()),
                Name               = pl.Name,
                Level              = pl.getLevel(),
                Class              = pl.getClass(),
                ZoneId             = pl.GetZoneId(),
                Flags              = (byte)GuildMemberFlags.Online,
                LogoutTime         = 0,
                RankId             = (uint)rankId,
                PublicNote         = "",
                OfficerNote        = "",
                AchievementPoints  = 0,
                BankRemainingMoney = 0,
                BankResetTimeMoney = 0,
            };

            for (int i = 0; i < 2; i++)
            {
                Member.Profession prof = new Member.Profession();
                prof.Level   = 0;
                prof.SkillId = 0;
                prof.Rank    = 0;
                member.ProfessionList.Add(prof);
            }

            MemberList.Add(member);

            member.SaveToDB(Guid);

            pl.SetInGuild(Guid);
            pl.SetGuildRank(member.RankId);
            pl.SetGuildLevel(GetLevel());
            pl.SetGuildInvited(0);

            /*
             * pl.GetReputationMgr().SetReputation(sFactionStore.LookupEntry(1168), 1);
             * if (sWorld->getBoolConfig(CONFIG_GUILD_LEVELING_ENABLED))
             * {
             *  for (uint32 i = 0; i < sGuildPerkSpellsStore.GetNumRows(); ++i)
             *      if (GuildPerkSpellsEntry const* entry = sGuildPerkSpellsStore.LookupEntry(i))
             *  if (entry->Level >= GetLevel())
             *      player->learnSpell(entry->SpellId, true);
             * }
             */
            return(true);
        }
示例#23
0
        public static void HandleGuildAssignRank(ref PacketReader packet, ref WorldSession session)
        {
            uint rankId = packet.ReadUInt32();

            var TGuid = new byte[8];
            var Guid  = new byte[8];

            TGuid[1] = packet.GetBit();
            TGuid[7] = packet.GetBit();
            Guid[4]  = packet.GetBit();
            Guid[2]  = packet.GetBit();
            TGuid[4] = packet.GetBit();
            TGuid[5] = packet.GetBit();
            TGuid[6] = packet.GetBit();
            Guid[1]  = packet.GetBit();
            Guid[7]  = packet.GetBit();
            TGuid[2] = packet.GetBit();
            TGuid[3] = packet.GetBit();
            TGuid[0] = packet.GetBit();
            Guid[6]  = packet.GetBit();
            Guid[3]  = packet.GetBit();
            Guid[0]  = packet.GetBit();
            Guid[5]  = packet.GetBit();

            packet.ReadXORByte(TGuid, 0);
            packet.ReadXORByte(Guid, 1);
            packet.ReadXORByte(Guid, 3);
            packet.ReadXORByte(Guid, 5);
            packet.ReadXORByte(TGuid, 7);
            packet.ReadXORByte(TGuid, 3);
            packet.ReadXORByte(Guid, 0);
            packet.ReadXORByte(TGuid, 1);
            packet.ReadXORByte(Guid, 6);
            packet.ReadXORByte(TGuid, 2);
            packet.ReadXORByte(TGuid, 5);
            packet.ReadXORByte(TGuid, 4);
            packet.ReadXORByte(Guid, 2);
            packet.ReadXORByte(Guid, 4);
            packet.ReadXORByte(Guid, 6);
            packet.ReadXORByte(Guid, 7);

            ObjectGuid TargetGuid = new ObjectGuid(TGuid);
            ObjectGuid PlGuid     = new ObjectGuid(Guid);

            Player pl    = ObjMgr.FindPlayer(PlGuid);
            Guild  guild = GuildMgr.GetGuildByGuid(pl.GuildGuid);

            if (guild == null)
            {
                SendCommandResult(ref session, GuildCommandType.Create_S, GuildCommandErrors.PlayerNotInGuild);
                return;
            }

            Guild.Member member = guild.GetMember(TargetGuid);
            if (member == null)
            {
                SendCommandResult(ref session, GuildCommandType.Create_S, GuildCommandErrors.PlayerNotInGuild);
                return;
            }

            bool promote = false;

            if (member.RankId > rankId)
            {
                promote = true;
            }

            member.ChangeRank(rankId);

            guild.LogGuildEvent(promote ? GuildEventLogTypes.PromotePlayer : GuildEventLogTypes.DemotePlayer, pl.GetGUIDLow(), member.CharGuid, rankId);
            guild.SendBroadcastEvent(promote ? GuildEvents.Promotion : GuildEvents.Demotion, 0, pl.GetName(), member.Name, guild.GetRankName(rankId));

            guild.SendRoster();
        }
示例#24
0
 private void Awake()
 {
     _Instance = this;
 }
示例#25
0
        public static void HandlePlayerLogin(ref PacketReader packet, ref WorldSession session)
        {
            var mask  = new byte[] { 5, 7, 6, 1, 2, 3, 4, 0 };
            var bytes = new byte[] { 6, 4, 3, 5, 0, 2, 7, 1 };
            var guid  = packet.GetGuid(mask, bytes);

            Player pChar = new Player(ref session);

            session.SetPlayer(pChar);

            if (!pChar.LoadCharacter(guid))
            {
                session.SetPlayer(null);
                session.KickPlayer();                                       // disconnect client, player no set to session and it will not deleted or saved at kick
                //m_playerLoading = false;
                return;
            }

            //pCurrChar->GetMotionMaster()->Initialize();
            //pCurrChar->SendDungeonDifficulty(false);

            PacketWriter world = new PacketWriter(Opcodes.SMSG_NewWorld);

            world.WriteUInt32(pChar.GetMapId());
            world.WriteFloat(pChar.Position.Y);
            world.WriteFloat(pChar.Position.Orientation);
            world.WriteFloat(pChar.Position.X);
            world.WriteFloat(pChar.Position.Z);
            session.Send(world);

            //LoadAccountData(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA), PER_CHARACTER_CACHE_MASK);
            //SendAccountDataTimes(PER_CHARACTER_CACHE_MASK);
            session.SendAccountDataTimes(AccountDataMasks.PerCharacterCacheMask);

            PacketWriter feature = new PacketWriter(Opcodes.SMSG_FeatureSystemStatus);

            feature.WriteUInt8(2);   // SystemStatus
            feature.WriteUInt32(1);  // Unknown, Mostly 1
            feature.WriteUInt32(1);  // Unknown, Mostly 1
            feature.WriteUInt32(2);  // Unknown, Mostly same as SystemStatus, but seen other values
            feature.WriteUInt32(0);  // Unknown, Hmm???

            feature.WriteBit(true);  // Unknown
            feature.WriteBit(true);  // Unknown
            feature.WriteBit(false); // Unknown
            feature.WriteBit(true);  // Unknown
            feature.WriteBit(false); // EnableVoiceChat, not sure
            feature.WriteBit(false); // Unknown
            feature.BitFlush();

            feature.WriteUInt32(1);    // Only seen 1
            feature.WriteUInt32(0);    // Unknown, like random values
            feature.WriteUInt32(0xA);  // Only seen 10
            feature.WriteUInt32(0x3C); // Only seen 60

            //session.Send(feature);

            MiscHandler.SendMOTD(ref session);

            //if (pChar.GuildGuid != 0)
            {
                //Guild guild = GuildMgr.GetGuildByGuid(pChar.GuildGuid);
                //if (guild != null)
                {
                    //var member = guild.GetMember(pChar.Guid);
                    //pChar.SetInGuild(pChar.GuildGuid);
                    //pChar.SetGuildRank(member.RankId);
                    //pChar.SetGuildLevel(guild.GetLevel());
                    //guild.HandleMemberLogin(pChar);
                }
                //else
                {
                    //pChar.SetInGuild(0);
                    //pChar.SetGuildRank(0);
                    //pChar.SetGuildLevel(0);
                }
            }

            PacketWriter data = new PacketWriter(Opcodes.SMSG_LearnedDanceMoves);

            data.WriteUInt64(0);
            //session.Send(data);

            //hotfix

            pChar.SendInitialPacketsBeforeAddToMap();

            /*
             * //Show cinematic at the first time that player login
             * if (!pCurrChar->getCinematic())
             * {
             *  pCurrChar->setCinematic(1);
             *
             *  if (ChrClassesEntry cEntry = sChrClassesStore.LookupEntry(pCurrChar->getClass()))
             *  {
             *      if (cEntry->CinematicSequence)
             *          pCurrChar->SendCinematicStart(cEntry->CinematicSequence);
             *      else if (ChrRacesEntry rEntry = sChrRacesStore.LookupEntry(pCurrChar->getRace()))
             *      pCurrChar->SendCinematicStart(rEntry->CinematicSequence);
             *
             *      // send new char string if not empty
             *      if (!sWorld->GetNewCharString().empty())
             *          chH.PSendSysMessage("%s", sWorld->GetNewCharString().c_str());
             *  }
             * }
             * if (Group* group = pCurrChar->GetGroup())
             * {
             *  if (group->isLFGGroup())
             *  {
             *      LfgDungeonSet Dungeons;
             *      Dungeons.insert(sLFGMgr->GetDungeon(group->GetGUID()));
             *      sLFGMgr->SetSelectedDungeons(pCurrChar->GetGUID(), Dungeons);
             *      sLFGMgr->SetState(pCurrChar->GetGUID(), sLFGMgr->GetState(group->GetGUID()));
             *  }
             * }
             */
            if (!pChar.GetMap().AddPlayer(pChar))//|| !pCurrChar.CheckInstanceLoginValid())
            {
                //AreaTrigger at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId());
                //if (at)
                //pCurrChar->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, pCurrChar->GetOrientation());
                //else
                //pCurrChar->TeleportTo(pCurrChar->m_homebindMapId, pCurrChar->m_homebindX, pCurrChar->m_homebindY, pCurrChar->m_homebindZ, pCurrChar->GetOrientation());
            }
            ObjMgr.AddObject(pChar);

            pChar.SendInitialPacketsAfterAddToMap();

            PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.CHAR_UPD_CHAR_ONLINE);

            stmt.AddValue(0, pChar.GetGUIDLow());
            DB.Characters.Execute(stmt);

            stmt = DB.Auth.GetPreparedStatement(LoginStatements.Upd_AccountOnline);
            stmt.AddValue(0, session.GetAccountId());
            DB.Auth.Execute(stmt);

            //pCurrChar->SetInGameTime(getMSTime());

            // announce group about member online (must be after add to player list to receive announce to self)
            //if (Group* group = pCurrChar->GetGroup())
            {
                //pCurrChar->groupInfo.group->SendInit(this); // useless
                //group->SendUpdate();
                //group->ResetMaxEnchantingLevel();
            }

            // friend status
            //sSocialMgr->SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUIDLow(), true);

            // Place character in world (and load zone) before some object loading
            //pCurrChar->LoadCorpse();

            // setting Ghost+speed if dead
            //if (pCurrChar->m_deathState != ALIVE)
            {
                // not blizz like, we must correctly save and load player instead...
                //if (pCurrChar->getRace() == RACE_NIGHTELF)
                //pCurrChar->CastSpell(pCurrChar, 20584, true, 0);// auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form)
                //pCurrChar->CastSpell(pCurrChar, 8326, true, 0);     // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?)

                //pCurrChar->SendMovementSetWaterWalking(true);
            }

            //pCurrChar->ContinueTaxiFlight();

            // reset for all pets before pet loading
            //if (pChar.HasAtLoginFlag(AtLoginFlags.ResetPetTalents))
            //resetTalentsForAllPetsOf(pCurrChar);

            // Load pet if any (if player not alive and in taxi flight or another then pet will remember as temporary unsummoned)
            //pCurrChar->LoadPet();

            // Set FFA PvP for non GM in non-rest mode
            //if (sWorld->IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING))
            //pCurrChar->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);

            //if (pChar.HasFlag(PlayerFields.PlayerFlags, PlayerFlags.ContestedPVP))
            //pChar->SetContestedPvP();

            // Apply at_login requests
            if (pChar.HasAtLoginFlag(AtLoginFlags.ResetSpells))
            {
                //pChar.resetSpells();
                pChar.SendNotification(CypherStrings.ResetSpells);
            }

            if (pChar.HasAtLoginFlag(AtLoginFlags.ResetTalents))
            {
                //pChar.ResetTalents(true);
                //pChar.SendTalentsInfoData(false);              // original talents send already in to SendInitialPacketsBeforeAddToMap, resend reset state
                pChar.SendNotification(CypherStrings.ResetTalents);
            }

            if (pChar.HasAtLoginFlag(AtLoginFlags.LoginFirst))
            {
                pChar.RemoveAtLoginFlag(AtLoginFlags.LoginFirst);
            }

            // show time before shutdown if shutdown planned.
            //if (sWorld->IsShuttingDown())
            //sWorld->ShutdownMsg(true, pChar);

            //if (sWorld->getBoolConfig(CONFIG_ALL_TAXI_PATHS))
            //pChar->SetTaxiCheater(true);

            if (pChar.isGameMaster())
            {
                pChar.SendNotification(CypherStrings.GmOn);
            }

            //string IP_str = GetRemoteAddress();
            Log.outDebug("Account: {0} (IP: {1}) Login Character:[{2}] (GUID: {3}) Level: {4}",
                         session.GetAccountId(), 0, pChar.GetName(), pChar.GetGUIDLow(), pChar.getLevel());

            //if (!pChar->IsStandState() && !pChar->HasUnitState(UNIT_STATE_STUNNED))
            //pChar->SetStandState(UNIT_STAND_STATE_STAND);

            //m_playerLoading = false;

            //sScriptMgr->OnPlayerLogin(pCurrChar);
        }
示例#26
0
        public static bool BuildEnumData(SQLResult result, ref PacketWriter data)
        {
            for (int c = 0; c < result.Count; c++)
            {
                ObjectGuid guid      = new ObjectGuid(result.Read <ulong>(c, 0));
                ObjectGuid guildGuid = new ObjectGuid();//result.Read<uint>(c, 13));
                string     name      = result.Read <string>(c, 1);

                data.WriteBit(guid[7]);
                data.WriteBit(guid[0]);
                data.WriteBit(guid[4]);
                data.WriteBit(guildGuid[2]);
                data.WriteBit(guid[5]);
                data.WriteBit(guid[3]);
                data.WriteBits(name.Length, 7);
                data.WriteBit(guildGuid[0]);
                data.WriteBit(guildGuid[5]);
                data.WriteBit(guildGuid[3]);
                data.WriteBit(0);
                data.WriteBit(guildGuid[6]);
                data.WriteBit(guildGuid[7]);
                data.WriteBit(guid[1]);
                data.WriteBit(guildGuid[4]);
                data.WriteBit(guildGuid[1]);
                data.WriteBit(guid[2]);
                data.WriteBit(guid[6]);
            }
            data.WriteBit(1);
            data.BitFlush();

            for (int c = 0; c < result.Count; c++)
            {
                ObjectGuid   guid         = new ObjectGuid(result.Read <ulong>(c, 0));
                string       name         = result.Read <string>(c, 1);
                byte         plrRace      = result.Read <byte>(c, 2);
                Class        plrClass     = (Class)result.Read <byte>(c, 3);
                byte         gender       = result.Read <byte>(c, 4);
                byte         skin         = (byte)(result.Read <uint>(c, 5) & 0xFF);
                byte         face         = (byte)((result.Read <uint>(c, 5) >> 8) & 0xFF);
                byte         hairStyle    = (byte)((result.Read <uint>(c, 5) >> 16) & 0xFF);
                byte         hairColor    = (byte)((result.Read <uint>(c, 5) >> 24) & 0xFF);
                byte         facialHair   = (byte)(result.Read <uint>(c, 6) & 0xFF);
                byte         level        = result.Read <byte>(c, 7);
                uint         zone         = result.Read <uint>(c, 8);
                uint         mapId        = result.Read <uint>(c, 9);
                float        x            = result.Read <float>(c, 10);
                float        y            = result.Read <float>(c, 11);
                float        z            = result.Read <float>(c, 12);
                ObjectGuid   guildGuid    = new ObjectGuid();//result.Read<ulong>(c, 13));
                PlayerFlags  playerFlags  = (PlayerFlags)result.Read <uint>(c, 14);
                AtLoginFlags atLoginFlags = (AtLoginFlags)result.Read <uint>(c, 15);
                string[]     equipment    = result.Read <string>(c, 19).Split(' ');
                byte         slot         = result.Read <byte>(c, 21);

                CharacterFlags charFlags = 0;
                if (Convert.ToBoolean(playerFlags & PlayerFlags.HideHelm))
                {
                    charFlags |= CharacterFlags.HideHelm;
                }

                if (Convert.ToBoolean(playerFlags & PlayerFlags.HideCloak))
                {
                    charFlags |= CharacterFlags.HideCloak;
                }

                if (Convert.ToBoolean(playerFlags & PlayerFlags.Ghost))
                {
                    charFlags |= CharacterFlags.Ghost;
                }

                if (Convert.ToBoolean(atLoginFlags & AtLoginFlags.Rename))
                {
                    charFlags |= CharacterFlags.Rename;
                }

                //if (result.Read<uint>(c, 20) != 0)
                //charFlags |= CharacterFlags.LockedByBilling;

                //if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED) && !fields[22].GetString().empty())
                //charFlags |= CHARACTER_FLAG_DECLINED;

                CharacterCustomizeFlags customizationFlag = 0;
                if (Convert.ToBoolean(atLoginFlags & AtLoginFlags.Customize))
                {
                    customizationFlag = CharacterCustomizeFlags.Customize;
                }
                else if (Convert.ToBoolean(atLoginFlags & AtLoginFlags.ChangeFaction))
                {
                    customizationFlag = CharacterCustomizeFlags.Faction;
                }
                else if (Convert.ToBoolean(atLoginFlags & AtLoginFlags.ChangeRace))
                {
                    customizationFlag = CharacterCustomizeFlags.Race;
                }

                uint petDisplayId = 0;
                uint petLevel     = 0;
                uint petFamily    = 0;
                // show pet at selection character in character list only for non-ghost character
                if (!Convert.ToBoolean(playerFlags & PlayerFlags.Ghost) && (plrClass == Class.Warlock || plrClass == Class.Hunter || plrClass == Class.Deathknight))
                {
                    //uint entry = result.Read<uint>(c, 16);
                    //var creatureInfo = ObjMgr.GetCreatureTemplate(entry);
                    //if (creatureInfo != null)
                    {
                        //petDisplayId = result.Read<uint>(c, 17);
                        //petLevel = result.Read<uint>(c, 18);
                        //petFamily = creatureInfo.Family;
                    }
                }

                data.WriteUInt32(charFlags);
                data.WriteUInt32(petFamily);
                data.WriteFloat(z);
                data.WriteByteSeq(guid[7]);
                data.WriteByteSeq(guildGuid[6]);

                for (uint i = 0; i < InventorySlots.BagEnd; ++i)
                {
                    uint index = i * 2;
                    uint itemId;
                    uint.TryParse(equipment[index], out itemId);
                    var entry = ObjMgr.GetItemTemplate(itemId);
                    if (entry == null)
                    {
                        data.WriteInt32(0);
                        data.WriteInt8(0);
                        data.WriteInt32(0);
                        continue;
                    }

                    uint enchants;
                    SpellItemEnchantmentEntry enchant = null;
                    uint.TryParse(equipment[index + 1], out enchants);
                    for (int enchantSlot = (int)EnchantmentSlot.PERM_ENCHANTMENT_SLOT; enchantSlot <= (int)EnchantmentSlot.TEMP_ENCHANTMENT_SLOT; enchantSlot++)
                    {
                        // values stored in 2 uint16
                        uint enchantId = 0x0000FFFF & (enchants >> enchantSlot * 16);
                        if (enchantId == 0)
                        {
                            continue;
                        }

                        enchant = DBCStorage.SpellItemEnchantmentStorage.LookupByKey(enchantId);
                        if (enchant != null)
                        {
                            break;
                        }
                    }
                    data.WriteInt32(0);//enchant != null ? enchant.aura_id : 0);
                    data.WriteInt8(entry.inventoryType);
                    data.WriteInt32(entry.DisplayInfoID);
                }

                data.WriteFloat(x);
                data.WriteUInt8(plrClass);
                data.WriteByteSeq(guid[5]);
                data.WriteFloat(y);
                data.WriteByteSeq(guildGuid[3]);
                data.WriteByteSeq(guid[6]);
                data.WriteUInt32(petLevel);
                data.WriteUInt32(petDisplayId);
                data.WriteByteSeq(guid[2]);
                data.WriteByteSeq(guid[1]);
                data.WriteUInt8(hairColor);
                data.WriteUInt8(facialHair);
                data.WriteByteSeq(guildGuid[2]);
                data.WriteUInt32(zone);
                data.WriteUInt8(slot);                                    // List order
                data.WriteByteSeq(guid[0]);
                data.WriteByteSeq(guildGuid[1]);
                data.WriteUInt8(skin);
                data.WriteByteSeq(guid[4]);
                data.WriteByteSeq(guildGuid[5]);
                data.WriteString(name);
                data.WriteByteSeq(guildGuid[0]);
                data.WriteUInt8(level);
                data.WriteByteSeq(guid[3]);
                data.WriteByteSeq(guildGuid[7]);
                data.WriteUInt8(hairStyle);
                data.WriteByteSeq(guildGuid[4]);
                data.WriteUInt8(gender);
                data.WriteUInt32(mapId);
                data.WriteUInt32((uint)customizationFlag);
                data.WriteUInt8(plrRace);
                data.WriteUInt8(face);
            }
            return(true);
        }
示例#27
0
        public void SendRoster(WorldSession session = null)
        {
            PacketWriter writer = new PacketWriter(Opcodes.SMSG_GuildRoster);

            int size = GetMemberSize();

            writer.WriteBits(MOTD.Length, 11);
            writer.WriteBits(size, 18);

            foreach (Member pmember in MemberList)
            {
                var guid = pmember.CharGuid;

                writer.WriteBit(guid[3]);
                writer.WriteBit(guid[4]);
                writer.WriteBit(false); //Has Authenticator
                writer.WriteBit(false); //Can SoR
                writer.WriteBits(pmember.PublicNote.Length, 8);
                writer.WriteBits(pmember.OfficerNote.Length, 8);
                writer.WriteBit(guid[0]);
                writer.WriteBits(pmember.Name.Length, 7);
                writer.WriteBit(guid[1]);
                writer.WriteBit(guid[2]);
                writer.WriteBit(guid[6]);
                writer.WriteBit(guid[5]);
                writer.WriteBit(guid[7]);
            }
            writer.WriteBits(INFO.Length, 12);
            writer.BitFlush();
            foreach (Member pmember in MemberList)
            {
                Player pl = ObjMgr.FindPlayer(pmember.CharGuid);

                if (pl != null)
                {
                    var guid = new ObjectGuid(pl.GetGUIDLow());
                    writer.WriteUInt8(pl.getClass());
                    writer.WriteUInt32(0); //Guild Reputation
                    writer.WriteByteSeq(guid[0]);
                    writer.WriteUInt64(0); //week activity
                    writer.WriteUInt32(pmember.RankId);
                    writer.WriteUInt32(0); //GetAchievementPoints());

                    for (int j = 0; j < 2; j++)
                    {
                        writer.WriteUInt32(pmember.ProfessionList[j].Rank);
                        writer.WriteUInt32(pmember.ProfessionList[j].Level);
                        writer.WriteUInt32(pmember.ProfessionList[j].SkillId);
                    }

                    writer.WriteByteSeq(guid[2]);
                    writer.WriteUInt8((byte)GuildMemberFlags.Online);
                    writer.WriteUInt32(pl.GetZoneId());
                    writer.WriteUInt64(0); //total activity
                    writer.WriteByteSeq(guid[7]);
                    writer.WriteUInt32(0); // remaining guild week rep
                    writer.Write(pmember.PublicNote.ToCharArray());
                    writer.WriteByteSeq(guid[3]);
                    writer.WriteUInt8((byte)pl.getLevel());
                    writer.WriteUInt32(0);//unk
                    writer.WriteByteSeq(guid[5]);
                    writer.WriteByteSeq(guid[4]);
                    writer.WriteUInt8(0);//unk
                    writer.WriteByteSeq(guid[1]);
                    writer.WriteFloat(0);
                    writer.Write(pmember.OfficerNote.ToCharArray());
                    writer.WriteByteSeq(guid[6]);
                    writer.Write(pl.Name.ToCharArray());
                }
                else
                {
                    var guid = pmember.CharGuid;

                    writer.WriteUInt8(pmember.Class);
                    writer.WriteUInt32(0);              //unk
                    writer.WriteByteSeq(guid[0]);
                    writer.WriteUInt64(0);              //week activity
                    writer.WriteUInt32(pmember.RankId); //rank
                    writer.WriteUInt32(0);              //GetAchievementPoints());

                    for (int j = 0; j < 2; j++)
                    {
                        writer.WriteUInt32(pmember.ProfessionList[j].Rank);
                        writer.WriteUInt32(pmember.ProfessionList[j].Level);
                        writer.WriteUInt32(pmember.ProfessionList[j].SkillId);
                    }
                    writer.WriteByteSeq(guid[2]);
                    writer.WriteUInt8((byte)GuildMemberFlags.Offline);
                    writer.WriteUInt32(pmember.ZoneId);
                    writer.WriteUInt64(0); //total activity
                    writer.WriteByteSeq(guid[7]);
                    writer.WriteUInt32(0); // remaining guild rep
                    writer.Write(pmember.PublicNote.ToCharArray());
                    writer.WriteByteSeq(guid[3]);
                    writer.WriteUInt8((byte)pmember.Level);
                    writer.WriteUInt32(0);//unk
                    writer.WriteByteSeq(guid[5]);
                    writer.WriteByteSeq(4);
                    writer.WriteUInt8(0);                                                                                                                   //unk
                    writer.WriteByteSeq(guid[1]);
                    writer.WriteFloat(Convert.ToSingle(new TimeSpan((DateTime.UtcNow.Ticks - (long)pmember.LogoutTime) / (int)TimeConstants.Day).Minutes)); // ?? time(NULL)-itr2->second.LogoutTime) / DAY);
                    writer.Write(pmember.OfficerNote.ToCharArray());
                    writer.WriteByteSeq(guid[6]);
                    writer.Write(pmember.Name.ToCharArray());
                }
            }
            writer.Write(INFO.ToCharArray());
            writer.Write(MOTD.ToCharArray());
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);

            if (session != null)
            {
                session.Send(writer);
            }
            else
            {
                BroadcastPacket(writer);
            }
        }
示例#28
0
        public static bool Delete(string[] args, CommandGroup command)
        {
            if (args.Length < 1)
            {
                return(false);
            }

            string account = args[0];

            if (account == string.Empty)
            {
                return(false);
            }

            if (!account.Contains("@"))
            {
                return(command.SendSysMessage("Account name requires an email address"));
            }

            PreparedStatement stmt = DB.Auth.GetPreparedStatement(LoginStatements.Get_AccountIDByUsername);

            stmt.AddValue(0, account);
            SQLResult result = DB.Auth.Select(stmt);


            if (result.Count == 0)
            {
                command.SendErrorMessage(CypherStrings.AccountNotExist, account);
            }

            uint accountId = result.Read <uint>(0, 0);

            stmt = DB.Characters.GetPreparedStatement(CharStatements.CHAR_SEL_CHARS_BY_ACCOUNT_ID);
            stmt.AddValue(0, accountId);
            result = DB.Characters.Select(stmt);

            if (result.Count != 0)
            {
                for (var i = 0; i < result.Count; i++)
                {
                    uint guidLow = result.Read <uint>(i, 0);

                    // Kick if player is online
                    Player pl = ObjMgr.FindPlayer(guidLow);
                    if (pl != null)
                    {
                        WorldSession s = pl.GetSession();
                        s.KickPlayer();                            // mark session to remove at next session list update
                        //s.LogoutPlayer(false);                     // logout player without waiting next session list update
                    }

                    //Player::DeleteFromDB(guid, accountId, false);       // no need to update realm characters todo fixme
                }
            }

            stmt = DB.Characters.GetPreparedStatement(CharStatements.CHAR_DEL_TUTORIALS);
            stmt.AddValue(0, accountId);
            DB.Characters.Execute(stmt);

            stmt = DB.Characters.GetPreparedStatement(CharStatements.CHAR_DEL_ACCOUNT_DATA);
            stmt.AddValue(0, accountId);
            DB.Characters.Execute(stmt);

            stmt = DB.Characters.GetPreparedStatement(CharStatements.CHAR_DEL_CHARACTER_BAN);
            stmt.AddValue(0, accountId);
            DB.Characters.Execute(stmt);

            stmt = DB.Auth.GetPreparedStatement(LoginStatements.Del_Account);
            stmt.AddValue(0, accountId);
            DB.Auth.Execute(stmt);

            stmt = DB.Auth.GetPreparedStatement(LoginStatements.Del_account_access);
            stmt.AddValue(0, accountId);
            DB.Auth.Execute(stmt);

            stmt = DB.Auth.GetPreparedStatement(LoginStatements.Del_RealmCharacters);
            stmt.AddValue(0, accountId);
            DB.Auth.Execute(stmt);

            stmt = DB.Auth.GetPreparedStatement(LoginStatements.Del_AccountBanned);
            stmt.AddValue(0, accountId);
            DB.Auth.Execute(stmt);

            return(command.SendSysMessage(CypherStrings.AccountDeleted, account));
        }
示例#29
0
        public void DeleteMember(ulong guid)
        {
            Player player = ObjMgr.FindPlayer(guid);

            if (GetLeaderGuid() == guid)
            {
                Member oldLeader = null;
                Member newLeader = null;
                foreach (var member in MemberList.OrderBy(p => p.RankId))
                {
                    if (member.CharGuid == guid)
                    {
                        oldLeader = member;
                    }
                    else if (newLeader == null || newLeader.RankId > member.RankId)
                    {
                        newLeader = member;
                    }
                }

                if (newLeader == null)
                {
                    Disband();
                    return;
                }

                SetLeader(newLeader);

                Player newLeaderPlayer = ObjMgr.FindPlayer(newLeader.CharGuid);
                if (newLeaderPlayer != null)
                {
                    newLeaderPlayer.SetGuildRank((uint)GuildDefaultRanks.Master);
                }

                if (oldLeader != null)
                {
                    SendBroadcastEvent(GuildEvents.LeaderChanged, 0, oldLeader.Name, newLeader.Name);
                    SendBroadcastEvent(GuildEvents.Left, guid, oldLeader.Name);
                }
            }
            Member m = GetMember(guid);

            if (m == null)
            {
                return;
            }
            MemberList.Remove(m);

            if (player != null)
            {
                player.SetInGuild(0);
                player.SetGuildRank(0);
                player.SetGuildLevel(0);

                /*
                 * for (uint32 i = 0; i < sGuildPerkSpellsStore.GetNumRows(); ++i)
                 *  if (GuildPerkSpellsEntry const* entry = sGuildPerkSpellsStore.LookupEntry(i))
                 * if (entry->Level >= GetLevel())
                 *  player->removeSpell(entry->SpellId, false, false);
                 */
            }
            PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.GuildDelMember);

            stmt.AddValue(0, guid);
            DB.Characters.Execute(stmt);
        }