示例#1
0
        public void Write(VoidPtr userDataAddr)
        {
            if (Count == 0 || userDataAddr == null)
            {
                return;
            }

            UserData *data = (UserData *)userDataAddr;

            ResourceGroup *pGroup = data->Group;
            ResourceEntry *pEntry = &pGroup->_first + 1;

            *pGroup = new ResourceGroup(Count);

            byte *pData = (byte *)pGroup + pGroup->_totalSize;

            int id = 0;

            foreach (UserDataClass s in this)
            {
                (pEntry++)->_dataOffset = (int)pData - (int)pGroup;
                UserDataEntry *p = (UserDataEntry *)pData;
                *p = new UserDataEntry(
                    s.DataType != UserValueType.String ? s._entries.Count : s._entries.Count > 0 ? 1 : 0, s._type,
                    id++);
                pData += 0x18;
                if (s.DataType != UserValueType.String)
                {
                    for (int i = 0; i < s._entries.Count; i++)
                    {
                        if (s.DataType == UserValueType.Float)
                        {
                            if (!float.TryParse(s._entries[i], out float x))
                            {
                                x = 0;
                            }

                            *(bfloat *)pData = x;
                            pData           += 4;
                        }
                        else if (s.DataType == UserValueType.Int)
                        {
                            if (!int.TryParse(s._entries[i], out int x))
                            {
                                x = 0;
                            }

                            *(bint *)pData = x;
                            pData         += 4;
                        }
                    }
                }

                p->_totalLen = (int)pData - (int)p;
            }

            data->_totalLen = (int)pData - (int)userDataAddr;
        }
        public void Write(VoidPtr userDataAddr)
        {
            if (Count == 0 || userDataAddr == null) return;

            UserData* data = (UserData*)userDataAddr;

            ResourceGroup* pGroup = data->Group;
            ResourceEntry* pEntry = &pGroup->_first + 1;
            *pGroup = new ResourceGroup(Count);

            byte* pData = (byte*)pGroup + pGroup->_totalSize;

            int id = 0;
            foreach (UserDataClass s in this)
            {
                (pEntry++)->_dataOffset = (int)pData - (int)pGroup;
                UserDataEntry* p = (UserDataEntry*)pData;
                *p = new UserDataEntry(s.DataType != UserValueType.String ? s._entries.Count : (s._entries.Count > 0 ? 1 : 0), s._type, id++);
                pData += 0x18;
                if (s.DataType != UserValueType.String)
                    for (int i = 0; i < s._entries.Count; i++)
                        if (s.DataType == UserValueType.Float)
                        {
                            float x;
                            if (!float.TryParse(s._entries[i], out x))
                                x = 0;
                            *(bfloat*)pData = x;
                            pData += 4;
                        }
                        else if (s.DataType == UserValueType.Int)
                        {
                            int x;
                            if (!int.TryParse(s._entries[i], out x))
                                x = 0;
                            *(bint*)pData = x;
                            pData += 4;
                        }
                p->_totalLen = (int)pData - (int)p;
            }
            data->_totalLen = (int)pData - (int)userDataAddr;
        }