diff --git a/Core/Libraries/Source/WWVegas/WW3D2/htree.cpp b/Core/Libraries/Source/WWVegas/WW3D2/htree.cpp index 3abc52fb0bc..93dc7a35462 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/htree.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/htree.cpp @@ -529,6 +529,11 @@ bool HTreeClass::Simple_Evaluate_Pivot *=============================================================================================*/ void HTreeClass::Base_Update(const Matrix3D & root) { + // Validate Pivot array exists and has at least one element + if (Pivot == NULL || NumPivots <= 0) { + return; + } + PivotClass *pivot; Pivot[0].Transform = root; @@ -538,6 +543,11 @@ void HTreeClass::Base_Update(const Matrix3D & root) pivot = &Pivot[piv_idx]; + // Validate parent pointer before accessing it + if (pivot->Parent == NULL) { + continue; + } + assert(pivot->Parent != NULL); Matrix3D::Multiply(pivot->Parent->Transform, pivot->BaseTransform, &(pivot->Transform)); pivot->IsVisible = 1; diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/animobj.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/animobj.cpp index 4cf15ff8292..3532d3bc922 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/animobj.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/animobj.cpp @@ -766,6 +766,12 @@ void Animatable3DObjClass::Update_Sub_Object_Transforms(void) */ CompositeRenderObjClass::Update_Sub_Object_Transforms(); + // Validate HTree exists before accessing it + if (HTree == NULL) { + Set_Hierarchy_Valid(true); + return; + } + /* ** Update the transforms */ diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hlod.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/hlod.cpp index e78a0f90527..3ba1b56f886 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hlod.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/hlod.cpp @@ -3348,15 +3348,31 @@ void HLodClass::Update_Sub_Object_Transforms(void) */ Animatable3DObjClass::Update_Sub_Object_Transforms(); + // Validate HTree exists before accessing it + if (HTree == NULL) { + Set_Sub_Object_Transforms_Dirty(false); + return; + } + /* ** Put the computed transforms into our sub objects. */ int lod,model; for (lod = 0; lod < LodCount; lod++) { + // Validate LOD array exists + if (Lod == NULL) { + break; + } + for (model = 0; model < Lod[lod].Count(); model++) { RenderObjClass * robj = Lod[lod][model].Model; + // Validate render object pointer before using it + if (robj == NULL) { + continue; + } + int bone = Lod[lod][model].BoneIndex; robj->Set_Transform(HTree->Get_Transform(bone)); @@ -3368,6 +3384,11 @@ void HLodClass::Update_Sub_Object_Transforms(void) for (model = 0; model < AdditionalModels.Count(); model++) { RenderObjClass * robj = AdditionalModels[model].Model; + // Validate render object pointer before using it + if (robj == NULL) { + continue; + } + int bone = AdditionalModels[model].BoneIndex; robj->Set_Transform(HTree->Get_Transform(bone)); diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/animobj.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/animobj.cpp index 15e089a0bab..18244838bc5 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/animobj.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/animobj.cpp @@ -765,6 +765,12 @@ void Animatable3DObjClass::Update_Sub_Object_Transforms(void) */ CompositeRenderObjClass::Update_Sub_Object_Transforms(); + // Validate HTree exists before accessing it + if (HTree == NULL) { + Set_Hierarchy_Valid(true); + return; + } + /* ** Update the transforms */ diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hlod.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hlod.cpp index 261d70a2ff7..20ec6b48824 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hlod.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hlod.cpp @@ -3348,15 +3348,31 @@ void HLodClass::Update_Sub_Object_Transforms(void) */ Animatable3DObjClass::Update_Sub_Object_Transforms(); + // Validate HTree exists before accessing it + if (HTree == NULL) { + Set_Sub_Object_Transforms_Dirty(false); + return; + } + /* ** Put the computed transforms into our sub objects. */ int lod,model; for (lod = 0; lod < LodCount; lod++) { + // Validate LOD array exists + if (Lod == NULL) { + break; + } + for (model = 0; model < Lod[lod].Count(); model++) { RenderObjClass * robj = Lod[lod][model].Model; + // Validate render object pointer before using it + if (robj == NULL) { + continue; + } + int bone = Lod[lod][model].BoneIndex; robj->Set_Transform(HTree->Get_Transform(bone)); @@ -3368,6 +3384,11 @@ void HLodClass::Update_Sub_Object_Transforms(void) for (model = 0; model < AdditionalModels.Count(); model++) { RenderObjClass * robj = AdditionalModels[model].Model; + // Validate render object pointer before using it + if (robj == NULL) { + continue; + } + int bone = AdditionalModels[model].BoneIndex; robj->Set_Transform(HTree->Get_Transform(bone));