Skip to content

Commit a24b3ab

Browse files
authored
Merge pull request #217 from patrikjuvonen/issue-9742
0009742: add support for Vec2s on createColPolygon client-side and allow passing in more Vec2s server-side
2 parents 5ce8d6c + 8ebc876 commit a24b3ab

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
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();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ int CLuaColShapeDefs::CreateColPolygon(lua_State* luaVM)
249249
std::vector<CVector2D> vecPointList;
250250

251251
CScriptArgReader argStream(luaVM);
252-
for (uint i = 0; i < 4 || argStream.NextCouldBeNumber(); i++)
252+
for (uint i = 0; i < 4 || argStream.NextIsVector2D(); i++)
253253
{
254254
CVector2D vecPoint;
255255
argStream.ReadVector2D(vecPoint);

0 commit comments

Comments
 (0)