예제 #1
0
        public void LoadRBAC()
        {
            ClearRBAC();

            Log.outDebug(LogFilter.Rbac, "AccountMgr:LoadRBAC");
            uint oldMSTime = Time.GetMSTime();
            uint count1    = 0;
            uint count2    = 0;
            uint count3    = 0;

            Log.outDebug(LogFilter.Rbac, "AccountMgr:LoadRBAC: Loading permissions");
            SQLResult result = DB.Login.Query("SELECT id, name FROM rbac_permissions");

            if (result.IsEmpty())
            {
                Log.outInfo(LogFilter.ServerLoading, "Loaded 0 account permission definitions. DB table `rbac_permissions` is empty.");
                return;
            }

            do
            {
                uint id = result.Read <uint>(0);
                _permissions[id] = new RBACPermission(id, result.Read <string>(1));
                ++count1;
            }while (result.NextRow());

            Log.outDebug(LogFilter.Rbac, "AccountMgr:LoadRBAC: Loading linked permissions");
            result = DB.Login.Query("SELECT id, linkedId FROM rbac_linked_permissions ORDER BY id ASC");
            if (result.IsEmpty())
            {
                Log.outInfo(LogFilter.ServerLoading, "Loaded 0 linked permissions. DB table `rbac_linked_permissions` is empty.");
                return;
            }

            uint           permissionId = 0;
            RBACPermission permission   = null;

            do
            {
                uint newId = result.Read <uint>(0);
                if (permissionId != newId)
                {
                    permissionId = newId;
                    permission   = _permissions[newId];
                }

                uint linkedPermissionId = result.Read <uint>(1);
                if (linkedPermissionId == permissionId)
                {
                    Log.outError(LogFilter.Sql, "RBAC Permission {0} has itself as linked permission. Ignored", permissionId);
                    continue;
                }
                permission.AddLinkedPermission(linkedPermissionId);
                ++count2;
            }while (result.NextRow());

            Log.outDebug(LogFilter.Rbac, "AccountMgr:LoadRBAC: Loading default permissions");
            result = DB.Login.Query("SELECT secId, permissionId FROM rbac_default_permissions ORDER BY secId ASC");
            if (result.IsEmpty())
            {
                Log.outInfo(LogFilter.ServerLoading, "Loaded 0 default permission definitions. DB table `rbac_default_permissions` is empty.");
                return;
            }

            uint secId = 255;

            do
            {
                uint newId = result.Read <uint>(0);
                if (secId != newId)
                {
                    secId = newId;
                }

                _defaultPermissions.Add((byte)secId, result.Read <uint>(1));
                ++count3;
            }while (result.NextRow());

            Log.outInfo(LogFilter.ServerLoading, "Loaded {0} permission definitions, {1} linked permissions and {2} default permissions in {3} ms", count1, count2, count3, Time.GetMSTimeDiffToNow(oldMSTime));
        }
예제 #2
0
        void HandleRequestBattlefieldStatus(RequestBattlefieldStatus packet)
        {
            // we must update all queues here
            Battleground bg = null;

            for (byte i = 0; i < SharedConst.MaxPlayerBGQueues; ++i)
            {
                BattlegroundQueueTypeId bgQueueTypeId = GetPlayer().GetBattlegroundQueueTypeId(i);
                if (bgQueueTypeId == 0)
                {
                    continue;
                }

                BattlegroundTypeId bgTypeId  = Global.BattlegroundMgr.BGTemplateId(bgQueueTypeId);
                ArenaTypes         arenaType = Global.BattlegroundMgr.BGArenaType(bgQueueTypeId);
                if (bgTypeId == GetPlayer().GetBattlegroundTypeId())
                {
                    bg = GetPlayer().GetBattleground();
                    //i cannot check any variable from player class because player class doesn't know if player is in 2v2 / 3v3 or 5v5 arena
                    //so i must use bg pointer to get that information
                    if (bg && bg.GetArenaType() == arenaType)
                    {
                        BattlefieldStatusActive battlefieldStatus;
                        Global.BattlegroundMgr.BuildBattlegroundStatusActive(out battlefieldStatus, bg, GetPlayer(), i, GetPlayer().GetBattlegroundQueueJoinTime(bgQueueTypeId), arenaType);
                        SendPacket(battlefieldStatus);
                        continue;
                    }
                }

                //we are sending update to player about queue - he can be invited there!
                //get GroupQueueInfo for queue status
                BattlegroundQueue bgQueue = Global.BattlegroundMgr.GetBattlegroundQueue(bgQueueTypeId);
                GroupQueueInfo    ginfo;
                if (!bgQueue.GetPlayerGroupInfoData(GetPlayer().GetGUID(), out ginfo))
                {
                    continue;
                }

                if (ginfo.IsInvitedToBGInstanceGUID != 0)
                {
                    bg = Global.BattlegroundMgr.GetBattleground(ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
                    if (!bg)
                    {
                        continue;
                    }

                    BattlefieldStatusNeedConfirmation battlefieldStatus;
                    Global.BattlegroundMgr.BuildBattlegroundStatusNeedConfirmation(out battlefieldStatus, bg, GetPlayer(), i, GetPlayer().GetBattlegroundQueueJoinTime(bgQueueTypeId), Time.GetMSTimeDiff(Time.GetMSTime(), ginfo.RemoveInviteTime), arenaType);
                    SendPacket(battlefieldStatus);
                }
                else
                {
                    bg = Global.BattlegroundMgr.GetBattlegroundTemplate(bgTypeId);
                    if (!bg)
                    {
                        continue;
                    }

                    // expected bracket entry
                    PvpDifficultyRecord bracketEntry = Global.DB2Mgr.GetBattlegroundBracketByLevel(bg.GetMapId(), GetPlayer().getLevel());
                    if (bracketEntry == null)
                    {
                        continue;
                    }

                    uint avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry.GetBracketId());
                    BattlefieldStatusQueued battlefieldStatus;
                    Global.BattlegroundMgr.BuildBattlegroundStatusQueued(out battlefieldStatus, bg, GetPlayer(), i, GetPlayer().GetBattlegroundQueueJoinTime(bgQueueTypeId), avgTime, arenaType, ginfo.Players.Count > 1);
                    SendPacket(battlefieldStatus);
                }
            }
        }
