Skip to content

Commit

Permalink
Merge pull request #6 from nikich340/develop-pull-serialization_fixes
Browse files Browse the repository at this point in the history
CR2W Serialization fixes
  • Loading branch information
rfuzzo authored Apr 30, 2022
2 parents bb80821 + 7f27113 commit d34bcde
Show file tree
Hide file tree
Showing 71 changed files with 160 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public override void Read(BinaryReader file, uint size)
{
var len = file.ReadInt32();
backingfield = file.ReadBytes(len);
SetIsSerialized();
}

public override void Write(BinaryWriter file)
Expand All @@ -52,9 +53,11 @@ public override CVariable SetValue(object val)
{
case XDocument document:
Data = document;
SetIsSerialized();
break;
case CXml cvar:
this.Data = cvar.Data;
Data = cvar.Data;
SetIsSerialized();
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public override void Read(BinaryReader file, uint size)
pieces.Read(file, size, count);


SetIsSerialized();
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public override void Read(BinaryReader file, uint size)
}

values.Read(file, size, valueCount.val);
SetIsSerialized();
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public override void Read(BinaryReader file, uint size)
{
throw new InvalidParsingException("read too far");
}
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public override void Read(BinaryReader file, uint size)
{
throw new InvalidParsingException("read too far");
}
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public override void Read(BinaryReader file, uint size)
{
throw new InvalidParsingException("read too far");
}
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public override void Read(BinaryReader file , uint size)
Guid.Read(file, 16);
Buffer.Read(file, size);
}
SetIsSerialized();
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public override void Read(BinaryReader file, uint size)
sizeofdata.Read(file, 4);
componentName.Read(file, 2);
variables.Read(file, size);
SetIsSerialized();
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public override void Read(BinaryReader file, uint size)
throw new NotImplementedException();

unk1.Read(file, (uint)bytesize.val - 2);
SetIsSerialized();
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public override void Read(BinaryReader file, uint size)
CVariable variable = fields[i];
variable.Read(file, size);
}
SetIsSerialized();
}

public override void Write(BinaryWriter file)
Expand All @@ -193,6 +194,7 @@ public override CVariable SetValue(object val)
if (val is SParticleEmitterModuleData)
{
fields = (val as SParticleEmitterModuleData).fields;
SetIsSerialized();
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public override void Read(BinaryReader file, uint size)
X.Read(file, size);
Y.Read(file, size);
Z.Read(file, size);
SetIsSerialized();
}

public override void Write(BinaryWriter file)
Expand All @@ -82,6 +83,7 @@ public override CVariable SetValue(object val)
this.X = v.X;
this.Y = v.Y;
this.Z = v.Z;
SetIsSerialized();
}

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public override void Read(BinaryReader file, uint size)
// if is uncooked
if (this.REDFlags == 0)
Mip.Read(file, 0);
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public override CVariable SetValue(object val)
{
this.x = v.x;
this.y = v.y;
SetIsSerialized();
}

return this;
Expand Down
2 changes: 2 additions & 0 deletions WolvenKit.CR2W/Types/BufferedTypes/BufferedClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public override CVariable SetValue(object val)
if (val is CXml)
{
Ragdolldata = (CXml)val;
SetIsSerialized();
}

return this;
Expand All @@ -207,6 +208,7 @@ public override void Read(BinaryReader file, uint size)
return;
Unk1 = new CUInt32(cr2w, this, nameof(Unk1)) { IsSerialized = true };
Unk1.Read(file, size);
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public override void Read(BinaryReader file, uint size)
unk1.Read(file, 2);
unk2.Read(file, 2);
Residentmip.Read(file, ResidentmipSize.val);
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/BufferedTypes/Complex/CCubeTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public override void Read(BinaryReader file, uint size)


Rawfile.Read(file, Filesize.val);
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/BufferedTypes/Complex/CEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public override void Read(BinaryReader file, uint size)
}
#endregion

//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/BufferedTypes/Complex/CFXTrackItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public override void Read(BinaryReader file, uint size)
{

}
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/BufferedTypes/Complex/CFont.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public override void Read(BinaryReader file, uint size)

Glyphs.AddVariable(glyph);
}
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public override void Read(BinaryReader file, uint size)
if (MaskRes == null) return;
var res = MaskRes.val;
grassmask.Bytes = file.ReadBytes((int)(res * res >> 3));
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/BufferedTypes/Complex/CLayerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public override void Read(BinaryReader file, uint size)
ParentGroup.ChunkHandle = true;
ParentGroup.Read(file, 4);
}
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public override void Read(BinaryReader file, uint size)
var endpos = file.BaseStream.Position;

Data.Read(file, (uint)(size - (endpos - startpos)));
SetIsSerialized();
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public override void Read(BinaryReader file, uint size)

