Skip to content

Commit

Permalink
Merge pull request #552 from FabianTerhorst/dev
Browse files Browse the repository at this point in the history
RC
  • Loading branch information
FabianTerhorst committed May 11, 2022
2 parents 886e00a + 3fa1e03 commit 5cc53f7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions api/AltV.Net.Async/AsyncBaseObjectPool.cs
Expand Up @@ -22,9 +22,11 @@ protected AsyncBaseObjectPool(IBaseObjectFactory<TBaseObject> entityFactory)

public TBaseObject Create(ICore core, IntPtr entityPointer)
{
var entity = entityFactory.Create(core, entityPointer);
Add(entity);
return entity;
if (entityPointer == IntPtr.Zero) return default;
if (entities.TryGetValue(entityPointer, out var baseObject)) return baseObject;
baseObject = entityFactory.Create(core, entityPointer);
Add(baseObject);
return baseObject;
}

public void Add(TBaseObject entity)
Expand Down Expand Up @@ -66,9 +68,7 @@ public TBaseObject GetOrCreate(ICore core, IntPtr entityPointer)

if (entities.TryGetValue(entityPointer, out var entity)) return entity;

entity = Create(core, entityPointer);

return entity;
return Create(core, entityPointer);
}

public IReadOnlyCollection<TBaseObject> GetAllObjects()
Expand Down

0 comments on commit 5cc53f7

Please sign in to comment.