diff --git a/.gitignore b/.gitignore index 2a41c8a..eca47f8 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,4 @@ Debug/ Release/ .cproject .project +*.launch diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4387beb --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +CC=gcc +#CFLAGS= -Wextra -Wall -O0 -g +CFLAGS= -Wall -O3 +LDFLAGS= -lz -lpng + +TARGET=RogueDE-texture +VERSION=1.0a +SRC_DIR=src +SRC= $(wildcard $(SRC_DIR)/*.c) +INCLUDES=-I$(SRC_DIR) +BUILD_DIR=obj +OBJS= $(subst src,$(BUILD_DIR),$(SRC:%.c=%.o)) + + +.PHONY: $(BUILD_DIR) all clean + + +all: clean $(BUILD_DIR) $(TARGET) + + +$(BUILD_DIR)/%.o: src/%.c + $(CC) $(INCLUDES) -DVERSION='"$(VERSION)"' -c -o $@ $< $(CFLAGS) + +$(BUILD_DIR): + @mkdir -p $(BUILD_DIR) + +$(TARGET): $(OBJS) + $(CC) -o $@_$(VERSION) $^ $(LDFLAGS) + + +clean: + @rm -rf $(BUILD_DIR) + @rm -f RogueDE-* diff --git a/README.md b/README.md index 924aab6..20269b4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # RogueSquadron Data Extractor - TEXTURE module -Inspired by the work **dpethes** (https://github.com/dpethes/rerogue) +Inspired by the work of **dpethes** (https://github.com/dpethes/rerogue) This set of git repos are a compilation of tools coded in C to make RS modding far more than a dream! The collection consist of few independants modules, each of them deals with specific data like sound, textures, heightmaps, etc... @@ -16,8 +16,9 @@ It's extract texture datas from Rogue Squadron 3D (PC) game files (DAT). This module can do: - Extract textures inside HMT files to PNG format, - Extract automatically inside subfolder (usefull when you have a lot of pictures to extract), +- Multiple inputs files, - Manage transparent textures, -- Fixed some error RGB color encoding. +- Fixed some errored RGB color encoding. ### Using @@ -33,10 +34,14 @@ This module can do: Necessary libs for running (provided in release) and for compiling. -- zlib (1.2.11) -- libpng (1.6.37) +- zlib +- libpng (recommended: 1.6.37) ### Compiling You can compile on both Windows or Linux system, you only need to adjust your dependencies. -*Makefile is coming...* + +zlib and libpng16 distrib package can be used. +To compile, just type on linux: + +`make` \ No newline at end of file diff --git a/Texture-Extractor Debug.launch b/Texture-Extractor Debug.launch deleted file mode 100644 index 05dfc8f..0000000 --- a/Texture-Extractor Debug.launch +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Texture-Extractor Release.launch b/Texture-Extractor Release.launch deleted file mode 100644 index 985c68d..0000000 --- a/Texture-Extractor Release.launch +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/HMT_Parser.c b/src/HMT_Parser.c index 77297b2..f96d333 100644 --- a/src/HMT_Parser.c +++ b/src/HMT_Parser.c @@ -132,10 +132,12 @@ int getSamplesFromFile(RS_IMAGE *img, FILE *f) { int sample_bits = img->sampleBits; int size = div(img->width*img->height*sample_bits, 8).quot; - if (f->_bufsiz >= ftell(f)+size) { + /* + if (f->_bufsize >= ftell(f)+size) { //TODO: Check C equivalent printf("[ERR] WARNING! Please fix size/sample."); return EXIT_FAILURE; } + */ img->samples = calloc(1, size); fread(img->samples, size, 1, f); diff --git a/src/Texture-Extractor.c b/src/Texture-Extractor.c index 0e6ae8c..3263801 100644 --- a/src/Texture-Extractor.c +++ b/src/Texture-Extractor.c @@ -2,7 +2,6 @@ ================================================================================ Name : Texture-Extractor.c Author : JackCarterSmith - Version : 1.0a License : GPL-v3.0 Description : DAT textures extractor to PNG format with enhanced function in C ================================================================================ @@ -18,10 +17,13 @@ int main(int argc, char *argv[]) { HMT_FILE *hmt_fdatas = NULL; int file_index; + printf("\n*** RogueSquadron Data Extractor - TEXTURE module - v%s ***\n", VERSION); + // Check if filenames arguments exist if (argc < 2) { - printf("\nNo input file/commands specified!\n\nCorrect syntax is:\n$> Texture-Extractor \n"); - return EXCEPTION_NONCONTINUABLE; //TODO: implement own error codes system + printf("\n[ERR] No input file/commands specified!\n"); + dispHelp(); + return EXIT_FAILURE; //TODO: implement own error codes system } _options = checkArgs(argv, argc); // Analyse program arguments if (_options == -1) return EXIT_SUCCESS; @@ -74,7 +76,7 @@ void createSubDir(char *dirName) { #ifdef _WIN32 CreateDirectory(_dir, NULL); #else - mkdir(_dir, 755); + mkdir(_dir, 0755); #endif } @@ -120,11 +122,9 @@ int exportTextures(HMT_FILE *hmt_f, char *filename) { } void dispHelp() { - printf("\n"); - printf("RogueSquadron Data Extractor - TEXTURE module\n"); printf("\n"); printf("Options:\n -h Print this message\n -v Activate verbose console output\n -no-subdir Extract textures inside current folder\n"); printf("\n"); - printf("Usage: Texture-Extractor_\"version\" [options] \n"); + printf("Usage: RogueRE-texture_%s [options] \n", VERSION); printf("\n"); }