mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge pull request #7877 from ChillerDragon/pr_fix_ub_if_no_game_layer
Fix clang warning and UB when there is no game layer
This commit is contained in:
commit
8366bfb881
|
@ -405,7 +405,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
||||||
{
|
{
|
||||||
// gather all tile layers
|
// gather all tile layers
|
||||||
std::vector<std::shared_ptr<CLayerTiles>> vpLayers;
|
std::vector<std::shared_ptr<CLayerTiles>> vpLayers;
|
||||||
int GameLayerIndex;
|
int GameLayerIndex = -1;
|
||||||
for(int LayerIndex = 0; LayerIndex < (int)pEditor->m_Map.m_pGameGroup->m_vpLayers.size(); LayerIndex++)
|
for(int LayerIndex = 0; LayerIndex < (int)pEditor->m_Map.m_pGameGroup->m_vpLayers.size(); LayerIndex++)
|
||||||
{
|
{
|
||||||
auto &pLayer = pEditor->m_Map.m_pGameGroup->m_vpLayers.at(LayerIndex);
|
auto &pLayer = pEditor->m_Map.m_pGameGroup->m_vpLayers.at(LayerIndex);
|
||||||
|
@ -446,8 +446,15 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
|
||||||
|
|
||||||
if(!pGameLayer->m_TilesHistory.empty())
|
if(!pGameLayer->m_TilesHistory.empty())
|
||||||
{
|
{
|
||||||
// record undo
|
if(GameLayerIndex == -1)
|
||||||
pEditor->m_EditorHistory.RecordAction(std::make_shared<CEditorActionTileChanges>(pEditor, pEditor->m_SelectedGroup, GameLayerIndex, "Clean up game tiles", pGameLayer->m_TilesHistory));
|
{
|
||||||
|
dbg_msg("editor", "failed to record action (GameLayerIndex not found)");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// record undo
|
||||||
|
pEditor->m_EditorHistory.RecordAction(std::make_shared<CEditorActionTileChanges>(pEditor, pEditor->m_SelectedGroup, GameLayerIndex, "Clean up game tiles", pGameLayer->m_TilesHistory));
|
||||||
|
}
|
||||||
pGameLayer->ClearHistory();
|
pGameLayer->ClearHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue