diff --git a/main.c b/main.c index af104aa..b173e02 100644 --- a/main.c +++ b/main.c @@ -39,6 +39,7 @@ struct options { int l; int w; int h; + int d; }; void printHelp() { @@ -48,6 +49,11 @@ void printHelp() { "A maximum of 360 different frames can be used for a single avatar.\n" "If the size of any frame does not match, it will be resized to match the first frame.\n" "\n" + "When using KAvEAT to create environment textures, please keep in mind that Worlds has\n" + "a limit of 9x9 tiles per CMP/MOV file due to the URL parser only reading single digits.\n" + "This makes the practical maximum resolution of avatars 2048x2048. World textures can not\n" + "have more than 9 frames but can bypass both limits by splitting walls into more pieces.\n" + "\n" "Available options:\n" " -r # Maximum resolution, where # is a power of 2. For example, 256 pixels would be \"-r 8\"\n" " -s Stretch the image when non-pot or mismatched size, as opposed to fitting it within.\n" @@ -57,6 +63,8 @@ void printHelp() { " so using this setting with different image sizes will cause visible bars to appear\n" " unless you combine it with the -s option, which will always fill the canvas for each\n" " frame. The same is true for all imported frames which contain an alpha channel.\n" + " -d Don't run COMPIMG, don't delete temporary files. Useful if COMPIMG is broken for some\n" + " reason, or if you want to customize the command line options given to it.\n" // " -l Enable Lanczos filtering when scaling the image.\n" //point filter unimplemented //" -w Specify the number of subdivisions to make horizontally per frame.\n" //" Use this if you are importing a spritesheet. Each cut is perfectly even.\n" @@ -96,17 +104,20 @@ int main(const int argc, char *argv[]) { opt.l = 0; opt.w = 0; opt.h = 0; + opt.d = 0; uint16_t numFrames = 0; char* frames[360]; int i = 2; while (i < argc) { if (argv[i][0] == '+') { - frames[numFrames] = (char*)malloc(strlen(argv[i]) + 1); - memcpy(frames[numFrames], &argv[i][1], strlen(argv[i]) + 1); - printf("Adding frame to search index: %s\n", frames[numFrames]); + if (numFrames < 360) { + frames[numFrames] = (char*)malloc(strlen(argv[i]) + 1); + memcpy(frames[numFrames], &argv[i][1], strlen(argv[i]) + 1); + printf("Adding frame to search index: %s\n", frames[numFrames]); - numFrames++; + numFrames++; + } else printf("REJECTING new frame as it exceeds the frame limit.\n"); } else if (strcmp(argv[i], "-r") == 0) { if (i == argc-1) { printf("No parameter for option: -r\n"); return 0; } int r = pow(2, trunc(atof(argv[i+1]))); @@ -125,6 +136,8 @@ int main(const int argc, char *argv[]) { if (c < 1 || c > 256) { printf("Invalid number of colors: %s\n", argv[i+1]); return 0; } opt.c = c - 1; i++; + } else if (strcmp(argv[i], "-d") == 0) { + opt.d = !opt.d; } else { printf("I don't know what \"%s\" means!\n", argv[i]); return 0; @@ -306,6 +319,7 @@ int main(const int argc, char *argv[]) { } fclose(partlist); + if (opt.d) { // Pass on images to COMPIMG printf("Encoding texture file...\n"); char* command = (char*)malloc((54 + 3 * abs(1-opt.o) + strlen(filename))*sizeof(char)); // MSVC @@ -319,26 +333,28 @@ int main(const int argc, char *argv[]) { printf("%s\n", command); if (system(command)) { printf("ERROR trying to run COMPIMG!\nMake sure that COMPIMG.EXE is inside of the folder you are working in.\n"); return 0; } - printf("Cleaning up temporary files...\n"); + printf("Cleaning up temporary files...\n"); + while (i < numFrames) { + int ih = 0; + while (ih < piecesY) { + int iw = 0; + while (iw < piecesX) { + char* framename = (char*)malloc(12 * piecesX * piecesY * sizeof(char)); // MSVC + sprintf(framename, "f%d%d%d.bmp", i, iw, ih); + remove(framename); + free(framename); - while (i < numFrames) { - int ih = 0; - while (ih < piecesY) { - int iw = 0; - while (iw < piecesX) { - char* framename = (char*)malloc(12 * piecesX * piecesY * sizeof(char)); // MSVC - sprintf(framename, "f%d%d%d.bmp", i, iw, ih); - remove(framename); - free(framename); - - iw++; + iw++; + } + ih++; } - ih++; + i++; } - i++; } - printf("\n\n!!! DONE !!!\nYour avatar name is: %s%ds*%dh*%dv*.mov\n", filename, numFrames, piecesX, piecesY); + printf("\n\n!!! DONE !!!\n"); + if (opt.d) + printf("Your avatar name is: %s%ds*%dh*%dv*.mov\n", filename, numFrames, piecesX, piecesY); if(mw) mw = DestroyMagickWand(mw); MagickWandTerminus();