Seperate map and asset directories

This commit is contained in:
2025-01-07 14:35:46 +00:00
parent a82586f327
commit 0cbc541bce
13 changed files with 17 additions and 20 deletions

View File

@@ -7,7 +7,9 @@ else()
target_link_libraries(game PRIVATE engine)
endif()
set_default_target_options(game)
target_compile_definitions(game PRIVATE ASSET_DIR="${ASSET_DIR}")
target_compile_definitions(game PRIVATE
MAP_DIR="${CMAKE_SOURCE_DIR}/map"
ASSET_DIR="${ASSET_DIR}")
target_include_directories(game PUBLIC include)
target_link_libraries(game PRIVATE

View File

@@ -250,8 +250,8 @@ static unsigned load_objtype(
xmlNodePtr sprites)
{
static char buf[MAX_PATH_LEN];
assert(strlen(ASSET_DIR) + strlen(templ) + 1 < MAX_PATH_LEN);
strcpy(buf, ASSET_DIR);
assert(strlen(MAP_DIR) + strlen(templ) + 1 < MAX_PATH_LEN);
strcpy(buf, MAP_DIR);
strcat(buf, "/");
strcat(buf, templ);
@@ -361,8 +361,8 @@ static void
load_objects(gamestate_t *state, xmlNodePtr node, SDL_Renderer *renderer)
{
char path[MAX_PATH_LEN];
assert(strlen(ASSET_DIR OBJSPRITES) < MAX_PATH_LEN);
strcpy(path, ASSET_DIR OBJSPRITES);
assert(strlen(MAP_DIR OBJSPRITES) < MAX_PATH_LEN);
strcpy(path, MAP_DIR OBJSPRITES);
xmlDocPtr spritesdoc = xmlParseFile(path);
xmlNodePtr sprites = xmlDocGetRootElement(spritesdoc);
@@ -498,8 +498,8 @@ void game_init(void *mem, SDL_Renderer *renderer)
gamestate_t *state = (gamestate_t *)mem;
// Load map
assert(strlen(ASSET_DIR MAP_ASSET) < MAX_PATH_LEN);
strcpy(path, ASSET_DIR MAP_ASSET);
assert(strlen(MAP_DIR MAP_ASSET) < MAX_PATH_LEN);
strcpy(path, MAP_DIR MAP_ASSET);
load_map(state, path, renderer);
// Load tileset