Skip to content

Commit 6e73646

Browse files
authored
Fix entity reservation on 32-bit platforms (#21401)
# Objective - Casting `u32::MAX` to `IdCursor` on platforms such as GBA results in -1. ## Solution - I replaced with `IdCursor::MAX` and made the panic less cryptic. ## Testing - I porting https://github.com/bushrat011899/bevy_mod_gba to 0.17 and this change fixes the breakout example.
1 parent d00240d commit 6e73646

File tree

1 file changed

+2
-2
lines changed
  • crates/bevy_ecs/src/entity

1 file changed

+2
-2
lines changed

crates/bevy_ecs/src/entity/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,8 @@ impl Entities {
841841
// As `self.free_cursor` goes more and more negative, we return IDs farther
842842
// and farther beyond `meta.len()`.
843843
let raw = self.meta.len() as IdCursor - n;
844-
if raw >= u32::MAX as IdCursor {
845-
panic!("too many entities");
844+
if raw == IdCursor::MAX {
845+
panic!("number of entities can't exceed {}", IdCursor::MAX);
846846
}
847847
// SAFETY: We just checked the bounds
848848
let row = unsafe { EntityRow::new(NonMaxU32::new_unchecked(raw as u32)) };

0 commit comments

Comments
 (0)