suriyun-production / mmorpg-kit-docs

This is document for MMORPG KIT project (https://www.assetstore.unity3d.com/#!/content/110188?aid=1100lGeN)
https://suriyun-production.github.io/mmorpg-kit-docs
49 stars 10 forks source link

BuildingArea.cs wrong check #2604

Closed moepi2k closed 3 weeks ago

moepi2k commented 3 weeks ago

this is wrong

 public virtual bool AllowToBuild(BuildingEntity newBuilding)
 {
     if (entity != null && !entity.IsCreator(newBuilding.Builder))
         return false;
     if (!newBuilding.BuildingTypes.Contains(buildingType))
         return false;
     if (buildConditions != null && buildConditions.Length > 0)
     {
         for (int i = 0; i < buildConditions.Length; ++i)
         {
             if (!buildConditions[i].AllowToBuild(this, newBuilding))
                 return false;
         }
     }
     return true;
 }

should be

 if (newBuilding == null || (entity != null && !entity.IsCreator(newBuilding.Builder)))
        return false;
insthync commented 3 weeks ago

No null check then you determine that it is wrong?

insthync commented 3 weeks ago

If you are going to tell me to add null check, then you should tell me to add null check to avoid null ref error, something like this instead, not telling that it is wrong like all of it is wrong.