File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Shared/mods/deathmatch/logic/lua Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,27 @@ struct CLuaFunctionParserBase
172172 return T{};
173173 }
174174
175+ // Check if lua table is array (std::vector) or map
176+ bool IsArray (lua_State* L, int index)
177+ {
178+ if (!lua_istable (L, index))
179+ return false ;
180+
181+ lua_pushnil (L);
182+ while (lua_next (L, index < 0 ? (index - 1 ) : index))
183+ {
184+ if (!lua_isnumber (L, -2 ))
185+ {
186+ lua_pop (L, 2 );
187+ return false ;
188+ }
189+
190+ lua_pop (L, 1 );
191+ }
192+
193+ return true ;
194+ }
195+
175196 // Special type matcher for variants. Returns -1 if the type does not match
176197 // returns n if the nth type of the variant matches
177198 template <typename T>
@@ -241,7 +262,7 @@ struct CLuaFunctionParserBase
241262
242263 // std::vector is used for arrays built from tables
243264 else if constexpr (is_2specialization<T, std::vector>::value)
244- return iArgument == LUA_TTABLE;
265+ return iArgument == LUA_TTABLE && IsArray (L, index) ;
245266
246267 // std::unordered_map<k,v> is used for maps built from tables
247268 else if constexpr (is_5specialization<T, std::unordered_map>::value)
You can’t perform that action at this time.
0 commit comments