Skip to content

Commit aca6c1f

Browse files
authored
Fix missing return values and use CVector2D instead of ints (#2378)
Addendum to 201de35 (PR #2026)
1 parent fe93f94 commit aca6c1f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ bool CLuaVectorGraphicDefs::SetDocument(CClientVectorGraphic* pVectorGraphic, CX
6161
if (!pVectorGraphic || !pXMLNode || !pXMLNode->IsValid())
6262
return false;
6363

64-
pVectorGraphic->SetDocument(pXMLNode);
64+
return pVectorGraphic->SetDocument(pXMLNode);
6565
}
6666

6767
bool CLuaVectorGraphicDefs::LoadFromFile(lua_State* luaVM, CClientVectorGraphic* pVectorGraphic, CScriptFile* pFile, std::string strPath,
@@ -94,6 +94,8 @@ bool CLuaVectorGraphicDefs::LoadFromFile(lua_State* luaVM, CClientVectorGraphic*
9494
return false;
9595
}
9696
}
97+
98+
return true;
9799
}
98100

99101
bool CLuaVectorGraphicDefs::SetSize(CClientVectorGraphic* pVectorGraphic, CVector2D size)
@@ -276,16 +278,14 @@ CLuaMultiReturn<int, int> CLuaVectorGraphicDefs::SVGGetSize(CClientVectorGraphic
276278
return {(int)pVectorGraphic->GetRenderItem()->m_uiSizeX, (int)pVectorGraphic->GetRenderItem()->m_uiSizeY};
277279
}
278280

279-
bool CLuaVectorGraphicDefs::SVGSetSize(CClientVectorGraphic* pVectorGraphic, int width, int height, std::optional<CLuaFunctionRef> luaFunctionRef)
281+
bool CLuaVectorGraphicDefs::SVGSetSize(CClientVectorGraphic* pVectorGraphic, CVector2D size, std::optional<CLuaFunctionRef> luaFunctionRef)
280282
{
281-
if (width <= 0 || height <= 0)
283+
if (size.fX <= 0 || size.fY <= 0)
282284
throw std::invalid_argument("A vector graphic must be atleast 1x1 in size.");
283285

284-
if (width > 4096 || height > 4096)
286+
if (size.fX > 4096 || size.fY > 4096)
285287
throw std::invalid_argument("A vector graphic cannot exceed 4096x4096 in size.");
286288

287-
CVector2D size = CVector2D(width, height);
288-
289289
if (luaFunctionRef.has_value() && VERIFY_FUNCTION(luaFunctionRef.value()))
290290
{
291291
CLuaFunctionRef funcRef = luaFunctionRef.value();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CLuaVectorGraphicDefs : public CLuaDefs
2424
static bool SVGSetDocumentXML(CClientVectorGraphic* pVectorGraphic, CXMLNode* pXMLNode, std::optional<CLuaFunctionRef> luaFunctionRef);
2525

2626
static CLuaMultiReturn<int, int> SVGGetSize(CClientVectorGraphic* pVectorGraphic);
27-
static bool SVGSetSize(CClientVectorGraphic* pVectorGraphic, int width, int height, std::optional<CLuaFunctionRef> luaFunctionRef);
27+
static bool SVGSetSize(CClientVectorGraphic* pVectorGraphic, CVector2D size, std::optional<CLuaFunctionRef> luaFunctionRef);
2828

2929
private:
3030
static bool LoadFromData(lua_State* luaVM, CClientVectorGraphic* pVectorGraphic, std::string strRawData);

0 commit comments

Comments
 (0)