diff --git a/src/common/scripting/core/dynarrays.cpp b/src/common/scripting/core/dynarrays.cpp index eebb97da8..82dd8e774 100644 --- a/src/common/scripting/core/dynarrays.cpp +++ b/src/common/scripting/core/dynarrays.cpp @@ -87,11 +87,12 @@ template void ArrayDelete(T *self, int index, int count) template void ArrayInsert(T *self, int index, U val) { - //int oldSize = self->Size(); + int oldSize = self->Size(); self->Insert(index, static_cast(val)); - // Is this even necessary? All Insert does is inserting one defined element into the array and moving the rest. - // It never creates empty tailing entries. fillcount in the macro will always be 0 - //if (fill) { DYNARRAY_FILL_ITEMS_SKIP(1); } + if constexpr (fill) + { + for (unsigned i = oldSize; i < self->Size() - 1; i++) (*self)[i] = 0; + } } template void ArrayShrinkToFit(T *self)