diff --git a/README.md b/README.md index 3a5885c..5696f09 100644 --- a/README.md +++ b/README.md @@ -51,5 +51,4 @@ __Website:__ Third party licenses __sclpython.h:__ zlib License
-__fcecodec scripts:__ zlib License
-__bfut_mywrappers.py:__ zlib License +__fcecodec scripts:__ zlib License diff --git a/python/README.md b/python/README.md index 786c451..ebbcc85 100644 --- a/python/README.md +++ b/python/README.md @@ -258,5 +258,5 @@ FUNCTIONS Returns 1 for valid FCE data, 0 otherwise. VERSION - 1.8 + 1.9 ``` diff --git a/setup.py b/setup.py index ba6b11e..df7c39f 100644 --- a/setup.py +++ b/setup.py @@ -59,6 +59,7 @@ # # debug # ("-g"), ("-O0"), # ("-pedantic-errors"), + ("-pedantic"), ("-fvisibility=hidden"), # sets the default symbol visibility to hidden ("-Wformat-security"), ("-Wdeprecated-declarations"), diff --git a/src/fcelib/fcelib.h b/src/fcelib/fcelib.h index 6ed9014..ea40874 100644 --- a/src/fcelib/fcelib.h +++ b/src/fcelib/fcelib.h @@ -41,7 +41,7 @@ #include #include -#define FCECVERS "1.8" +#define FCECVERS "1.9" #ifndef FCECVERBOSE #define FCECVERBOSE 0 /* >=1 for verbose console output */ #endif diff --git a/src/fcelib/fcelib_io.h b/src/fcelib/fcelib_io.h index e0d4b87..96d4891 100644 --- a/src/fcelib/fcelib_io.h +++ b/src/fcelib/fcelib_io.h @@ -142,8 +142,6 @@ int __FCELIB_IO_DECODE_GETPARTS(FcelibMesh *mesh, const char *header_PartNames, Params: FCE buffer, FcelibMesh. Returns bool. Assumes (mesh != NULL). Silently releases and re-initializes existing mesh. Assumes valid FCE data. - - C API: mesh must have been initialized */ int FCELIB_IO_DecodeFce(FcelibMesh *mesh, const unsigned char *buf, int buf_size) { @@ -161,24 +159,17 @@ int FCELIB_IO_DecodeFce(FcelibMesh *mesh, const unsigned char *buf, int buf_size break; } -#ifdef __cplusplus - if (mesh->_consumed && mesh->release == &FCELIB_TYPES_FreeMesh) + if (mesh->release == &FCELIB_TYPES_FreeMesh) { mesh->release(mesh); FCELIB_TYPES_InitMesh(mesh); } #ifndef FCELIB_PYTHON_BINDINGS - else if (!mesh->release) - FCELIB_TYPES_InitMesh(mesh); - else if (mesh->_consumed || mesh->release != &FCELIB_TYPES_FreeMesh) + else if (!mesh->release || mesh->release != &FCELIB_TYPES_FreeMesh) { - fprintf(stderr, "DecodeFce: mesh is not free and cannot be initialized.\n"); - break; + FCELIB_TYPES_InitMesh(mesh); } #endif -#endif - - mesh->_consumed = 1; if (buf_size < 0x1F04) { @@ -1792,7 +1783,7 @@ int FCELIB_IO_EncodeFce4(FcelibMesh *mesh, unsigned char **outbuf, const int buf } /* - Assumes (mesh != NULL). If necessary, will initialize mesh. + Assumes (mesh != NULL). Otherwise, expects non-NULL parameters. vert_idxs: 012... @@ -1827,20 +1818,8 @@ int FCELIB_IO_GeomDataToNewPart(FcelibMesh *mesh, fprintf(stderr, "DecodeFce: an input is NULL\n"); break; } - -#ifdef __cplusplus - if (!mesh->release) - FCELIB_TYPES_InitMesh(mesh); - else if (mesh->release != &FCELIB_TYPES_FreeMesh) - { - fprintf(stderr, "DecodeFce: mesh is not free and cannot be initialized.\n"); - break; - } -#endif #endif - mesh->_consumed = 1; - if (vert_idxs_len % 3 != 0) { fprintf(stderr, "GeomDataToNewPart: Expects N*3 == vert_idxs_len, for N triangles.\n"); diff --git a/src/fcelib/fcelib_types.h b/src/fcelib/fcelib_types.h index 29a5e11..5b9b278 100644 --- a/src/fcelib/fcelib_types.h +++ b/src/fcelib/fcelib_types.h @@ -100,12 +100,6 @@ struct FcelibHeader { }; struct FcelibMesh { -#ifdef __cplusplus - int _consumed = 0; /* previously decoded? yes/no 1/0, internal fcelib use only */ -#else - int _consumed; /* previously decoded? yes/no 1/0, internal fcelib use only */ -#endif - int parts_len; /* capacity: array length */ int triangles_len; /* capacity: array length */ int vertices_len; /* capacity: array length */ @@ -125,11 +119,7 @@ struct FcelibMesh { FcelibTriangle **triangles; /* may contain NULL elements */ FcelibVertex **vertices; /* may contain NULL elements */ -#ifdef __cplusplus - void (*release)(struct FcelibMesh*) = NULL; -#else void (*release)(struct FcelibMesh*); -#endif }; #ifdef __cplusplus @@ -138,7 +128,11 @@ struct FcelibMesh { /* release, init, validate -------------------------------------------------- */ -/* Call via mesh->release(), never directly. */ +/* + Call via mesh->release(), never directly. + + Afterwards (!mesh->release). +*/ void FCELIB_TYPES_FreeMesh(FcelibMesh *mesh) { int i; @@ -184,17 +178,11 @@ void FCELIB_TYPES_FreeMesh(FcelibMesh *mesh) if (mesh->triangles) free(mesh->triangles); if (mesh->vertices) free(mesh->vertices); -#ifdef __cplusplus - *mesh = {}; -#else - memset(mesh, 0, sizeof(*mesh)); -#endif + mesh->release = NULL; } /* - Assumes (mesh != NULL). Silently re-initializes. - - C API: mesh must have been initialized + Assumes (mesh). memset's mesh to 0. Silently re-initializes. */ FcelibMesh *FCELIB_TYPES_InitMesh(FcelibMesh *mesh) { @@ -202,21 +190,10 @@ FcelibMesh *FCELIB_TYPES_InitMesh(FcelibMesh *mesh) #ifdef __cplusplus if (mesh->release == &FCELIB_TYPES_FreeMesh) mesh->release(mesh); - if (mesh->release && mesh->release != &FCELIB_TYPES_FreeMesh) - { - fprintf(stderr, "InitMesh: mesh is not free and cannot be initialized.\n"); - return NULL; - } #endif #endif -#ifdef __cplusplus - *mesh = {}; -#else memset(mesh, 0, sizeof(*mesh)); - /* array_dirty = 0; */ -#endif - mesh->hdr.NumArts = 1; mesh->release = &FCELIB_TYPES_FreeMesh; return mesh; @@ -232,10 +209,7 @@ int FCELIB_TYPES_ValidateMesh(const FcelibMesh *mesh) int sum_verts = 0; FcelibPart *part = NULL; - if (!mesh->release) - return 0; - if (mesh->release != &FCELIB_TYPES_FreeMesh) - return 0; + if (!mesh->release || mesh->release != &FCELIB_TYPES_FreeMesh) return 0; if (mesh->parts_len == 0 && !mesh->parts && !mesh->hdr.Parts && mesh->triangles_len == 0 && !mesh->triangles && diff --git a/src/fcelib/fcelib_util.h b/src/fcelib/fcelib_util.h index 2eb47de..063489c 100644 --- a/src/fcelib/fcelib_util.h +++ b/src/fcelib/fcelib_util.h @@ -26,13 +26,8 @@ #include #include -#ifndef __cplusplus -enum { kFceLibImplementedFce3Parts = 13 }; -enum { kFceLibNumFce4HiBodyParts = 18 }; -#else -static const int kFceLibImplementedFce3Parts = 13; -static const int kFceLibNumFce4HiBodyParts = 18; -#endif +#define kFceLibImplementedFce3Parts 13 +#define kFceLibNumFce4HiBodyParts 18 /* Represent FCE dummies (light/fx objects) Mainly used for OBJ output, hence kTrianglesDiamond has 1-based indexes. */ @@ -58,10 +53,8 @@ const int kTrianglesDiamond[8 * 3] = { 4, 5, 1 }; -#ifndef FCELIB_UTIL_Min #define FCELIB_UTIL_Min(x,y) ((x)<(y)?(x):(y)) #define FCELIB_UTIL_Abs(x) ((x)<0 ? -(x) : (x)) -#endif const char *FCELIB_UTIL_GetLastSlash(const char *path) {