Fix various warnings by testing a clang-cl compile

This commit is contained in:
Jonathan 2021-10-12 14:39:15 -04:00
parent c6393abdd9
commit fd18fc154c
14 changed files with 40 additions and 48 deletions

View File

@ -850,15 +850,15 @@ bool ConvertBSPFormat(bspdata_t *bspdata, const bspversion_t *to_version)
try { try {
if (to_version == &bspver_q1 || to_version == &bspver_h2 || to_version == &bspver_hl) { if (to_version == &bspver_q1 || to_version == &bspver_h2 || to_version == &bspver_hl) {
bspdata->bsp = std::move(ConvertGenericToQ1BSP<bsp29_t>(mbsp, to_version)); bspdata->bsp = ConvertGenericToQ1BSP<bsp29_t>(mbsp, to_version);
} else if (to_version == &bspver_q2) { } else if (to_version == &bspver_q2) {
bspdata->bsp = std::move(ConvertGenericToQ2BSP<q2bsp_t>(mbsp, to_version)); bspdata->bsp = ConvertGenericToQ2BSP<q2bsp_t>(mbsp, to_version);
} else if (to_version == &bspver_qbism) { } else if (to_version == &bspver_qbism) {
bspdata->bsp = std::move(ConvertGenericToQ2BSP<q2bsp_qbism_t>(mbsp, to_version)); bspdata->bsp = ConvertGenericToQ2BSP<q2bsp_qbism_t>(mbsp, to_version);
} else if (to_version == &bspver_bsp2rmq || to_version == &bspver_h2bsp2rmq) { } else if (to_version == &bspver_bsp2rmq || to_version == &bspver_h2bsp2rmq) {
bspdata->bsp = std::move(ConvertGenericToQ1BSP<bsp2rmq_t>(mbsp, to_version)); bspdata->bsp = ConvertGenericToQ1BSP<bsp2rmq_t>(mbsp, to_version);
} else if (to_version == &bspver_bsp2 || to_version == &bspver_h2bsp2) { } else if (to_version == &bspver_bsp2 || to_version == &bspver_h2bsp2) {
bspdata->bsp = std::move(ConvertGenericToQ1BSP<bsp2_t>(mbsp, to_version)); bspdata->bsp = ConvertGenericToQ1BSP<bsp2_t>(mbsp, to_version);
} else { } else {
return false; return false;
} }
@ -1273,12 +1273,12 @@ public:
write_lump(LUMP_MARKSURFACES, bsp.dmarksurfaces); write_lump(LUMP_MARKSURFACES, bsp.dmarksurfaces);
write_lump(LUMP_SURFEDGES, bsp.dsurfedges); write_lump(LUMP_SURFEDGES, bsp.dsurfedges);
write_lump(LUMP_EDGES, bsp.dedges); write_lump(LUMP_EDGES, bsp.dedges);
std::visit([this](auto&& arg) { write_lump(LUMP_MODELS, arg); }, bsp.dmodels); std::visit([this](auto&& arg) { this->write_lump(LUMP_MODELS, arg); }, bsp.dmodels);
write_lump(LUMP_LIGHTING, bsp.dlightdata); write_lump(LUMP_LIGHTING, bsp.dlightdata);
write_lump(LUMP_VISIBILITY, bsp.dvisdata); write_lump(LUMP_VISIBILITY, bsp.dvisdata);
write_lump(LUMP_ENTITIES, bsp.dentdata); write_lump(LUMP_ENTITIES, bsp.dentdata);
std::visit([this](auto&& arg) { write_lump(LUMP_TEXTURES, arg); }, bsp.dtex); std::visit([this](auto&& arg) { this->write_lump(LUMP_TEXTURES, arg); }, bsp.dtex);
} }
template<typename T, typename std::enable_if_t<std::is_base_of_v<q2bsp_tag_t, T>, int> = 0> template<typename T, typename std::enable_if_t<std::is_base_of_v<q2bsp_tag_t, T>, int> = 0>
@ -1318,7 +1318,7 @@ public:
auto bspxheader = stream.tellp(); auto bspxheader = stream.tellp();
// write dummy lump headers // write dummy lump headers
for (auto &x : bspdata.bspx.entries) { for ([[maybe_unused]] auto &_ : bspdata.bspx.entries) {
stream <= bspx_lump_t{}; stream <= bspx_lump_t{};
} }

