diff --git a/Source/Core/IO/DoomMapSetIO.cs b/Source/Core/IO/DoomMapSetIO.cs index 56b62f8e2256308f03195bfe06a814b467e05c03..01f5310348c3c2d66727a7879b621302c03bd2e4 100644 --- a/Source/Core/IO/DoomMapSetIO.cs +++ b/Source/Core/IO/DoomMapSetIO.cs @@ -129,7 +129,7 @@ namespace CodeImp.DoomBuilder.IO reader = new BinaryReader(mem); // Read items from the lump - map.SetCapacity(0, 0, 0, 0, num); + map.SetCapacity(0, 0, 0, 0, map.Things.Count + num); for(i = 0; i < num; i++) { // Read properties from stream @@ -179,7 +179,7 @@ namespace CodeImp.DoomBuilder.IO link = new Dictionary<int, Vertex>(num); // Read items from the lump - map.SetCapacity(num, 0, 0, 0, 0); + map.SetCapacity(map.Vertices.Count + num, 0, 0, 0, 0); for(i = 0; i < num; i++) { // Read properties from stream @@ -224,7 +224,7 @@ namespace CodeImp.DoomBuilder.IO link = new Dictionary<int, Sector>(num); // Read items from the lump - map.SetCapacity(0, 0, 0, num, 0); + map.SetCapacity(0, 0, 0, map.Sectors.Count + num, 0); for(i = 0; i < num; i++) { // Read properties from stream @@ -282,7 +282,7 @@ namespace CodeImp.DoomBuilder.IO readside = new BinaryReader(sidedefsmem); // Read items from the lump - map.SetCapacity(0, num, numsides, 0, 0); + map.SetCapacity(0, map.Linedefs.Count + num, map.Sidedefs.Count + numsides, 0, 0); for(i = 0; i < num; i++) { // Read properties from stream diff --git a/Source/Core/IO/HexenMapSetIO.cs b/Source/Core/IO/HexenMapSetIO.cs index b2a88216414f811a1933199e40b6a63fce5d36c1..2581b1c8a05e21172e406792f0fd9990e67e9efe 100644 --- a/Source/Core/IO/HexenMapSetIO.cs +++ b/Source/Core/IO/HexenMapSetIO.cs @@ -131,7 +131,7 @@ namespace CodeImp.DoomBuilder.IO reader = new BinaryReader(mem); // Read items from the lump - map.SetCapacity(0, 0, 0, 0, num); + map.SetCapacity(0, 0, 0, 0, map.Things.Count + num); for(i = 0; i < num; i++) { // Read properties from stream @@ -189,7 +189,7 @@ namespace CodeImp.DoomBuilder.IO link = new Dictionary<int, Vertex>(num); // Read items from the lump - map.SetCapacity(num, 0, 0, 0, 0); + map.SetCapacity(map.Vertices.Count + num, 0, 0, 0, 0); for(i = 0; i < num; i++) { // Read properties from stream @@ -234,7 +234,7 @@ namespace CodeImp.DoomBuilder.IO link = new Dictionary<int, Sector>(num); // Read items from the lump - map.SetCapacity(0, 0, 0, num, 0); + map.SetCapacity(0, 0, 0, map.Sectors.Count + num, 0); for(i = 0; i < num; i++) { // Read properties from stream @@ -293,7 +293,7 @@ namespace CodeImp.DoomBuilder.IO readside = new BinaryReader(sidedefsmem); // Read items from the lump - map.SetCapacity(0, num, numsides, 0, 0); + map.SetCapacity(0, map.Linedefs.Count + num, map.Sidedefs.Count + numsides, 0, 0); for(i = 0; i < num; i++) { // Read properties from stream diff --git a/Source/Core/IO/UniversalStreamReader.cs b/Source/Core/IO/UniversalStreamReader.cs index e4953bc93cce2264999a23cddfa0a4bfe02240da..a159a19a48ecca3d604256b081508e355d851d64 100644 --- a/Source/Core/IO/UniversalStreamReader.cs +++ b/Source/Core/IO/UniversalStreamReader.cs @@ -150,7 +150,7 @@ namespace CodeImp.DoomBuilder.IO List<UniversalCollection> collections = GetNamedCollections(textmap.Root, "thing"); // Go for all collections - map.SetCapacity(0, 0, 0, 0, collections.Count); + map.SetCapacity(0, 0, 0, 0, map.Things.Count + collections.Count); for(int i = 0; i < collections.Count; i++) { // Read fields @@ -198,7 +198,7 @@ namespace CodeImp.DoomBuilder.IO List<UniversalCollection> sidescolls = GetNamedCollections(textmap.Root, "sidedef"); // Go for all lines - map.SetCapacity(0, linescolls.Count, sidescolls.Count, 0, 0); + map.SetCapacity(0, map.Linedefs.Count + linescolls.Count, map.Sidedefs.Count + sidescolls.Count, 0, 0); for(int i = 0; i < linescolls.Count; i++) { // Read fields @@ -313,7 +313,7 @@ namespace CodeImp.DoomBuilder.IO link = new Dictionary<int, Sector>(collections.Count); // Go for all collections - map.SetCapacity(0, 0, 0, collections.Count, 0); + map.SetCapacity(0, 0, 0, map.Sectors.Count + collections.Count, 0); for(int i = 0; i < collections.Count; i++) { // Read fields @@ -354,7 +354,7 @@ namespace CodeImp.DoomBuilder.IO link = new Dictionary<int, Vertex>(collections.Count); // Go for all collections - map.SetCapacity(collections.Count, 0, 0, 0, 0); + map.SetCapacity(map.Vertices.Count + collections.Count, 0, 0, 0, 0); for(int i = 0; i < collections.Count; i++) { // Read fields