diff --git a/source/common/scripting/core/maps.cpp b/source/common/scripting/core/maps.cpp index bb7cd369bb8..28fda643e88 100644 --- a/source/common/scripting/core/maps.cpp +++ b/source/common/scripting/core/maps.cpp @@ -162,7 +162,15 @@ template void MapInsert(M * self, expand_types_vmInsert(key, value); + + if constexpr(std::is_same_v) + { + self->Insert(key,static_cast(value)); + } + else + { + self->Insert(key, value); + } self->info->rev++; // invalidate iterators } @@ -246,7 +254,15 @@ template void MapIteratorSetValue(I * self, expand_types_vm) + { + val = static_cast(value); + } + else + { + val = value; + } } diff --git a/source/common/scripting/core/types.cpp b/source/common/scripting/core/types.cpp index 702277e892c..838275dad50 100644 --- a/source/common/scripting/core/types.cpp +++ b/source/common/scripting/core/types.cpp @@ -2399,10 +2399,6 @@ void PMap::Construct(void * addr) const { void PMap::InitializeValue(void *addr, const void *def) const { - if (def != nullptr) - { - I_Error("Map cannot have default values"); - } Construct(addr); } @@ -2475,7 +2471,6 @@ void PMap::DestroyValue(void *addr) const void PMap::SetDefaultValue(void *base, unsigned offset, TArray *special) { - assert(!(base && special)); if (base != nullptr) { Construct(((uint8_t*)base)+offset); // is this needed? string/dynarray do this initialization if base != nullptr, but their initialization doesn't need to allocate @@ -2603,7 +2598,7 @@ template static bool PMapValueReader(FSerializer &ar, M *map, const PMap *m) { const char * k; - while(k = ar.GetKey()) + while((k = ar.GetKey())) { typename M::ValueType * val; if constexpr(std::is_same_v) @@ -2868,10 +2863,6 @@ void PMapIterator::Construct(void * addr) const { void PMapIterator::InitializeValue(void *addr, const void *def) const { - if (def != nullptr) - { - I_Error("Map cannot have default values"); - } Construct(addr); } @@ -2944,7 +2935,6 @@ void PMapIterator::DestroyValue(void *addr) const void PMapIterator::SetDefaultValue(void *base, unsigned offset, TArray *special) { - assert(!(base && special)); if (base != nullptr) { Construct(((uint8_t*)base)+offset);