예제 #3
0
        void HandleTextEmote(CTextEmote packet)
        {
            if (!GetPlayer().IsAlive())
            {
                return;
            }

            if (!GetPlayer().CanSpeak())
            {
                string timeStr = Time.secsToTimeString((ulong)(m_muteTime - Time.UnixTime));
                SendNotification(CypherStrings.WaitBeforeSpeaking, timeStr);
                return;
            }

            Global.ScriptMgr.OnPlayerTextEmote(GetPlayer(), (uint)packet.SoundIndex, (uint)packet.EmoteID, packet.Target);

            EmotesTextRecord em = CliDB.EmotesTextStorage.LookupByKey(packet.EmoteID);

            if (em == null)
            {
                return;
            }

            uint emote_anim = em.EmoteId;

            switch ((Emote)emote_anim)
            {
            case Emote.StateSleep:
            case Emote.StateSit:
            case Emote.StateKneel:
            case Emote.OneshotNone:
                break;

            case Emote.StateDance:
            case Emote.StateRead:
                GetPlayer().SetEmoteState((Emote)emote_anim);
                break;

            default:
                // Only allow text-emotes for "dead" entities (feign death included)
                if (GetPlayer().HasUnitState(UnitState.Died))
                {
                    break;
                }
                GetPlayer().HandleEmoteCommand((Emote)emote_anim);
                break;
            }

            STextEmote textEmote = new STextEmote();

            textEmote.SourceGUID        = GetPlayer().GetGUID();
            textEmote.SourceAccountGUID = GetAccountGUID();
            textEmote.TargetGUID        = packet.Target;
            textEmote.EmoteID           = packet.EmoteID;
            textEmote.SoundIndex        = packet.SoundIndex;
            GetPlayer().SendMessageToSetInRange(textEmote, WorldConfig.GetFloatValue(WorldCfg.ListenRangeTextemote), true);

            Unit unit = Global.ObjAccessor.GetUnit(GetPlayer(), packet.Target);

            GetPlayer().UpdateCriteria(CriteriaTypes.DoEmote, (uint)packet.EmoteID, 0, 0, unit);

            // Send scripted event call
            if (unit)
            {
                Creature creature = unit.ToCreature();
                if (creature)
                {
                    creature.GetAI().ReceiveEmote(GetPlayer(), (TextEmotes)packet.EmoteID);
                }
            }
        }
예제 #4
0
        void HandleMovementOpcode(ClientOpcodes opcode, MovementInfo movementInfo)
        {
            Unit   mover    = GetPlayer().m_unitMovedByMe;
            Player plrMover = mover.ToPlayer();

            if (plrMover && plrMover.IsBeingTeleported())
            {
                return;
            }

            GetPlayer().ValidateMovementInfo(movementInfo);

            if (movementInfo.Guid != mover.GetGUID())
            {
                Log.outError(LogFilter.Network, "HandleMovementOpcodes: guid error");
                return;
            }
            if (!movementInfo.Pos.IsPositionValid())
            {
                Log.outError(LogFilter.Network, "HandleMovementOpcodes: Invalid Position");
                return;
            }

            // stop some emotes at player move
            if (plrMover && (plrMover.GetUInt32Value(UnitFields.NpcEmotestate) != 0))
            {
                plrMover.SetUInt32Value(UnitFields.NpcEmotestate, (uint)Emote.OneshotNone);
            }

            //handle special cases
            if (!movementInfo.transport.guid.IsEmpty())
            {
                if (movementInfo.transport.pos.GetPositionX() > 50 || movementInfo.transport.pos.GetPositionY() > 50 || movementInfo.transport.pos.GetPositionZ() > 50)
                {
                    return;
                }

                if (!GridDefines.IsValidMapCoord(movementInfo.Pos.posX + movementInfo.transport.pos.posX, movementInfo.Pos.posY + movementInfo.transport.pos.posY,
                                                 movementInfo.Pos.posZ + movementInfo.transport.pos.posZ, movementInfo.Pos.Orientation + movementInfo.transport.pos.Orientation))
                {
                    return;
                }

                if (plrMover)
                {
                    if (!plrMover.GetTransport())
                    {
                        Transport transport = plrMover.GetMap().GetTransport(movementInfo.transport.guid);
                        if (transport)
                        {
                            transport.AddPassenger(plrMover);
                        }
                    }
                    else if (plrMover.GetTransport().GetGUID() != movementInfo.transport.guid)
                    {
                        plrMover.GetTransport().RemovePassenger(plrMover);
                        Transport transport = plrMover.GetMap().GetTransport(movementInfo.transport.guid);
                        if (transport)
                        {
                            transport.AddPassenger(plrMover);
                        }
                        else
                        {
                            movementInfo.ResetTransport();
                        }
                    }
                }

                if (!mover.GetTransport() && !mover.GetVehicle())
                {
                    GameObject go = mover.GetMap().GetGameObject(movementInfo.transport.guid);
                    if (!go || go.GetGoType() != GameObjectTypes.Transport)
                    {
                        movementInfo.transport.Reset();
                    }
                }
            }
            else if (plrMover && plrMover.GetTransport())                // if we were on a transport, leave
            {
                plrMover.GetTransport().RemovePassenger(plrMover);
            }

            // fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map).
            if (opcode == ClientOpcodes.MoveFallLand && plrMover && !plrMover.IsInFlight())
            {
                plrMover.HandleFall(movementInfo);
            }

            if (plrMover && movementInfo.HasMovementFlag(MovementFlag.Swimming) != plrMover.IsInWater())
            {
                // now client not include swimming flag in case jumping under water
                plrMover.SetInWater(!plrMover.IsInWater() || plrMover.GetMap().IsUnderWater(plrMover.GetPhaseShift(), movementInfo.Pos.posX, movementInfo.Pos.posY, movementInfo.Pos.posZ));
            }

            uint mstime = Time.GetMSTime();

            if (m_clientTimeDelay == 0)
            {
                m_clientTimeDelay = mstime - movementInfo.Time;
            }

            movementInfo.Time = movementInfo.Time + m_clientTimeDelay;

            movementInfo.Guid    = mover.GetGUID();
            mover.m_movementInfo = movementInfo;

            // Some vehicles allow the passenger to turn by himself
            Vehicle vehicle = mover.GetVehicle();

            if (vehicle)
            {
                VehicleSeatRecord seat = vehicle.GetSeatForPassenger(mover);
                if (seat != null)
                {
                    if (seat.Flags.HasAnyFlag(VehicleSeatFlags.AllowTurning))
                    {
                        if (movementInfo.Pos.GetOrientation() != mover.GetOrientation())
                        {
                            mover.SetOrientation(movementInfo.Pos.GetOrientation());
                            mover.RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Turning);
                        }
                    }
                }
                return;
            }

            mover.UpdatePosition(movementInfo.Pos);

            MoveUpdate moveUpdate = new MoveUpdate();

            moveUpdate.Status = mover.m_movementInfo;
            mover.SendMessageToSet(moveUpdate, GetPlayer());

            if (plrMover)                                            // nothing is charmed, or player charmed
            {
                if (plrMover.IsSitState() && movementInfo.HasMovementFlag(MovementFlag.MaskMoving | MovementFlag.MaskTurning))
                {
                    plrMover.SetStandState(UnitStandStateType.Stand);
                }

                plrMover.UpdateFallInformationIfNeed(movementInfo, opcode);

                if (movementInfo.Pos.posZ < plrMover.GetMap().GetMinHeight(movementInfo.Pos.GetPositionX(), movementInfo.Pos.GetPositionY()))
                {
                    if (!(plrMover.GetBattleground() && plrMover.GetBattleground().HandlePlayerUnderMap(GetPlayer())))
                    {
                        // NOTE: this is actually called many times while falling
                        // even after the player has been teleported away
                        /// @todo discard movement packets after the player is rooted
                        if (plrMover.IsAlive())
                        {
                            plrMover.SetFlag(PlayerFields.Flags, PlayerFlags.IsOutOfBounds);
                            plrMover.EnvironmentalDamage(EnviromentalDamage.FallToVoid, (uint)GetPlayer().GetMaxHealth());
                            // player can be alive if GM/etc
                            // change the death state to CORPSE to prevent the death timer from
                            // starting in the next player update
                            if (plrMover.IsAlive())
                            {
                                plrMover.KillPlayer();
                            }
                        }
                    }
                }
                else
                {
                    plrMover.RemoveFlag(PlayerFields.Flags, PlayerFlags.IsOutOfBounds);
                }
            }
        }
