Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -971,13 +971,15 @@ else
$(EXE): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(ULTRA_O_FILES) $(GODDARD_O_FILES)
$(LD) -L $(BUILD_DIR) -o $@ $(O_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)

# Copying the dynamically linked DLL files
# Copying the dynamically linked DLL files (Windows only)
ifeq ($(TARGET_WINDOWS),1)
$(shell a=$(PATH); b=$${a%%:*}; cp "$${b}/SDL2.dll" "$(BUILD_DIR)/SDL2.dll")

ifeq ($(TARGET_32BIT),1)
$(shell a=$(PATH); b=$${a%%:*}; cp "$${b}/libgcc_s_dw2-1.dll" "$(BUILD_DIR)/libgcc_s_dw2-1.dll")
$(shell a=$(PATH); b=$${a%%:*}; cp "$${b}/libwinpthread-1.dll" "$(BUILD_DIR)/libwinpthread-1.dll")
endif
endif
endif

.PHONY: all clean distclean default diff test load libultra
Expand Down
7 changes: 6 additions & 1 deletion src/pc/gfx/gfx_pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,12 @@ static void import_texture(int tile) {
#ifdef TARGET_MACOS
_NSGetExecutablePath(exec_path, &size);
#else
readlink("/proc/self/exe", exec_path, size);
ssize_t len = readlink("/proc/self/exe", exec_path, size - 1);
if (len >= 0) {
exec_path[len] = '\0';
} else {
exec_path[0] = '\0';
}
#endif
dir = dirname(exec_path);
const char gfx_path[1024];
Expand Down
37 changes: 33 additions & 4 deletions tools/skyconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,29 +230,58 @@ void write_tiles() {
exit(EXIT_FAILURE);
}

strcat(buffer, "/");
size_t dirLength = strlen(buffer);
if (dirLength + 1 >= sizeof(buffer)) {
fprintf(stderr, "err: Image dir path too long\n");
exit(EXIT_FAILURE);
}

buffer[dirLength++] = '/';
buffer[dirLength] = '\0';

switch(type) {
case Skybox:
if (dirLength + strlen(skyboxName) >= sizeof(buffer)) {
fprintf(stderr, "err: Skybox name path too long\n");
exit(EXIT_FAILURE);
}
strcat(buffer, skyboxName);
break;
case Cake:
if (dirLength + strlen("cake") >= sizeof(buffer)) {
fprintf(stderr, "err: Cake path too long\n");
exit(EXIT_FAILURE);
}
strcat(buffer, "cake");
break;
case CakeEU:
if (dirLength + strlen("cake_eu") >= sizeof(buffer)) {
fprintf(stderr, "err: Cake path too long\n");
exit(EXIT_FAILURE);
}
strcat(buffer, "cake_eu");
break;
default:
exit(EXIT_FAILURE);
break;
}

int dirLength = strlen(buffer);
dirLength = strlen(buffer);
char *filename = buffer + dirLength;
size_t remaining = sizeof(buffer) - dirLength;
if (remaining == 0) {
fprintf(stderr, "err: Image dir path too long\n");
exit(EXIT_FAILURE);
}

for (int i = 0; i < props.numRows * props.numCols; i++) {
if (!tiles[i].useless) {
*filename = 0;
snprintf(filename, PATH_MAX, ".%d.rgba16.png", tiles[i].pos);
int written = snprintf(filename, remaining, ".%d.rgba16.png", tiles[i].pos);
if (written < 0 || (size_t) written >= remaining) {
fprintf(stderr, "err: Tile filename too long\n");
exit(EXIT_FAILURE);
}
rgba2png(buffer, tiles[i].px, props.tileWidth, props.tileHeight);
}
}
Expand Down Expand Up @@ -676,4 +705,4 @@ int main(int argc, char *argv[]) {


return EXIT_SUCCESS;
}
}