From 5a52f61096cf28e9e0da759be49fd9707921d64c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 20 Oct 2022 20:23:35 +0200 Subject: [PATCH] - fixed: R_LoadVoxelDef did not fully initialize the voxel descriptor it creates. --- src/common/models/voxels.cpp | 1 + src/r_data/models.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/models/voxels.cpp b/src/common/models/voxels.cpp index b85f2f851..d8d2b2245 100644 --- a/src/common/models/voxels.cpp +++ b/src/common/models/voxels.cpp @@ -314,6 +314,7 @@ FVoxelDef *R_LoadVoxelDef(int lumpnum, int spin) else { FVoxelDef *voxdef = new FVoxelDef; + *voxdef = {}; voxdef->Voxel = vox; voxdef->Scale = 1.; voxdef->DroppedSpin = voxdef->PlacedSpin = spin; diff --git a/src/r_data/models.cpp b/src/r_data/models.cpp index 9c204df04..453d67180 100644 --- a/src/r_data/models.cpp +++ b/src/r_data/models.cpp @@ -425,9 +425,11 @@ void InitModels() smf.animationIDs[0] = -1; smf.xscale = smf.yscale = smf.zscale = VoxelDefs[i]->Scale; smf.angleoffset = VoxelDefs[i]->AngleOffset.Degrees(); - if (VoxelDefs[i]->PitchFromMomentum == true) smf.flags |= MDL_PITCHFROMMOMENTUM; - if (VoxelDefs[i]->UseActorPitch == true) smf.flags |= MDL_USEACTORPITCH; - if (VoxelDefs[i]->UseActorRoll == true) smf.flags |= MDL_USEACTORROLL; + // this helps catching uninitialized data. + assert(VoxelDefs[i]->PitchFromMomentum == true || VoxelDefs[i]->PitchFromMomentum == false); + if (VoxelDefs[i]->PitchFromMomentum) smf.flags |= MDL_PITCHFROMMOMENTUM; + if (VoxelDefs[i]->UseActorPitch) smf.flags |= MDL_USEACTORPITCH; + if (VoxelDefs[i]->UseActorRoll) smf.flags |= MDL_USEACTORROLL; if (VoxelDefs[i]->PlacedSpin != 0) { smf.yrotate = 1.f;