View File

@ -39,8 +39,6 @@
#include <string> #include <string>
constexpr char PATHSEPERATOR = '/';
/* set these before calling CheckParm */ /* set these before calling CheckParm */
int myargc; int myargc;
char **myargv; char **myargv;

View File

@ -272,6 +272,11 @@ struct miptex_t
std::string name; std::string name;
uint32_t width, height; uint32_t width, height;
std::array<std::unique_ptr<uint8_t[]>, MIPLEVELS> data; std::array<std::unique_ptr<uint8_t[]>, MIPLEVELS> data;
miptex_t() = default;
miptex_t(miptex_t &&) = default;
virtual ~miptex_t() { }
virtual void stream_read(std::istream &stream) virtual void stream_read(std::istream &stream)
{ {
@ -827,8 +832,8 @@ struct texvec : qmat<T, 2, 4>
template<typename T2> template<typename T2>
constexpr qvec<T2, 2> uvs(const qvec<T2, 3> &pos) const constexpr qvec<T2, 2> uvs(const qvec<T2, 3> &pos) const
{ {
return {(pos[0] * at(0, 0) + pos[1] * at(0, 1) + pos[2] * at(0, 2) + at(0, 3)), return {(pos[0] * this->at(0, 0) + pos[1] * this->at(0, 1) + pos[2] * this->at(0, 2) + this->at(0, 3)),
(pos[0] * at(1, 0) + pos[1] * at(1, 1) + pos[2] * at(1, 2) + at(1, 3))}; (pos[0] * this->at(1, 0) + pos[1] * this->at(1, 1) + pos[2] * this->at(1, 2) + this->at(1, 3))};
} }
template<typename T2> template<typename T2>
@ -844,7 +849,7 @@ struct texvec : qmat<T, 2, 4>
{ {
for (size_t i = 0; i < 2; i++) for (size_t i = 0; i < 2; i++)
for (size_t x = 0; x < 4; x++) { for (size_t x = 0; x < 4; x++) {
stream >= at(i, x); stream >= this->at(i, x);
} }
} }
@ -852,7 +857,7 @@ struct texvec : qmat<T, 2, 4>
{ {
for (size_t i = 0; i < 2; i++) for (size_t i = 0; i < 2; i++)
for (size_t x = 0; x < 4; x++) { for (size_t x = 0; x < 4; x++) {
stream <= at(i, x); stream <= this->at(i, x);
} }
} }
}; };

View File

