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;
|
||||
Building building = (Building)observer.state;
|
||||
|
||||
if (building == null)
|
||||
{
|
||||
if(observer != null)
|
||||
{
|
||||
UnityEngine.Object.Destroy(observer.gameObject);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Guid guid = building.guid;
|
||||
|
||||
if (lastUpdateTime.ContainsKey(guid) && Time.time < lastUpdateTime[guid] + UpdateInterval)
|
||||
@@ -39,6 +49,8 @@ namespace KCM.StateManagement.BuildingState
|
||||
else
|
||||
lastUpdateTime[guid] = Time.time;
|
||||
|
||||
//Main.helper.Log("Should send building network update for: " + building.UniqueName);
|
||||
|
||||
new BuildingStatePacket()
|
||||
{
|
||||
customName = building.customName,
|
||||
|
||||
Reference in New Issue
Block a user