Skip to content

Commit

Permalink
Merge pull request #67 from CarperAI/daveey-git-pr-30948-5332
Browse files Browse the repository at this point in the history
fix the bug with entity culling code
  • Loading branch information
jsuarez5341 committed Jun 5, 2023
2 parents f0e8055 + 74a73f6 commit 74b58e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
12 changes: 6 additions & 6 deletions nmmo/entity/entity_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, realm):
self.config = realm.config

self.entities: Dict[int, Entity] = {}
self.dead: Dict[int, Entity] = {}
self.dead_this_tick: Dict[int, Entity] = {}

def __len__(self):
return len(self.entities)
Expand All @@ -37,7 +37,7 @@ def items(self):

@property
def corporeal(self):
return {**self.entities, **self.dead}
return {**self.entities, **self.dead_this_tick}

@property
def packet(self):
Expand All @@ -52,21 +52,21 @@ def reset(self):
ent.datastore_record.delete()

self.entities = {}
self.dead = {}
self.dead_this_tick = {}

def spawn(self, entity):
pos, ent_id = entity.pos, entity.id.val
self.realm.map.tiles[pos].add_entity(entity)
self.entities[ent_id] = entity

def cull(self):
self.dead = {}
self.dead_this_tick = {}
for ent_id in list(self.entities):
player = self.entities[ent_id]
if not player.alive:
r, c = player.pos
ent_id = player.ent_id
self.dead[ent_id] = player
self.dead_this_tick[ent_id] = player

self.realm.map.tiles[r, c].remove_entity(ent_id)

Expand All @@ -79,7 +79,7 @@ def cull(self):
self.entities[ent_id].datastore_record.delete()
del self.entities[ent_id]

return self.dead
return self.dead_this_tick

def update(self, actions):
for entity in self.entities.values():
Expand Down
11 changes: 9 additions & 2 deletions utils/pre-git-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ echo "Checking pylint, xcxc, pytest without touching git"
echo

# Check the number of physical cores only
cores=$(lscpu -b -p=Core,Socket | grep -v '^#' | sort -u | wc -l)
if command -v lscpu &> /dev/null
then
# lscpu is available
cores=$(lscpu -b -p=Core,Socket | grep -v '^#' | sort -u | wc -l)
else
# lscpu is not available, use sysctl instead
cores=$(sysctl -n hw.physicalcpu)
fi

# Run linter
echo "--------------------------------------------------------------------"
Expand Down Expand Up @@ -51,4 +58,4 @@ fi

echo
echo "Pre-git checks look good!"
echo
echo

0 comments on commit 74b58e6

Please sign in to comment.