Fix null reference handling in building state updates
This commit is contained in:
@@ -27,6 +27,16 @@ namespace KCM.StateManagement.BuildingState
|
|||||||
{
|
{
|
||||||
Observer observer = (Observer)sender;
|
Observer observer = (Observer)sender;
|
||||||
Building building = (Building)observer.state;
|
Building building = (Building)observer.state;
|
||||||
|
|
||||||
|
if (building == null)
|
||||||
|
{
|
||||||
|
if(observer != null)
|
||||||
|
{
|
||||||
|
UnityEngine.Object.Destroy(observer.gameObject);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Guid guid = building.guid;
|
Guid guid = building.guid;
|
||||||
|
|
||||||
if (lastUpdateTime.ContainsKey(guid) && Time.time < lastUpdateTime[guid] + UpdateInterval)
|
if (lastUpdateTime.ContainsKey(guid) && Time.time < lastUpdateTime[guid] + UpdateInterval)
|
||||||
@@ -39,6 +49,8 @@ namespace KCM.StateManagement.BuildingState
|
|||||||
else
|
else
|
||||||
lastUpdateTime[guid] = Time.time;
|
lastUpdateTime[guid] = Time.time;
|
||||||
|
|
||||||
|
//Main.helper.Log("Should send building network update for: " + building.UniqueName);
|
||||||
|
|
||||||
new BuildingStatePacket()
|
new BuildingStatePacket()
|
||||||
{
|
{
|
||||||
customName = building.customName,
|
customName = building.customName,
|
||||||
|
|||||||
Reference in New Issue
Block a user