Restructure/refactor of main.c
This commit is contained in:
@@ -9,20 +9,20 @@
|
||||
|
||||
BzTileMap BZ_TILEMAP_INVALID = {.isValid = false};
|
||||
|
||||
void bzTileLayerSkipRender(BzTileLayer *layer) {
|
||||
void bzTileLayerSkipRender(BzTileMap *map, BzTileLayer *layer) {
|
||||
|
||||
}
|
||||
void bzTileObjectGroupSkipRender(BzTileObjectGroup *objectGroup) {
|
||||
void bzTileObjectGroupSkipRender(BzTileMap *map, BzTileObjectGroup *objectGroup) {
|
||||
|
||||
}
|
||||
|
||||
BzTileLayerRenderFunc BZ_TILE_LAYER_SKIP_RENDER = bzTileLayerSkipRender;
|
||||
BzTileObjectGroupRenderFunc BZ_TILE_OBJECTS_SKIP_RENDER = bzTileObjectGroupSkipRender;
|
||||
|
||||
bool bzTileLayerClear(BzTileLayer *layer, BzTile *data, i32 dataCount) {
|
||||
bool bzTileLayerClear(BzTileMap *map, BzTileLayer *layer) {
|
||||
return true;
|
||||
}
|
||||
bool bzTileObjectsClear(BzTileObjectGroup *objectGroup, BzTileObject *objects, i32 objectCount) {
|
||||
bool bzTileObjectsClear(BzTileMap *map, BzTileObjectGroup *objectGroup) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,12 @@ BzTileset *bzTileLayerGetTileset(BzTileMap *map, BzTileLayer *layer) {
|
||||
return NULL;
|
||||
return &map->tilesets[idx];
|
||||
}
|
||||
BzTileset *bzTileObjectGroupGetTileset(BzTileMap *map, BzTileObjectGroup *objectGroup) {
|
||||
i32 idx = objectGroup->tilesetIdx;
|
||||
if (idx < 0 || idx >= map->tilesetCount)
|
||||
return NULL;
|
||||
return &map->tilesets[idx];
|
||||
}
|
||||
|
||||
static void handleTileLayer(BzTileLayer *layer, cute_tiled_layer_t *cuteLayer) {
|
||||
layer->id = cuteLayer->id;
|
||||
@@ -283,7 +289,7 @@ void bzTileMapOverrideLayer(BzTileMap *map, i32 slotID, BzTileLayerFunc func) {
|
||||
BzTileLayer *layer = map->layers + slotID;
|
||||
i32 dataCount = layer->dataCount;
|
||||
BzTile *data = layer->data;
|
||||
if (func(layer, data, dataCount)) {
|
||||
if (func(map, layer)) {
|
||||
if (!layer->hasOwnership) return;
|
||||
bzFree(layer->data);
|
||||
if (layer->data == data) {
|
||||
@@ -300,7 +306,7 @@ void bzTileMapOverrideObjectGroup(BzTileMap *map, i32 slotID, BzTileObjectsFunc
|
||||
BzTileObjectGroup *objectGroup = map->objectGroups + slotID;
|
||||
BzTileObject *objects = objectGroup->objects;
|
||||
i32 objectCount = objectGroup->objectCount;
|
||||
if (func(objectGroup, objects, objectCount)) {
|
||||
if (func(map, objectGroup)) {
|
||||
bzFree(objectGroup->objects);
|
||||
if (objectGroup->objects == objects) {
|
||||
objectGroup->objects = NULL;
|
||||
|
||||
Reference in New Issue
Block a user