Ejemplo n.º 1
0
        /// <summary>
        /// This should be called after any postback and/or before any save.  due to how we can delete mid-row
        /// in the UI, properties are only soft-deleted and need to be physically removed here.
        /// </summary>
        public void CleanDeletedAndEmptyProperties()
        {
            StringStats?.RemoveAll(x => x == null || x.Deleted || string.IsNullOrEmpty(x.Value));
            IntStats?.RemoveAll(x => x == null || x.Deleted);
            Int64Stats?.RemoveAll(x => x == null || x.Deleted);
            FloatStats?.RemoveAll(x => x == null || x.Deleted);
            BoolStats?.RemoveAll(x => x == null || x.Deleted);
            DidStats?.RemoveAll(x => x == null || x.Deleted);
            Spells?.RemoveAll(x => x == null || x.Deleted);
            Book?.Pages?.RemoveAll(x => x == null || x.Deleted);
            Positions?.RemoveAll(x => x == null || x.Deleted);
            EmoteTable?.ForEach(es => es?.Emotes?.ForEach(esa => esa?.Actions?.RemoveAll(x => x == null || x.Deleted)));
            EmoteTable?.ForEach(es => es?.Emotes?.RemoveAll(x => x == null || x.Deleted));
            EmoteTable?.RemoveAll(x => x == null || x.Deleted || x.Emotes?.Count < 1);
            Body?.BodyParts?.RemoveAll(x => x == null || x.Deleted);
            GeneratorTable?.RemoveAll(x => x == null || x.Deleted);
            CreateList?.RemoveAll(x => x == null || x.Deleted);
            Skills?.RemoveAll(x => x == null || x.Deleted);

            // this property's existence causes all sorts of problems.  needs to go away.
            IntStats?.RemoveAll(x => x.Key == 9007);

            if (!HasAbilities)
            {
                Attributes = null;
            }
        }
Ejemplo n.º 2
0
        public EmoteTable ReadEmoteTable(string[] sqlLines)
        {
            var emoteTable = new EmoteTable();

            bool?isEmote        = null;
            var  currentColumns = new List <string>();

            foreach (var line in sqlLines)
            {
                var match = Regex.Match(line, @"`class_Id` = (\d+);");
                if (match.Success)
                {
                    //Console.WriteLine($"Found wcid {Wcid}");
                    if (uint.TryParse(match.Groups[1].Value, out var wcid))
                    {
                        emoteTable.Wcid = wcid;
                    }
                    continue;
                }

                if (line.StartsWith("INSERT INTO"))
                {
                    var startEmoteSet = line.StartsWith("INSERT INTO `weenie_properties_emote`");
                    var startEmote    = line.StartsWith("INSERT INTO `weenie_properties_emote_action`");

                    if (!startEmoteSet && !startEmote)
                    {
                        isEmote = null;
                        continue;
                    }

                    isEmote        = startEmote;
                    currentColumns = GetColumns(line);
                    //Console.WriteLine($"Found columns: {string.Join(", ", CurrentColumns)}");
                    continue;
                }

                if (isEmote == null)
                {
                    continue;
                }

                if (line.Contains("SET @parent_id = LAST_INSERT_ID()"))
                {
                    continue;
                }

                if (line.Contains("("))
                {
                    var fields = GetFields(line);
                    //Console.WriteLine($"Found fields: {string.Join(", ", fields)}");

                    AddRecord(emoteTable.EmoteSets, currentColumns, fields, isEmote.Value);
                }
            }

            return(emoteTable);
        }
