Esempio n. 1
0
        public bool LoadInfo()
        {
            m_UidAttrList.Clear();

            if (!File.Exists(m_Forder + @"\\uid.dat"))
            {
                return(false);
            }


            FileStream fs = new FileStream(m_Forder + @"\\uid.dat", FileMode.Open, FileAccess.ReadWrite);

            int     ret = 0;
            UidHead ts  = new UidHead();

            byte[] _bytData = new byte[Marshal.SizeOf(ts)];

            ret = fs.Read(_bytData, 0, _bytData.Length);
            if (ret > 0) //记录头
            {
                m_UidHead = CStructBytesFormat.rawDeserialize <UidHead>(_bytData);
            }
            while (ret > 0)
            {
                UidAttr ts2            = new UidAttr();
                byte[]  bytAccAttrData = new byte[Marshal.SizeOf(ts2)];

                ret = fs.Read(bytAccAttrData, 0, bytAccAttrData.Length);
                if (ret <= 0)
                {
                    break;
                }

                ts2         = CStructBytesFormat.rawDeserialize <UidAttr>(bytAccAttrData);
                m_lastUid   = (UInt32)ts2.nUid;
                m_lastAccId = (UInt32)ts2.nAccId;

                m_UidAttrList.Add(ts2);
            }

            fs.Close();

            return(true);
        }
Esempio n. 2
0
        public bool LoadPlayerInfos()
        {
            m_playersAttrList.Clear();

            if (!File.Exists(m_Forder + @"\\players.dat"))
            {
                return(false);
            }


            FileStream fs = new FileStream(m_Forder + @"\\players.dat", FileMode.Open, FileAccess.ReadWrite);

            int         ret = 0;
            AccAttrHead ts  = new AccAttrHead();

            byte[] _bytData = new byte[Marshal.SizeOf(ts)];

            ret = fs.Read(_bytData, 0, _bytData.Length);
            if (ret > 0) //记录头
            {
                //m_AccAttrHead = CStructBytesFormat.BytesToStruct<AccAttrHead>(_bytData);
                m_AccAttrHead = CStructBytesFormat.rawDeserialize <AccAttrHead>(_bytData);
            }
            while (ret > 0)
            {
                AccAttr ts2            = new AccAttr();
                byte[]  bytAccAttrData = new byte[Marshal.SizeOf(ts2)];

                ret = fs.Read(bytAccAttrData, 0, bytAccAttrData.Length);
                if (ret <= 0)
                {
                    break;
                }

                ts2         = CStructBytesFormat.rawDeserialize <AccAttr>(bytAccAttrData);
                m_lastIndex = (UInt32)ts2.nIndex;

                m_playersAttrList.Add(ts2);
            }

            fs.Close();

            return(true);
        }
Esempio n. 3
0
        public bool LoadInfos()
        {
            m_SoldiersAttrList.Clear();

            if (!File.Exists(m_Forder + @"\\npc.dat"))
            {
                return(false);
            }


            FileStream fs = new FileStream(m_Forder + @"\\npc.dat", FileMode.Open, FileAccess.ReadWrite);

            int             ret = 0;
            SoldierAttrHead ts  = new SoldierAttrHead();

            byte[] _bytData = new byte[Marshal.SizeOf(ts)];

            ret = fs.Read(_bytData, 0, _bytData.Length);
            if (ret > 0) //记录头
            {
                m_SoldierAttrHead = CStructBytesFormat.rawDeserialize <SoldierAttrHead>(_bytData);
            }
            while (ret > 0)
            {
                SoldiersAttr ts2            = new SoldiersAttr();
                byte[]       bytAccAttrData = new byte[Marshal.SizeOf(ts2)];

                ret = fs.Read(bytAccAttrData, 0, bytAccAttrData.Length);
                if (ret <= 0)
                {
                    break;
                }

                ts2 = CStructBytesFormat.rawDeserialize <SoldiersAttr>(bytAccAttrData);

                m_SoldiersAttrList.Add(ts2);
            }

            fs.Close();

            return(true);
        }