public override void Parse(VoidPtr address) { _nameID = _name; if (_size == 0) { throw new Exception("Nothing to read"); } CharacterInfo cInfo = Manager.SelectedInfo; SectionParamInfo data = null; if (_name != null && cInfo._parameters.ContainsKey(_name)) { data = cInfo._parameters[_name]; _info = data._attributes; if (!String.IsNullOrEmpty(data._newName)) { _name = data._newName; } } else { _info = new List <AttributeInfo>(); } if (_size > 0) { attributeBuffer = new UnsafeBuffer(_size); byte *pOut = (byte *)attributeBuffer.Address; byte *pIn = (byte *)address; for (int i = 0; i < _size; i++) { if (i % 4 == 0) { if (data == null) { AttributeInfo info = new AttributeInfo(); //Guess if the value is a an integer or float if (((((uint)*((buint *)pIn)) >> 24) & 0xFF) != 0 && *((bint *)pIn) != -1 && !float.IsNaN(((float)*((bfloat *)pIn)))) { info._type = 0; } else { info._type = 1; } info._name = (info._type == 1 ? "*" : "") + "0x" + i.ToString("X"); info._description = "No Description Available."; _info.Add(info); } } *pOut++ = *pIn++; } } }
protected override bool OnInitialize() { offsets = new Dictionary <int, FDefListOffset>(); base.OnInitialize(); if (Size == 0) { SetSizeInternal(4); } OldName = _name; SectionParamInfo data = null; if (Parent is MoveDefArticleNode) { if (Root.Params.ContainsKey((Parent as MoveDefArticleNode).ArticleStringID + "/" + _name)) { data = Root.Params[(Parent as MoveDefArticleNode).ArticleStringID + "/" + _name]; _info = data.Attributes; if (!String.IsNullOrEmpty(data.NewName)) { _name = data.NewName; } } else { _info = new List <AttributeInfo>(); } } else if (Parent is MoveDefSectionParamNode) { if (Root.Params.ContainsKey(TreePath)) { data = Root.Params[TreePath]; _info = data.Attributes; if (!String.IsNullOrEmpty(data.NewName)) { _name = data.NewName; } } else { _info = new List <AttributeInfo>(); } } else if (Root.Params.ContainsKey(Name)) { data = Root.Params[Name]; _info = data.Attributes; if (!String.IsNullOrEmpty(data.NewName)) { _name = data.NewName; } } else { _info = new List <AttributeInfo>(); } attributeBuffer = new UnsafeBuffer(Size); byte *pOut = (byte *)attributeBuffer.Address; byte *pIn = (byte *)Header; //if (String.IsNullOrEmpty(_name = new String((sbyte*)Header))) // _name = OldName; for (int i = 0; i < Size; i++) { if (i % 4 == 0) { if (data == null) { AttributeInfo info = new AttributeInfo(); //Guess if (((((uint)*((buint *)pIn)) >> 24) & 0xFF) != 0 && *((bint *)pIn) != -1 && !float.IsNaN(((float)*((bfloat *)pIn)))) { info._type = 0; } else { if (*((bint *)pIn) > 1480 && *((bint *)pIn) < Root.dataSize) { info._type = 3; } else { info._type = 1; } } info._name = (info._type == 1 ? "*" : "" + (info._type > 3 ? "+" : "")) + "0x" + i.ToString("X"); info._description = "No Description Available."; _info.Add(info); } //if (_info.Count == i / 4) // break; //AttributeInfo n = _info[i / 4]; //if (n._type == 3) //{ // int id = 0; // if (!int.TryParse(n._description, out id)) // id = i / 4; // if (!offsets.ContainsKey(id)) // offsets.Add(id, new FDefListOffset() { _startOffset = *(bint*)pIn, _listCount = 1 }); // else // { // FDefListOffset d = offsets[id]; // d._startOffset = *(bint*)pIn; // offsets[id] = d; // } //} //else if (n._type == 4) //{ // int id = int.Parse(n._description); // if (!offsets.ContainsKey(id)) // offsets.Add(id, new FDefListOffset() { _listCount = *(bint*)pIn }); // else // { // FDefListOffset d = offsets[id]; // d._listCount = *(bint*)pIn; // offsets[id] = d; // } //} } *pOut++ = *pIn++; } if (Parent is MoveDefArticleNode) { string id = (Parent as MoveDefArticleNode).ArticleStringID + "/" + _name; if (!Root.Params.ContainsKey(id)) { Root.Params.Add(id, new SectionParamInfo()); Root.Params[id].Attributes = _info; Root.Params[id].NewName = _name; data = Root.Params[id]; } } else if (Parent is MoveDefSectionParamNode) { if (!Root.Params.ContainsKey(TreePath)) { Root.Params.Add(TreePath, new SectionParamInfo()); Root.Params[TreePath].Attributes = _info; Root.Params[TreePath].NewName = _name; data = Root.Params[TreePath]; } } return(false); //return offsets.Values.Count > 0; }