Index: src/tools/ufo2map/ufo2map.c =================================================================== --- src/tools/ufo2map/ufo2map.c (revision 19297) +++ src/tools/ufo2map/ufo2map.c (working copy) @@ -148,7 +148,7 @@ /** * @brief Check for bsping, radiosity and checking/fixing command line parameters */ -static void U2M_Parameter (int argc, const char **argv) +static int U2M_Parameter (int argc, const char **argv) { int i; @@ -390,9 +390,15 @@ } else { Sys_Error("invalid parameter count\n"); } - } else if (i < (argc - 1)) { - /* Last param is the map path, every other param should have been caught by now. */ + } else if (!strcmp(argv[i],"--")) { + /* End of options mapfiles coming */ + break; + } else if (argv[i][0] == '-') { + /* Unrecognized option */ Verb_Printf(VERB_LESS, "*** parameter not understood: %s try --help for more info\n", argv[i]); + } else { + /* End of options mapfiles coming */ + break; } } @@ -405,6 +411,8 @@ config.generateFootstepFile = qfalse; config.generateMaterialFile = qfalse; } + + return i; } /** @@ -526,6 +534,7 @@ char bspFilename[MAX_OSPATH]; double begin, start, end; long size; + int fileParam; memset(&config, 0, sizeof(config)); /* init thread state */ @@ -533,7 +542,7 @@ U2M_SetDefaultConfigValues(); - U2M_Parameter(argc, argv); + fileParam = U2M_Parameter(argc, argv); Verb_Printf(VERB_NORMAL, "---- ufo2map "VERSION" ----\n"); @@ -544,149 +553,151 @@ Swap_Init(); - start = time(NULL); + while (fileParam < argc) { + start = time(NULL); - Verb_Printf(VERB_NORMAL, "path: '%s'\n", argv[argc - 1]); - FS_Init(argv[argc - 1]); + Verb_Printf(VERB_NORMAL, "path: '%s'\n", argv[fileParam]); + FS_Init(argv[fileParam]); - COM_StripExtension(COM_ExpandRelativePath(argv[argc - 1]), mapFilename, sizeof(mapFilename)); - strncpy(baseFilename, mapFilename, sizeof(baseFilename) - 1); - strncpy(bspFilename, mapFilename, sizeof(bspFilename) - 1); - COM_DefaultExtension(mapFilename, sizeof(mapFilename), ".map"); - COM_DefaultExtension(bspFilename, sizeof(bspFilename), ".bsp"); + COM_StripExtension(COM_ExpandRelativePath(argv[fileParam]), mapFilename, sizeof(mapFilename)); + strncpy(baseFilename, mapFilename, sizeof(baseFilename) - 1); + strncpy(bspFilename, mapFilename, sizeof(bspFilename) - 1); + COM_DefaultExtension(mapFilename, sizeof(mapFilename), ".map"); + COM_DefaultExtension(bspFilename, sizeof(bspFilename), ".bsp"); - if (config.info) { - LoadBSPFile(bspFilename); - PrintBSPFileSizes(); - return 0; - } + if (config.info) { + LoadBSPFile(bspFilename); + PrintBSPFileSizes(); + return 0; + } - Verb_Printf(VERB_NORMAL, "...map: '%s'\n", mapFilename); - if (!(config.performMapCheck || config.fixMap)) - Verb_Printf(VERB_NORMAL, "...bsp: '%s'\n", bspFilename); + Verb_Printf(VERB_NORMAL, "...map: '%s'\n", mapFilename); + if (!(config.performMapCheck || config.fixMap)) + Verb_Printf(VERB_NORMAL, "...bsp: '%s'\n", bspFilename); - if (config.verbosity == VERB_MAPNAME && !(config.performMapCheck || config.fixMap)) - PrintName(); + if (config.verbosity == VERB_MAPNAME && !(config.performMapCheck || config.fixMap)) + PrintName(); - if (config.onlynewer && CheckTimeDiff(mapFilename, bspFilename)) { - Verb_Printf(VERB_LESS, "bsp file is up-to-date\n"); - return 0; - } + if (config.onlynewer && CheckTimeDiff(mapFilename, bspFilename)) { + Verb_Printf(VERB_LESS, "bsp file is up-to-date\n"); + return 0; + } - /* if onlyents just grab the entites and resave */ - if (config.onlyents) { - LoadBSPFile(bspFilename); - num_entities = 0; /* use the map source entities */ + /* if onlyents just grab the entites and resave */ + if (config.onlyents) { + LoadBSPFile(bspFilename); + num_entities = 0; /* use the map source entities */ - LoadMapFile(mapFilename); - SetModelNumbers(); + LoadMapFile(mapFilename); + SetModelNumbers(); - UnparseEntities(); + UnparseEntities(); - WriteBSPFile(bspFilename); - } else if (config.performMapCheck || config.fixMap) { - int i; - Verb_Printf(VERB_NORMAL, "Starting map %s\n", config.fixMap ? "fixes" : "checks"); - LoadMapFile(mapFilename); - /* level flags must be fixed before mixed face contents, or they swamp the - * console with output, as levelflags are contentflags */ - if (config.chkLevelFlags || config.chkBrushes || config.chkAll) - CheckLevelFlags(); - if (config.chkFillLevelFlags || config.chkBrushes || config.chkAll) - CheckFillLevelFlags(); - /* this must be before mfc check, as otherwise mfc warnings are given - * which are auto-fixed based on textures */ - if (config.chkTextures || config.chkBrushes || config.chkAll) - CheckFlagsBasedOnTextures(); - /* mixed face contents check may remove contentflags. this should be done - * before tex based on flags check, as tex may replace tex on the basis - * of contentflags.*/ - if (config.chkMixedFaceContents || config.chkBrushes || config.chkAll) - CheckMixedFaceContents(); - if (config.chkTextures || config.chkBrushes || config.chkAll) - CheckTexturesBasedOnFlags(); - if (config.chkMMicro || config.chkBrushes || config.chkAll) - CheckMapMicro(); - if (config.chkContained || config.chkBrushes || config.chkAll) - Check_ContainedBrushes(); - if (config.chkBrushes || config.chkAll) - CheckBrushes(); - /** @todo include in chkAll when it works */ - if (config.chkNodraws /* || config.chkAll */) - CheckNodraws(); - if (config.chkZFight || config.chkAll || config.chkBrushes) - CheckZFighting(); - if (config.chkEntities || config.chkAll) - CheckEntities(); + WriteBSPFile(bspFilename); + } else if (config.performMapCheck || config.fixMap) { + int i; + Verb_Printf(VERB_NORMAL, "Starting map %s\n", config.fixMap ? "fixes" : "checks"); + LoadMapFile(mapFilename); + /* level flags must be fixed before mixed face contents, or they swamp the + * console with output, as levelflags are contentflags */ + if (config.chkLevelFlags || config.chkBrushes || config.chkAll) + CheckLevelFlags(); + if (config.chkFillLevelFlags || config.chkBrushes || config.chkAll) + CheckFillLevelFlags(); + /* this must be before mfc check, as otherwise mfc warnings are given + * which are auto-fixed based on textures */ + if (config.chkTextures || config.chkBrushes || config.chkAll) + CheckFlagsBasedOnTextures(); + /* mixed face contents check may remove contentflags. this should be done + * before tex based on flags check, as tex may replace tex on the basis + * of contentflags.*/ + if (config.chkMixedFaceContents || config.chkBrushes || config.chkAll) + CheckMixedFaceContents(); + if (config.chkTextures || config.chkBrushes || config.chkAll) + CheckTexturesBasedOnFlags(); + if (config.chkMMicro || config.chkBrushes || config.chkAll) + CheckMapMicro(); + if (config.chkContained || config.chkBrushes || config.chkAll) + Check_ContainedBrushes(); + if (config.chkBrushes || config.chkAll) + CheckBrushes(); + /** @todo include in chkAll when it works */ + if (config.chkNodraws /* || config.chkAll */) + CheckNodraws(); + if (config.chkZFight || config.chkAll || config.chkBrushes) + CheckZFighting(); + if (config.chkEntities || config.chkAll) + CheckEntities(); - /* not included in bru or all by design */ - if (config.chkIntersection) - Check_BrushIntersection(); - if (config.chkRemoveStepons) - Check_RemoveSteponBrushes(); + /* not included in bru or all by design */ + if (config.chkIntersection) + Check_BrushIntersection(); + if (config.chkRemoveStepons) + Check_RemoveSteponBrushes(); - if (config.fixMap) { - /* update dentdata */ - UnparseEntities(); - WriteMapFile(GetScriptFile()); - } + if (config.fixMap) { + /* update dentdata */ + UnparseEntities(); + WriteMapFile(GetScriptFile()); + } - /* several of the check functions use nearBrushes list for speedup - * it can only be freed when the checks have finished */ - for (i = 0; i < nummapbrushes; i++) { - mapbrush_t *iBrush = &mapbrushes[i]; + /* several of the check functions use nearBrushes list for speedup + * it can only be freed when the checks have finished */ + for (i = 0; i < nummapbrushes; i++) { + mapbrush_t *iBrush = &mapbrushes[i]; - if (iBrush->numNear) { - assert(iBrush->nearBrushes); - free(iBrush->nearBrushes); - iBrush->numNear = 0; - iBrush->nearBrushes = NULL; + if (iBrush->numNear) { + assert(iBrush->nearBrushes); + free(iBrush->nearBrushes); + iBrush->numNear = 0; + iBrush->nearBrushes = NULL; + } } + return 0; + } else { + /* start from scratch */ + LoadMapFile(mapFilename); + SetModelNumbers(); + + ProcessModels(bspFilename); } - return 0; - } else { - /* start from scratch */ - LoadMapFile(mapFilename); - SetModelNumbers(); - ProcessModels(bspFilename); - } + end = time(NULL); + Verb_Printf(VERB_LESS, "%5.0f seconds elapsed\n", end - start); + begin = start; - end = time(NULL); - Verb_Printf(VERB_LESS, "%5.0f seconds elapsed\n", end - start); - begin = start; + if (!config.onlyents && config.noradiosity != RADIOSITY_NONE) { + Verb_Printf(VERB_LESS, "----- Radiosity ----\n"); - if (!config.onlyents && config.noradiosity != RADIOSITY_NONE) { - Verb_Printf(VERB_LESS, "----- Radiosity ----\n"); + CalcTextureReflectivity(); - CalcTextureReflectivity(); + if (config.noradiosity != RADIOSITY_DAY_ONLY) { + /* compile night version */ + start = time(NULL); + RadWorld(); + end = time(NULL); + Verb_Printf(VERB_LESS, "%5.0f seconds elapsed\n", end - start); + } - if (config.noradiosity != RADIOSITY_DAY_ONLY) { - /* compile night version */ - start = time(NULL); - RadWorld(); - end = time(NULL); - Verb_Printf(VERB_LESS, "%5.0f seconds elapsed\n", end - start); - } + if (config.noradiosity != RADIOSITY_NIGHT_ONLY) { + /* compile day version */ + config.compile_for_day = 1; + start = time(NULL); + RadWorld(); + end = time(NULL); + Verb_Printf(VERB_LESS, "%5.0f seconds elapsed\n", end - start); + } - if (config.noradiosity != RADIOSITY_NIGHT_ONLY) { - /* compile day version */ - config.compile_for_day = 1; - start = time(NULL); - RadWorld(); + Verb_Printf(VERB_LESS, "writing %s\n", bspFilename); + size = WriteBSPFile(bspFilename); + } else { + /* build per-vertex normals for phong shading */ + BuildVertexNormals(); + size = WriteBSPFile(bspFilename); end = time(NULL); - Verb_Printf(VERB_LESS, "%5.0f seconds elapsed\n", end - start); } - - Verb_Printf(VERB_LESS, "writing %s\n", bspFilename); - size = WriteBSPFile(bspFilename); - } else { - /* build per-vertex normals for phong shading */ - BuildVertexNormals(); - size = WriteBSPFile(bspFilename); - end = time(NULL); + Verb_Printf(VERB_LESS, "sum: %5.0f seconds elapsed - %.1g MB (%li bytes)\n\n", end - begin, (float)size / (1024.0f * 1024.0f), size); + fileParam++; } - Verb_Printf(VERB_LESS, "sum: %5.0f seconds elapsed - %.1g MB (%li bytes)\n\n", end - begin, (float)size / (1024.0f * 1024.0f), size); - return 0; }