diff --git a/source/core/maploader.cpp b/source/core/maploader.cpp index cd36a0c7e..8df554461 100644 --- a/source/core/maploader.cpp +++ b/source/core/maploader.cpp @@ -375,6 +375,9 @@ static void insertAllSprites(const char* filename, const vec3_t* pos, int16_t* c void engineLoadBoard(const char* filename, int flags, vec3_t* pos, int16_t* ang, int16_t* cursectnum) { inputState.ClearAllInput(); + memset(sector, 0, sizeof(*sector) * MAXSECTORS); + memset(wall, 0, sizeof(*wall) * MAXWALLS); + memset(sprite, 0, sizeof(*sector) * MAXSPRITES); FileReader fr = fileSystem.OpenFileReader(filename); if (!fr.isOpen()) I_Error("Unable to open map %s", filename); diff --git a/source/games/blood/src/blood.cpp b/source/games/blood/src/blood.cpp index 9aea146d5..55399119e 100644 --- a/source/games/blood/src/blood.cpp +++ b/source/games/blood/src/blood.cpp @@ -112,7 +112,6 @@ void StartLevel(MapRecord* level) } } memset(xsprite, 0, sizeof(xsprite)); - memset(sprite, 0, kMaxSprites * sizeof(spritetype)); //drawLoadingScreen(); dbLoadMap(currentLevel->fileName, (int*)&startpos.x, (int*)&startpos.y, (int*)&startpos.z, &startang, &startsectnum, nullptr); SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); diff --git a/source/games/blood/src/db.cpp b/source/games/blood/src/db.cpp index 5df48a6fc..4900a9614 100644 --- a/source/games/blood/src/db.cpp +++ b/source/games/blood/src/db.cpp @@ -512,6 +512,10 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor gModernMap = false; #endif + memset(sector, 0, sizeof(*sector) * MAXSECTORS); + memset(wall, 0, sizeof(*wall) * MAXWALLS); + memset(sprite, 0, sizeof(*sector) * MAXSPRITES); + #ifdef USE_OPENGL Polymost::Polymost_prepare_loadboard(); #endif diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 97c0d65e7..dbe8c2e71 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -924,7 +924,7 @@ static void SpawnPortals() if (findwallbetweensectors(i, t) >= 0) { sector[i].portalflags = PORTAL_SECTOR_FLOOR; - sector[i].portalnum = uint8_t(&pt - allPortals.Data()); + sector[i].portalnum = uint8_t(1 ^ (&pt - allPortals.Data())); pt.targets.Push(i); goto nexti; } @@ -943,7 +943,7 @@ static void SpawnPortals() if (findwallbetweensectors(i, t) >= 0) { sector[i].portalflags = PORTAL_SECTOR_CEILING; - sector[i].portalnum = uint8_t(&pt - allPortals.Data()); + sector[i].portalnum = uint8_t(1 ^ (&pt - allPortals.Data())); pt.targets.Push(i); goto nexti; }