예제 #5
0
        public void LoadCreatureTexts()
        {
            uint oldMSTime = Time.GetMSTime();

            mTextMap.Clear(); // for reload case
            //all currently used temp texts are NOT reset

            PreparedStatement stmt   = DB.World.GetPreparedStatement(WorldStatements.SEL_CREATURE_TEXT);
            SQLResult         result = DB.World.Query(stmt);

            if (result.IsEmpty())
            {
                Log.outInfo(LogFilter.ServerLoading, "Loaded 0 ceature texts. DB table `creature_texts` is empty.");
                return;
            }

            uint textCount     = 0;
            uint creatureCount = 0;

            do
            {
                CreatureTextEntry temp = new();

                temp.creatureId      = result.Read <uint>(0);
                temp.groupId         = result.Read <byte>(1);
                temp.id              = result.Read <byte>(2);
                temp.text            = result.Read <string>(3);
                temp.type            = (ChatMsg)result.Read <byte>(4);
                temp.lang            = (Language)result.Read <byte>(5);
                temp.probability     = result.Read <float>(6);
                temp.emote           = (Emote)result.Read <uint>(7);
                temp.duration        = result.Read <uint>(8);
                temp.sound           = result.Read <uint>(9);
                temp.BroadcastTextId = result.Read <uint>(10);
                temp.TextRange       = (CreatureTextRange)result.Read <byte>(11);

                if (temp.sound != 0)
                {
                    if (!CliDB.SoundKitStorage.ContainsKey(temp.sound))
                    {
                        Log.outError(LogFilter.Sql, "GossipManager:  Entry {0}, Group {1} in table `creature_texts` has Sound {2} but sound does not exist.", temp.creatureId, temp.groupId, temp.sound);
                        temp.sound = 0;
                    }
                }
                if (ObjectManager.GetLanguageDescByID(temp.lang) == null)
                {
                    Log.outError(LogFilter.Sql, "GossipManager:  Entry {0}, Group {1} in table `creature_texts` using Language {2} but Language does not exist.", temp.creatureId, temp.groupId, temp.lang);
                    temp.lang = Language.Universal;
                }
                if (temp.type >= ChatMsg.Max)
                {
                    Log.outError(LogFilter.Sql, "GossipManager:  Entry {0}, Group {1} in table `creature_texts` has Type {2} but this Chat Type does not exist.", temp.creatureId, temp.groupId, temp.type);
                    temp.type = ChatMsg.Say;
                }
                if (temp.emote != 0)
                {
                    if (!CliDB.EmotesStorage.ContainsKey((uint)temp.emote))
                    {
                        Log.outError(LogFilter.Sql, "GossipManager:  Entry {0}, Group {1} in table `creature_texts` has Emote {2} but emote does not exist.", temp.creatureId, temp.groupId, temp.emote);
                        temp.emote = Emote.OneshotNone;
                    }
                }

                if (temp.BroadcastTextId != 0)
                {
                    if (!CliDB.BroadcastTextStorage.ContainsKey(temp.BroadcastTextId))
                    {
                        Log.outError(LogFilter.Sql, "CreatureTextMgr: Entry {0}, Group {1}, Id {2} in table `creature_texts` has non-existing or incompatible BroadcastTextId {3}.", temp.creatureId, temp.groupId, temp.id, temp.BroadcastTextId);
                        temp.BroadcastTextId = 0;
                    }
                }

                if (temp.TextRange > CreatureTextRange.World)
                {
                    Log.outError(LogFilter.Sql, "CreatureTextMgr: Entry {0}, Group {1}, Id {2} in table `creature_text` has incorrect TextRange {3}.", temp.creatureId, temp.groupId, temp.id, temp.TextRange);
                    temp.TextRange = CreatureTextRange.Normal;
                }

                if (!mTextMap.ContainsKey(temp.creatureId))
                {
                    mTextMap[temp.creatureId] = new MultiMap <byte, CreatureTextEntry>();
                    ++creatureCount;
                }

                mTextMap[temp.creatureId].Add(temp.groupId, temp);
                ++textCount;
            } while (result.NextRow());

            Log.outInfo(LogFilter.ServerLoading, "Loaded {0} creature texts for {1} creatures in {2} ms", textCount, creatureCount, Time.GetMSTimeDiffToNow(oldMSTime));
        }
