Chunk loading improvements

This commit is contained in:
2025-11-11 19:36:04 -06:00
parent 5c8b314689
commit d39ed1ea5a
12 changed files with 97 additions and 32 deletions

View File

@@ -167,6 +167,14 @@ errorret_t assetInit(void) {
errorOk();
}
bool_t assetFileExists(const char_t *filename) {
assertStrLenMax(filename, FILENAME_MAX, "Filename too long.");
zip_int64_t idx = zip_name_locate(ASSET.zip, filename, 0);
if(idx < 0) return false;
return true;
}
errorret_t assetLoad(const char_t *filename, void *output) {
assertStrLenMax(filename, FILENAME_MAX, "Filename too long.");
assertNotNull(output, "Output pointer cannot be NULL.");

View File

@@ -69,6 +69,14 @@ static asset_t ASSET;
*/
errorret_t assetInit(void);
/**
* Checks if an asset file exists.
*
* @param filename The filename of the asset to check.
* @return true if the asset file exists, false otherwise.
*/
bool_t assetFileExists(const char_t *filename);
/**
* Loads an asset by its filename, the output type depends on the asset type.
*

View File

@@ -32,6 +32,12 @@ errorret_t assetChunkLoad(assetcustom_t custom) {
assertNotNull(custom.zipFile, "Zip file pointer cannot be NULL");
chunk_t *chunk = (chunk_t *)custom.output;
printf(
"Loading chunk asset at position (%d, %d, %d)...\n",
chunk->position.x,
chunk->position.y,
chunk->position.z
);
// Read header
assetchunkheader_t header;