From bd7731272b77d829479a8ae27bc72f31aa0a5f0b Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 21 Mar 2005 04:55:01 +0000 Subject: [PATCH] some mild diff reduction with zmodel git-svn-id: svn://svn.icculus.org/twilight/trunk/dpmodel@5109 d7cf8633-e32d-0410-b094-e92efae38249 --- dpmodel.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/dpmodel.c b/dpmodel.c index fd4d4f8..bd22315 100644 --- a/dpmodel.c +++ b/dpmodel.c @@ -1,4 +1,13 @@ +// converter for .smd files (and a .txt script) to .dpm +// written by Forest 'LordHavoc' Hale but placed into public domain +// +// disclaimer: Forest Hale is not not responsible if this code blinds you with +// its horrible design, sets your house on fire, makes you cry, +// or anything else - use at your own risk. +// +// Yes, this is perhaps my second worst code ever (next to zmodel). + #include #include #include @@ -12,29 +21,33 @@ #pragma warning (disable : 4244) #endif +#define MAX_FILEPATH 1024 #define MAX_NAME 32 #define MAX_FRAMES 65536 #define MAX_TRIS 65536 #define MAX_VERTS (MAX_TRIS * 3) #define MAX_BONES 256 #define MAX_SHADERS 256 -#define MAX_FILESIZE 16777216 +#define MAX_FILESIZE (64*1024*1024) #define MAX_ATTACHMENTS MAX_BONES // model format related flags #define DPMBONEFLAG_ATTACH 1 -char outputdir_name[1024]; -char output_name[1024]; -char header_name[1024]; -char model_name[1024]; -char scene_name[1024]; -char model_name_uppercase[1024]; -char scene_name_uppercase[1024]; +char outputdir_name[MAX_FILEPATH]; +char output_name[MAX_FILEPATH]; +char header_name[MAX_FILEPATH]; +char model_name[MAX_FILEPATH]; +char scene_name[MAX_FILEPATH]; +char model_name_uppercase[MAX_FILEPATH]; +char scene_name_uppercase[MAX_FILEPATH]; FILE *headerfile = NULL; double modelorigin[3], modelscale; +// this makes it keep all bones, not removing unused ones (as they might be used for attachments) +int keepallbones = 1; + void stringtouppercase(char *in, char *out) { // cleanup name @@ -132,7 +145,7 @@ void *readfile(char *filename, int *filesize) { FILE *file; void *mem; - unsigned long size; + size_t size; if (!filename[0]) { printf("readfile: tried to open empty filename\n");