예제 #6
0
        void HandleChat(ChatMsg type, Language lang, string msg, string target = "")
        {
            Player sender = GetPlayer();

            if (lang == Language.Universal && type != ChatMsg.Emote)
            {
                Log.outError(LogFilter.Network, "CMSG_MESSAGECHAT: Possible hacking-attempt: {0} tried to send a message in universal language", GetPlayerInfo());
                SendNotification(CypherStrings.UnknownLanguage);
                return;
            }

            // prevent talking at unknown language (cheating)
            LanguageDesc langDesc = ObjectManager.GetLanguageDescByID(lang);

            if (langDesc == null)
            {
                SendNotification(CypherStrings.UnknownLanguage);
                return;
            }

            if (langDesc.skill_id != 0 && !sender.HasSkill((SkillType)langDesc.skill_id))
            {
                // also check SPELL_AURA_COMPREHEND_LANGUAGE (client offers option to speak in that language)
                var  langAuras = sender.GetAuraEffectsByType(AuraType.ComprehendLanguage);
                bool foundAura = false;
                foreach (var eff in langAuras)
                {
                    if (eff.GetMiscValue() == (int)lang)
                    {
                        foundAura = true;
                        break;
                    }
                }
                if (!foundAura)
                {
                    SendNotification(CypherStrings.NotLearnedLanguage);
                    return;
                }
            }

            // 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 (HasPermission(RBACPermissions.TwoSideInteractionChat))
                {
                    lang = Language.Universal;
                }
                else
                {
                    switch (type)
                    {
                    case ChatMsg.Party:
                    case ChatMsg.Raid:
                    case ChatMsg.RaidWarning:
                        // allow two side chat at group channel if two side group allowed
                        if (WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionGroup))
                        {
                            lang = Language.Universal;
                        }
                        break;

                    case ChatMsg.Guild:
                    case ChatMsg.Officer:
                        // allow two side chat at guild channel if two side guild allowed
                        if (WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionGuild))
                        {
                            lang = Language.Universal;
                        }
                        break;
                    }
                }
                // but overwrite it by SPELL_AURA_MOD_LANGUAGE auras (only single case used)
                var ModLangAuras = sender.GetAuraEffectsByType(AuraType.ModLanguage);
                if (!ModLangAuras.Empty())
                {
                    lang = (Language)ModLangAuras.FirstOrDefault().GetMiscValue();
                }
            }

            if (!sender.CanSpeak())
            {
                string timeStr = Time.secsToTimeString((ulong)(m_muteTime - Time.UnixTime));
                SendNotification(CypherStrings.WaitBeforeSpeaking, timeStr);
                return;
            }

            if (sender.HasAura(1852) && type != ChatMsg.Whisper)
            {
                SendNotification(Global.ObjectMgr.GetCypherString(CypherStrings.GmSilence), sender.GetName());
                return;
            }

            if (string.IsNullOrEmpty(msg))
            {
                return;
            }

            if (new CommandHandler(this).ParseCommand(msg))
            {
                return;
            }

            switch (type)
            {
            case ChatMsg.Say:
                // Prevent cheating
                if (!sender.IsAlive())
                {
                    return;
                }

                if (sender.GetLevel() < WorldConfig.GetIntValue(WorldCfg.ChatSayLevelReq))
                {
                    SendNotification(Global.ObjectMgr.GetCypherString(CypherStrings.SayReq), WorldConfig.GetIntValue(WorldCfg.ChatSayLevelReq));
                    return;
                }

                sender.Say(msg, lang);
                break;

            case ChatMsg.Emote:
                // Prevent cheating
                if (!sender.IsAlive())
                {
                    return;
                }

                if (sender.GetLevel() < WorldConfig.GetIntValue(WorldCfg.ChatEmoteLevelReq))
                {
                    SendNotification(Global.ObjectMgr.GetCypherString(CypherStrings.SayReq), WorldConfig.GetIntValue(WorldCfg.ChatEmoteLevelReq));
                    return;
                }

                sender.TextEmote(msg);
                break;

            case ChatMsg.Yell:
                // Prevent cheating
                if (!sender.IsAlive())
                {
                    return;
                }

                if (sender.GetLevel() < WorldConfig.GetIntValue(WorldCfg.ChatYellLevelReq))
                {
                    SendNotification(Global.ObjectMgr.GetCypherString(CypherStrings.SayReq), WorldConfig.GetIntValue(WorldCfg.ChatYellLevelReq));
                    return;
                }

                sender.Yell(msg, lang);
                break;

            case ChatMsg.Whisper:
                // @todo implement cross realm whispers (someday)
                ExtendedPlayerName extName = ObjectManager.ExtractExtendedPlayerName(target);

                if (!ObjectManager.NormalizePlayerName(ref extName.Name))
                {
                    SendChatPlayerNotfoundNotice(target);
                    break;
                }

                Player receiver = Global.ObjAccessor.FindPlayerByName(extName.Name);
                if (!receiver || (lang != Language.Addon && !receiver.IsAcceptWhispers() && receiver.GetSession().HasPermission(RBACPermissions.CanFilterWhispers) && !receiver.IsInWhisperWhiteList(sender.GetGUID())))
                {
                    SendChatPlayerNotfoundNotice(target);
                    return;
                }
                if (!sender.IsGameMaster() && sender.GetLevel() < WorldConfig.GetIntValue(WorldCfg.ChatWhisperLevelReq) && !receiver.IsInWhisperWhiteList(sender.GetGUID()))
                {
                    SendNotification(Global.ObjectMgr.GetCypherString(CypherStrings.WhisperReq), WorldConfig.GetIntValue(WorldCfg.ChatWhisperLevelReq));
                    return;
                }

                if (GetPlayer().GetTeam() != receiver.GetTeam() && !HasPermission(RBACPermissions.TwoSideInteractionChat) && !receiver.IsInWhisperWhiteList(sender.GetGUID()))
                {
                    SendChatPlayerNotfoundNotice(target);
                    return;
                }

                if (GetPlayer().HasAura(1852) && !receiver.IsGameMaster())
                {
                    SendNotification(Global.ObjectMgr.GetCypherString(CypherStrings.GmSilence), GetPlayer().GetName());
                    return;
                }

                if (receiver.GetLevel() < WorldConfig.GetIntValue(WorldCfg.ChatWhisperLevelReq) ||
                    (HasPermission(RBACPermissions.CanFilterWhispers) && !sender.IsAcceptWhispers() && !sender.IsInWhisperWhiteList(receiver.GetGUID())))
                {
                    sender.AddWhisperWhiteList(receiver.GetGUID());
                }

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

            case ChatMsg.Party:
            {
                // if player is in Battleground, he cannot say to Battlegroundmembers by /p
                Group group = GetPlayer().GetOriginalGroup();
                if (!group)
                {
                    group = GetPlayer().GetGroup();
                    if (!group || group.IsBGGroup())
                    {
                        return;
                    }
                }

                if (group.IsLeader(GetPlayer().GetGUID()))
                {
                    type = ChatMsg.PartyLeader;
                }

                Global.ScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, group);

                ChatPkt data = new ChatPkt();
                data.Initialize(type, lang, sender, null, msg);
                group.BroadcastPacket(data, false, group.GetMemberGroup(GetPlayer().GetGUID()));
            }
            break;

            case ChatMsg.Guild:
                if (GetPlayer().GetGuildId() != 0)
                {
                    Guild guild = Global.GuildMgr.GetGuildById(GetPlayer().GetGuildId());
                    if (guild)
                    {
                        Global.ScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, guild);

                        guild.BroadcastToGuild(this, false, msg, lang == Language.Addon ? Language.Addon : Language.Universal);
                    }
                }
                break;

            case ChatMsg.Officer:
                if (GetPlayer().GetGuildId() != 0)
                {
                    Guild guild = Global.GuildMgr.GetGuildById(GetPlayer().GetGuildId());
                    if (guild)
                    {
                        Global.ScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, guild);

                        guild.BroadcastToGuild(this, true, msg, lang == Language.Addon ? Language.Addon : Language.Universal);
                    }
                }
                break;

            case ChatMsg.Raid:
            {
                Group group = GetPlayer().GetGroup();
                if (!group || !group.IsRaidGroup() || group.IsBGGroup())
                {
                    return;
                }

                if (group.IsLeader(GetPlayer().GetGUID()))
                {
                    type = ChatMsg.RaidLeader;
                }

                Global.ScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, group);

                ChatPkt data = new ChatPkt();
                data.Initialize(type, lang, sender, null, msg);
                group.BroadcastPacket(data, false);
            }
            break;

            case ChatMsg.RaidWarning:
            {
                Group group = GetPlayer().GetGroup();
                if (!group || !(group.IsRaidGroup() || WorldConfig.GetBoolValue(WorldCfg.ChatPartyRaidWarnings)) || !(group.IsLeader(GetPlayer().GetGUID()) || group.IsAssistant(GetPlayer().GetGUID())) || group.IsBGGroup())
                {
                    return;
                }

                Global.ScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, group);

                ChatPkt data = new ChatPkt();
                //in Battleground, raid warning is sent only to players in Battleground - code is ok
                data.Initialize(ChatMsg.RaidWarning, lang, sender, null, msg);
                group.BroadcastPacket(data, false);
            }
            break;

            case ChatMsg.Channel:
                if (!HasPermission(RBACPermissions.SkipCheckChatChannelReq))
                {
                    if (GetPlayer().GetLevel() < WorldConfig.GetIntValue(WorldCfg.ChatChannelLevelReq))
                    {
                        SendNotification(Global.ObjectMgr.GetCypherString(CypherStrings.ChannelReq), WorldConfig.GetIntValue(WorldCfg.ChatChannelLevelReq));
                        return;
                    }
                }
                Channel chn = ChannelManager.GetChannelForPlayerByNamePart(target, sender);
                if (chn != null)
                {
                    Global.ScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, chn);
                    chn.Say(GetPlayer().GetGUID(), msg, lang);
                }
                break;

            case ChatMsg.InstanceChat:
            {
                Group group = GetPlayer().GetGroup();
                if (!group)
                {
                    return;
                }

                if (group.IsLeader(GetPlayer().GetGUID()))
                {
                    type = ChatMsg.InstanceChatLeader;
                }

                Global.ScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, group);

                ChatPkt packet = new ChatPkt();
                packet.Initialize(type, lang, sender, null, msg);
                group.BroadcastPacket(packet, false);
                break;
            }

            default:
                Log.outError(LogFilter.ChatSystem, "CHAT: unknown message type {0}, lang: {1}", type, lang);
                break;
            }
        }
