x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

RepNotify shadow data is stale when single properties are changed

When replicating a property that is a struct containing multiple properties, the RepNotify "old" or "shadow" value is not being populated correctly. Rough repro steps:

 USTRUCT()
 struct FMyStruct
 {
 UPROPERTY(Transient)
 float A;
 UPROPERTY(Transient)
 float B;
 };
 UPROPERTY(Transient, ReplicatedUsing = OnRep_StructProperty)
 FMyStruct theStruct;
 UFUNCTION()
 void OnRep_StructProperty(FMyStruct const& oldStructVal) {}

On the server do the following set of operations over multiple frames:

  1. theStruct.A = 10.0f; theStruct.B = 0.0f;

  2. theStruct.A = 0.0f; theStruct.B = 5.0f; (these must be done at the same time)

  3. theStruct.B = 4.0f;

  4. theStruct.B = 3.0f;

The result on the client is that you'll see OnRep_StructProperty called with the following current and "oldStructVal" values:

  1. theStruct{A = 10.0f, B = 0.0f} oldStructVal{A = 0.0f, B = 0.0f}

  2. theStruct{A = 0.0f, B = 5.0f} oldStructVal{A = 10.0f, B = 0.0f}

  3. theStruct{A = 0.0f, B = 4.0f} oldStructVal{A = 10.0f, B = 5.0f}

  4. theStruct{A = 0.0f, B = 3.0f} oldStructVal{A = 10.0f, B = 4.0f}

Note that the "A" value in the 3rd and 4th step are still set to 10.0 even though it was previously set to 0.0 This causes some serious problems if you're relying on this functionality to fire events when a value passes a particular threshold, like dropping to 0 from a non-zero value.

The problem appears to be in RepLayout.cpp inside FRepLayout::ReceiveProperties and PROCESS_CMD( FReceivedPropertiesStackState ), where each individual property update command does an independent operation of {StorePropertyToShadowData, NetSerializeItem, AddRepNotifyIfModified}, leaving the shadow data in a partially updated state. The RepNotify is called with the whole object shadow copy, not just the modified properties, so the whole object needs to be refreshed before any properties are serialized.

Product Version: UE 4.8
Tags:
more ▼

asked Sep 17 '15 at 02:27 PM in C++ Programming

avatar image

AndyCampbellNV
11 2 3

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question