mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 18:18:18 +00:00
Merge #6816
6816: Fix editor crash when filling entities layer with empty brush r=def- a=Robyt3 The brush passed to `FillSelection` can be `nullptr` when the selection is empty. Regression from #6648. Closes #6815. ## Checklist - [X] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [X] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
commit
83a2ad0e24
|
@ -1294,7 +1294,7 @@ void CLayerTele::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
||||||
if(!Destructive && GetTile(fx, fy).m_Index)
|
if(!Destructive && GetTile(fx, fy).m_Index)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const int SrcIndex = (y * pLt->m_Width + x % pLt->m_Width) % (pLt->m_Width * pLt->m_Height);
|
const int SrcIndex = Empty ? 0 : (y * pLt->m_Width + x % pLt->m_Width) % (pLt->m_Width * pLt->m_Height);
|
||||||
const int TgtIndex = fy * m_Width + fx;
|
const int TgtIndex = fy * m_Width + fx;
|
||||||
|
|
||||||
if(Empty || (!m_pEditor->m_AllowPlaceUnusedTiles && !IsValidTeleTile((pLt->m_pTiles[SrcIndex]).m_Index)))
|
if(Empty || (!m_pEditor->m_AllowPlaceUnusedTiles && !IsValidTeleTile((pLt->m_pTiles[SrcIndex]).m_Index)))
|
||||||
|
@ -1549,7 +1549,7 @@ void CLayerSpeedup::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
||||||
if(!Destructive && GetTile(fx, fy).m_Index)
|
if(!Destructive && GetTile(fx, fy).m_Index)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const int SrcIndex = (y * pLt->m_Width + x % pLt->m_Width) % (pLt->m_Width * pLt->m_Height);
|
const int SrcIndex = Empty ? 0 : (y * pLt->m_Width + x % pLt->m_Width) % (pLt->m_Width * pLt->m_Height);
|
||||||
const int TgtIndex = fy * m_Width + fx;
|
const int TgtIndex = fy * m_Width + fx;
|
||||||
|
|
||||||
if(Empty || (!m_pEditor->m_AllowPlaceUnusedTiles && !IsValidSpeedupTile((pLt->m_pTiles[SrcIndex]).m_Index))) // no speed up tile chosen: reset
|
if(Empty || (!m_pEditor->m_AllowPlaceUnusedTiles && !IsValidSpeedupTile((pLt->m_pTiles[SrcIndex]).m_Index))) // no speed up tile chosen: reset
|
||||||
|
@ -1844,7 +1844,7 @@ void CLayerSwitch::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
||||||
if(!Destructive && GetTile(fx, fy).m_Index)
|
if(!Destructive && GetTile(fx, fy).m_Index)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const int SrcIndex = (y * pLt->m_Width + x % pLt->m_Width) % (pLt->m_Width * pLt->m_Height);
|
const int SrcIndex = Empty ? 0 : (y * pLt->m_Width + x % pLt->m_Width) % (pLt->m_Width * pLt->m_Height);
|
||||||
const int TgtIndex = fy * m_Width + fx;
|
const int TgtIndex = fy * m_Width + fx;
|
||||||
|
|
||||||
if(Empty || (!m_pEditor->m_AllowPlaceUnusedTiles && !IsValidSwitchTile((pLt->m_pTiles[SrcIndex]).m_Index)))
|
if(Empty || (!m_pEditor->m_AllowPlaceUnusedTiles && !IsValidSwitchTile((pLt->m_pTiles[SrcIndex]).m_Index)))
|
||||||
|
@ -2092,7 +2092,7 @@ void CLayerTune::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
|
||||||
if(!Destructive && GetTile(fx, fy).m_Index)
|
if(!Destructive && GetTile(fx, fy).m_Index)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const int SrcIndex = (y * pLt->m_Width + x % pLt->m_Width) % (pLt->m_Width * pLt->m_Height);
|
const int SrcIndex = Empty ? 0 : (y * pLt->m_Width + x % pLt->m_Width) % (pLt->m_Width * pLt->m_Height);
|
||||||
const int TgtIndex = fy * m_Width + fx;
|
const int TgtIndex = fy * m_Width + fx;
|
||||||
|
|
||||||
if(Empty || (!m_pEditor->m_AllowPlaceUnusedTiles && !IsValidTuneTile((pLt->m_pTiles[SrcIndex]).m_Index)))
|
if(Empty || (!m_pEditor->m_AllowPlaceUnusedTiles && !IsValidTuneTile((pLt->m_pTiles[SrcIndex]).m_Index)))
|
||||||
|
|
Loading…
Reference in a new issue