예제 #7
0
        public void Update()
        {
            if (_initialized)
            {
                uint currentTimestamp = GameTime.GetGameTimeMS();
                uint diff             = currentTimestamp - _previousTimestamp;
                _previousTimestamp = currentTimestamp;

                if (_dataSent)
                {
                    uint maxClientResponseDelay = WorldConfig.GetUIntValue(WorldCfg.WardenClientResponseDelay);
                    if (maxClientResponseDelay > 0)
                    {
                        // Kick player if client response delays more than set in config
                        if (_clientResponseTimer > maxClientResponseDelay * Time.InMilliseconds)
                        {
                            Log.outWarn(LogFilter.Warden, "{0} (latency: {1}, IP: {2}) exceeded Warden module response delay for more than {3} - disconnecting client",
                                        _session.GetPlayerInfo(), _session.GetLatency(), _session.GetRemoteAddress(), Time.secsToTimeString(maxClientResponseDelay, TimeFormat.ShortText));
                            _session.KickPlayer("Warden::Update Warden module response delay exceeded");
                        }
                        else
                        {
                            _clientResponseTimer += diff;
                        }
                    }
                }
                else
                {
                    if (diff >= _checkTimer)
                    {
                        RequestData();
                    }
                    else
                    {
                        _checkTimer -= diff;
                    }
                }
            }
        }
예제 #8
0
        public void LoadCreatureTextLocales()
        {
            uint oldMSTime = Time.GetMSTime();

            mLocaleTextMap.Clear(); // for reload case

            SQLResult result = DB.World.Query("SELECT CreatureId, GroupId, ID, Locale, Text FROM creature_text_locale");

            if (result.IsEmpty())
            {
                return;
            }

            do
            {
                uint   creatureId = result.Read <uint>(0);
                uint   groupId    = result.Read <byte>(1);
                uint   id         = result.Read <byte>(2);
                string localeName = result.Read <string>(3);
                Locale locale     = localeName.ToEnum <Locale>();
                if (!SharedConst.IsValidLocale(locale) || locale == Locale.enUS)
                {
                    continue;
                }

                var key = new CreatureTextId(creatureId, groupId, id);
                if (!mLocaleTextMap.ContainsKey(key))
                {
                    mLocaleTextMap[key] = new CreatureTextLocale();
                }

                CreatureTextLocale data = mLocaleTextMap[key];
                ObjectManager.AddLocaleString(result.Read <string>(4), locale, data.Text);
            } while (result.NextRow());

            Log.outInfo(LogFilter.ServerLoading, "Loaded {0} creature localized texts in {1} ms", mLocaleTextMap.Count, Time.GetMSTimeDiffToNow(oldMSTime));
        }
