Skip to content

Commit 721c2b6

Browse files
authored
Fix #3306: Fix svgSetSize() logic (#3309)
Fix svgSetSize()
1 parent 59cc584 commit 721c2b6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Client/mods/deathmatch/logic/luadefs/CLuaVectorGraphicDefs.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,16 @@ bool CLuaVectorGraphicDefs::SetSize(CClientVectorGraphic* vectorGraphic, CVector
101101
if (!vectorGraphicItem)
102102
return false;
103103

104-
vectorGraphicItem->Resize(size);
104+
if (size.fX <= 0 || size.fY <= 0)
105+
throw std::invalid_argument("A vector graphic must be atleast 1x1 in size.");
106+
107+
if (size.fX > 4096 || size.fY > 4096)
108+
throw std::invalid_argument("A vector graphic cannot exceed 4096x4096 in size.");
109+
110+
int intSizeX = static_cast<int>(size.fX);
111+
int intSizeY = static_cast<int>(size.fY);
105112

106-
if ((int)vectorGraphicItem->m_uiSizeX != size.fX || (int)vectorGraphicItem->m_uiSizeY != size.fY)
107-
return false; // failed to resize
113+
vectorGraphicItem->Resize(CVector2D(intSizeX, intSizeY));
108114

109115
vectorGraphic->GetDisplay()->Update();
110116
return true;

0 commit comments

Comments
 (0)