Exemplo n.º 1
0
        public static void InitDbPhaseShift(PhaseShift phaseShift, PhaseUseFlagsValues phaseUseFlags, uint phaseId, uint phaseGroupId)
        {
            phaseShift.ClearPhases();
            phaseShift.IsDbPhaseShift = true;

            PhaseShiftFlags flags = PhaseShiftFlags.None;

            if (phaseUseFlags.HasAnyFlag(PhaseUseFlagsValues.AlwaysVisible))
            {
                flags = flags | PhaseShiftFlags.AlwaysVisible | PhaseShiftFlags.Unphased;
            }
            if (phaseUseFlags.HasAnyFlag(PhaseUseFlagsValues.Inverse))
            {
                flags |= PhaseShiftFlags.Inverse;
            }

            if (phaseId != 0)
            {
                phaseShift.AddPhase(phaseId, GetPhaseFlags(phaseId), null);
            }
            else
            {
                var phasesInGroup = Global.DB2Mgr.GetPhasesForGroup(phaseGroupId);
                foreach (uint phaseInGroup in phasesInGroup)
                {
                    phaseShift.AddPhase(phaseInGroup, GetPhaseFlags(phaseInGroup), null);
                }
            }

            if (phaseShift.Phases.Empty() || phaseShift.HasPhase(169))
            {
                if (flags.HasFlag(PhaseShiftFlags.Inverse))
                {
                    flags |= PhaseShiftFlags.InverseUnphased;
                }
                else
                {
                    flags |= PhaseShiftFlags.Unphased;
                }
            }

            phaseShift.Flags = flags;
        }
Exemplo n.º 2
0
        public void SpawnContinentTransports()
        {
            if (_transportTemplates.Empty())
            {
                return;
            }

            uint oldMSTime = Time.GetMSTime();

            SQLResult result = DB.World.Query("SELECT guid, entry, phaseUseFlags, phaseid, phasegroup FROM transports");

            uint count = 0;

            if (!result.IsEmpty())
            {
                do
                {
                    ulong guid  = result.Read <ulong>(0);
                    uint  entry = result.Read <uint>(1);
                    PhaseUseFlagsValues phaseUseFlags = (PhaseUseFlagsValues)result.Read <byte>(2);
                    uint phaseId      = result.Read <uint>(3);
                    uint phaseGroupId = result.Read <uint>(4);

                    if (Convert.ToBoolean(phaseUseFlags & ~PhaseUseFlagsValues.All))
                    {
                        Log.outError(LogFilter.Sql, $"Table `transports` have transport (GUID: {guid} Entry: {entry}) with unknown `phaseUseFlags` set, removed unknown value.");
                        phaseUseFlags &= PhaseUseFlagsValues.All;
                    }

                    if (phaseUseFlags.HasAnyFlag(PhaseUseFlagsValues.AlwaysVisible) && phaseUseFlags.HasAnyFlag(PhaseUseFlagsValues.Inverse))
                    {
                        Log.outError(LogFilter.Sql, $"Table `transports` have transport (GUID: {guid} Entry: {entry}) has both `phaseUseFlags` PHASE_USE_FLAGS_ALWAYS_VISIBLE and PHASE_USE_FLAGS_INVERSE," +
                                     " removing PHASE_USE_FLAGS_INVERSE.");
                        phaseUseFlags &= ~PhaseUseFlagsValues.Inverse;
                    }

                    if (phaseGroupId != 0 && phaseId != 0)
                    {
                        Log.outError(LogFilter.Sql, $"Table `transports` have transport (GUID: {guid} Entry: {entry}) with both `phaseid` and `phasegroup` set, `phasegroup` set to 0");
                        phaseGroupId = 0;
                    }

                    if (phaseId != 0)
                    {
                        if (!CliDB.PhaseStorage.ContainsKey(phaseId))
                        {
                            Log.outError(LogFilter.Sql, $"Table `transports` have transport (GUID: {guid} Entry: {entry}) with `phaseid` {phaseId} does not exist, set to 0");
                            phaseId = 0;
                        }
                    }

                    if (phaseGroupId != 0)
                    {
                        if (Global.DB2Mgr.GetPhasesForGroup(phaseGroupId).Empty())
                        {
                            Log.outError(LogFilter.Sql, $"Table `transports` have transport (GUID: {guid} Entry: {entry}) with `phaseGroup` {phaseGroupId} does not exist, set to 0");
                            phaseGroupId = 0;
                        }
                    }

                    TransportTemplate tInfo = GetTransportTemplate(entry);
                    if (tInfo != null)
                    {
                        if (!tInfo.inInstance)
                        {
                            if (CreateTransport(entry, guid, null, phaseUseFlags, phaseId, phaseGroupId))
                            {
                                ++count;
                            }
                        }
                    }
                } while (result.NextRow());
            }

            Log.outInfo(LogFilter.ServerLoading, "Spawned {0} continent transports in {1} ms", count, Time.GetMSTimeDiffToNow(oldMSTime));
        }