From 70f7ccd29a249bd815af882150d2f4c9300e42a9 Mon Sep 17 00:00:00 2001 From: _ <_> Date: Thu, 19 Apr 2018 05:19:02 -0700 Subject: [PATCH 1/6] Addressed warnings for pld module --- include/devil1pld.h | 14 +++++--------- src/devil1pld.c | 8 +++++++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/devil1pld.h b/include/devil1pld.h index ef6abac..6057cd1 100644 --- a/include/devil1pld.h +++ b/include/devil1pld.h @@ -14,23 +14,19 @@ struct PldHeader { #pragma pack(pop) typedef struct { - bool (* const getheader) (struct PldHeader*, const char*); - int (* const sizeofsector)(struct PldHeader*, unsigned int, unsigned int); - void (* const printheader) (struct PldHeader*); -} fn_devil1pld; -extern fn_devil1pld const DEVIL1PLD; - // input: pointer to a struct, contents of the .pld file. // * = pass by reference of a struct PldHeader -static bool getpldh(struct PldHeader*, const char*); + bool (* const getheader) (struct PldHeader*, const char*); // input: pointer to header, index of offset, filesize // * = pass by reference of a struct PldHeader -static int sizeofpldstruct(struct PldHeader*, unsigned int, unsigned int); + int (* const sizeofsector)(struct PldHeader*, unsigned int, unsigned int); // input: a pld header struct. // * = pass by reference of a struct PldHeader -static void printpldh(struct PldHeader*); + void (* const printheader) (struct PldHeader*); +} fn_devil1pld; +extern fn_devil1pld const DEVIL1PLD; #endif diff --git a/src/devil1pld.c b/src/devil1pld.c index 3e3d96f..7717d98 100644 --- a/src/devil1pld.c +++ b/src/devil1pld.c @@ -1,6 +1,12 @@ #include "devil1pld.h" #include +static bool getpldh(struct PldHeader*, const char*); + +static int sizeofpldstruct(struct PldHeader*, unsigned int, unsigned int); + +static void printpldh(struct PldHeader*); + fn_devil1pld const DEVIL1PLD = {getpldh, sizeofpldstruct, printpldh}; static bool getpldh(struct PldHeader *ph, const char *filedata) { @@ -36,7 +42,7 @@ static void printpldh(struct PldHeader *ph) { return; } printf("number of offsets = %i\n", ph -> numOffset); - printf("offsets = %x\n", ph -> offsets); + printf("offsets = %p\n", ph -> offsets); unsigned int i; for (i = 0; i < ph -> numOffset; i++) { printf("offset %i = %x\n", i, ph -> offsets[i]); From ed2ee7bf71dceaf598d50285b8f83042adfcb482 Mon Sep 17 00:00:00 2001 From: _ <_> Date: Thu, 19 Apr 2018 05:19:38 -0700 Subject: [PATCH 2/6] Added -Wall to flags and moved devil1geo.o to main directory --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index bfd5878..7cc9e14 100644 --- a/Makefile +++ b/Makefile @@ -3,17 +3,17 @@ TEX=demo-extracttexture MEX=demo-extractmesh CC=gcc -CFLAGS= -I"include" +CFLAGS= -I"include" -Wall all: pld texture mesh -pld: devil1pld.o devil1tex.o src/devil1geo.o +pld: devil1pld.o devil1tex.o devil1geo.o $(CC) $^ demo/extractpld.c $(CFLAGS) -o $(PEX) -texture: devil1pld.o devil1tex.o src/devil1geo.o +texture: devil1pld.o devil1tex.o devil1geo.o $(CC) $^ demo/extracttexture.c $(CFLAGS) -o $(TEX) -mesh: devil1pld.o devil1tex.o src/devil1geo.o +mesh: devil1pld.o devil1tex.o devil1geo.o $(CC) $^ demo/extractmesh.c $(CFLAGS) -o $(MEX) devil1pld.o: src/devil1pld.c From dd5af2004da45ab3a4247ccfdf45a797ac54db36 Mon Sep 17 00:00:00 2001 From: _ <_> Date: Thu, 19 Apr 2018 05:30:13 -0700 Subject: [PATCH 3/6] Addressed warnings for texture module --- include/devil1tex.h | 43 ++++++++++++------------------------------- src/devil1tex.c | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/include/devil1tex.h b/include/devil1tex.h index bc37674..52a61b8 100644 --- a/include/devil1tex.h +++ b/include/devil1tex.h @@ -39,51 +39,32 @@ struct TextureBatch { #pragma pack(pop) typedef struct { +// input: pointer to struct void (* const printheader) (struct TexturePack*); + +// input: pointer to struct void (* const printbatchdesc)(struct TextureBatchDescriptor*); + +// input: pointer of pointer to struct, order, file data, file size +// ** = 'pass by reference' of a pointer to struct bool (* const getbatchdesc) (struct TextureBatchDescriptor**, unsigned int, const char *, unsigned int); + +// input: pointer of pointer to struct, order, file data, file size +// ** = 'pass by reference' of a pointer to struct bool (* const getbatch) (struct TextureBatch**, unsigned int, const char*, unsigned int); - bool (* const gettextures) (struct Texture*, + +// input: pointer to struct, order, file data, file size +bool (* const gettextures) (struct Texture*, unsigned int, const char*, const unsigned int); } fn_devil1tex; extern fn_devil1tex const DEVIL1TEX; -// -------------------------------------------------------+ -// Functions -// -------------------------------------------------------+ - -// Print Texture Pack Header. -static void printtph(struct TexturePack*); - -// Print Texture Batch Descriptor. -static void printtbd(struct TextureBatchDescriptor*); - -// Get Texture Batch Descriptor. -// ** = 'pass by reference' of a pointer to struct -static bool gettexdescriptor(struct TextureBatchDescriptor**, - unsigned int, - const char *, - unsigned int); - -// Get Texture Batch. -// ** = 'pass by reference' of a pointer to struct -static bool gettexbatch(struct TextureBatch**, - unsigned int, - const char*, - unsigned int); - -// Unpack Texture Batch -static bool unpacktexbatch(struct Texture*, - unsigned int, - const char*, - const unsigned int); - #endif diff --git a/src/devil1tex.c b/src/devil1tex.c index ed1417d..b27fc81 100644 --- a/src/devil1tex.c +++ b/src/devil1tex.c @@ -2,6 +2,32 @@ #include #include +// Print Texture Pack Header. +static void printtph(struct TexturePack*); + +// Print Texture Batch Descriptor. +static void printtbd(struct TextureBatchDescriptor*); + +// Get Texture Batch Descriptor. + +static bool gettexdescriptor(struct TextureBatchDescriptor**, + unsigned int, + const char *, + unsigned int); + +// Get Texture Batch. + +static bool gettexbatch(struct TextureBatch**, + unsigned int, + const char*, + unsigned int); + +// Unpack Texture Batch +static bool unpacktexbatch(struct Texture*, + unsigned int, + const char*, + const unsigned int); + fn_devil1tex const DEVIL1TEX = {printtph, printtbd, gettexdescriptor, From 9f614e794c15dff4449960ab68fc14a8672cb049 Mon Sep 17 00:00:00 2001 From: _ <_> Date: Thu, 19 Apr 2018 05:42:44 -0700 Subject: [PATCH 4/6] Addressed compiler warnings for geometry module --- include/devil1geo.h | 28 ++++++++++++---------------- src/devil1geo.c | 35 +++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/include/devil1geo.h b/include/devil1geo.h index 00375ad..9755435 100644 --- a/include/devil1geo.h +++ b/include/devil1geo.h @@ -73,39 +73,35 @@ struct Mesh { #pragma pack(pop) typedef struct { +// input: pointer to struct void (* const printheader) (struct Header*); + +// input: pointer to struct void (* const printmeshheader)(struct MeshHeader*); + +// input: pointer to struct void (* const printbatch) (struct Batch*); + +// input: pointer to struct void (* const printcoordinate)(struct Coordinate*, unsigned int); +// input: pointer of pointer to struct, order, file data +// ** = 'pass by reference' of a pointer to struct bool (* const getmeshheader) (struct MeshHeader**, unsigned int i, const char * const); +// input: pointer to struct, offset of file data batch is at, file data bool (* const getbatch) (struct Batch*, unsigned int offset, const char * const); +// input: pointer to struct, order, file data bool (* const getmesh) (struct Mesh*, unsigned int i, - const char* filename); + const char*); } fn_devil1geo; extern fn_devil1geo const DEVIL1GEO; -static void printgheader(struct Header*); - -static void printmeshheader(struct MeshHeader*); - -static void printmeshbatch(struct Batch*); - -static void printcoordinate(struct Coordinate*, unsigned int); - -// ** = 'pass by reference' of a pointer to struct -static bool getmeshheader(struct MeshHeader**, unsigned int i, const char * const); - -static bool getmeshbatch(struct Batch*, unsigned int offset, const char * const); - -static bool getmesh(struct Mesh*, unsigned int i, const char* filename); - #endif diff --git a/src/devil1geo.c b/src/devil1geo.c index 7bd72c7..4284ba2 100644 --- a/src/devil1geo.c +++ b/src/devil1geo.c @@ -1,6 +1,21 @@ #include "devil1geo.h" #include +static void printgheader(struct Header*); + +static void printmeshheader(struct MeshHeader*); + +static void printmeshbatch(struct Batch*); + +static void printcoordinate(struct Coordinate*, unsigned int); + + +static bool getmeshheader(struct MeshHeader**, unsigned int i, const char * const); + +static bool getmeshbatch(struct Batch*, unsigned int offset, const char * const); + +static bool getmesh(struct Mesh*, unsigned int i, const char*); + fn_devil1geo const DEVIL1GEO = {printgheader, printmeshheader, printmeshbatch, @@ -11,13 +26,13 @@ fn_devil1geo const DEVIL1GEO = {printgheader, static void printgheader(struct Header *gh) { if (gh != NULL) { - printf("pointer %x\n", gh); + printf("pointer %p\n", gh); printf("number of meshes %x\n", gh -> numMesh); printf("unknown number B %x\n", gh -> unknownNumberB); printf("unknown number C %x\n", gh -> unknownNumberC); printf("unknown number D %x\n", gh -> unknownNumberD); printf("padding %x\n", gh -> padding); - printf("unknown offset %x\n", gh -> unknownOffset); + printf("unknown offset %lx\n", gh -> unknownOffset); } } @@ -28,8 +43,8 @@ static void printmeshheader(struct MeshHeader *mh) { printf("number of batches %x\n", mh -> numBatch); printf("number of vertices %x\n", mh -> numVertex); printf("unknown %x\n", mh -> u); - printf("batch offset %x\n", mh -> offsetBatches); - printf("flags %x\n\n", mh -> flags); + printf("batch offset %lx\n", mh -> offsetBatches); + printf("flags %lx\n\n", mh -> flags); } static void printmeshbatch(struct Batch *b) { @@ -40,12 +55,12 @@ static void printmeshbatch(struct Batch *b) { printf("number of vertices %x\n", bd -> numVertex); printf("unknown byte %x\n", bd -> uB); printf("padding %x\n", bd -> padding); - printf("offsetPositions %x\n", bd -> offsetPositions); - printf("offsetNormals %x\n", bd -> offsetNormals); - printf("offsetUVs %x\n", bd -> offsetUVs); - printf("offsetBoneIndexes %x\n", bd -> offsetBoneIndexes); - printf("offsetBoneWeights %x\n", bd -> offsetBoneWeights); - printf("offsets %x\n\n", bd -> offsets[0]); + printf("offsetPositions %lx\n", bd -> offsetPositions); + printf("offsetNormals %lx\n", bd -> offsetNormals); + printf("offsetUVs %lx\n", bd -> offsetUVs); + printf("offsetBoneIndexes %lx\n", bd -> offsetBoneIndexes); + printf("offsetBoneWeights %lx\n", bd -> offsetBoneWeights); + printf("offsets %lx\n\n", bd -> offsets[0]); printcoordinate(b -> vd.positions, 3); } From 444e157d77d20e1ce9a401bd826167e064b82780 Mon Sep 17 00:00:00 2001 From: _ <_> Date: Thu, 19 Apr 2018 05:46:23 -0700 Subject: [PATCH 5/6] Minor adjustments of spacing and alignment --- include/devil1tex.h | 2 +- src/devil1geo.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/devil1tex.h b/include/devil1tex.h index 52a61b8..9013b2b 100644 --- a/include/devil1tex.h +++ b/include/devil1tex.h @@ -60,7 +60,7 @@ typedef struct { unsigned int); // input: pointer to struct, order, file data, file size -bool (* const gettextures) (struct Texture*, + bool (* const gettextures) (struct Texture*, unsigned int, const char*, const unsigned int); diff --git a/src/devil1geo.c b/src/devil1geo.c index 4284ba2..25f5d88 100644 --- a/src/devil1geo.c +++ b/src/devil1geo.c @@ -31,8 +31,8 @@ static void printgheader(struct Header *gh) { printf("unknown number B %x\n", gh -> unknownNumberB); printf("unknown number C %x\n", gh -> unknownNumberC); printf("unknown number D %x\n", gh -> unknownNumberD); - printf("padding %x\n", gh -> padding); - printf("unknown offset %lx\n", gh -> unknownOffset); + printf("padding %x\n", gh -> padding); + printf("unknown offset %lx\n", gh -> unknownOffset); } } @@ -40,11 +40,11 @@ static void printmeshheader(struct MeshHeader *mh) { if (mh == NULL) { return; } - printf("number of batches %x\n", mh -> numBatch); + printf("number of batches %x\n", mh -> numBatch); printf("number of vertices %x\n", mh -> numVertex); - printf("unknown %x\n", mh -> u); - printf("batch offset %lx\n", mh -> offsetBatches); - printf("flags %lx\n\n", mh -> flags); + printf("unknown %x\n", mh -> u); + printf("batch offset %lx\n", mh -> offsetBatches); + printf("flags %lx\n\n", mh -> flags); } static void printmeshbatch(struct Batch *b) { From 7dc8bfced337b8bcc3aed4d3f411e62d19825933 Mon Sep 17 00:00:00 2001 From: _ <_> Date: Thu, 19 Apr 2018 05:49:16 -0700 Subject: [PATCH 6/6] Addressed compiler warning in texture demo / pointer types --- demo/extracttexture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/extracttexture.c b/demo/extracttexture.c index 268f58f..f686ff7 100644 --- a/demo/extracttexture.c +++ b/demo/extracttexture.c @@ -23,7 +23,7 @@ void extracttextures(const char *filedata, DEVIL1TEX.gettextures(t, i, filedata, filesize); for (j = 0; j < d -> texNumber; j++) { sprintf(fmt, "%s_%d.dds", filename, id); - write(fmt, t[j].data, d -> textureSize); + write(fmt, (char*)t[j].data, d -> textureSize); id++; } free(t);