File tree 1 file changed +22
-1
lines changed
Shared/mods/deathmatch/logic/lua
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,27 @@ struct CLuaFunctionParserBase
172
172
return T{};
173
173
}
174
174
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
+
175
196
// Special type matcher for variants. Returns -1 if the type does not match
176
197
// returns n if the nth type of the variant matches
177
198
template <typename T>
@@ -241,7 +262,7 @@ struct CLuaFunctionParserBase
241
262
242
263
// std::vector is used for arrays built from tables
243
264
else if constexpr (is_2specialization<T, std::vector>::value)
244
- return iArgument == LUA_TTABLE;
265
+ return iArgument == LUA_TTABLE && IsArray (L, index ) ;
245
266
246
267
// std::unordered_map<k,v> is used for maps built from tables
247
268
else if constexpr (is_5specialization<T, std::unordered_map>::value)
You can’t perform that action at this time.
0 commit comments