当前位置: 首页>>代码示例>>C#>>正文


C# GenericReader.ReadUInt32方法代码示例

本文整理汇总了C#中GenericReader.ReadUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# GenericReader.ReadUInt32方法的具体用法?C# GenericReader.ReadUInt32怎么用?C# GenericReader.ReadUInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GenericReader的用法示例。


在下文中一共展示了GenericReader.ReadUInt32方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Deserialize

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt32();
            switch (version)
            {
                case 0:
                {
                    m_LockdownData = reader.ReadUInt32();
                    break;
                }
            }
		}
开发者ID:zerodowned,项目名称:angelisland,代码行数:14,代码来源:BuildingUpgradeContracts.cs

示例2: ParsePacket

        private uint ParsePacket(GenericReader gr, StreamWriter sw, StreamWriter swe, StreamWriter data)
        {
            StringBuilder sb = new StringBuilder();

            //MessageBox.Show(br.BaseStream.Position.ToString() + " " + br.BaseStream.Length.ToString());

            uint opcode = gr.ReadUInt16();
            if (opcode != 0x00A9)
            {
                return 2;
            }

            sb.AppendLine("Packet offset " + (gr.BaseStream.Position - 2).ToString("X2"));

            sb.AppendLine("Packet number: " + packet);

            sb.AppendLine("Opcode: " + opcode.ToString("X4"));

            uint count = gr.ReadUInt32();
            sb.AppendLine("Object count: " + count);

            uint unk = gr.ReadByte();
            sb.AppendLine("Unk: " + unk);

            for (uint i = 1; i < count+1; i++)
            {
                sb.AppendLine("Update block for object " + i + ":");
                sb.AppendLine("Block offset " + gr.BaseStream.Position.ToString("X2"));

                if (!ParseBlock(gr, sb, swe, data))
                {
                    sw.WriteLine(sb.ToString());
                    return 1;
                }
            }
            sw.WriteLine(sb.ToString());
            return 0;
        }
开发者ID:arkanoid1,项目名称:mywowtools,代码行数:38,代码来源:a9_parser.cs

