Browse Source

implicit operators are super dangerous

tags/2.7
sebas77 6 years ago
parent
commit
336d854866
2 changed files with 7 additions and 7 deletions
  1. +4
    -4
      Svelto.ECS/EGID.cs
  2. +3
    -3
      Svelto.ECS/EnginesRoot.GenericEntityFunctions.cs

+ 4
- 4
Svelto.ECS/EGID.cs View File

@@ -42,19 +42,19 @@ namespace Svelto.ECS
return (long)groupId << 32 | ((long)(uint)entityId & 0xFFFFFFFF);
}

public static implicit operator int(EGID id)
public static explicit operator int(EGID id)
{
return id.entityID;
}
public static implicit operator long(EGID id)
public static explicit operator long(EGID id)
{
return id._GID;
}

public bool Equals(EGID other)
{
return _GID == other;
return _GID == other._GID;
}

public bool Equals(EGID x, EGID y)
@@ -69,7 +69,7 @@ namespace Svelto.ECS

public int CompareTo(EGID other)
{
return _GID.CompareTo(other);
return _GID.CompareTo(other._GID);
}
}
}

+ 3
- 3
Svelto.ECS/EnginesRoot.GenericEntityFunctions.cs View File

@@ -103,7 +103,7 @@ namespace Svelto.ECS
#if DEBUG && !PROFILER
entitySubmitOperation.trace = Environment.StackTrace;
var egid = new EGID(entitySubmitOperation.ID, entitySubmitOperation.fromGroupID);
if (_entitiesOperationsDebug.ContainsKey(egid) == true)
if (_entitiesOperationsDebug.ContainsKey((long)egid) == true)
Utilities.Console.LogError("Only one entity operation per submission is allowed. Entity "
.FastConcat(" with not found ID is about to be removed: ")
.FastConcat(" id: ")
@@ -114,9 +114,9 @@ namespace Svelto.ECS
.FastConcat(" entityType: ")
.FastConcat(typeof(T).Name)
.FastConcat(" submission type ", entitySubmitOperation.type.ToString(),
" previous type: ", _entitiesOperationsDebug[egid].ToString()));
" previous type: ", _entitiesOperationsDebug[(long)egid].ToString()));
else
_entitiesOperationsDebug[egid] = entitySubmitOperation.type;
_entitiesOperationsDebug[(long)egid] = entitySubmitOperation.type;
#endif
_entitiesOperations.AddRef(ref entitySubmitOperation);
}


Loading…
Cancel
Save