Skip to content

Commit 565f99e

Browse files
fix: network list contains backport 1.0.0 (#1622)
* changelog (cherry picked from commit 2b16478) * changelog * Update CHANGELOG.md (cherry picked from commit db8126d) * fix: NetworkList.Contains inverted (#1363) (cherry picked from commit cf0c9b4) Co-authored-by: Matt Walsh <69258106+mattwalsh-unity@users.noreply.github.com>
1 parent 5344c18 commit 565f99e

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

com.unity.netcode.adapter.utp/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ All notable changes to this package will be documented in this file. The format
1818
### Fixed
1919

2020
- Lifted the limit of ~44KB for reliable payloads. Before the fix, attempting to send a payload larger than that with reliable delivery would silently fail. Note that it is still not recommended to send such large reliable payloads, since their delivery could take a few network round-trips. (#1596)
21+
- Fixed a bug where NetworkList.contains value was inverted (#1363)
2122

2223
## [1.0.0-pre.4] - 2022-01-04
2324

com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ public void Clear()
373373
public bool Contains(T item)
374374
{
375375
int index = NativeArrayExtensions.IndexOf(m_List, item);
376-
return index == -1;
376+
return index != -1;
377377
}
378378

379379
/// <inheritdoc />

com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariableTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ public IEnumerator NetworkListContains([Values(true, false)] bool useHost)
224224
{
225225
return m_Player1OnServer.TheList.Count == 1 &&
226226
m_Player1OnClient1.TheList.Count == 1 &&
227-
m_Player1OnServer.TheList.Contains(k_TestKey1) &&
228-
m_Player1OnClient1.TheList.Contains(k_TestKey1);
227+
m_Player1OnServer.TheList.Contains(k_TestVal1) &&
228+
m_Player1OnClient1.TheList.Contains(k_TestVal1);
229229
}
230230
);
231231
}

0 commit comments

Comments
 (0)