예제 #9
0
        public void LoadDisables()
        {
            uint oldMSTime = Time.GetMSTime();

            // reload case
            m_DisableMap.Clear();

            SQLResult result = DB.World.Query("SELECT sourceType, entry, flags, params_0, params_1 FROM disables");

            if (result.IsEmpty())
            {
                Log.outError(LogFilter.ServerLoading, "Loaded 0 disables. DB table `disables` is empty!");
                return;
            }

            uint total_count = 0;

            do
            {
                DisableType type = (DisableType)result.Read <uint>(0);
                if (type >= DisableType.Max)
                {
                    Log.outError(LogFilter.Sql, "Invalid type {0} specified in `disables` table, skipped.", type);
                    continue;
                }

                uint   entry    = result.Read <uint>(1);
                byte   flags    = result.Read <byte>(2);
                string params_0 = result.Read <string>(3);
                string params_1 = result.Read <string>(4);

                DisableData data = new DisableData();
                data.flags = flags;

                switch (type)
                {
                case DisableType.Spell:
                    if (!(Global.SpellMgr.HasSpellInfo(entry, Difficulty.None) || flags.HasAnyFlag <byte>(DisableFlags.SpellDeprecatedSpell)))
                    {
                        Log.outError(LogFilter.Sql, "Spell entry {0} from `disables` doesn't exist in dbc, skipped.", entry);
                        continue;
                    }

                    if (flags == 0 || flags > DisableFlags.MaxSpell)
                    {
                        Log.outError(LogFilter.Sql, "Disable flags for spell {0} are invalid, skipped.", entry);
                        continue;
                    }

                    if (flags.HasAnyFlag(DisableFlags.SpellMap))
                    {
                        var array = new StringArray(params_0, ',');
                        for (byte i = 0; i < array.Length;)
                        {
                            if (uint.TryParse(array[i++], out uint id))
                            {
                                data.param0.Add(id);
                            }
                        }
                    }

                    if (flags.HasAnyFlag(DisableFlags.SpellArea))
                    {
                        var array = new StringArray(params_1, ',');
                        for (byte i = 0; i < array.Length;)
                        {
                            if (uint.TryParse(array[i++], out uint id))
                            {
                                data.param1.Add(id);
                            }
                        }
                    }

                    break;

                // checked later
                case DisableType.Quest:
                    break;

                case DisableType.Map:
                case DisableType.LFGMap:
                {
                    MapRecord mapEntry = CliDB.MapStorage.LookupByKey(entry);
                    if (mapEntry == null)
                    {
                        Log.outError(LogFilter.Sql, "Map entry {0} from `disables` doesn't exist in dbc, skipped.", entry);
                        continue;
                    }
                    bool isFlagInvalid = false;
                    switch (mapEntry.InstanceType)
                    {
                    case MapTypes.Common:
                        if (flags != 0)
                        {
                            isFlagInvalid = true;
                        }
                        break;

                    case MapTypes.Instance:
                    case MapTypes.Raid:
                        if (flags.HasAnyFlag(DisableFlags.DungeonStatusHeroic) && Global.DB2Mgr.GetMapDifficultyData(entry, Difficulty.Heroic) == null)
                        {
                            flags -= DisableFlags.DungeonStatusHeroic;
                        }
                        if (flags.HasAnyFlag(DisableFlags.DungeonStatusHeroic10Man) && Global.DB2Mgr.GetMapDifficultyData(entry, Difficulty.Raid10HC) == null)
                        {
                            flags -= DisableFlags.DungeonStatusHeroic10Man;
                        }
                        if (flags.HasAnyFlag(DisableFlags.DungeonStatusHeroic25Man) && Global.DB2Mgr.GetMapDifficultyData(entry, Difficulty.Raid25HC) == null)
                        {
                            flags -= DisableFlags.DungeonStatusHeroic25Man;
                        }
                        if (flags == 0)
                        {
                            isFlagInvalid = true;
                        }
                        break;

                    case MapTypes.Battleground:
                    case MapTypes.Arena:
                        Log.outError(LogFilter.Sql, "Battlegroundmap {0} specified to be disabled in map case, skipped.", entry);
                        continue;
                    }
                    if (isFlagInvalid)
                    {
                        Log.outError(LogFilter.Sql, "Disable flags for map {0} are invalid, skipped.", entry);
                        continue;
                    }
                    break;
                }

                case DisableType.Battleground:
                    if (!CliDB.BattlemasterListStorage.ContainsKey(entry))
                    {
                        Log.outError(LogFilter.Sql, "Battlegroundentry {0} from `disables` doesn't exist in dbc, skipped.", entry);
                        continue;
                    }
                    if (flags != 0)
                    {
                        Log.outError(LogFilter.Sql, "Disable flags specified for Battleground{0}, useless data.", entry);
                    }
                    break;

                case DisableType.OutdoorPVP:
                    if (entry > (int)OutdoorPvPTypes.Max)
                    {
                        Log.outError(LogFilter.Sql, "OutdoorPvPTypes value {0} from `disables` is invalid, skipped.", entry);
                        continue;
                    }
                    if (flags != 0)
                    {
                        Log.outError(LogFilter.Sql, "Disable flags specified for outdoor PvP {0}, useless data.", entry);
                    }
                    break;

                case DisableType.Criteria:
                    if (Global.CriteriaMgr.GetCriteria(entry) == null)
                    {
                        Log.outError(LogFilter.Sql, "Criteria entry {0} from `disables` doesn't exist in dbc, skipped.", entry);
                        continue;
                    }
                    if (flags != 0)
                    {
                        Log.outError(LogFilter.Sql, "Disable flags specified for Criteria {0}, useless data.", entry);
                    }
                    break;

                case DisableType.VMAP:
                {
                    MapRecord mapEntry = CliDB.MapStorage.LookupByKey(entry);
                    if (mapEntry == null)
                    {
                        Log.outError(LogFilter.Sql, "Map entry {0} from `disables` doesn't exist in dbc, skipped.", entry);
                        continue;
                    }
                    switch (mapEntry.InstanceType)
                    {
                    case MapTypes.Common:
                        if (flags.HasAnyFlag(DisableFlags.VmapAreaFlag))
                        {
                            Log.outInfo(LogFilter.Server, "Areaflag disabled for world map {0}.", entry);
                        }
                        if (flags.HasAnyFlag(DisableFlags.VmapLiquidStatus))
                        {
                            Log.outInfo(LogFilter.Server, "Liquid status disabled for world map {0}.", entry);
                        }
                        break;

                    case MapTypes.Instance:
                    case MapTypes.Raid:
                        if (flags.HasAnyFlag(DisableFlags.VmapHeight))
                        {
                            Log.outInfo(LogFilter.Server, "Height disabled for instance map {0}.", entry);
                        }
                        if (flags.HasAnyFlag(DisableFlags.VmapLOS))
                        {
                            Log.outInfo(LogFilter.Server, "LoS disabled for instance map {0}.", entry);
                        }
                        break;

                    case MapTypes.Battleground:
                        if (flags.HasAnyFlag(DisableFlags.VmapHeight))
                        {
                            Log.outInfo(LogFilter.Server, "Height disabled for Battlegroundmap {0}.", entry);
                        }
                        if (flags.HasAnyFlag(DisableFlags.VmapLOS))
                        {
                            Log.outInfo(LogFilter.Server, "LoS disabled for Battlegroundmap {0}.", entry);
                        }
                        break;

                    case MapTypes.Arena:
                        if (flags.HasAnyFlag(DisableFlags.VmapHeight))
                        {
                            Log.outInfo(LogFilter.Server, "Height disabled for arena map {0}.", entry);
                        }
                        if (flags.HasAnyFlag(DisableFlags.VmapLOS))
                        {
                            Log.outInfo(LogFilter.Server, "LoS disabled for arena map {0}.", entry);
                        }
                        break;

                    default:
                        break;
                    }
                    break;
                }

                case DisableType.MMAP:
                {
                    MapRecord mapEntry = CliDB.MapStorage.LookupByKey(entry);
                    if (mapEntry == null)
                    {
                        Log.outError(LogFilter.Sql, "Map entry {0} from `disables` doesn't exist in dbc, skipped.", entry);
                        continue;
                    }
                    switch (mapEntry.InstanceType)
                    {
                    case MapTypes.Common:
                        Log.outInfo(LogFilter.Server, "Pathfinding disabled for world map {0}.", entry);
                        break;

                    case MapTypes.Instance:
                    case MapTypes.Raid:
                        Log.outInfo(LogFilter.Server, "Pathfinding disabled for instance map {0}.", entry);
                        break;

                    case MapTypes.Battleground:
                        Log.outInfo(LogFilter.Server, "Pathfinding disabled for Battlegroundmap {0}.", entry);
                        break;

                    case MapTypes.Arena:
                        Log.outInfo(LogFilter.Server, "Pathfinding disabled for arena map {0}.", entry);
                        break;

                    default:
                        break;
                    }
                    break;
                }

                default:
                    break;
                }
                if (!m_DisableMap.ContainsKey(type))
                {
                    m_DisableMap[type] = new Dictionary <uint, DisableData>();
                }

                m_DisableMap[type].Add(entry, data);
                ++total_count;
            }while (result.NextRow());

            Log.outInfo(LogFilter.ServerLoading, "Loaded {0} disables in {1} ms", total_count, Time.GetMSTimeDiffToNow(oldMSTime));
        }
