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


C# NetBuffer.ReadInt32方法代码示例

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


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

示例1: Read

 public void Read(NetBuffer im)
 {
     MessagePacketId = im.ReadInt64();
     Number          = im.ReadInt32();
     int length      = im.ReadInt32();
     if (length != 0)
     {
         Bytes = im.ReadBytes(length);
     }
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:10,代码来源:PacketMessage.cs

示例2: Read

 public override void Read(NetBuffer im)
 {
     base.Read(im);
     int c = im.ReadInt32();
     for(int i = 0; i < c; ++i)
     {
         int id = im.ReadInt32();
         FollowerId.Add(id);
     }
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:10,代码来源:HireFollowerMessage.cs

示例3: Read

 public override void Read(NetBuffer im)
 {
     base.Read(im);
     int c = im.ReadInt32();
     for(int i = 0; i < c; ++i)
     {
         int objId = im.ReadInt32();
         int folId = im.ReadInt32();
         Followers.Add(new KeyValuePair<int, int>(objId, folId));
     }
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:11,代码来源:HireResultMessage.cs

示例4: ClientCommand

        bool ClientCommand(client_t cl, NetBuffer msg)
        {
            int seq = msg.ReadInt32();
            string s = msg.ReadString();

            // see if we have already executed it
            if (cl.lastClientCommand >= seq)
                return true;

            Common.Instance.WriteLine("ClientCommand: {0}[s{1}]: {2}", cl.name, seq, s);

            // drop the connection if we have somehow lost commands
            if (seq > cl.lastClientCommand + 1)
            {
                Common.Instance.WriteLine("Client {0} lost {1} clientCommands", cl.name, seq-cl.lastClientCommand+1);
                DropClient(cl, "Lost reliable commands");
                return false;
            }

            // don't allow another command for one second
            cl.nextReliableTime = (int)time + 1000;

            ExecuteClientCommand(cl, s);
            cl.lastClientCommand = seq;
            cl.lastClientCommandString = s;
            return true;    // continue procesing
        }
开发者ID:maesse,项目名称:CubeHags,代码行数:27,代码来源:ServerClient.cs

示例5: Read

 public override void Read(NetBuffer im)
 {
     base.Read(im);
     int c = im.ReadInt32();
     for(int i = 0; i < c; ++i)
     {
         var objid       = im.ReadInt32();
         var followerid  = im.ReadInt32();
         FollowerList.Add(new KeyValuePair<int, int>(objid, followerid));
     }
     c = im.ReadInt32();
     for (int i = 0; i < c; ++i)
     {
         var follower = im.ReadInt32();
         FightFollowerList.Add(follower);
     }
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:17,代码来源:PushMessage.cs

示例6: ParseCommandString

        /*
        =====================
        CL_ParseCommandString

        Command strings are just saved off until cgame asks for them
        when it transitions a snapshot
        =====================
        */
        void ParseCommandString(NetBuffer buf)
        {
            int seq = buf.ReadInt32();
            string s = buf.ReadString();

            // see if we have already executed stored it off
            if (clc.serverCommandSequence >= seq)
                return;

            clc.serverCommandSequence = seq;
            int index = seq & 63;
            clc.serverCommands[index] = s;
        }
开发者ID:maesse,项目名称:CubeHags,代码行数:21,代码来源:ClientParse.cs

示例7: Read

        public void Read(NetBuffer im)
        {
            if (Plugins == null)
            {
                Plugins = new List<string>();
            }

            int count = im.ReadInt32();
            for(int i = 0; i < count; ++i)
            {
                var plugin = im.ReadString();
                Plugins.Add(plugin);
            }
        }
开发者ID:xxy1991,项目名称:cozy,代码行数:14,代码来源:PluginQueryMessage.cs

示例8: Read

 public void Read(NetBuffer im)
 {
     PluginName  = im.ReadString();
     MethodName  = im.ReadString();
     RspType     = im.ReadByte();
     if (RspType == StringDataType)
     {
         StringCommandRsp = im.ReadString();
     }
     else if (RspType == BinaryDataType)
     {
         int l = im.ReadInt32();
         BinaryCommandRsp = im.ReadBytes(l);
     }
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:15,代码来源:CommandMessageRsp.cs

示例9: Read

 public void Read(NetBuffer im)
 {
     MetaData    = im.ReadString();
     int l       = im.ReadInt32();
     Data        = im.ReadBytes(l);
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:6,代码来源:BinaryPacketMessage.cs

示例10: ParseGameState

        void ParseGameState(NetBuffer msg)
        {
            clc.connectPacketCount = 0;
            // wipe local client state
            ClearState();
            // a gamestate always marks a server command sequence
            clc.serverCommandSequence = msg.ReadInt32();
            // parse all the configstrings and baselines
            while (true)
            {
                int cmd = msg.ReadByte();

                if (cmd == (int)svc_ops_e.svc_EOF)
                    break;

                if (cmd == (int)svc_ops_e.svc_configstring)
                {
                    int index = msg.ReadInt16();
                    string s = msg.ReadString();
                    cl.gamestate.data.Add(index, s);
                }
                else if (cmd == (int)svc_ops_e.svc_baseline)
                {
                    int newnum = msg.ReadInt32();
                    if (newnum < 0 || newnum >= 1024)
                    {
                        Common.Instance.Error("ParseGameState: Baseline number out of range: " + newnum);
                    }
                    Common.entityState_t nullstate = new Common.entityState_t();
                    Net.Instance.MSG_ReadDeltaEntity(msg, ref nullstate, ref cl.entityBaselines[newnum], newnum);
                }
                else
                {
                    Common.Instance.Error("ParseGameState: bad command byte");
                }
            }

            clc.clientNum = msg.ReadInt32();

            // parse useful values out of CS_SERVERINFO
            //ParseServerInfo();

            // parse serverId and other cvars
            SystemInfoChanged();

            InitDownloads();
        }
开发者ID:maesse,项目名称:CubeHags,代码行数:47,代码来源:ClientParse.cs

示例11: ParseSnapshot

        /*
        ================
        CL_ParseSnapshot

        If the snapshot is parsed properly, it will be copied to
        cl.snap and saved in cl.snapshots[].  If the snapshot is invalid
        for any reason, no changes to the state will be made at all.
        ================
        */
        void ParseSnapshot(NetBuffer msg)
        {
            // read in the new snapshot to a temporary buffer
            // we will only copy to cl.snap if it is valid
            clSnapshot_t newsnap = new clSnapshot_t();
            clSnapshot_t old;

            // we will have read any new server commands in this
            // message before we got to svc_snapshot
            newsnap.ServerCommandNum = clc.serverCommandSequence;
            newsnap.serverTime = msg.ReadInt32();
            newsnap.messageNum = clc.serverMessageSequence;

            int deltaNum = msg.ReadByte();

            if (deltaNum <= 0)
            {
                newsnap.deltaNum = -1;
            }
            else
                newsnap.deltaNum = newsnap.messageNum - deltaNum;
            newsnap.snapFlags = msg.ReadByte();

            // If the frame is delta compressed from data that we
            // no longer have available, we must suck up the rest of
            // the frame, but not use it, then ask for a non-compressed
            // message
            if (newsnap.deltaNum <= 0)
            {
                newsnap.valid = true;   // uncompressed frame
                old = null;
            }
            else
            {
                old = cl.snapshots[newsnap.deltaNum & 31];
                if (!old.valid)
                {
                    // should never happen
                    Common.Instance.WriteLine("ParseSnapshot: Delta from invalid frame (not supposed to happen!).");
                }
                else if (old.messageNum != newsnap.deltaNum)
                {
                    // The frame that the server did the delta from
                    // is too old, so we can't reconstruct it properly.
                    Common.Instance.WriteLine("ParseSnapshot: Delta frame too old.");
                }
                else if (cl.parseEntitiesNum - old.parseEntitiesNum > 2048 - 128)
                {
                    Common.Instance.WriteLine("ParseSnapshot: Delta parseEntitiesNum too old");
                }
                else
                    newsnap.valid = true;   // valid delta parse
            }

            // read areamask
            int len = msg.ReadByte();
            newsnap.areamask = msg.ReadBytes(32);
            // read playerinfo
            if (old != null)
            {
                Net.ReadDeltaPlayerstate(msg, old.ps, newsnap.ps);
            }
            else
                Net.ReadDeltaPlayerstate(msg, null, newsnap.ps);

            // read packet entities
            ParsePacketEntities(msg, old, newsnap);

            // if not valid, dump the entire thing now that it has
            // been properly read
            if (!newsnap.valid)
                return;

            // clear the valid flags of any snapshots between the last
            // received and this one, so if there was a dropped packet
            // it won't look like something valid to delta from next
            // time we wrap around in the buffer
            int oldMessageNum = cl.snap.messageNum + 1;
            if (newsnap.messageNum - oldMessageNum >= 32)
            {
                oldMessageNum = newsnap.messageNum - 31;
            }
            for (; oldMessageNum < newsnap.messageNum; oldMessageNum++ )
            {
                cl.snapshots[oldMessageNum & 31].valid = false;
            }

            // copy to the current good spot
            cl.snap = newsnap;
            cl.snap.ping = 999;
            // calculate ping time
//.........这里部分代码省略.........
开发者ID:maesse,项目名称:CubeHags,代码行数:101,代码来源:ClientParse.cs

示例12: ParsePacketEntities

        void ParsePacketEntities(NetBuffer msg, clSnapshot_t oldframe, clSnapshot_t newframe)
        {
            newframe.parseEntitiesNum = cl.parseEntitiesNum;
            newframe.numEntities = 0;

            // delta from the entities present in oldframe
            int oldindex = 0, oldnum = 0;
            Common.entityState_t oldstate = null;
            if (oldframe == null)
                oldnum = 99999;
            else
            {
                if (oldnum >= oldframe.numEntities)
                    oldnum = 99999;
                else
                {
                    oldstate = cl.parseEntities[(oldframe.parseEntitiesNum + oldindex) & 2047];
                    oldnum = oldstate.number;
                }
            }

            while (true)
            {
                // read the entity index number
                int newnum = msg.ReadInt32();

                if (newnum == 1023)
                    break;

                while (oldnum < newnum)
                {
                    // one or more entities from the old packet are unchanged
                    DeltaEntity(msg, newframe, oldnum, oldstate, true);
                    oldindex++;

                    if (oldindex >= oldframe.numEntities)
                        oldnum = 99999;
                    else
                    {
                        oldstate = cl.parseEntities[(oldframe.parseEntitiesNum + oldindex) & 2047];
                        oldnum = oldstate.number;
                    }
                }
                if (oldnum == newnum)
                {
                    // delta from previous state
                    DeltaEntity(msg, newframe, newnum, oldstate, false);

                    oldindex++;

                    if (oldindex >= oldframe.numEntities)
                        oldnum = 99999;
                    else
                    {
                        oldstate = cl.parseEntities[(oldframe.parseEntitiesNum + oldindex) & 2047];
                        oldnum = oldstate.number;
                    }
                    continue;
                }

                if (oldnum > newnum)
                {
                    // delta from baseline
                    DeltaEntity(msg, newframe, newnum, cl.entityBaselines[newnum], false);
                    continue;
                }
            }

            // any remaining entities in the old frame are copied over
            while (oldnum != 99999)
            {
                // one or more entities from the old packet are unchanged
                DeltaEntity(msg, newframe, oldnum, oldstate, true);

                oldindex++;

                if (oldindex >= oldframe.numEntities)
                    oldnum = 99999;
                else
                {
                    oldstate = cl.parseEntities[(oldframe.parseEntitiesNum + oldindex) & 2047];
                    oldnum = oldstate.number;
                }
            }
        }
开发者ID:maesse,项目名称:CubeHags,代码行数:85,代码来源:ClientParse.cs

示例13: Read

 public void Read(NetBuffer im)
 {
     UniqueIdentifier    = im.ReadInt64();
     TargetSize          = im.ReadInt32();
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:5,代码来源:SendPacketMessage.cs

示例14: ReadDeltaPlayerstate

        public static void ReadDeltaPlayerstate(NetBuffer msg, Common.PlayerState from, Common.PlayerState to)
        {
            int startoffset = msg.Position;
            if (from == null)
                from = new Common.PlayerState();

            to.commandTime = msg.ReadBoolean() ? msg.ReadInt32() : from.commandTime;
            to.pm_type = msg.ReadBoolean() ? (Common.PMType)msg.ReadInt32() : from.pm_type;
            to.pm_flags = msg.ReadBoolean() ? (client.PMFlags)msg.ReadInt32() : from.pm_flags;
            to.pm_time = msg.ReadBoolean() ? msg.ReadInt32() : from.pm_time;
            to.origin.X = msg.ReadBoolean() ? msg.ReadFloat() : from.origin.X;
            to.origin.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.origin.Y;
            to.origin.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.origin.Z;
            to.velocity.X = msg.ReadBoolean() ? msg.ReadFloat() : from.velocity.X;
            to.velocity.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.velocity.Y;
            to.velocity.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.velocity.Z;
            to.weaponTime = msg.ReadBoolean() ? msg.ReadInt32() : from.weaponTime;
            to.gravity = msg.ReadBoolean() ? msg.ReadInt32() : from.gravity;
            to.delta_angles[0] = msg.ReadBoolean() ? msg.ReadInt32() : from.delta_angles[0];
            to.delta_angles[1] = msg.ReadBoolean() ? msg.ReadInt32() : from.delta_angles[1];
            to.delta_angles[2] = msg.ReadBoolean() ? msg.ReadInt32() : from.delta_angles[2];
            to.groundEntityNum = msg.ReadBoolean() ? msg.ReadInt32() : from.groundEntityNum;
            to.movementDir = msg.ReadBoolean() ? msg.ReadInt32() : from.movementDir;
            to.ladderNormal.X = msg.ReadBoolean() ? msg.ReadFloat() : from.ladderNormal.X;
            to.ladderNormal.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.ladderNormal.Y;
            to.ladderNormal.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.ladderNormal.Z;
            to.speed = msg.ReadBoolean() ? msg.ReadInt32() : from.speed;
            to.eFlags = msg.ReadBoolean() ? (Common.EntityFlags)Enum.Parse(typeof(Common.EntityFlags), ""+msg.ReadInt32()) : from.eFlags;
            to.eventSequence = msg.ReadBoolean() ? msg.ReadInt32() : from.eventSequence;
            to.events[0] = msg.ReadBoolean() ? msg.ReadInt32() : from.events[0];
            to.events[1] = msg.ReadBoolean() ? msg.ReadInt32() : from.events[1];
            to.eventParms[0] = msg.ReadBoolean() ? msg.ReadInt32() : from.eventParms[0];
            to.eventParms[1] = msg.ReadBoolean() ? msg.ReadInt32() : from.eventParms[1];
            to.externalEvent = msg.ReadBoolean() ? msg.ReadInt32() : from.externalEvent;
            to.externalEventParm = msg.ReadBoolean() ? msg.ReadInt32() : from.externalEventParm;
            to.externalEventTime = msg.ReadBoolean() ? msg.ReadInt32() : from.externalEventTime;
            to.clientNum = msg.ReadBoolean() ? msg.ReadInt32() : from.clientNum;
            to.viewangles.X = msg.ReadBoolean() ? msg.ReadFloat() : from.viewangles.X;
            to.viewangles.Y = msg.ReadBoolean() ? msg.ReadFloat() : from.viewangles.Y;
            to.viewangles.Z = msg.ReadBoolean() ? msg.ReadFloat() : from.viewangles.Z;
            to.viewheight = msg.ReadBoolean() ? msg.ReadInt32() : from.viewheight;
            //if (to.viewheight == 16)
            //{
            //    int test = 2;
            //}
            to.generic1 = msg.ReadBoolean() ? msg.ReadInt32() : from.generic1;
            to.bobCycle = msg.ReadBoolean() ? msg.ReadInt32() : from.bobCycle;

            to.Ducked = msg.ReadBoolean() ? msg.ReadBoolean() : from.Ducked;
            to.Ducking = msg.ReadBoolean() ? msg.ReadBoolean() : from.Ducking;
            to.DuckTime = msg.ReadBoolean() ? msg.ReadInt32() : from.DuckTime;
            to.OldButtons = msg.ReadBoolean() ? msg.ReadInt32() : from.OldButtons;

            // Got diff arrays

            int msgMiddle = 99999;
            if (msg.ReadBoolean())
            {
                if (msg.ReadBoolean())
                {
                    // stat
                    int statbits = msg.ReadInt32();
                    for (int i = 0; i < 16; i++)
                    {
                        if ((statbits & (1 << i)) == (1 << i))
                        {
                            to.stats[i] = msg.ReadInt16();
                        }
                        else
                            to.stats[i] = from.stats[i];
                    }
                }
                else
                    to.stats = from.stats;
                msgMiddle = msg.Position;
                if (msg.ReadBoolean())
                {
                    // pers
                    int persbits = msg.ReadInt32();
                    for (int i = 0; i < 16; i++)
                    {
                        if ((persbits & (1 << i)) == (1 << i))
                        {
                            to.persistant[i] = msg.ReadInt16();
                        }
                        else
                            to.persistant[i] = from.persistant[i];
                    }
                }
                else
                    to.persistant = from.persistant;
            }
            else
            {
                to.stats = from.stats;
                to.persistant = from.persistant;
            }

            //System.Console.WriteLine("Read {0}bits snapshot, {1} middle", msg.Position - startoffset, msgMiddle - startoffset);
        }
开发者ID:maesse,项目名称:CubeHags,代码行数:100,代码来源:Net.cs

示例15: MSG_ReadDeltaKey

 int MSG_ReadDeltaKey(NetBuffer msg, int oldV, int bits)
 {
     if (msg.ReadBoolean())
     {
         return (msg.ReadInt32(bits));
     }
     return oldV;
 }
开发者ID:maesse,项目名称:CubeHags,代码行数:8,代码来源:Input.cs


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