Ejemplo n.º 3
0
        public static List <string> GetSQL(EmoteTable emoteTable)
        {
            var sqlLines = new List <string>();

            foreach (var emoteSet in emoteTable.EmoteSets)
            {
                if (emoteSet.Emotes?.Count == 0)
                {
                    continue;
                }

                var objectId = emoteTable.Wcid != null?emoteTable.Wcid.ToString() : "#####";

                var categoryStr      = $"{(int)emoteSet.Category} /* {emoteSet.Category} */";
                var probability      = emoteSet.Probability?.ToString() ?? "1";
                var weenieClassIdStr = GetSQLString(emoteSet.WeenieClassId) + GetWeenieName(emoteSet.WeenieClassId);
                var styleStr         = emoteSet.Style != null ? $"0x{(uint)emoteSet.Style:X8} /* {emoteSet.Style} */" : "NULL";
                var substyleStr      = emoteSet.Substyle != null ? $"0x{(uint)emoteSet.Substyle:X8} /* {emoteSet.Substyle} */" : "NULL";
                var quest            = GetSQLString(emoteSet.Quest);
                var vendorTypeStr    = emoteSet.VendorType != null ? $"{(int)emoteSet.VendorType} /* {emoteSet.VendorType} */" : "NULL";
                var minHealth        = GetSQLString(emoteSet.MinHealth);
                var maxHealth        = GetSQLString(emoteSet.MaxHealth);

                sqlLines.Add("INSERT INTO `weenie_properties_emote` (`object_Id`, `category`, `probability`, `weenie_Class_Id`, `style`, `substyle`, `quest`, `vendor_Type`, `min_Health`, `max_Health`)");
                sqlLines.Add($"VALUES ({objectId}, {categoryStr}, {probability}, {weenieClassIdStr}, {styleStr}, {substyleStr}, {quest}, {vendorTypeStr}, {minHealth}, {maxHealth});");
                sqlLines.Add(string.Empty);

                sqlLines.Add("SET @parent_id = LAST_INSERT_ID();");
                sqlLines.Add(string.Empty);

                var emoteSqlLines = GetSQL(emoteSet.Emotes);

                sqlLines.AddRange(emoteSqlLines);
            }

            return(sqlLines);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This should be called after any postback and/or before any save.  due to how we can delete mid-row
        /// in the UI, properties are only soft-deleted and need to be physically removed here.
        /// </summary>
        public void CleanDeletedAndEmptyProperties()
        {
            StringProperties?.RemoveAll(x => x == null || x.Deleted || x.Value == null);
            IntProperties?.RemoveAll(x => x == null || x.Deleted || x.Value == null);
            Int64Properties?.RemoveAll(x => x == null || x.Deleted || x.Value == null);
            DoubleProperties?.RemoveAll(x => x == null || x.Deleted || x.Value == null);
            BoolProperties?.RemoveAll(x => x == null || x.Deleted);
            DidProperties?.RemoveAll(x => x == null || x.Deleted || x.Value == null);
            IidProperties?.RemoveAll(x => x == null || x.Deleted || x.Value == null);
            Spells?.RemoveAll(x => x == null || x.Deleted);
            BookProperties?.RemoveAll(x => x == null || x.Deleted);
            Positions?.RemoveAll(x => x == null || x.Deleted);
            EmoteTable.ForEach(es => es.Emotes.RemoveAll(x => x == null || x.Deleted));
            EmoteTable?.RemoveAll(x => x == null || x.Deleted);
            BodyParts?.RemoveAll(x => x == null || x.Deleted);
            GeneratorTable?.RemoveAll(x => x == null || x.Deleted);
            CreateList?.RemoveAll(x => x == null || x.Deleted);
            Skills.RemoveAll(x => x == null || x.Deleted);

            if (!HasAbilities)
            {
                Abilities = null;
            }
        }
Ejemplo n.º 5
0
        public Weenie.Weenie ConvertToWeenie(out List <string> messages)
        {
            messages = new List <string>();
            Weenie.Weenie w = new Weenie.Weenie
            {
                DataObjectId  = WeenieId,
                WeenieClassId = WeenieId
            };

            w.IntProperties.Add(new Shared.IntProperty()
            {
                IntPropertyId = (int)IntPropertyId.WeenieType,
                Value         = WeenieTypeId
            });

            IntStats.ForEach(stat =>
            {
                w.IntProperties.Add(new Shared.IntProperty()
                {
                    IntPropertyId = stat.Key,
                    Value         = stat.Value
                });
            });

            Int64Stats?.ForEach(stat =>
            {
                w.Int64Properties.Add(new Shared.Int64Property()
                {
                    Int64PropertyId = stat.Key,
                    Value           = stat.Value
                });
            });

            FloatStats?.ForEach(stat =>
            {
                w.DoubleProperties.Add(new Shared.DoubleProperty()
                {
                    DoublePropertyId = stat.Key,
                    Value            = stat.Value
                });
            });

            DidStats?.ForEach(stat =>
            {
                w.DidProperties.Add(new Shared.DataIdProperty()
                {
                    DataIdPropertyId = stat.Key,
                    Value            = stat.Value
                });
            });

            BoolStats?.ForEach(stat =>
            {
                w.BoolProperties.Add(new Shared.BoolProperty()
                {
                    BoolPropertyId = stat.Key,
                    Value          = stat.BoolValue
                });
            });

            StringStats?.ForEach(stat =>
            {
                w.StringProperties.Add(new Shared.StringProperty()
                {
                    StringPropertyId = stat.Key,
                    Value            = stat.Value
                });
            });

            Book?.Pages.ForEach(page =>
            {
                w.BookProperties.Add(new Shared.BookPage()
                {
                    AuthorAccount = page.AuthorAccount,
                    AuthorId      = page.AuthorId,
                    AuthorName    = page.AuthorName,
                    IgnoreAuthor  = page.IgnoreAuthor ?? false,
                    Page          = 1 + (uint)Book.Pages.IndexOf(page),
                    PageText      = page.PageText
                });
            });

            Skills?.ForEach(skill =>
            {
                w.Skills.Add(new Shared.Skill()
                {
                    SkillId         = skill.SkillId,
                    Ranks           = skill.Skill.Ranks,
                    ExperienceSpent = skill.Skill.XpInvested,
                    Status          = skill.Skill.TrainedLevel,
                    BaseValue       = 0
                });
            });

            Spells?.ForEach(spell =>
            {
                w.Spells.Add(new Shared.Spell()
                {
                    SpellId     = spell.SpellId,
                    Probability = spell.Stats.CastingChance
                });
            });

            Positions?.ForEach(position =>
            {
                w.Positions.Add(new Shared.Position()
                {
                    X            = position.Position.Frame.Position.X,
                    Y            = position.Position.Frame.Position.Y,
                    Z            = position.Position.Frame.Position.Z,
                    QW           = position.Position.Frame.Rotations.W,
                    QX           = position.Position.Frame.Rotations.X,
                    QY           = position.Position.Frame.Rotations.Y,
                    QZ           = position.Position.Frame.Rotations.Z,
                    Landblock    = position.Position.LandCellId,
                    PositionType = position.PositionType
                });
            });

            GeneratorTable?.ForEach(entry =>
            {
                Shared.GeneratorTable gt = new Shared.GeneratorTable
                {
                    Frame = new Shared.Frame()
                };
                gt.Frame.Origin = new Shared.Origin();
                gt.Frame.Angles = new Shared.Angles();

                PropertyCopier <GeneratorTable, Shared.GeneratorTable> .Copy(entry, gt);
                gt.Frame.Angles.W = entry.Frame.Rotations.W;
                gt.Frame.Angles.X = entry.Frame.Rotations.X;
                gt.Frame.Angles.Y = entry.Frame.Rotations.Y;
                gt.Frame.Angles.Z = entry.Frame.Rotations.Z;
                gt.Frame.Origin.X = entry.Frame.Position.X;
                gt.Frame.Origin.Y = entry.Frame.Position.Y;
                gt.Frame.Origin.Z = entry.Frame.Position.Z;

                w.GeneratorTable.Add(gt);
            });

            uint emoteSetCounter = 0;

            if (EmoteTable != null)
            {
                emoteSetCounter = (uint)EmoteTable?.Count;
            }

            uint emoteCounter = 0;
            uint holdCategory = 0;

            EmoteTable?.ForEach(category =>
            {
                if (category.EmoteCategoryId != holdCategory)
                {
                    holdCategory = (uint)category.EmoteCategoryId;

                    if (holdCategory != 0)
                    {
                        emoteSetCounter--;
                    }
                }

                category.Emotes.ForEach(e =>
                {
                    var es = new Shared.EmoteSet()
                    {
                        EmoteSetGuid    = Guid.NewGuid(),
                        ClassId         = e.ClassId,
                        EmoteCategoryId = e.Category,
                        MaxHealth       = e.MaxHealth,
                        MinHealth       = e.MinHealth,
                        Probability     = e.Probability,
                        Quest           = e.Quest,
                        Style           = e.Style,
                        SubStyle        = e.SubStyle,
                        SortOrder       = emoteSetCounter,
                        VendorType      = e.VendorType
                    };

                    emoteCounter = 0;
                    e.Emotes.ForEach(ea =>
                    {
                        es.Emotes.Add(new Shared.Emote()
                        {
                            Amount              = ea.Amount,
                            Amount64            = ea.Amount64,
                            CreationProfile     = ea?.Item?.Convert(),
                            Delay               = ea.Delay ?? 0f,
                            Deleted             = false,
                            Display             = ea.Display,
                            EmoteTypeId         = ea.EmoteActionType,
                            EmoteGuid           = Guid.NewGuid(),
                            EmoteSetGuid        = es.EmoteSetGuid,
                            Extent              = ea.Extent ?? 0f,
                            HeroXp64            = ea.HeroXp64,
                            Maximum             = ea.Max,
                            Maximum64           = ea.Maximum64,
                            MaximumFloat        = ea.FMax,
                            Message             = ea.Message,
                            Minimum             = ea.Min,
                            Minimum64           = ea.Minimum64,
                            MinimumFloat        = ea.FMin,
                            Motion              = (MotionCommand?)ea.Motion,
                            Percent             = ea.Percent,
                            PhysicsScript       = (PhysicsScriptType?)ea.PScript,
                            PositionLandBlockId = null, // no source
                            PositionX           = ea.Frame?.Position.X,
                            PositionY           = ea.Frame?.Position.Y,
                            PositionZ           = ea.Frame?.Position.Z,
                            RotationW           = ea.Frame?.Rotations.W,
                            RotationX           = ea.Frame?.Rotations.X,
                            RotationY           = ea.Frame?.Rotations.Y,
                            RotationZ           = ea.Frame?.Rotations.Z,
                            Sound               = ea.Sound,
                            SpellId             = ea.SpellId,
                            Stat          = ea.Stat,
                            TestString    = ea.TestString,
                            TreasureClass = (TreasureClass?)ea.TreasureClass,
                            TreasureType  = (uint?)ea.TreasureType,
                            SortOrder     = emoteCounter,
                            WealthRating  = (WealthRating?)ea.WealthRating
                        });
                        emoteCounter++;
                    });
                    w.EmoteTable.Add(es);
                });
            });

            CreateList?.ForEach(ci =>
            {
                w.CreateList.Add(ci.Convert());
            });

            if (w.HasAbilities)
            {
                w.Abilities.Strength     = Attributes.Strength.Convert(AbilityId.Strength);
                w.Abilities.Endurance    = Attributes.Endurance.Convert(AbilityId.Endurance);
                w.Abilities.Coordination = Attributes.Coordination.Convert(AbilityId.Coordination);
                w.Abilities.Quickness    = Attributes.Quickness.Convert(AbilityId.Quickness);
                w.Abilities.Focus        = Attributes.Focus.Convert(AbilityId.Focus);
                w.Abilities.Self         = Attributes.Self.Convert(AbilityId.Self);

                w.Vitals.Health  = Attributes.Health.Convert(AbilityId.Health);
                w.Vitals.Stamina = Attributes.Stamina.Convert(AbilityId.Stamina);
                w.Vitals.Mana    = Attributes.Mana.Convert(AbilityId.Mana);
            }

            Body?.BodyParts?.ForEach(bp =>
            {
                var part = new Shared.BodyPart()
                {
                    BodyHeight     = bp.BodyPart.BH,
                    BodyPartType   = (BodyPartType)bp.Key,
                    Damage         = bp.BodyPart.DVal,
                    DamageType     = (DamageType)bp.BodyPart.DType,
                    DamageVariance = bp.BodyPart.DVar
                };

                if (bp.BodyPart.ArmorValues != null)
                {
                    part.ArmorValues.Base     = bp.BodyPart.ArmorValues.BaseArmor;
                    part.ArmorValues.Acid     = bp.BodyPart.ArmorValues.ArmorVsAcid;
                    part.ArmorValues.Bludgeon = bp.BodyPart.ArmorValues.ArmorVsBludgeon;
                    part.ArmorValues.Cold     = bp.BodyPart.ArmorValues.ArmorVsCold;
                    part.ArmorValues.Electric = bp.BodyPart.ArmorValues.ArmorVsElectric;
                    part.ArmorValues.Fire     = bp.BodyPart.ArmorValues.ArmorVsFire;
                    part.ArmorValues.Nether   = bp.BodyPart.ArmorValues.ArmorVsNether;
                    part.ArmorValues.Pierce   = bp.BodyPart.ArmorValues.ArmorVsPierce;
                    part.ArmorValues.Slash    = bp.BodyPart.ArmorValues.ArmorVsSlash;
                }

                if (bp.BodyPart.SD != null)
                {
                    part.TargetingData.HighLeftBack   = bp.BodyPart.SD.HLB;
                    part.TargetingData.HighLeftFront  = bp.BodyPart.SD.HLF;
                    part.TargetingData.HighRightBack  = bp.BodyPart.SD.HRB;
                    part.TargetingData.HighRightFront = bp.BodyPart.SD.HRF;
                    part.TargetingData.LowLeftBack    = bp.BodyPart.SD.LLB;
                    part.TargetingData.LowLeftFront   = bp.BodyPart.SD.LLF;
                    part.TargetingData.LowRightBack   = bp.BodyPart.SD.LRB;
                    part.TargetingData.LowRightFront  = bp.BodyPart.SD.LRF;
                    part.TargetingData.MidLeftBack    = bp.BodyPart.SD.MLB;
                    part.TargetingData.MidLeftFront   = bp.BodyPart.SD.MLF;
                    part.TargetingData.MidRightBack   = bp.BodyPart.SD.MRB;
                    part.TargetingData.MidRightFront  = bp.BodyPart.SD.MRF;
                }

                w.BodyParts.Add(part);
            });

            return(w);
        }