Skip to content

Commit

Permalink
Fix the crash problem.
Browse files Browse the repository at this point in the history
Not support the multi turret tank.
  • Loading branch information
adri1wcrow committed Nov 18, 2017
1 parent c90c45a commit 25423a0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
11 changes: 9 additions & 2 deletions TankInspector/Modeling/NationalDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,15 @@ public IDictionary<string, TObject> GetSharedObjects<TObject>()

private void LoadTanks()
{
foreach (var tankInfo in this.TankInfoCollection)
this.Tanks.Add(tankInfo.Key, new Tank(tankInfo));
foreach (var tankInfo in this.TankInfoCollection)
{
Tank t = new Tank(tankInfo);
if (t.Name == null)
{
continue;
}
this.Tanks.Add(tankInfo.Key, t);
}
}


Expand Down
23 changes: 13 additions & 10 deletions TankInspector/Modeling/Tank/Hull.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Xml;

namespace Smellyriver.TankInspector.Modeling
Expand Down Expand Up @@ -27,11 +28,11 @@ public Armor Armor
set => _armor = value;
}

private Vector3D _turretPosition;
private Queue<Vector3D> _turretPosition=new Queue<Vector3D>();
public Vector3D TurretPosition
{
get => _turretPosition;
set => _turretPosition = value;
get => _turretPosition.Dequeue();
set => _turretPosition.Enqueue(value);
}

private PrimaryArmorKeys _primaryArmorKeys;
Expand Down Expand Up @@ -70,15 +71,17 @@ protected override bool DeserializeSection(string name, XmlReader reader)
_ammoBay.Deserialize(reader);
return true;

case "turretPositions":

// turret position of usa T20 appeared twice, maozi sucks
if (this.TurretPosition != null)
return false;
case "turretPositions":

reader.ReadStartElement("turret");
reader.Read(out _turretPosition);
reader.ReadEndElement();
while (!reader.Name.Equals("turretPositions"))
{
reader.ReadStartElement(reader.Name);
Vector3D pos;
reader.Read(out pos);
_turretPosition.Enqueue(pos);
reader.ReadEndElement();
}
return true;

case "swinging":
Expand Down

0 comments on commit 25423a0

Please sign in to comment.