Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity generation changed from unit16 to uint32 #317

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ This change was necessary to get the same performance as before, despite the mor
* Adds functions `ComponentType(*World, ID) reflect.Type` and `ResourceType(*World, ID) reflect.Type` (#315)
* Adds methods `World.Ids(Entity) []ID` and `Query.Ids() []ID` (#315)

### Other

* Entity generation data type changed from `uint16` to `uint32` (#317)

## [[v0.9.0]](https://github.com/mlange-42/arche/compare/v0.8.1...v0.9.0)

### Infrastructure
Expand Down
4 changes: 2 additions & 2 deletions ecs/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var entityIndexSize uint32 = uint32(reflect.TypeOf(entityIndex{}).Size())
// The zero value should be used to indicate "nil", and can be checked with [Entity.IsZero].
type Entity struct {
id eid // Entity ID
gen uint16 // Entity generation
gen uint32 // Entity generation
}

// newEntity creates a new Entity.
Expand All @@ -31,7 +31,7 @@ func newEntity(id eid) Entity {
}

// newEntityGen creates a new Entity with a given generation.
func newEntityGen(id eid, gen uint16) Entity {
func newEntityGen(id eid, gen uint32) Entity {
return Entity{id, gen}
}

Expand Down
2 changes: 1 addition & 1 deletion ecs/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type entityPool struct {
// newEntityPool creates a new, initialized Entity pool.
func newEntityPool(capacityIncrement uint32) entityPool {
entities := make([]Entity, 1, capacityIncrement)
entities[0] = Entity{0, math.MaxUint16}
entities[0] = Entity{0, math.MaxUint32}
return entityPool{
entities: entities,
next: 0,
Expand Down
2 changes: 1 addition & 1 deletion ecs/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestEntityPool(t *testing.T) {
p := newEntityPool(128)

expectedAll := []Entity{newEntity(0), newEntity(1), newEntity(2), newEntity(3), newEntity(4), newEntity(5)}
expectedAll[0].gen = math.MaxUint16
expectedAll[0].gen = math.MaxUint32

for i := 0; i < 5; i++ {
_ = p.Get()
Expand Down
Loading