示例3: ParseValuesUpdateBlock

        private bool ParseValuesUpdateBlock(GenericReader gr, StringBuilder sb, StreamWriter swe, StreamWriter data, ObjectTypes objectTypeId, UpdateTypes updatetype)
        {
            // may be we can reduce size of code there...

            sb.AppendLine("=== values_update_block_start ===");

            byte blocks_count = gr.ReadByte(); // count of update blocks (4 bytes for each update block)
            sb.AppendLine("Bit mask blocks count: " + blocks_count);

            uint[] updatemask = new uint[blocks_count]; // create array of update blocks
            for (int j = 0; j < blocks_count; j++)
                updatemask[j] = gr.ReadUInt32(); // populate array of update blocks with data

            Mask = (BitArr)updatemask; // convert array of update blocks to bitmask array

            int reallength = Mask.RealLength; // bitmask size (bits)

            // item/container values update block
            if (objectTypeId == ObjectTypes.TYPEID_ITEM || objectTypeId == ObjectTypes.TYPEID_CONTAINER)
            {
                if (reallength > 160) // 5*32, ??
                {
                    long pos = gr.BaseStream.Position;
                    swe.WriteLine("error position " + pos.ToString("X2"));

                    swe.WriteLine("error while parsing ITEM values update block, count " + reallength);
                    return false;
                }

                for (uint index = 0; index < reallength; index++)
                {
                    if (index > UpdateFields.ITEM_END)
                        break;

                    if (Mask[index])
                    {
                        switch (UpdateFields.item_updatefields[index].type)
                        {
                            case 1:
                                sb.AppendLine(UpdateFields.item_updatefields[index].name + " (" + index + "): " + gr.ReadSingle().ToString().Replace(",", "."));
                                break;
                            default:
                                sb.AppendLine(UpdateFields.item_updatefields[index].name + " (" + index + "): " + gr.ReadUInt32());
                                break;
                        }
                    }
                }
            }

            // unit values update block
            if (objectTypeId == ObjectTypes.TYPEID_UNIT)
            {
                if (reallength > 256) // 32*8 (for units bitmask = 8)
                {
                    long pos = gr.BaseStream.Position;
                    swe.WriteLine("error position " + pos.ToString("X2"));

                    swe.WriteLine("error while parsing UNIT values update block, count " + reallength);
                    return false;
                }

                for (uint index = 0; index < reallength; index++)
                {
                    if (index > UpdateFields.UNIT_END)
                        break;

                    if (Mask[index])
                    {
                        switch (UpdateFields.unit_updatefields[index].type)
                        {
                            case 1:
                                string val1 = gr.ReadSingle().ToString().Replace(",", ".");
                                if(updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2)
                                    data.WriteLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val1);
                                sb.AppendLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val1);
                                break;
                            default:
                                uint val2 = gr.ReadUInt32();
                                if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2)
                                    data.WriteLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val2);
                                sb.AppendLine(UpdateFields.unit_updatefields[index].name + " (" + index + "): " + val2);
                                break;
                        }
                    }
                }
            }

            // player values update block
            if (objectTypeId == ObjectTypes.TYPEID_PLAYER)
            {
                if (reallength > 1440) // 32*45 (for player bitmask = 45)
                {
                    long pos = gr.BaseStream.Position;
                    swe.WriteLine("error position " + pos.ToString("X2"));

                    swe.WriteLine("error while parsing PLAYER values update block, count " + reallength);
                    return false;
                }

                for (uint index = 0; index < reallength; index++)
//.........这里部分代码省略.........
开发者ID:arkanoid1,项目名称:mywowtools,代码行数:101,代码来源:a9_parser.cs

示例4: ParseMovementUpdateBlock

        private bool ParseMovementUpdateBlock(GenericReader gr, StringBuilder sb, StreamWriter swe, StreamWriter data, ObjectTypes objectTypeId)
        {
            Coords4 coords;
            // need figure out flags2, check flags, because we can't read packet without it...
            // flags2:

            // 0x1 - not affect data
            // 0x2 - need check
            // 0x4
            // 0x8
            // 0x10 - need check
            // 0x20 - not affect data
            // 0x100
            // 0x800
            // 0x2000 - need check
            // 0x4000
            // 0x200000
            // 0x8000000 ?
            // 0x10000000
            // 0x20000000

            sb.AppendLine("=== movement_update_block_start ===");
            uint flags2 = 0;

            UpdateFlags flags = (UpdateFlags)gr.ReadByte();
            sb.AppendLine("flags " + flags.ToString("X"));

            if ((UpdateFlags.UPDATEFLAG_LIVING & flags) != 0) // 0x20
            {
                flags2 = gr.ReadUInt32();
                sb.AppendLine("flags2 " + flags2.ToString("X8"));

                uint time = gr.ReadUInt32();
                sb.AppendLine("time " + time);
            }

            if ((UpdateFlags.UPDATEFLAG_HASPOSITION & flags) != 0) // 0x40
            {
                if ((UpdateFlags.UPDATEFLAG_TRANSPORT & flags) != 0) // 0x02
                {
                    coords = gr.ReadCoords4();
                    sb.AppendLine("coords " + coords.GetCoordsAsString());
                }
                else // strange, we read the same data :)
                {
                    coords = gr.ReadCoords4();
                    sb.AppendLine("coords " + coords.GetCoordsAsString());
                }

                if (objectTypeId == ObjectTypes.TYPEID_UNIT || objectTypeId == ObjectTypes.TYPEID_GAMEOBJECT)
                {
                    data.WriteLine();
                    data.WriteLine(objectTypeId + ": " + coords.GetCoordsAsString());
                }

                if ((flags2 & 0x0200) != 0) // transport
                {
                    ulong t_guid = gr.ReadUInt64();
                    sb.Append("t_guid " + t_guid.ToString("X2") + ", ");

                    Coords4 transport = gr.ReadCoords4();
                    sb.AppendLine("t_coords " + transport.GetCoordsAsString());

                    uint unk1 = gr.ReadUInt32(); // unk, 2.0.6 == 0x11 or random
                    sb.AppendLine("unk1 " + unk1);
                }
            }

            if ((UpdateFlags.UPDATEFLAG_LIVING & flags) != 0) // 0x20
            {
                uint unk1 = gr.ReadUInt32();
                sb.AppendLine("unk1 " + unk1);

                if ((flags2 & 0x2000) != 0) // <---
                {
                    // looks like orientation/coords/speed
                    float unk2 = gr.ReadSingle();
                    sb.AppendLine("unk2 " + unk2);
                    float unk3 = gr.ReadSingle();
                    sb.AppendLine("unk3 " + unk3);
                    float unk4 = gr.ReadSingle();
                    sb.AppendLine("unk4 " + unk4);
                    float unk5 = gr.ReadSingle();
                    sb.AppendLine("unk5 " + unk5);
                }

                float ws = gr.ReadSingle();
                sb.AppendLine("Walk speed " + ws);
                float rs = gr.ReadSingle();
                sb.AppendLine("Run speed " + rs);
                float sbs = gr.ReadSingle();
                sb.AppendLine("Swimback speed " + sbs);
                float ss = gr.ReadSingle();
                sb.AppendLine("Swim speed " + ss);
                float wbs = gr.ReadSingle();
                sb.AppendLine("Walkback speed " + wbs);
                float fs = gr.ReadSingle();
                sb.AppendLine("Fly speed " + fs);
                float fbs = gr.ReadSingle();
                sb.AppendLine("Flyback speed " + fbs);
//.........这里部分代码省略.........
开发者ID:arkanoid1,项目名称:mywowtools,代码行数:101,代码来源:a9_parser.cs

示例5: ParseBlock

        private bool ParseBlock(GenericReader gr, StringBuilder sb, StreamWriter swe, StreamWriter data)
        {
            UpdateTypes updatetype = (UpdateTypes)gr.ReadByte();
            sb.AppendLine("Updatetype: " + updatetype);

            if (updatetype < UpdateTypes.UPDATETYPE_VALUES || updatetype > UpdateTypes.UPDATETYPE_NEAR_OBJECTS)
            {
                long pos = gr.BaseStream.Position;
                swe.WriteLine("wrong updatetype at position " + pos.ToString("X2"));

                // we there only if we read packet wrong way
                swe.WriteLine("Updatetype " + updatetype + " is not supported");
                return false;
            }

            if (updatetype == UpdateTypes.UPDATETYPE_VALUES)
            {
                ulong guid = gr.ReadPackedGuid();
                sb.AppendLine("Object guid: " + guid.ToString("X16"));

                if (guid == 0)
                {
                    long pos = gr.BaseStream.Position;
                    swe.WriteLine("wrong guid at position " + pos.ToString("X2"));

                    // we there only if we read packet wrong way
                    swe.WriteLine("Updatetype " + updatetype + " can't be with NULL guid");
                    return false;
                }

                // object type detection:
                ObjectTypes objecttype;
                if (guid.ToString("X16").Substring(0, 8) == "40000000")
                    objecttype = ObjectTypes.TYPEID_ITEM;
                else if (guid.ToString("X16").Substring(0, 8) == "00000000")
                    objecttype = ObjectTypes.TYPEID_PLAYER;
                else
                    objecttype = ObjectTypes.TYPEID_UNIT;

                if (!ParseValuesUpdateBlock(gr, sb, swe, data, objecttype, updatetype))
                    return false;

                return true;
            }

            if (updatetype == UpdateTypes.UPDATETYPE_MOVEMENT)
            {
                ulong guid = gr.ReadPackedGuid();
                sb.AppendLine("Object guid: " + guid.ToString("X2"));

                if (!ParseMovementUpdateBlock(gr, sb, swe, data, ObjectTypes.TYPEID_UNIT))
                    return false;

                return true;
            }

            if (updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT || updatetype == UpdateTypes.UPDATETYPE_CREATE_OBJECT2)
            {
                ulong guid = gr.ReadPackedGuid();
                sb.AppendLine("Object guid: " + guid.ToString("X2"));

                ObjectTypes objectTypeId = (ObjectTypes)gr.ReadByte();
                sb.AppendLine("objectTypeId " + objectTypeId);

                switch (objectTypeId)
                {
                    case ObjectTypes.TYPEID_OBJECT:
                        swe.WriteLine("Unhandled object type " + objectTypeId);
                        break;
                    case ObjectTypes.TYPEID_ITEM:
                    case ObjectTypes.TYPEID_CONTAINER:
                    case ObjectTypes.TYPEID_UNIT:
                    case ObjectTypes.TYPEID_PLAYER:
                    case ObjectTypes.TYPEID_GAMEOBJECT:
                    case ObjectTypes.TYPEID_DYNAMICOBJECT:
                    case ObjectTypes.TYPEID_CORPSE:
                        if (!ParseMovementUpdateBlock(gr, sb, swe, data, objectTypeId))
                            return false;
                        if (!ParseValuesUpdateBlock(gr, sb, swe, data, objectTypeId, updatetype))
                            return false;
                        break;
                    case ObjectTypes.TYPEID_AIGROUP:
                        swe.WriteLine("Unhandled object type " + objectTypeId);
                        break;
                    case ObjectTypes.TYPEID_AREATRIGGER:
                        swe.WriteLine("Unhandled object type " + objectTypeId);
                        break;
                    default:
                        swe.WriteLine("Unknown object type " + objectTypeId);
                        return false;
                }
                return true;
            }

            if (updatetype == UpdateTypes.UPDATETYPE_OUT_OF_RANGE_OBJECTS || updatetype == UpdateTypes.UPDATETYPE_NEAR_OBJECTS)
            {
                uint objects_count = gr.ReadUInt32();

                if (objects_count > 1000) // we read packet wrong way
                {
//.........这里部分代码省略.........
开发者ID:arkanoid1,项目名称:mywowtools,代码行数:101,代码来源:a9_parser.cs


注:本文中的GenericReader.ReadUInt32方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。