# TMap replication still not supported?

**URL:** <https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884>\
**Category:** C++\
**Tags:** Replication, UE4-11, tmap, unreal-engine, CPP, question\
**Created:** [February 27, 2016, 6:31pm UTC](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884 "2016-02-27T18:31:01Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mercus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mercus](https://forums.unrealengine.com/u/Mercus)\
**Post date:** [February 27, 2016, 6:31pm UTC](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884/1 "2016-02-27T18:31:01Z")

</div>

TMap replication still seems unsupported, or am I doing something wrong?

A mention of this is here already: [TMap\<\> Replication - exposing to Unreal reflection. - Feedback for Unreal Engine team - Unreal Engine Forums](https://forums.unrealengine.com/showthread.php?13133-TMap-lt-gt-Replication-exposing-to-Unreal-reflection&p=446346&viewfull=1#post446346)

Trying to get it to replicate seems to always lead to “Deprecated Code Path” in PropertyMap.cpp

```
bool UMapProperty::NetSerializeItem( FArchive& Ar, UPackageMap* Map, void* Data, TArray<uint8> * MetaData ) const
{
	UE_LOG( LogProperty, Fatal, TEXT( "Deprecated code path" ) );
	return 1;
}
```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b24d331](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b24d331](https://forums.unrealengine.com/u/anonymous_user_4b24d331)\
**Post date:** [November 23, 2016, 9:54am UTC](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884/2 "2016-11-23T09:54:38Z")

</div>

To add a little more info, the relevant part of the call stack: [UE4Editor-CoreUObject.dll!UMapProperty::NetSerializeItem(FArchive & Ar, UPacka - Pastebin.com](http://pastebin.com/KQW1qrtn)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61db4be4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61db4be4](https://forums.unrealengine.com/u/anonymous_user_61db4be4)\
**Post date:** [March 26, 2017, 9:35am UTC](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884/3 "2017-03-26T09:35:33Z")

</div>

I’m getting the same issue/crash with a blueprint struct containing a tmap from GUID → Blueprint struct.

---

<div class="post-metadata">

**Author:** ![Atheist91](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Atheist91](https://forums.unrealengine.com/u/Atheist91)\
**Post date:** [September 17, 2017, 10:58am UTC](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884/4 "2017-09-17T10:58:30Z")

</div>

Getting the same results in 4.17 :[

---

<div class="post-metadata">

**Author:** ![Atheist91](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Atheist91](https://forums.unrealengine.com/u/Atheist91)\
**Post date:** [January 28, 2018, 12:08am UTC](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884/5 "2018-01-28T00:08:25Z")

</div>

…and 4.18

---

<div class="post-metadata">

**Author:** ![Mercus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mercus](https://forums.unrealengine.com/u/Mercus)\
**Post date:** [March 5, 2018, 10:16pm UTC](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884/6 "2018-03-05T22:16:19Z")

</div>

Has anyone tried in 4.19? Right now still using UStructs in many places where TMap would just fit a lot nicer if properly supported with replication. As useful and amazing as structs can be in few places TMap would just be so much cleaner to use in my project.

---

<div class="post-metadata">

**Author:** ![Devel](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Devel](https://forums.unrealengine.com/u/Devel)\
**Post date:** [May 8, 2018, 5:51pm UTC](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884/7 "2018-05-08T17:51:28Z")

</div>

I am posting this in case it might be useful as a simple starting place for someone. Tested in 4.19 only, and only for simple types (ie. FString). The TMAP is placed inside of a USTRUCT where NetSerialize moves key/values between TMAP and TARRAY’s before/after network transport.

```
USTRUCT(BlueprintType)
struct FStructWithMap
{
	GENERATED_BODY()
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
    TMap<FString, FString> StringMap;
 
    TArray<FString> StringKeys;
    TArray<FString> StringValues;

	bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess)
	{
		if (Ar.IsLoading())
		{
			// Move data to Map
			Ar << StringKeys;
			Ar << StringValues;
			for (auto It = StringKeys.CreateConstIterator(); It; ++It)
			{
				StringMap.Add(StringKeys[It.GetIndex()], StringValues[It.GetIndex()]);
			}
		} else {
			// Move data to Arrays
			StringMap.GenerateKeyArray(StringKeys);
			StringMap.GenerateValueArray(StringValues);
			Ar << StringKeys;
			Ar << StringValues;
		}
		StringKeys.Empty();
		StringValues.Empty();

		bOutSuccess = true;
		return true;
	}
};
 
template<>
struct TStructOpsTypeTraits<FStructWithMap> : public TStructOpsTypeTraitsBase2<FStructWithMap>
{
	enum
	{
		WithNetSerializer = true
	};
};
```

---

<div class="post-metadata">

**Author:** ![Amneri](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Amneri](https://forums.unrealengine.com/u/Amneri)\
**Post date:** [July 2, 2018, 6:12pm UTC](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884/8 "2018-07-02T18:12:37Z")

</div>

Same for 4.19.  
Are TMap going to be replicated any time soon ?  
I mean, it seems like something pretty much essential.

---

<div class="post-metadata">

**Author:** ![Vaclav.Jarko](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vaclav.Jarko](https://forums.unrealengine.com/u/Vaclav.Jarko)\
**Post date:** [August 26, 2018, 7:44pm UTC](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884/9 "2018-08-26T19:44:33Z")

</div>

Well it’s not good. Work around is just mess

---

<div class="post-metadata">

**Author:** ![spacebares](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@spacebares](https://forums.unrealengine.com/u/spacebares)\
**Post date:** [November 9, 2018, 7:06pm UTC](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884/10 "2018-11-09T19:06:21Z")

</div>

this is the cleanest implementation of tmap replication workaround i have seen so far.

---

<div class="post-metadata">

**Author:** ![Philippe23](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Philippe23](https://forums.unrealengine.com/u/Philippe23)\
**Post date:** [May 1, 2020, 11:33pm UTC](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884/11 "2020-05-01T23:33:42Z")

</div>

`StringKeys` and `StringValues` should probably be local variables in `NetSerialize()` – they don’t need to be member variables for this.

---

<div class="post-metadata">

**Author:** ![Mewbits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mewbits/32/1194714_2.png) [@Mewbits](https://forums.unrealengine.com/u/Mewbits)\
**Post date:** [September 17, 2021, 5:00pm UTC](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884/12 "2021-09-17T17:00:59Z")

</div>

How would you get this to work with a TMap with a struct for the values? It doesn’t seem to like using AR \<\< on the struct values.
