Fix `face_get_contents` not handling hintskip properly

Simplify `Brush_GetContents` and use the first non-skip face as the base contents
Move period out of `LoadExternalMap` error message so it doesn't confuse the reader
Fix `WriteEntitiesToString` crashing on entities without any brushes (note: need a column/line on mapentity in future)
This commit is contained in:
Jonathan 2022-01-23 23:18:59 -05:00
parent e92b9f1ff9
commit be865bc5b8
4 changed files with 13 additions and 13 deletions

View File

@ -271,7 +271,7 @@ struct gamedef_q1_like_t : public gamedef_t
// check for strong content indicators
if (!Q_strcasecmp(texname.data(), "origin")) {
return create_extended_contents(CFLAGS_ORIGIN);
} else if (!Q_strcasecmp(texname.data(), "hint")) {
} else if (!Q_strcasecmp(texname.data(), "hint") || !Q_strcasecmp(texname.data(), "hintskip")) {
return create_extended_contents(CFLAGS_HINT);
} else if (!Q_strcasecmp(texname.data(), "clip")) {
return create_extended_contents(CFLAGS_CLIP);

View File

@ -264,7 +264,7 @@ struct surface_t
bounds += f->w.bounds();
Q_assert(!qv::emptyExact(bounds.size()));
//Q_assert(!qv::emptyExact(bounds.size()));
}
}
};

View File

@ -675,14 +675,8 @@ static void ExpandBrush(hullbrush_t *hullbrush, const aabb3d &hull_size, std::ve
static contentflags_t Brush_GetContents(const mapbrush_t *mapbrush)
{
// use the first side as the base contents value
contentflags_t base_contents;
{
const mapface_t &mapface = mapbrush->face(0);
const mtexinfo_t &texinfo = map.mtexinfos.at(mapface.texinfo);
base_contents = options.target_game->face_get_contents(mapface.texname.data(), texinfo.flags, mapface.contents);
}
bool base_contents_set = false;
contentflags_t base_contents = options.target_game->create_empty_contents();
// validate that all of the sides have valid contents
for (int i = 0; i < mapbrush->numfaces; i++) {
@ -694,6 +688,12 @@ static contentflags_t Brush_GetContents(const mapbrush_t *mapbrush)
}
contentflags_t contents = options.target_game->face_get_contents(mapface.texname.data(), texinfo.flags, mapface.contents);
// use the first non-skip as the base contents value
if (!base_contents_set) {
base_contents_set = true;
base_contents = contents;
}
if (!contents.types_equal(base_contents, options.target_game)) {
LogPrint("mixed face contents ({} != {}) at line {}\n",

View File

@ -1827,7 +1827,7 @@ mapentity_t LoadExternalMap(const char *filename)
auto file = fs::load(filename);
if (!file) {
FError("Couldn't load external map file \"{}.\"\n", filename);
FError("Couldn't load external map file \"{}\".\n", filename);
}
parser_t parser(file->data(), file->size());
@ -2147,11 +2147,11 @@ void WriteEntitiesToString()
for (auto &ep : entity.epairs) {
if (ep.first.size() >= options.target_game->max_entity_key - 1) {
LogPrint("WARNING: {} at {} (approx. line {}) has long key {} (length {} >= {})\n", ValueForKey(&entity, "classname"), entity.origin, entity.mapbrush(0).face(0).linenum, ep.first, ep.first.size(), options.target_game->max_entity_key - 1);
LogPrint("WARNING: {} at {} has long key {} (length {} >= {})\n", ValueForKey(&entity, "classname"), entity.origin, ep.first, ep.first.size(), options.target_game->max_entity_key - 1);
}
if (ep.second.size() >= options.target_game->max_entity_value - 1) {
LogPrint("WARNING: {} at {} (approx. line {}) has long value for key {} (length {} >= {})\n", ValueForKey(&entity, "classname"), entity.origin, entity.mapbrush(0).face(0).linenum, ep.first, ep.second.size(), options.target_game->max_entity_value - 1);
LogPrint("WARNING: {} at {} has long value for key {} (length {} >= {})\n", ValueForKey(&entity, "classname"), entity.origin, ep.first, ep.second.size(), options.target_game->max_entity_value - 1);
}
fmt::format_to(std::back_inserter(map.bsp.dentdata), "\"{}\" \"{}\"\n", ep.first, ep.second);