qbsp: szBSPName -> bsp_path, szMapName -> map_path
This commit is contained in:
parent
2c32177a69
commit
20a1b7b94b
|
|
@ -222,8 +222,8 @@ public:
|
|||
bool fNoverbose = false;
|
||||
const bspversion_t *target_version;
|
||||
const gamedef_t *target_game;
|
||||
fs::path szMapName;
|
||||
fs::path szBSPName;
|
||||
fs::path map_path;
|
||||
fs::path bsp_path;
|
||||
};
|
||||
}; // namespace settings
|
||||
|
||||
|
|
|
|||
|
|
@ -30,24 +30,24 @@
|
|||
|
||||
static std::ofstream InitObjFile(const std::string &filesuffix)
|
||||
{
|
||||
fs::path name = options.szBSPName;
|
||||
name.replace_filename(options.szBSPName.stem().string() + "_" + filesuffix).replace_extension("obj");
|
||||
fs::path name = options.bsp_path;
|
||||
name.replace_filename(options.bsp_path.stem().string() + "_" + filesuffix).replace_extension("obj");
|
||||
|
||||
std::ofstream objfile(name);
|
||||
if (!objfile)
|
||||
FError("Failed to open {}: {}", options.szBSPName, strerror(errno));
|
||||
FError("Failed to open {}: {}", options.bsp_path, strerror(errno));
|
||||
|
||||
return objfile;
|
||||
}
|
||||
|
||||
static std::ofstream InitMtlFile(const std::string &filesuffix)
|
||||
{
|
||||
fs::path name = options.szBSPName;
|
||||
name.replace_filename(options.szBSPName.stem().string() + "_" + filesuffix).replace_extension("mtl");
|
||||
fs::path name = options.bsp_path;
|
||||
name.replace_filename(options.bsp_path.stem().string() + "_" + filesuffix).replace_extension("mtl");
|
||||
|
||||
std::ofstream file(name);
|
||||
if (!file)
|
||||
FError("Failed to open {}: {}", options.szBSPName, strerror(errno));
|
||||
FError("Failed to open {}: {}", options.bsp_path, strerror(errno));
|
||||
|
||||
return file;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1869,10 +1869,10 @@ void LoadMapFile(void)
|
|||
logging::print(logging::flag::PROGRESS, "---- {} ----\n", __func__);
|
||||
|
||||
{
|
||||
auto file = fs::load(options.szMapName);
|
||||
auto file = fs::load(options.map_path);
|
||||
|
||||
if (!file) {
|
||||
FError("Couldn't load map file \"{}\".\n", options.szMapName);
|
||||
FError("Couldn't load map file \"{}\".\n", options.map_path);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2078,8 +2078,8 @@ void ConvertMapFile(void)
|
|||
default: FError("Internal error: unknown conversion_t\n");
|
||||
}
|
||||
|
||||
fs::path filename = options.szBSPName;
|
||||
filename.replace_filename(options.szBSPName.stem().string() + append);
|
||||
fs::path filename = options.bsp_path;
|
||||
filename.replace_filename(options.bsp_path.stem().string() + append);
|
||||
|
||||
std::ofstream f(filename);
|
||||
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ leakline should be a sequence of portals leading from leakentity to the void
|
|||
*/
|
||||
static void WriteLeakLine(const mapentity_t *leakentity, const std::vector<portal_t *> &leakline)
|
||||
{
|
||||
fs::path name = options.szBSPName;
|
||||
fs::path name = options.bsp_path;
|
||||
name.replace_extension("pts");
|
||||
|
||||
std::ofstream ptsfile(name);
|
||||
|
|
@ -479,7 +479,7 @@ bool FillOutside(mapentity_t *entity, node_t *node, const int hullnum)
|
|||
map.leakfile = true;
|
||||
|
||||
/* Get rid of the .prt file since the map has a leak */
|
||||
fs::path name = options.szBSPName;
|
||||
fs::path name = options.bsp_path;
|
||||
name.replace_extension("prt");
|
||||
remove(name);
|
||||
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ static void WritePortalfile(node_t *headnode, portal_state_t *state)
|
|||
NumberLeafs_r(headnode, state, -1);
|
||||
|
||||
// write the file
|
||||
fs::path name = options.szBSPName;
|
||||
fs::path name = options.bsp_path;
|
||||
name.replace_extension("prt");
|
||||
|
||||
std::ofstream portalFile(name, std::ios_base::binary | std::ios_base::out);
|
||||
|
|
|
|||
34
qbsp/qbsp.cc
34
qbsp/qbsp.cc
|
|
@ -75,10 +75,10 @@ void qbsp_settings::initialize(int argc, const char **argv)
|
|||
printHelp();
|
||||
}
|
||||
|
||||
options.szMapName = remainder[0];
|
||||
options.map_path = remainder[0];
|
||||
|
||||
if (remainder.size() == 2) {
|
||||
options.szBSPName = remainder[1];
|
||||
options.bsp_path = remainder[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -140,9 +140,9 @@ void qbsp_settings::postinitialize(int argc, const char **argv)
|
|||
|
||||
/* If no wadpath given, default to the map directory */
|
||||
if (wadpaths.pathsValue().empty()) {
|
||||
wadpath wp{options.szMapName.parent_path(), false};
|
||||
wadpath wp{options.map_path.parent_path(), false};
|
||||
|
||||
// If options.szMapName is a relative path, StrippedFilename will return the empty string.
|
||||
// If options.map_path is a relative path, StrippedFilename will return the empty string.
|
||||
// In that case, don't add it as a wad path.
|
||||
if (!wp.path.empty()) {
|
||||
wadpaths.addPath(wp);
|
||||
|
|
@ -1025,7 +1025,7 @@ void EnsureTexturesLoaded()
|
|||
logging::print("WARNING: No valid WAD filenames in worldmodel\n");
|
||||
|
||||
/* Try the default wad name */
|
||||
fs::path defaultwad = options.szMapName;
|
||||
fs::path defaultwad = options.map_path;
|
||||
defaultwad.replace_extension("wad");
|
||||
|
||||
WADList_Init(defaultwad.string().c_str());
|
||||
|
|
@ -1090,40 +1090,40 @@ static void InitQBSP(int argc, const char **argv)
|
|||
{
|
||||
options.run(argc, argv);
|
||||
|
||||
options.szMapName.replace_extension("map");
|
||||
options.map_path.replace_extension("map");
|
||||
|
||||
// The .map extension gets removed right away anyways...
|
||||
if (options.szBSPName.empty())
|
||||
options.szBSPName = options.szMapName;
|
||||
if (options.bsp_path.empty())
|
||||
options.bsp_path = options.map_path;
|
||||
|
||||
/* Start logging to <bspname>.log */
|
||||
logging::init(fs::path(options.szBSPName).replace_extension("log"), options);
|
||||
logging::init(fs::path(options.bsp_path).replace_extension("log"), options);
|
||||
|
||||
// Remove already existing files
|
||||
if (!options.onlyents.value() && options.convertmapformat.value() == conversion_t::none) {
|
||||
options.szBSPName.replace_extension("bsp");
|
||||
remove(options.szBSPName);
|
||||
options.bsp_path.replace_extension("bsp");
|
||||
remove(options.bsp_path);
|
||||
|
||||
// Probably not the best place to do this
|
||||
logging::print("Input file: {}\n", options.szMapName);
|
||||
logging::print("Output file: {}\n\n", options.szBSPName);
|
||||
logging::print("Input file: {}\n", options.map_path);
|
||||
logging::print("Output file: {}\n\n", options.bsp_path);
|
||||
|
||||
fs::path prtfile = options.szBSPName;
|
||||
fs::path prtfile = options.bsp_path;
|
||||
prtfile.replace_extension("prt");
|
||||
remove(prtfile);
|
||||
|
||||
fs::path ptsfile = options.szBSPName;
|
||||
fs::path ptsfile = options.bsp_path;
|
||||
ptsfile.replace_extension("pts");
|
||||
remove(ptsfile);
|
||||
|
||||
fs::path porfile = options.szBSPName;
|
||||
fs::path porfile = options.bsp_path;
|
||||
porfile.replace_extension("por");
|
||||
remove(porfile);
|
||||
}
|
||||
|
||||
// onlyents might not load this yet
|
||||
if (options.target_game) {
|
||||
options.target_game->init_filesystem(options.szMapName, options);
|
||||
options.target_game->init_filesystem(options.map_path, options);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ static mbsp_t LoadTestmap(const std::filesystem::path &name)
|
|||
options.nopercent.setValue(true);
|
||||
options.noprogress.setValue(true);
|
||||
|
||||
options.szMapName = std::filesystem::path(testmaps_dir) / name;
|
||||
options.szBSPName = options.szMapName;
|
||||
options.szBSPName.replace_extension(".bsp");
|
||||
options.map_path = std::filesystem::path(testmaps_dir) / name;
|
||||
options.bsp_path = options.map_path;
|
||||
options.bsp_path.replace_extension(".bsp");
|
||||
|
||||
options.target_version = &bspver_q1;
|
||||
options.target_game = options.target_version->game;
|
||||
|
|
@ -55,17 +55,17 @@ static mbsp_t LoadTestmap(const std::filesystem::path &name)
|
|||
if (strlen(test_quake_maps_dir) > 0) {
|
||||
auto dest = fs::path(test_quake_maps_dir) / name;
|
||||
dest.replace_extension(".bsp");
|
||||
fs::copy(options.szBSPName, dest, fs::copy_options::overwrite_existing);
|
||||
fs::copy(options.bsp_path, dest, fs::copy_options::overwrite_existing);
|
||||
}
|
||||
|
||||
// re-open the .bsp and return it
|
||||
|
||||
options.szBSPName.replace_extension("bsp");
|
||||
options.bsp_path.replace_extension("bsp");
|
||||
|
||||
bspdata_t bspdata;
|
||||
LoadBSPFile(options.szBSPName, &bspdata);
|
||||
LoadBSPFile(options.bsp_path, &bspdata);
|
||||
|
||||
bspdata.version->game->init_filesystem(options.szBSPName, options);
|
||||
bspdata.version->game->init_filesystem(options.bsp_path, options);
|
||||
|
||||
ConvertBSPFormat(&bspdata, &bspver_generic);
|
||||
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ void BeginBSPFile(void)
|
|||
*/
|
||||
static void WriteExtendedTexinfoFlags(void)
|
||||
{
|
||||
auto file = fs::path(options.szBSPName).replace_extension("texinfo.json");
|
||||
auto file = fs::path(options.bsp_path).replace_extension("texinfo.json");
|
||||
bool needwrite = false;
|
||||
|
||||
if (fs::exists(file)) {
|
||||
|
|
@ -427,10 +427,10 @@ static void WriteBSPFile()
|
|||
Q_assert(ConvertBSPFormat(&bspdata, extendedLimitsFormat));
|
||||
}
|
||||
|
||||
options.szBSPName.replace_extension("bsp");
|
||||
options.bsp_path.replace_extension("bsp");
|
||||
|
||||
WriteBSPFile(options.szBSPName, &bspdata);
|
||||
logging::print("Wrote {}\n", options.szBSPName);
|
||||
WriteBSPFile(options.bsp_path, &bspdata);
|
||||
logging::print("Wrote {}\n", options.bsp_path);
|
||||
|
||||
PrintBSPFileSizes(&bspdata);
|
||||
}
|
||||
|
|
@ -466,12 +466,12 @@ void UpdateBSPFileEntitiesLump()
|
|||
{
|
||||
bspdata_t bspdata;
|
||||
|
||||
options.szBSPName.replace_extension("bsp");
|
||||
options.bsp_path.replace_extension("bsp");
|
||||
|
||||
// load the .bsp
|
||||
LoadBSPFile(options.szBSPName, &bspdata);
|
||||
LoadBSPFile(options.bsp_path, &bspdata);
|
||||
|
||||
bspdata.version->game->init_filesystem(options.szBSPName, options);
|
||||
bspdata.version->game->init_filesystem(options.bsp_path, options);
|
||||
|
||||
ConvertBSPFormat(&bspdata, &bspver_generic);
|
||||
|
||||
|
|
@ -482,7 +482,7 @@ void UpdateBSPFileEntitiesLump()
|
|||
|
||||
// write the .bsp back to disk
|
||||
ConvertBSPFormat(&bspdata, bspdata.loadversion);
|
||||
WriteBSPFile(options.szBSPName, &bspdata);
|
||||
WriteBSPFile(options.bsp_path, &bspdata);
|
||||
|
||||
logging::print("Wrote {}\n", options.szBSPName);
|
||||
logging::print("Wrote {}\n", options.bsp_path);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue