Seperate map and asset directories
This commit is contained in:
@@ -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
|
||||
|
||||
12
game/main.c
12
game/main.c
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user