Skip to content

Commit 8ebc876

Browse files
committed
client/createColPolygon: support Vec2s and require 3 more Vec2 args
1 parent 90e0bb6 commit 8ebc876

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,15 @@ int CLuaColShapeDefs::CreateColPolygon(lua_State* luaVM)
255255
CScriptArgReader argStream(luaVM);
256256
argStream.ReadVector2D(vecPosition);
257257

258+
// Get the points
259+
std::vector<CVector2D> vecPointList;
260+
for (uint i = 0; i < 3 || argStream.NextIsVector2D(); i++)
261+
{
262+
CVector2D vecPoint;
263+
argStream.ReadVector2D(vecPoint);
264+
vecPointList.push_back(vecPoint);
265+
}
266+
258267
if (!argStream.HasErrors())
259268
{
260269
CLuaMain* pLuaMain = m_pLuaManager->GetVirtualMachine(luaVM);
@@ -267,11 +276,10 @@ int CLuaColShapeDefs::CreateColPolygon(lua_State* luaVM)
267276
CClientColPolygon* pShape = CStaticFunctionDefinitions::CreateColPolygon(*pResource, vecPosition);
268277
if (pShape)
269278
{
270-
// Get the points
271-
while (argStream.NextCouldBeNumber() && argStream.NextCouldBeNumber(1))
279+
// Add the points
280+
for (uint i = 0; i < vecPointList.size(); i++)
272281
{
273-
argStream.ReadVector2D(vecPosition);
274-
pShape->AddPoint(vecPosition);
282+
pShape->AddPoint(vecPointList[i]);
275283
}
276284

277285
CElementGroup* pGroup = pResource->GetElementGroup();

0 commit comments

Comments
 (0)