BufferParameters.AddVariableWithName(cVariant);
}
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/BufferedTypes/Complex/CSectorData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public override void Read(BinaryReader file, uint size)
blockdata.Read(file, (uint)len);
BlockData.AddVariable(blockdata);
}
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/BufferedTypes/Complex/CSkeleton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public override void Read(BinaryReader file, uint size)

rigdata.Read(file, (uint)bonecount * 48, bonecount);

//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public override void Read(BinaryReader file, uint size)

BufferParameters.AddVariableWithName(cVariant);
}
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/BufferedTypes/Complex/CSwfTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public override void Read(BinaryReader file, uint size)
//var textureSize = Convert.ToInt32( size - (file.BaseStream.Position - pos) );

//swfTexture.Read(file, (uint)textureSize);
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/BufferedTypes/Complex/CTerrainTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public override void Read(BinaryReader file, uint size)
base.Read(file, size);

var maxres = file.ReadInt32();
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public override void Read(BinaryReader file, uint size)
base.Read(file, size);

rawfile.Read(file, filesize.val);
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public override void Read(BinaryReader file, uint size)
throw new InvalidParsingException("Did not read buffer to the end.");
}

//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public override void Read(BinaryReader file, uint size)
{
throw new InvalidParsingException($"Error in parsing SAppearanceAttachment: Data Variable. Bytes read: {bytesread} out of {bytecount}.");
}
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/Generic/Arrays/CArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public CArray(CR2WFile cr2w, CVariable parent, string name) : base(cr2w, parent,
public override void Read(BinaryReader file, uint size)
{
base.Read(file, size, (int)file.ReadUInt32());
//SetIsSerialized() in base
}


Expand Down
2 changes: 2 additions & 0 deletions WolvenKit.CR2W/Types/Generic/Arrays/CArrayBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public override List<IEditableVariable> GetEditableVariables()
public override void Read(BinaryReader file, uint size)
{
throw new NotImplementedException();
SetIsSerialized();
}

protected void Read(BinaryReader file, uint size, int elementcount)
Expand Down Expand Up @@ -98,6 +99,7 @@ public override CVariable SetValue(object val)
if (val is CArrayBase<T> cvar)
{
this.Elements = cvar.Elements;
SetIsSerialized();
}

return this;
Expand Down
7 changes: 5 additions & 2 deletions WolvenKit.CR2W/Types/Generic/Arrays/CBufferBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -53,6 +53,7 @@ public override List<IEditableVariable> GetEditableVariables()
public override void Read(BinaryReader file, uint size)
{
throw new NotImplementedException();
SetIsSerialized();
}

public void Read(BinaryReader file, uint size, int elementcount)
Expand Down Expand Up @@ -94,6 +95,7 @@ public override void AddVariable(CVariable variable)
variable.SetREDName(elements.Count.ToString());
tvar.IsSerialized = true;
elements.Add(tvar);
SetIsSerialized();
}
}
public void AddVariableWithName(CVariable variable)
Expand All @@ -102,6 +104,7 @@ public void AddVariableWithName(CVariable variable)
{
tvar.IsSerialized = true;
elements.Add(tvar);
SetIsSerialized();
}
}
public override bool CanRemoveVariable(IEditableVariable child)
Expand Down Expand Up @@ -274,4 +277,4 @@ public void CopyTo(Array array, int index)
#endregion

}
}
}
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/Generic/Arrays/CBufferBit6.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public CBufferBit6(CR2WFile cr2w, CVariable parent, string name) : base(cr2w, pa
public override void Read(BinaryReader file, uint size)
{
base.Read(file, size, (int)file.ReadBit6());
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/Generic/Arrays/CBufferUInt32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public CBufferUInt32(CR2WFile cr2w, CVariable parent, string name) : base(cr2w,
public override void Read(BinaryReader file, uint size)
{
base.Read(file, size, (int)file.ReadUInt32());
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/Generic/Arrays/CBufferUint16.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public override void Read(BinaryReader file, uint size)
count.Read(file, size);

base.Read(file, size, (int)count.val);
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/Generic/Arrays/CBufferVLQInt32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public CBufferVLQInt32(CR2WFile cr2w, CVariable parent, string name) : base(cr2w
public override void Read(BinaryReader file, uint size)
{
base.Read(file, size, (int)file.ReadVLQInt32());
//SetIsSerialized() in base
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/Generic/Arrays/CCompressedBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public CCompressedBuffer(CR2WFile cr2w, CVariable parent, string name) : base(cr
public override void Read(BinaryReader file, uint size)
{
throw new NotImplementedException();
SetIsSerialized();
}

public override void Write(BinaryWriter file)
Expand Down
1 change: 1 addition & 0 deletions WolvenKit.CR2W/Types/Generic/Arrays/CPaddedBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public override void Read(BinaryReader file, uint size)
base.Read(file, size, count.val);

padding.Read(file, 4);
//SetIsSerialized() in base
}

public override List<IEditableVariable> GetEditableVariables()
Expand Down
Loading

0 comments on commit d34bcde

Please sign in to comment.