Zipfile for Levels and Doodads #80
Labels
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: SketchyMaze/doodle#80
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently: levels are gzipped JSON files of type level.Level and all drawn chunks of the level are in there, which for very large and colorful levels, is a problem on memory.
Levels could instead be made as a zipfile, like levelpacks do. Chunks can be stored in separate files of the archive and accessed randomly in a more memory efficient way.
Layout of the zipfile like:
Implementation Hints
In either level.Base or level.Level structs:
level.New():
level.Chunker
The Chunker is the main thing being ousted from the main json file, so the feature may be close to here.
It's used in two ways:
Chunkers should be given the Zipfile reference and be able to smartly proxy its API calls to handle reading chunks from the zipfile contents.
coordinate not sent on step 1.
Collision
The level collision detection knows nothing about the Chunker and expects to get an accessible grid of pixel data.
Replacing it by an interface to proxy its access to pixel data the Zipfile chunker can work.
level.FromJSON() and ToJSON()
Levels: FromJSON() and ToJSON() are the current root functions for the level file format, already supporting gzip or plain JSON files. FromJSON() currently inspects the file header to see if it begins with:
{
= plain text JSON file.0x1f8b
= gzip compressed JSON file.ToJSON() currently defers straight to ToGzip() if compressing drawings, and FromJSON() defers to FromGzip() when it detects the gzip header.
Add a ToZipfile() that ToJSON() will call instead when the zipfile feature is enabled which would:
/index.json
in the zipfile (headers only)Add a FromZipfile() function to read that back from disk:
*Zipfile
handle and be sure the Chunkers can access it.As the game calls GetChunk() to pull up chunks of interest, read and parse them from the zip file.
Caching, loading/unloading and mobile doodads
Problem: actors on a level are always active without culling. If the game were to completely unload the chunks that a far away mob is in, they would fall into the void.
The Chunker doesn't know and can't know about Actors but should have a way to either mark chunks to keep active or have a Least Recently Used cache. Ideas: