Exemplo n.º 1
0
        static CharData LoadCharData(StringReader sr, UserConnection conn)
        {
            var ch = new CharData(conn);

            while (true)
            {
                var word = sr.ReadWord();
                switch (word)
                {
                // A ----------------
                case "Act": ch.Act = sr.ReadNumber(); break;

                case "AffectedBy": ch.AffectedBy = sr.ReadNumber(); break;

                case "Alignment": ch.Alignment = sr.ReadNumber(); break;

                case "Armor": ch.Armor = sr.ReadNumber(); break;

                case "Avatarmessage": ch.PCData.AvatarMessage = sr.ReadString(); break;

                case "Awin": ch.PCData.Awins = sr.ReadNumber(); break;

                case "Alos": ch.PCData.Alosses = sr.ReadNumber(); break;

                case "Affect":
                case "AffectData":
                    var aff = new AffectData();
                    if (word == "Affect")
                    {
                        aff.Type = sr.ReadShort();
                    }
                    else
                    {
                        aff.Type = (short)SkillType.Lookup(sr.ReadWord());
                    }
                    aff.Duration  = sr.ReadShort();
                    aff.Modifier  = sr.ReadShort();
                    aff.Location  = sr.ReadShort();
                    aff.BitVector = sr.ReadNumber();
                    ch.Affected.Add(aff);
                    // TODO add to affect_free
                    break;

                case "AttrMod":
                    ch.PCData.ModStr = sr.ReadShort();
                    ch.PCData.ModInt = sr.ReadShort();
                    ch.PCData.ModWis = sr.ReadShort();
                    ch.PCData.ModDex = sr.ReadShort();
                    ch.PCData.ModCon = sr.ReadShort();
                    break;

                case "AttrPerm":
                    ch.PCData.PermStr = sr.ReadShort();
                    ch.PCData.PermInt = sr.ReadShort();
                    ch.PCData.PermWis = sr.ReadShort();
                    ch.PCData.PermDex = sr.ReadShort();
                    ch.PCData.PermCon = sr.ReadShort();
                    break;

                case "Alias":
                    var ad = new AliasData();
                    ad.ShortN = sr.ReadString();
                    ad.LongN  = sr.ReadString();
                    ch.PCData.Alias.Add(ad);
                    // add to alias_free
                    break;

                // B ----------------
                case "Bamfin": ch.PCData.Bamfin = sr.ReadString(); break;

                case "Bamfout": ch.PCData.Bamfout = sr.ReadString(); break;

                case "Beast": ch.Beast = sr.ReadShort(); break;

                case "Bounty": ch.PCData.Bounty = sr.ReadNumber(); break;

                case "Breath1": sr.ReadNumber(); break;

                case "Breath2": sr.ReadNumber(); break;

                case "Breath3": sr.ReadNumber(); break;

                case "Breath4": sr.ReadNumber(); break;

                case "Breath5": sr.ReadNumber(); break;

                case "Boards":
                    var numBoards = sr.ReadNumber();
                    for (int i = 0; i < numBoards; ++i)
                    {
                        var boardname = sr.ReadWord();
                        var lastNote  = sr.ReadNumberAsDateTime();

                        var board = BoardData.Lookup(boardname);
                        if (board == -1)
                        {
                            Content.log.Warn($"{ch.Name} had unknown board name: {boardname}. Skipped.");
                        }
                        else
                        {
                            ch.PCData.LastNote[i] = lastNote;
                        }
                    }
                    break;

                // C ----------------
                case "Clan": ch.Clan = sr.ReadString(); break;

                case "Class": ch.Class_ = sr.ReadNumber(); break;

                case "CurrentForm": ch.CurForm = sr.ReadShort(); break;

                case "Combat":
                    ch.Cmbt = ReadArray(sr, _ => _.ReadShort(), 8);
                    break;

                case "Chi":
                    ch.Chi = ReadArray(sr, _ => _.ReadShort(), 2);
                    break;

                case "Conception":
                    ch.PCData.Conception = sr.ReadString();
                    break;

                case "Condition":
                    ch.PCData.Condition = ReadArray(sr, _ => _.ReadShort(), 3);
                    break;

                case "CPower":
                    ch.Power = ReadArray(sr, _ => _.ReadNumber(), 44);
                    break;

                case "Cparents": ch.PCData.CParents = sr.ReadString(); break;

                case "Cprompt": ch.CPrompt = sr.ReadString(); break;

                case "Createtime": ch.CreateTime = sr.ReadString(); break;

                // D ----------------
                case "Damroll": ch.DamRoll = sr.ReadNumber(); break;

                case "Deaf": ch.Deaf = sr.ReadNumber(); break;

                case "Decapmessage": ch.PCData.DecapMessage = sr.ReadString(); break;

                case "Demonic": sr.ReadNumber(); break;

                case "Description": ch.Description = sr.ReadString(); break;

                case "DiscRese": ch.PCData.DiscResearch = sr.ReadNumber(); break;

                case "DiscPoin": ch.PCData.DiscPoints = sr.ReadNumber(); break;

                case "Dragonaff": sr.ReadNumber(); break;

                case "Dragonage": sr.ReadNumber(); break;

                case "Disc": for (int i = 0; i < 11; ++i)
                    {
                        sr.ReadNumber();
                    }
                    break;

                case "Drowaff": sr.ReadNumber(); break;

                case "Drowpwr": sr.ReadNumber(); break;

                case "Drowmag": sr.ReadNumber(); break;

                // E ----------------
                case "Email": sr.ReadString(); break;

                case "End": return(ch);

                case "Exhaustion": ch.PCData.Exhaustion = sr.ReadShort(); break;

                case "Exp": ch.Exp = sr.ReadNumber(); break;

                case "Explevel": ch.ExpLevel = sr.ReadNumber(); break;

                case "Expgained": ch.ExpGained = sr.ReadNumber(); break;

                case "Extra": ch.Extra = sr.ReadNumber(); break;

                // F ----------------
                case "FakeCon":
                    ch.PCData.FakeSkill  = sr.ReadShort();
                    ch.PCData.FakeStance = sr.ReadShort();
                    ch.PCData.FakeHit    = sr.ReadShort();
                    ch.PCData.FakeDam    = sr.ReadShort();
                    ch.PCData.FakeAC     = sr.ReadNumber();
                    ch.PCData.FakeHP     = sr.ReadShort();
                    ch.PCData.FakeMana   = sr.ReadShort();
                    ch.PCData.FakeMove   = sr.ReadShort();
                    break;

                case "Focus":
                    ch.Focus = ReadArray(sr, _ => _.ReadShort(), 2);
                    break;

                case "Flag2": ch.Flag2 = sr.ReadNumber(); break;

                case "Flag3": ch.Flag3 = sr.ReadNumber(); break;

                case "Flag4": ch.Flag4 = sr.ReadNumber(); break;

                case "Form": ch.Form = sr.ReadNumber(); break;

                // G ----------------
                case "Generation": ch.Generation = sr.ReadShort(); break;

                case "Gnosis": ch.Gnosis = new short[Garou.GMAXIMUM] {
                        sr.ReadShort()
                }; break;

                case "Genes":
                    ch.PCData.Genes = ReadArray(sr, _ => _.ReadNumber(), 10);
                    break;

                case "Garou1": ch.Garou1 = sr.ReadNumber(); break;

                case "Garou2": ch.Garou2 = sr.ReadNumber(); break;

                case "Gifts":
                    ch.Gifts = ReadArray(sr, _ => _.ReadNumber(), 21);
                    break;

                case "Gold": ch.Gold = sr.ReadNumber(); break;

                // H ----------------
                case "Hitroll": ch.HitRoll = sr.ReadNumber(); break;

                case "Home": ch.Home = sr.ReadNumber(); break;

                case "Hatch": sr.ReadNumber(); break;

                case "HpManaMove":
                    ch.Hit     = sr.ReadNumber();
                    ch.MaxHit  = sr.ReadNumber();
                    ch.Mana    = sr.ReadNumber();
                    ch.MaxMana = sr.ReadNumber();
                    ch.Move    = sr.ReadNumber();
                    ch.MaxMove = sr.ReadNumber();
                    break;

                // I ----------------
                case "Immune": ch.Immune = sr.ReadNumber(); break;

                case "Itemaffect": ch.ItemAffect = sr.ReadNumber(); break;

                // J ----------------
                case "Jflags": ch.PCData.JFlags = sr.ReadNumber(); break;

                // K ----------------
                case "Kingdom": ch.PCData.Kingdom = sr.ReadNumber(); break;

                // L ----------------
                case "Language":
                    ch.PCData.Language = ReadArray(sr, _ => _.ReadNumber(), 2);
                    break;

                case "Lasthost": ch.LastHost = sr.ReadString(); break;

                case "Lastdecap1": ch.PCData.LastDecap[0] = sr.ReadString(); break;

                case "Lastdecap2": ch.PCData.LastDecap[1] = sr.ReadString(); break;

                case "Lasttime": ch.LastTime = sr.ReadString(); break;

                case "Level": ch.Level = sr.ReadNumber(); break;

                case "Levelexp": sr.ReadNumber(); break;

                case "Locationhp":
                    ch.LocHP = ReadArray(sr, _ => _.ReadShort(), 7);
                    break;

                case "Loginmessage": ch.PCData.LoginMessage = sr.ReadString(); break;

                case "Logoutmessage": ch.PCData.LogoutMessage = sr.ReadString(); break;

                case "LongDescr": ch.LongDescription = sr.ReadString(); break;

                case "Lord": ch.Lord = sr.ReadString(); break;

                // M ----------------
                case "MageFlags": sr.ReadNumber(); break;

                case "Monkab":
                    ch.MonkAb = ReadArray(sr, _ => _.ReadNumber(), 4);
                    break;

                case "Meanparadox": ch.PCData.MeanParadoxCounter = sr.ReadShort(); break;

                case "Monkstuff": ch.MonkStuff = sr.ReadNumber(); break;

                case "Monkcrap": ch.MonkCrap = sr.ReadNumber(); break;

                case "Marriage": ch.PCData.Marriage = sr.ReadString(); break;

                case "Morph": ch.Morph = sr.ReadString(); break;

                // N ----------------
                case "Newbits": ch.NewBits = sr.ReadNumber(); break;

                case "Name": sr.ReadToEOL(); break;

                // O ----------------
                case "Objvnum": ch.PCData.ObjVNum = sr.ReadVnum(); break;

                case "ObjDesc": ch.ObjDesc = sr.ReadString(); break;

                // P ----------------
                case "Paradox":
                    ch.Paradox = ReadArray(sr, _ => _.ReadNumber(), 3);
                    break;

                case "Parents": ch.PCData.Parents = sr.ReadString(); break;

                case "Password": ch.PCData.Pwd = sr.ReadString(); break;

                case "Played": ch.Played = sr.ReadNumber(); break;

                case "Polyaff": ch.PolyAff = sr.ReadNumber(); break;

                case "Power_Point": sr.ReadNumber(); break;

                case "Power":
                    ch.PCData.Powers = ReadArray(sr, _ => _.ReadNumber(), 20);
                    break;

                case "Poweraction": ch.PowerAction = sr.ReadString(); break;

                case "Powertype": ch.PowerType = sr.ReadString(); break;

                case "Position": ch.Position = sr.ReadNumber(); break;

                case "Practice": ch.Practice = sr.ReadNumber(); break;

                case "PkPdMkMd":
                    ch.PKill  = sr.ReadNumber();
                    ch.PDeath = sr.ReadNumber();
                    ch.MKill  = sr.ReadNumber();
                    ch.MDeath = sr.ReadNumber();
                    break;

                case "Prompt": ch.Prompt = sr.ReadString(); break;

                // Q ----------------
                case "Quest": ch.PCData.Quest = sr.ReadNumber(); break;

                case "Questsrun": ch.PCData.QuestsRun = sr.ReadNumber(); break;

                case "Queststotal": ch.PCData.QuestsTotal = sr.ReadNumber(); break;

                // R ----------------
                case "Race": ch.PCData.Quest = sr.ReadNumber(); break;

                case "Rage": ch.Rage = sr.ReadShort(); break;

                case "Rank": ch.PCData.Rank = sr.ReadShort(); break;

                case "Relrank": ch.PCData.RelRank = sr.ReadShort(); break;

                case "Revision": ch.PCData.Revision = sr.ReadShort(); break;

                case "Runecount": ch.PCData.RuneCount = sr.ReadShort(); break;

                case "Room":
                    RoomDef room;
                    if (RoomDef.TryGetRoomDef(sr.ReadVnum(), out room))
                    {
                        ch.InRoom = room;
                    }
                    break;

                case "Runes":
                    ReadArray(sr, _ => _.ReadNumber(), 4);
                    break;

                // S ----------------
                case "Smite": sr.ReadString(); break;

                case "SavingThrow": ch.SavingThrow = sr.ReadNumber(); break;

                case "Switchname": ch.PCData.SwitchName = sr.ReadString(); break;

                case "SilTol": ch.SilTol = sr.ReadShort(); break;

                case "Souls": ch.PCData.Souls = sr.ReadShort(); break;

                case "Score":
                    ch.PCData.Score = ReadArray(sr, _ => _.ReadNumber(), 6);
                    break;

                case "Sex": ch.Sex = (Gender)sr.ReadShort(); break;

                case "ShortDescr": ch.ShortDescription = sr.ReadString(); break;

                case "Security": ch.PCData.Security = sr.ReadNumber(); break;

                case "Skill":
                    var value = sr.ReadShort();
                    var sn    = SkillType.Lookup(sr.ReadWord());
                    if (sn >= 0)
                    {
                        ch.PCData.Learned[sn] = value;
                    }
                    break;

                case "Specpower": ch.SpecPower = sr.ReadShort(); break;

                case "Spectype": ch.SpecType = sr.ReadShort(); break;

                case "Special": ch.Special = sr.ReadNumber(); break;

                case "Spells":
                    ch.Spl = ReadArray(sr, _ => _.ReadShort(), 5);
                    break;

                case "Stage":
                    ch.PCData.Stage = ReadArray(sr, _ => _.ReadShort(), 3);
                    break;

                case "Stance":
                    for (int i = 0; i < 12; ++i)
                    {
                        ch.Stance[i] = sr.ReadNumber();
                    }
                    break;

                case "Stance2":
                    for (int i = 0; i < 12; ++i)
                    {
                        ch.Stance[i + 12] = sr.ReadNumber();
                    }
                    break;

                case "StatAbility":
                    ch.PCData.StatAbility = ReadArray(sr, _ => _.ReadShort(), 4);
                    break;

                case "StatAmount":
                    ch.PCData.StatAmount = ReadArray(sr, _ => _.ReadShort(), 4);
                    break;

                case "StatDuration":
                    ch.PCData.StatDuration = ReadArray(sr, _ => _.ReadShort(), 4);
                    break;

                case "Stats":
                    ch.PCData.Stats = ReadArray(sr, _ => _.ReadNumber(), 12);
                    break;

                // T ----------------
                case "Tiemessage": ch.PCData.TimeMessage = sr.ReadString(); break;

                case "Trust": ch.Trust = sr.ReadShort(); break;

                case "Title":
                    var title = sr.ReadString().Trim();
                    ch.PCData.Title = " " + title;
                    break;

                // U ----------------
                case "Upgradelevel": ch.PCData.UpgradeLevel = sr.ReadShort(); break;

                // V ----------------
                case "Vampaff": sr.ReadNumber(); break;

                case "Vampgen": sr.ReadNumber(); break;

                case "Vnum":
                    var       mdvnum = sr.ReadVnum();
                    MobileDef md;
                    if (MobileDef.TryGetMobileDef(mdvnum, out md))
                    {
                        ch.IndexData = md;
                    }
                    break;

                // W ----------------
                case "Warps": ch.Warp = sr.ReadNumber(); break;

                case "WarpCount": ch.WarpCount = sr.ReadShort(); break;

                case "Weapons":
                    ch.Wpn = ReadArray(sr, _ => _.ReadShort(), 13);
                    break;

                case "Wimpy": ch.Wimpy = sr.ReadShort(); break;

                case "Wolf": sr.ReadShort(); break;

                case "Wolfform":
                    sr.ReadNumber();
                    sr.ReadNumber();
                    break;

                // X ----------------
                case "XHitroll": ch.XHitRoll = sr.ReadNumber(); break;

                case "XDamroll": ch.XDamRoll = sr.ReadNumber(); break;

                default:
                    Content.log.Error($"no match.WORD: {word}");
                    sr.ReadToEOL();
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public static void LoadFromArea(StringReader sr, AreaData area)
        {
            if (area == null)
            {
                throw new Exception("Load_objects: no #AREA seen yet.");
            }

            while (true)
            {
                var letter = sr.ReadLetter();
                if (letter != '#')
                {
                    throw new Exception("Load_objects: # not found.");
                }

                var vnum = sr.ReadVnum();
                if (vnum == Vnum.None)
                {
                    break;
                }

                ObjectDef existing;
                if (!TryGetObjectData(vnum, out existing))
                {
                    throw new Exception($"Load_objects: vnum % {vnum} duplicated.");
                }

                var od = new ObjectDef
                {
                    Vnum = vnum,
                    Area = area
                };

                od.Name = sr.ReadString();
                // TODO upper first char
                od.ShortDescription = sr.ReadString();
                // TODO upper first char
                od.Description = sr.ReadString();
                sr.ReadString(); // Action description

                od.ItemType   = (ItemType)sr.ReadShort();
                od.ExtraFlags = (ExtraFlags)sr.ReadNumber();
                od.WearFlags  = sr.ReadNumber();

                switch (od.ItemType)
                {
                case ItemType.Wand:
                case ItemType.Staff:
                    od.Value[0] = sr.ReadNumber();
                    od.Value[1] = sr.ReadNumber();
                    od.Value[2] = sr.ReadNumber();
                    od.Value[3] = SkillType.Lookup(sr.ReadWord());
                    break;

                case ItemType.Potion:
                case ItemType.Pill:
                case ItemType.Scroll:
                    od.Value[0] = sr.ReadNumber();
                    od.Value[1] = SkillType.Lookup(sr.ReadWord());
                    od.Value[2] = SkillType.Lookup(sr.ReadWord());
                    od.Value[3] = SkillType.Lookup(sr.ReadWord());
                    break;

                default:
                    od.Value[0] = sr.ReadNumber();
                    od.Value[1] = sr.ReadNumber();
                    od.Value[2] = sr.ReadNumber();
                    od.Value[3] = sr.ReadNumber();
                    break;
                }

                od.Weight = sr.ReadShort();
                od.Cost   = sr.ReadNumber();

                sr.ReadNumber(); // Cost per day

                //if (od.ItemType == ItemType.Potion)
                //{
                //    od.ExtraFlags |= ExtraFlags.NoDrop;
                //}

                while (true)
                {
                    bool done = false;
                    switch (sr.PeekLetter())
                    {
                    case 'A':
                        sr.ReadLetter();
                        var aff = new AffectData
                        {
                            Type     = -1,
                            Duration = -1
                        };
                        aff.Location = sr.ReadShort();
                        aff.Modifier = sr.ReadShort();
                        od.Affected.Add(aff);
                        // top_affect++;
                        break;

                    case 'E':
                        sr.ReadLetter();
                        var ed = new ExtraDescrData();
                        ed.Keyword     = sr.ReadString();
                        ed.Description = sr.ReadString();
                        od.ExtraDescr.Add(ed);
                        //top_ed++;
                        break;

                    case 'Q':
                        sr.ReadLetter();
                        od.CHPowerOn      = sr.ReadString();
                        od.CHPowerOff     = sr.ReadString();
                        od.CHPowerUse     = sr.ReadString();
                        od.VictimPowerOn  = sr.ReadString();
                        od.VictimPowerOff = sr.ReadString();
                        od.VictimPowerUse = sr.ReadString();
                        od.SpecType       = sr.ReadNumber();
                        od.SpecPower      = sr.ReadNumber();
                        break;

                    default:
                        done = true;
                        break;
                    }
                    if (done)
                    {
                        break;
                    }
                }

                // ?????
                switch (od.ItemType)
                {
                case ItemType.Pill:
                case ItemType.Potion:
                case ItemType.Scroll:
                case ItemType.Staff:
                case ItemType.Wand:
                    break;
                }

                switch (od.Vnum)
                {
                case (Vnum)3375:
                    // CHAOS = true;
                    break;

                case (Vnum)29515:
                    // VISOR = true;
                    break;

                case (Vnum)29512:
                    // DARKNESS = true;
                    break;

                case (Vnum)29505:
                    // SPEED = true;
                    break;

                case (Vnum)29518:
                    // BRACELET = true;
                    break;

                case (Vnum)29504:
                    // TORC = true;
                    break;

                case (Vnum)29514:
                    // ARMOUR = true;
                    break;

                case (Vnum)29516:
                    // CLAWS = true;
                    break;

                case (Vnum)29555:
                    // ITEMAFFMANTIS = true;
                    break;

                case (Vnum)2654:
                    // ITEMAFFENTROPY = true;
                    break;

                case (Vnum)29598:
                    // ITEMAFFENTROPY = true;
                    break;
                }


                // TODO ???????

                //iHash = vnum % MAX_KEY_HASH;
                //pObjIndex->next = obj_index_hash[iHash];
                //obj_index_hash[iHash] = pObjIndex;
                //top_obj_index++;
                //top_vnum_obj = top_vnum_obj < vnum ? vnum : top_vnum_obj;  /* OLC */
                //assign_area_vnum(vnum);                                  /* OLC */
            }
        }