1.InvalidOperationException: tree modified
-exception
1.Unitwalking die로 Collision list 삭제가 빈번한 상황에서 발생.
2.Error 내용 InvalidOperationException: tree modified.
-exception location
//@ If unit is null, Delete unit from collideList.
List<UnitWalking> listCollideCollect = new List<UnitWalking>();
ICollection<int> collectionID = listCollider.Keys;
foreach (int idunit in collectionID) { <-Error
UnitWalking unitWalking = unitpool[idunit] as UnitWalking;
if (null == unitWalking) {
listCollider.Remove(idunit); // <-InvalidOperationException: tree modified
}
else {
if (true == unitWalking.IsUnitDie())
listCollider.Remove(idunit); // <-InvalidOperationException: tree modified
else
listCollideCollect.Add(unitWalking);
}
}
-exception solution
//@ If unit is null, Delete unit from collideList.
List<UnitWalking> listCollideCollect = new List<UnitWalking>();
ICollection<int> collectionID = listCollider.Keys;
List<int> listcollideremove = new List<int>();
foreach (int idunit in collectionID)
{
UnitWalking unitWalking = unitpool[idunit] as UnitWalking;
if (null == unitWalking) {
listcollideremove.Add(idunit);
}
else {
if (true == unitWalking.IsUnitDie())
listcollideremove.Add(idunit);
else
listCollideCollect.Add(unitWalking);
}
}
//@ for safety elimination
foreach (int idunitremove in listcollideremove)
{
listCollider.Remove(idunitremove);
}
2. Shallow copy and destruct original data problem (얕은 복사와 원본 데이터 삭제 오류)
-exception
1.map save 시에 2번 이상 연속 호출 되는 경우 2번째 이후로 저장이 안됨.
2.내부 링크 참조된 list들이 clear()된 이후 접근 된 것.
-exception location
//@ Process : Save
void _SaveAll()
{
// MapSave
Map.Release();
navigation_toCMapTemplate();
SaveBaseCore();
Map.Save();
} // void _SaveAll()
public void Release()
{
…
if (null != CoreList)
{
CoreList.Clear(); <-clear all lists as copy shallow
}
…
}
void _SaveBaseCore()
{
BaseInfo core = null;
foreach (CBASE__ arrBase in m_baseCoreCollector.m_listBase)
{
core = new BaseInfo();
core.Type = arrBase.getIdxType();
core.CellIndex = arrBase._listIdxTris; <-list copy shallow
core.CoreTriPnt = arrBase._listv3Pnts; <-list copy shallow
core.CoreTriPntSrc = arrBase._listv3PntsSrc;<-list copy shallow
core.CenterPos = arrBase._v3PositionCenter;
CoreList.Add(core);
}
}
-exception solution
1.Deep copy
void _SaveBaseCore()
{
BaseInfo core = null;
foreach (CBASE__ arrBase in m_baseCoreCollector.m_listBase)
{
core = new BaseInfo();
core.Type = arrBase.getIdxType();
core.CellIndex = new List<int>(arrBase._listIdxTris);
core.CoreTriPnt = new List<Vector3>(arrBase._listv3Pnts);
core.CoreTriPntSrc = new List<Vector3>(arrBase._listv3PntsSrc);
core.CenterPos = arrBase._v3PositionCenter;
CoreList. Add(core);
}
}