diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/part_buf.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/part_buf.cpp index 6f8e52b0d59..d78f0e67616 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/part_buf.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/part_buf.cpp @@ -270,7 +270,10 @@ ParticleBufferClass::ParticleBufferClass { LineGroup=W3DNEW LineGroupClass(); LineGroup->Set_Flag(LineGroupClass::TRANSFORM, true); - LineGroup->Set_Texture(tex); + // Only set texture if it's not NULL to prevent access violation + if (tex) { + LineGroup->Set_Texture(tex); + } LineGroup->Set_Shader(shader); LineGroup->Set_Line_Mode(LineGroupClass::TETRAHEDRON); TailPosition = NEW_REF( ShareBufferClass , (MaxNum, "ParticleBufferClass::TailPosition" ) ); @@ -283,7 +286,10 @@ ParticleBufferClass::ParticleBufferClass { LineGroup=W3DNEW LineGroupClass(); LineGroup->Set_Flag(LineGroupClass::TRANSFORM, true); - LineGroup->Set_Texture(tex); + // Only set texture if it's not NULL to prevent access violation + if (tex) { + LineGroup->Set_Texture(tex); + } LineGroup->Set_Shader(shader); LineGroup->Set_Line_Mode(LineGroupClass::PRISM); TailPosition = NEW_REF( ShareBufferClass , (MaxNum, "ParticleBufferClass::TailPosition" ) ); @@ -662,7 +668,11 @@ ParticleBufferClass::ParticleBufferClass(const ParticleBufferClass & src) : WWASSERT(src.LineGroup); LineGroup = W3DNEW LineGroupClass(); LineGroup->Set_Flag(LineGroupClass::TRANSFORM, true); - LineGroup->Set_Texture(src.LineGroup->Peek_Texture()); + // Only set texture if it's not NULL to prevent access violation + TextureClass* srcTexture = src.LineGroup->Peek_Texture(); + if (srcTexture) { + LineGroup->Set_Texture(srcTexture); + } LineGroup->Set_Shader(src.LineGroup->Get_Shader()); LineGroup->Set_Line_Mode(LineGroupClass::TETRAHEDRON); TailPosition = NEW_REF( ShareBufferClass , (MaxNum, "ParticleBufferClass::TailPosition") ); @@ -676,7 +686,11 @@ ParticleBufferClass::ParticleBufferClass(const ParticleBufferClass & src) : WWASSERT(src.LineGroup); LineGroup = W3DNEW LineGroupClass(); LineGroup->Set_Flag(LineGroupClass::TRANSFORM, true); - LineGroup->Set_Texture(src.LineGroup->Peek_Texture()); + // Only set texture if it's not NULL to prevent access violation + TextureClass* srcTexture = src.LineGroup->Peek_Texture(); + if (srcTexture) { + LineGroup->Set_Texture(srcTexture); + } LineGroup->Set_Shader(src.LineGroup->Get_Shader()); LineGroup->Set_Line_Mode(LineGroupClass::PRISM); TailPosition = NEW_REF( ShareBufferClass , (MaxNum, "ParticleBufferClass::TailPosition") );