예제 #10
0
        public void CheckQuestDisables()
        {
            if (!m_DisableMap.ContainsKey(DisableType.Quest) || m_DisableMap[DisableType.Quest].Count == 0)
            {
                Log.outInfo(LogFilter.ServerLoading, "Checked 0 quest disables.");
                return;
            }

            uint oldMSTime = Time.GetMSTime();

            // check only quests, rest already done at startup
            foreach (var pair in m_DisableMap[DisableType.Quest])
            {
                uint entry = pair.Key;
                if (Global.ObjectMgr.GetQuestTemplate(entry) == null)
                {
                    Log.outError(LogFilter.Sql, "Quest entry {0} from `disables` doesn't exist, skipped.", entry);
                    m_DisableMap[DisableType.Quest].Remove(entry);
                    continue;
                }
                if (pair.Value.flags != 0)
                {
                    Log.outError(LogFilter.Sql, "Disable flags specified for quest {0}, useless data.", entry);
                }
            }

            Log.outInfo(LogFilter.ServerLoading, "Checked {0} quest disables in {1} ms", m_DisableMap[DisableType.Quest].Count, Time.GetMSTimeDiffToNow(oldMSTime));
        }
예제 #11
0
        public void ScanDesign(CellFace start, Vector3 direction, ComponentMiner componentMiner)
        {
            FurnitureDesign          design           = null;
            FurnitureDesign          furnitureDesign  = null;
            Dictionary <Point3, int> valuesDictionary = new Dictionary <Point3, int>();
            Point3 point      = start.Point;
            Point3 point2     = start.Point;
            int    startValue = base.SubsystemTerrain.Terrain.GetCellValue(start.Point.X, start.Point.Y, start.Point.Z);
            int    num        = Terrain.ExtractContents(startValue);

            if (BlocksManager.Blocks[num] is FurnitureBlock)
            {
                int designIndex = FurnitureBlock.GetDesignIndex(Terrain.ExtractData(startValue));
                furnitureDesign = GetDesign(designIndex);
                if (furnitureDesign == null)
                {
                    componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage("Unsuitable block found", Color.White, blinking: true, playNotificationSound: false);
                    return;
                }
                design = furnitureDesign.Clone();
                design.LinkedDesign    = null;
                design.InteractionMode = FurnitureInteractionMode.None;
                valuesDictionary.Add(start.Point, startValue);
            }
            else
            {
                Stack <Point3> val = new Stack <Point3>();
                val.Push(start.Point);
                while (val.Count > 0)
                {
                    Point3 key = val.Pop();
                    if (valuesDictionary.ContainsKey(key))
                    {
                        continue;
                    }
                    int cellValue = base.SubsystemTerrain.Terrain.GetCellValue(key.X, key.Y, key.Z);
                    if (IsValueDisallowed(cellValue))
                    {
                        componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage("Unsuitable block found", Color.White, blinking: true, playNotificationSound: false);
                        return;
                    }
                    if (IsValueAllowed(cellValue))
                    {
                        if (key.X < point.X)
                        {
                            point.X = key.X;
                        }
                        if (key.Y < point.Y)
                        {
                            point.Y = key.Y;
                        }
                        if (key.Z < point.Z)
                        {
                            point.Z = key.Z;
                        }
                        if (key.X > point2.X)
                        {
                            point2.X = key.X;
                        }
                        if (key.Y > point2.Y)
                        {
                            point2.Y = key.Y;
                        }
                        if (key.Z > point2.Z)
                        {
                            point2.Z = key.Z;
                        }
                        if (MathUtils.Abs(point.X - point2.X) >= 16 || MathUtils.Abs(point.Y - point2.Y) >= 16 || MathUtils.Abs(point.Z - point2.Z) >= 16)
                        {
                            componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage("Furniture design is too large", Color.White, blinking: true, playNotificationSound: false);
                            return;
                        }
                        valuesDictionary[key] = cellValue;
                        val.Push(new Point3(key.X - 1, key.Y, key.Z));
                        val.Push(new Point3(key.X + 1, key.Y, key.Z));
                        val.Push(new Point3(key.X, key.Y - 1, key.Z));
                        val.Push(new Point3(key.X, key.Y + 1, key.Z));
                        val.Push(new Point3(key.X, key.Y, key.Z - 1));
                        val.Push(new Point3(key.X, key.Y, key.Z + 1));
                    }
                }
                if (valuesDictionary.Count == 0)
                {
                    componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage("No suitable blocks found", Color.White, blinking: true, playNotificationSound: false);
                    return;
                }
                design = new FurnitureDesign(base.SubsystemTerrain);
                Point3 point3 = point2 - point;
                int    num2   = MathUtils.Max(MathUtils.Max(point3.X, point3.Y, point3.Z) + 1, 2);
                int[]  array  = new int[num2 * num2 * num2];
                foreach (KeyValuePair <Point3, int> item in valuesDictionary)
                {
                    Point3 point4 = item.Key - point;
                    array[point4.X + point4.Y * num2 + point4.Z * num2 * num2] = item.Value;
                }
                design.SetValues(num2, array);
                int steps = (start.Face > 3) ? CellFace.Vector3ToFace(direction, 3) : CellFace.OppositeFace(start.Face);
                design.Rotate(1, steps);
                Point3 location = design.Box.Location;
                Point3 point5   = new Point3(design.Resolution) - (design.Box.Location + design.Box.Size);
                Point3 delta    = new Point3((point5.X - location.X) / 2, -location.Y, (point5.Z - location.Z) / 2);
                design.Shift(delta);
            }
            BuildFurnitureDialog dialog = new BuildFurnitureDialog(design, furnitureDesign, delegate(bool result)
            {
                if (result)
                {
                    design = TryAddDesign(design);
                    if (design == null)
                    {
                        componentMiner.ComponentPlayer?.ComponentGui.DisplaySmallMessage("Too many different furniture designs", Color.White, blinking: true, playNotificationSound: false);
                    }
                    else
                    {
                        if (m_subsystemGameInfo.WorldSettings.GameMode != 0)
                        {
                            foreach (KeyValuePair <Point3, int> item2 in valuesDictionary)
                            {
                                base.SubsystemTerrain.DestroyCell(0, item2.Key.X, item2.Key.Y, item2.Key.Z, 0, noDrop: true, noParticleSystem: true);
                            }
                        }
                        int value        = Terrain.MakeBlockValue(227, 0, FurnitureBlock.SetDesignIndex(0, design.Index, design.ShadowStrengthFactor, design.IsLightEmitter));
                        int num3         = MathUtils.Clamp(design.Resolution, 4, 8);
                        Matrix matrix    = componentMiner.ComponentCreature.ComponentBody.Matrix;
                        Vector3 position = matrix.Translation + 1f * matrix.Forward + 1f * Vector3.UnitY;
                        m_subsystemPickables.AddPickable(value, num3, position, null, null);
                        componentMiner.DamageActiveTool(1);
                        componentMiner.Poke(forceRestart: false);
                        for (int i = 0; i < 3; i++)
                        {
                            Time.QueueTimeDelayedExecution(Time.FrameStartTime + (double)((float)i * 0.25f), delegate
                            {
                                m_subsystemSoundMaterials.PlayImpactSound(startValue, new Vector3(start.Point), 1f);
                            });
                        }
                        if (componentMiner.ComponentCreature.PlayerStats != null)
                        {
                            componentMiner.ComponentCreature.PlayerStats.FurnitureItemsMade += num3;
                        }
                    }
                }
            });

            if (componentMiner.ComponentPlayer != null)
            {
                DialogsManager.ShowDialog(componentMiner.ComponentPlayer.GuiWidget, dialog);
            }
        }
