From cffe67dceed7f9d7132ef28d4350b218d29d0d42 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 26 Mar 2023 10:35:33 +0200 Subject: [PATCH] - fixed a few warnings pointed out by GCC. --- src/maploader/renderinfo.cpp | 2 +- src/maploader/specials.cpp | 4 ++-- src/p_setup.cpp | 4 ++-- src/playsim/p_map.cpp | 4 ++-- src/playsim/portal.h | 14 ++++++++++++-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/maploader/renderinfo.cpp b/src/maploader/renderinfo.cpp index 7a25d1335f7..533526237fb 100644 --- a/src/maploader/renderinfo.cpp +++ b/src/maploader/renderinfo.cpp @@ -828,7 +828,7 @@ void MapLoader::FixHoles() segloops.Reserve(1); auto *segloop = &segloops.Last(); - seg_t *startseg; + seg_t *startseg = nullptr; seg_t *checkseg; while (bogussegs.Size() > 0) { diff --git a/src/maploader/specials.cpp b/src/maploader/specials.cpp index 369f1377ccc..ce921fd0700 100644 --- a/src/maploader/specials.cpp +++ b/src/maploader/specials.cpp @@ -166,7 +166,7 @@ void MapLoader::SpawnLinePortal(line_t* line) line->portalindex = Level->linePortals.Reserve(1); FLinePortal *port = &Level->linePortals.Last(); - memset(port, 0, sizeof(FLinePortal)); + port->Clear(); port->mOrigin = line; port->mDestination = &ln; port->mType = PORTT_LINKED; @@ -177,7 +177,7 @@ void MapLoader::SpawnLinePortal(line_t* line) ln.portalindex = Level->linePortals.Reserve(1); port = &Level->linePortals.Last(); - memset(port, 0, sizeof(FLinePortal)); + port->Clear(); port->mOrigin = &ln; port->mDestination = line; port->mType = PORTT_LINKED; diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 4491b80c828..569f79919f0 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -245,11 +245,11 @@ void FLevelLocals::ClearPortals() PortalBlockmap.Clear(); // The first entry must always be the default skybox. This is what every sector gets by default. - memset(§orPortals[0], 0, sizeof(sectorPortals[0])); + sectorPortals[0].Clear(); sectorPortals[0].mType = PORTS_SKYVIEWPOINT; sectorPortals[0].mFlags = PORTSF_SKYFLATONLY; // The second entry will be the default sky. This is for forcing a regular sky through the skybox picker - memset(§orPortals[1], 0, sizeof(sectorPortals[0])); + sectorPortals[1].Clear(); sectorPortals[1].mType = PORTS_SKYVIEWPOINT; sectorPortals[1].mFlags = PORTSF_SKYFLATONLY; diff --git a/src/playsim/p_map.cpp b/src/playsim/p_map.cpp index 589376fea77..0ec9b686394 100644 --- a/src/playsim/p_map.cpp +++ b/src/playsim/p_map.cpp @@ -2510,8 +2510,8 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, while (true) { double bestfrac = 1.1; - spechit_t besthit; - int besthitnum; + spechit_t besthit{}; + int besthitnum = -1; // find the portal nearest to the crossing actor for (unsigned i = 0; i < portalhit.Size();i++) { diff --git a/src/playsim/portal.h b/src/playsim/portal.h index ca5e98427c0..74413fb2a34 100644 --- a/src/playsim/portal.h +++ b/src/playsim/portal.h @@ -197,7 +197,12 @@ struct FLinePortal FLinePortal() { - memset(this, 0, sizeof *this); + Clear(); + } + + void Clear() + { + memset((void*)this, 0, sizeof * this); } }; @@ -246,7 +251,12 @@ struct FSectorPortal FSectorPortal() { - memset(this, 0, sizeof * this); + Clear(); + } + + void Clear() + { + memset((void*)this, 0, sizeof * this); } bool MergeAllowed() const