Drop the chunk palette; chunks are plain u16 tile arrays
The 64-entry per-chunk palette was a wire-format artifact and capped a chunk at 64 distinct tiles. A Chunk is now Box<[u16; 1024]> with flags derived from the id on lookup — the same layout a binary on-disk format would use. Map path becomes the first CLI argument; assets/map_large is a generated 256×256 stress map (loads in ~0.5 ms release). The snapshot test takes SNAPSHOT_MAP. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
5a055c048d
commit
1d14076468
+3
-3
@@ -1,5 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
use crate::chunk::{Chunk, TileDef, TileFlags, PaletteFullError};
|
||||
use crate::chunk::{Chunk, TileFlags};
|
||||
use crate::entity::Entity;
|
||||
|
||||
pub fn tile_to_chunk(tx: i16, ty: i16) -> (i16, i16) {
|
||||
@@ -45,11 +45,11 @@ impl World {
|
||||
self.chunks.get(&(cx, cy)).map(|c| c.tile_flags(lx, ly))
|
||||
}
|
||||
|
||||
pub fn set_tile(&mut self, wx: i16, wy: i16, def: TileDef) -> Result<(), PaletteFullError> {
|
||||
pub fn set_tile(&mut self, wx: i16, wy: i16, id: u16) {
|
||||
let (cx, cy) = tile_to_chunk(wx, wy);
|
||||
let (lx, ly) = tile_to_local(wx, wy);
|
||||
let chunk = self.chunks.entry((cx, cy)).or_insert_with(Chunk::new);
|
||||
chunk.set_tile(lx, ly, def)
|
||||
chunk.set_tile(lx, ly, id);
|
||||
}
|
||||
|
||||
pub fn spawn_entity(&mut self, type_id: u16, pos: (i16, i16), hp: u16) -> u32 {
|
||||
|
||||
Reference in New Issue
Block a user