예제 #12
0
        public static void CleanDatabase()
        {
            // config to disable
            if (!WorldConfig.GetBoolValue(WorldCfg.CleanCharacterDb))
            {
                return;
            }

            Log.outInfo(LogFilter.Server, "Cleaning character database...");

            uint oldMSTime = Time.GetMSTime();

            // check flags which clean ups are necessary
            SQLResult result = DB.Characters.Query("SELECT value FROM worldstates WHERE entry = {0}", (uint)WorldStates.CleaningFlags);

            if (result.IsEmpty())
            {
                return;
            }

            CleaningFlags flags = (CleaningFlags)result.Read <uint>(0);

            // clean up
            if (flags.HasAnyFlag(CleaningFlags.AchievementProgress))
            {
                CleanCharacterAchievementProgress();
            }

            if (flags.HasAnyFlag(CleaningFlags.Skills))
            {
                CleanCharacterSkills();
            }

            if (flags.HasAnyFlag(CleaningFlags.Spells))
            {
                CleanCharacterSpell();
            }

            if (flags.HasAnyFlag(CleaningFlags.Talents))
            {
                CleanCharacterTalent();
            }

            if (flags.HasAnyFlag(CleaningFlags.Queststatus))
            {
                CleanCharacterQuestStatus();
            }

            // NOTE: In order to have persistentFlags be set in worldstates for the next cleanup,
            // you need to define them at least once in worldstates.
            flags &= (CleaningFlags)WorldConfig.GetIntValue(WorldCfg.PersistentCharacterCleanFlags);
            DB.Characters.DirectExecute("UPDATE worldstates SET value = {0} WHERE entry = {1}", flags, (uint)WorldStates.CleaningFlags);

            Global.WorldMgr.SetCleaningFlags(flags);

            Log.outInfo(LogFilter.ServerLoading, "Cleaned character database in {0} ms", Time.GetMSTimeDiffToNow(oldMSTime));
        }
예제 #13
0
 public void Update(float dt)
 {
     if (!base.IsAddedToProject)
     {
         return;
     }
     if (IsOnFire)
     {
         m_fireDuration = MathUtils.Max(m_fireDuration - dt, 0f);
         if (m_onFireParticleSystem == null)
         {
             m_onFireParticleSystem = new OnFireParticleSystem();
             m_subsystemParticles.AddParticleSystem(m_onFireParticleSystem);
         }
         BoundingBox boundingBox = ComponentBody.BoundingBox;
         m_onFireParticleSystem.Position = 0.5f * (boundingBox.Min + boundingBox.Max);
         m_onFireParticleSystem.Radius   = 0.5f * MathUtils.Min(boundingBox.Max.X - boundingBox.Min.X, boundingBox.Max.Z - boundingBox.Min.Z);
         if (ComponentBody.ImmersionFactor > 0.5f && ComponentBody.ImmersionFluidBlock is WaterBlock)
         {
             Extinguish();
             m_subsystemAudio.PlaySound("Audio/SizzleLong", 1f, 0f, m_onFireParticleSystem.Position, 4f, autoDelay: true);
         }
         if (Time.PeriodicEvent(0.5, 0.0))
         {
             float distance = m_subsystemAudio.CalculateListenerDistance(ComponentBody.Position);
             m_soundVolume = m_subsystemAudio.CalculateVolume(distance, 2f, 5f);
         }
         m_subsystemAmbientSounds.FireSoundVolume = MathUtils.Max(m_subsystemAmbientSounds.FireSoundVolume, m_soundVolume);
     }
     else
     {
         if (m_onFireParticleSystem != null)
         {
             m_onFireParticleSystem.IsStopped = true;
             m_onFireParticleSystem           = null;
         }
         m_soundVolume = 0f;
     }
     if (!(m_subsystemTime.GameTime > m_nextCheckTime))
     {
         return;
     }
     m_nextCheckTime = m_subsystemTime.GameTime + (double)m_random.Float(0.9f, 1.1f);
     TouchesFire     = CheckIfBodyTouchesFire();
     if (TouchesFire)
     {
         m_fireTouchCount++;
         if (m_fireTouchCount >= 5)
         {
             SetOnFire(null, m_random.Float(12f, 15f));
         }
     }
     else
     {
         m_fireTouchCount = 0;
     }
     if (ComponentBody.ImmersionFactor > 0.2f && ComponentBody.ImmersionFluidBlock is MagmaBlock)
     {
         SetOnFire(null, m_random.Float(12f, 15f));
     }
 }