Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix misplaced nullptr checks after creating textures in W3DProjectedShadowManager #1103

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/platform/w3dengine/client/shadow/w3dbuffermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ void W3DBufferManager::Release_Slot(W3DVertexBufferSlot *vb_slot)

W3DBufferManager::W3DVertexBufferSlot *W3DBufferManager::Allocate_Slot_Storage(VBM_FVF_TYPES fvf_type, int size)
{
captainslog_dbgassert(m_numEmptyVertexSlotsAllocated < MAX_NUMBER_SLOTS, "Nore more VB Slots");
captainslog_dbgassert(m_numEmptyVertexSlotsAllocated < MAX_NUMBER_SLOTS, "No more VB Slots");

for (W3DVertexBuffer *vb = m_W3DVertexBuffers[fvf_type]; vb != nullptr; vb = vb->m_nextVB) {

Expand Down Expand Up @@ -395,7 +395,7 @@ void W3DBufferManager::Release_Slot(W3DIndexBufferSlot *ib_slot)

W3DBufferManager::W3DIndexBufferSlot *W3DBufferManager::Allocate_Slot_Storage(int size)
{
captainslog_dbgassert(m_numEmptyIndexSlotsAllocated < MAX_NUMBER_SLOTS, "Nore more IB Slots");
captainslog_dbgassert(m_numEmptyIndexSlotsAllocated < MAX_NUMBER_SLOTS, "No more IB Slots");

for (W3DIndexBuffer *ib = m_W3DIndexBuffers; ib != nullptr; ib = ib->m_nextIB) {

Expand Down
47 changes: 23 additions & 24 deletions src/platform/w3dengine/client/shadow/w3dprojectedshadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,14 +1271,14 @@ Shadow *W3DProjectedShadowManager::Add_Decal(Shadow::ShadowTypeInfo *shadow_info

if (!tex) {
TextureClass *t = W3DAssetManager::Get_Instance()->Get_Texture(fname);
captainslog_dbgassert(t != nullptr, "Could not load decal texture: %s", fname);
if (t == nullptr) {
return nullptr;
}

t->Get_Texture_Filter()->Set_U_Address_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP);
t->Get_Texture_Filter()->Set_V_Address_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP);
t->Get_Texture_Filter()->Set_Mip_Mapping(TextureFilterClass::FILTER_TYPE_NONE);
captainslog_dbgassert(t, "Could not load decal texture: %s", fname);

if (!t) {
return nullptr;
}

tex = new W3DShadowTexture();
tex->Set_Name(fname);
Expand Down Expand Up @@ -1364,14 +1364,14 @@ Shadow *W3DProjectedShadowManager::Add_Decal(RenderObjClass *robj, Shadow::Shado

if (!tex) {
TextureClass *t = W3DAssetManager::Get_Instance()->Get_Texture(fname);
captainslog_dbgassert(t != nullptr, "Could not load decal texture: %s", fname);
if (t == nullptr) {
return nullptr;
}

t->Get_Texture_Filter()->Set_U_Address_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP);
t->Get_Texture_Filter()->Set_V_Address_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP);
t->Get_Texture_Filter()->Set_Mip_Mapping(TextureFilterClass::FILTER_TYPE_NONE);
captainslog_dbgassert(t, "Could not load decal texture: %s", fname);

if (!t) {
return nullptr;
}

tex = new W3DShadowTexture();
tex->Set_Name(fname);
Expand Down Expand Up @@ -1492,14 +1492,14 @@ W3DProjectedShadow *W3DProjectedShadowManager::Add_Shadow(

if (!tex) {
TextureClass *t = W3DAssetManager::Get_Instance()->Get_Texture(fname);
captainslog_dbgassert(t != nullptr, "Could not load decal texture: %s", fname);
if (t == nullptr) {
return nullptr;
}

t->Get_Texture_Filter()->Set_U_Address_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP);
t->Get_Texture_Filter()->Set_V_Address_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP);
t->Get_Texture_Filter()->Set_Mip_Mapping(TextureFilterClass::FILTER_TYPE_NONE);
captainslog_dbgassert(t, "Could not load decal texture: %s", fname);

if (!t) {
return nullptr;
}

tex = new W3DShadowTexture();
tex->Set_Name(fname);
Expand Down Expand Up @@ -1527,10 +1527,9 @@ W3DProjectedShadow *W3DProjectedShadowManager::Add_Shadow(
if (!tex) {
m_W3DShadowTextureManager->Create_Texture(robj, fname);
tex = m_W3DShadowTextureManager->Get_Texture(fname);
captainslog_dbgassert(tex, "Could not create shadow texture");

if (!tex) {
return 0;
captainslog_dbgassert(tex != nullptr, "Could not create shadow texture: %s", fname);
if (tex == nullptr) {
return nullptr;
}
}

Expand Down Expand Up @@ -1649,14 +1648,14 @@ W3DProjectedShadow *W3DProjectedShadowManager::Create_Decal_Shadow(Shadow::Shado

if (!tex) {
TextureClass *t = W3DAssetManager::Get_Instance()->Get_Texture(fname);
captainslog_dbgassert(t != nullptr, "Could not load decal texture: %s", fname);
if (t == nullptr) {
return nullptr;
}

t->Get_Texture_Filter()->Set_U_Address_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP);
t->Get_Texture_Filter()->Set_V_Address_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP);
t->Get_Texture_Filter()->Set_Mip_Mapping(TextureFilterClass::FILTER_TYPE_NONE);
captainslog_dbgassert(t, "Could not load decal texture");

if (!t) {
return nullptr;
}

tex = new W3DShadowTexture();
tex->Set_Name(fname);
Expand Down
Loading