@ -124,7 +124,7 @@ public:
class lockable_bool_t : public lockable_setting_t class lockable_bool_t : public lockable_setting_t
{ {
private: private:
bool _default, _value; [[maybe_unused]] bool _default, _value;
void setBoolValueInternal(bool f, setting_source_t newsource) void setBoolValueInternal(bool f, setting_source_t newsource)
{ {
@ -161,7 +161,7 @@ public:
class lockable_vec_t : public lockable_setting_t class lockable_vec_t : public lockable_setting_t
{ {
private: private:
vec_t _default, _value, _min, _max; [[maybe_unused]] vec_t _default, _value, _min, _max;
inline void setFloatInternal(vec_t f, setting_source_t newsource) inline void setFloatInternal(vec_t f, setting_source_t newsource)
{ {

View File

@ -60,10 +60,10 @@ struct winding_t : polylib::winding_base_t<MAX_WINDING_FIXED>
using winding_base_t::winding_base_t; using winding_base_t::winding_base_t;
// copy constructor // copy constructor
winding_t(const winding_t &copy) : origin(copy.origin), radius(copy.radius), winding_base_t(copy) { } winding_t(const winding_t &copy) : winding_base_t(copy), origin(copy.origin), radius(copy.radius) { }
// move constructor // move constructor
winding_t(winding_t &&move) : origin(move.origin), radius(move.radius), winding_base_t(move) { } winding_t(winding_t &&move) : winding_base_t(move), origin(move.origin), radius(move.radius) { }
// assignment copy // assignment copy
inline winding_t &operator=(const winding_t &copy) inline winding_t &operator=(const winding_t &copy)

View File

@ -521,19 +521,6 @@ static void LoadExtendedTexinfoFlags(const std::filesystem::path &sourcefilename
// obj // obj
static qfile_t InitObjFile(const std::filesystem::path &filename)
{
std::filesystem::path objfilename(filename);
objfilename.replace_extension("obj");
qfile_t objfile = SafeOpenWrite(objfilename);
if (!objfile)
FError("Failed to open {}: {}", objfilename, strerror(errno));
return objfile;
}
static void ExportObjFace(std::ofstream &f, const mbsp_t *bsp, const mface_t *face, int *vertcount) static void ExportObjFace(std::ofstream &f, const mbsp_t *bsp, const mface_t *face, int *vertcount)
{ {
// export the vertices and uvs // export the vertices and uvs
@ -697,6 +684,7 @@ static void CheckLitNeeded(const globalconfig_t &cfg)
} }
} }
#if 0
static void PrintLight(const light_t &light) static void PrintLight(const light_t &light)
{ {
bool first = true; bool first = true;
@ -726,6 +714,7 @@ static void PrintLights(void)
PrintLight(light); PrintLight(light);
} }
} }
#endif
static void PrintUsage() static void PrintUsage()
{ {
@ -846,6 +835,7 @@ static bool ParseIntOptional(int *result, int *i_inout, int argc, const char **a
} }
} }
#if 0
static const char *ParseStringOptional(int *i_inout, int argc, const char **argv) static const char *ParseStringOptional(int *i_inout, int argc, const char **argv)
{ {
if ((*i_inout + 1) < argc) { if ((*i_inout + 1) < argc) {
@ -854,6 +844,7 @@ static const char *ParseStringOptional(int *i_inout, int argc, const char **argv
return NULL; return NULL;
} }
} }
#endif
static void ParseVec3(vec3_t vec3_out, int *i_inout, int argc, const char **argv) static void ParseVec3(vec3_t vec3_out, int *i_inout, int argc, const char **argv)
{ {
@ -887,6 +878,7 @@ static int ParseInt(int *i_inout, int argc, const char **argv)
return result; return result;
} }
#if 0
static const char *ParseString(int *i_inout, int argc, const char **argv) static const char *ParseString(int *i_inout, int argc, const char **argv)
{ {
const char *result = NULL; const char *result = NULL;
@ -895,6 +887,7 @@ static const char *ParseString(int *i_inout, int argc, const char **argv)
} }
return result; return result;
} }
#endif
static inline void WriteNormals(const mbsp_t &bsp, bspdata_t &bspdata) static inline void WriteNormals(const mbsp_t &bsp, bspdata_t &bspdata)
{ {

View File

@ -818,6 +818,7 @@ static void Lightmap_AllocOrClear(lightmap_t *lightmap, const lightsurf_t *light
} }
} }
#if 0
static const lightmap_t *Lightmap_ForStyle_ReadOnly(const lightsurf_t *lightsurf, const int style) static const lightmap_t *Lightmap_ForStyle_ReadOnly(const lightsurf_t *lightsurf, const int style)
{ {
for (const auto &lm : lightsurf->lightmapsByStyle) { for (const auto &lm : lightsurf->lightmapsByStyle) {
@ -826,6 +827,7 @@ static const lightmap_t *Lightmap_ForStyle_ReadOnly(const lightsurf_t *lightsurf
} }
return nullptr; return nullptr;
} }
#endif
/* /*
* Lightmap_ForStyle * Lightmap_ForStyle
@ -2278,8 +2280,6 @@ static void LightFace_DebugNeighbours(lightsurf_t *lightsurf, lightmapdict_t *li
/* use a style 0 light map */ /* use a style 0 light map */
lightmap_t *lightmap = Lightmap_ForStyle(lightmaps, 0, lightsurf); lightmap_t *lightmap = Lightmap_ForStyle(lightmaps, 0, lightsurf);
const int fnum = Face_GetNum(lightsurf->bsp, lightsurf->face);
// std::vector<neighbour_t> neighbours = NeighbouringFaces_new(lightsurf->bsp, BSP_GetFace(lightsurf->bsp, // std::vector<neighbour_t> neighbours = NeighbouringFaces_new(lightsurf->bsp, BSP_GetFace(lightsurf->bsp,
// dump_facenum)); bool found = false; for (auto &f : neighbours) { // dump_facenum)); bool found = false; for (auto &f : neighbours) {
// if (f.face == lightsurf->face) // if (f.face == lightsurf->face)
@ -2611,6 +2611,7 @@ static float Lightmap_MaxBrightness(const lightmap_t *lm, const lightsurf_t *lig
return maxb; return maxb;
} }
#if 0
static void WritePPM(const std::filesystem::path &fname, int width, int height, const uint8_t *rgbdata) static void WritePPM(const std::filesystem::path &fname, int width, int height, const uint8_t *rgbdata)
{ {
qfile_t file = SafeOpenWrite(fname); qfile_t file = SafeOpenWrite(fname);
@ -2675,6 +2676,7 @@ static void DumpDownscaledLightmap(const mbsp_t *bsp, const mface_t *face, int w
WritePPM(fmt::format("face-small{:04}.ppm", fnum), w, h, rgbdata.data()); WritePPM(fmt::format("face-small{:04}.ppm", fnum), w, h, rgbdata.data());
} }
#endif
static std::vector<qvec4f> LightmapColorsToGLMVector(const lightsurf_t *lightsurf, const lightmap_t *lm) static std::vector<qvec4f> LightmapColorsToGLMVector(const lightsurf_t *lightsurf, const lightmap_t *lm)
{ {
@ -2698,6 +2700,7 @@ static std::vector<qvec4f> LightmapNormalsToGLMVector(const lightsurf_t *lightsu
return res; return res;
} }
#if 0
static std::vector<qvec4f> LightmapToGLMVector(const mbsp_t *bsp, const lightsurf_t *lightsurf) static std::vector<qvec4f> LightmapToGLMVector(const mbsp_t *bsp, const lightsurf_t *lightsurf)
{ {
const lightmap_t *lm = Lightmap_ForStyle_ReadOnly(lightsurf, 0); const lightmap_t *lm = Lightmap_ForStyle_ReadOnly(lightsurf, 0);
@ -2706,6 +2709,7 @@ static std::vector<qvec4f> LightmapToGLMVector(const mbsp_t *bsp, const lightsur
} }
return std::vector<qvec4f>(); return std::vector<qvec4f>();
} }
#endif
static qvec3f LinearToGamma22(const qvec3f &c) static qvec3f LinearToGamma22(const qvec3f &c)
{ {

View File

@ -614,13 +614,13 @@ void CalculateVertexNormals(const mbsp_t *bsp)
// normalize vertex normals (NOTE: updates smoothedNormals map) // normalize vertex normals (NOTE: updates smoothedNormals map)
for (auto &pair : smoothedNormals) { for (auto &pair : smoothedNormals) {
const int vertIndex = pair.first;
face_normal_t &vertNormal = pair.second; face_normal_t &vertNormal = pair.second;
if (0 == qv::length(vertNormal.normal)) { if (0 == qv::length(vertNormal.normal)) {
// this happens when there are colinear vertices, which give zero-area triangles, // this happens when there are colinear vertices, which give zero-area triangles,
// so there is no contribution to the normal of the triangle in the middle of the // so there is no contribution to the normal of the triangle in the middle of the
// line. Not really an error, just set it to use the face normal. // line. Not really an error, just set it to use the face normal.
#if 0 #if 0
const int vertIndex = pair.first;
LogPrint("Failed to calculate normal for vertex {} at ({} {} {})\n", LogPrint("Failed to calculate normal for vertex {} at ({} {} {})\n",
vertIndex, vertIndex,
bsp->dvertexes[vertIndex].point[0], bsp->dvertexes[vertIndex].point[0],

View File

@ -290,7 +290,6 @@ template<filtertype_t filtertype>
static void Embree_FilterFuncN(const struct RTCFilterFunctionNArguments *args) static void Embree_FilterFuncN(const struct RTCFilterFunctionNArguments *args)
{ {
int *const valid = args->valid; int *const valid = args->valid;
void *const userDataPtr = args->geometryUserPtr;
RTCIntersectContext *const context = args->context; RTCIntersectContext *const context = args->context;
struct RTCRayN *const ray = args->ray; struct RTCRayN *const ray = args->ray;
struct RTCHitN *const potentialHit = args->hit; struct RTCHitN *const potentialHit = args->hit;

View File

@ -1445,6 +1445,8 @@ static void ParseTextureDef(parser_t &parser, mapface_t &mapface, const mapbrush
tx_type = TX_QUAKED; tx_type = TX_QUAKED;
} }
} }
} else {
FError("Bad brush format");
} }
// If we're not Q2 but we're loading a Q2 map, just remove the extra // If we're not Q2 but we're loading a Q2 map, just remove the extra
@ -1455,7 +1457,6 @@ static void ParseTextureDef(parser_t &parser, mapface_t &mapface, const mapbrush
tx->miptex = FindMiptex(mapface.texname.c_str(), extinfo.info); tx->miptex = FindMiptex(mapface.texname.c_str(), extinfo.info);
const auto &miptex = map.miptex[tx->miptex];
mapface.contents = extinfo.info->contents; mapface.contents = extinfo.info->contents;
tx->flags = mapface.flags = {extinfo.info->flags}; tx->flags = mapface.flags = {extinfo.info->flags};
tx->value = mapface.value = extinfo.info->value; tx->value = mapface.value = extinfo.info->value;

View File

@ -298,6 +298,7 @@ FLOOD AREAS
========================================================= =========================================================
*/ */
#if 0
int32_t c_areas; int32_t c_areas;
/* /*
@ -491,6 +492,7 @@ static void EmitAreaPortals(node_t *headnode)
LogPrint(LOG_STAT, "{:5} numareas\n", map.bsp.dareas.size()); LogPrint(LOG_STAT, "{:5} numareas\n", map.bsp.dareas.size());
LogPrint(LOG_STAT, "{:5} numareaportals\n", map.bsp.dareaportals.size()); LogPrint(LOG_STAT, "{:5} numareaportals\n", map.bsp.dareaportals.size());
} }
#endif
winding_t BaseWindingForPlane(const qbsp_plane_t *p) winding_t BaseWindingForPlane(const qbsp_plane_t *p)
{ {

View File

@ -285,7 +285,7 @@ inline size_t GetEdge(mapentity_t *entity, const qvec3d &p1, const qvec3d &p2, c
/* emit an edge */ /* emit an edge */
size_t i = map.bsp.dedges.size(); size_t i = map.bsp.dedges.size();
auto &edge = map.bsp.dedges.emplace_back(bsp2_dedge_t{static_cast<uint32_t>(v1), static_cast<uint32_t>(v2)}); map.bsp.dedges.emplace_back(bsp2_dedge_t{static_cast<uint32_t>(v1), static_cast<uint32_t>(v2)});
AddHashEdge(v1, v2, i); AddHashEdge(v1, v2, i);

View File

@ -365,16 +365,6 @@ static void CopyVector(const std::vector<C> &vec, int *elementCountOut, C **arra
*arrayCopyOut = (C *)data; *arrayCopyOut = (C *)data;
} }
static void CopyString(const std::string &string, bool addNullTermination, int *elementCountOut, void **arrayCopyOut)
{
const size_t numBytes = addNullTermination ? string.size() + 1 : string.size();
void *data = new uint8_t[numBytes];
memcpy(data, string.data(), numBytes); // std::string::data() has null termination, so it's safe to copy it
*elementCountOut = numBytes;
*arrayCopyOut = data;
}
/* /*
============= =============
WriteBSPFile WriteBSPFile

View File

@ -192,7 +192,7 @@ void CalcPHS(mbsp_t *bsp)
const long *src = (long *)uncompressed_2; const long *src = (long *)uncompressed_2;
long *dest = (long *)uncompressed; long *dest = (long *)uncompressed;
for (int32_t l = 0; l < leaflongs; l++) for (int32_t l = 0; l < leaflongs; l++)
((long *)uncompressed)[l] |= src[l]; dest[l] |= src[l];
} }
} }
for (int32_t j = 0; j < portalleafs; j++) for (int32_t j = 0; j < portalleafs; j++)