File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
Runtime/Colyseus/Serializer/Schema Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -80,20 +80,23 @@ public bool Has(int refId)
80
80
/// Remove a reference by ID
81
81
/// </summary>
82
82
/// <param name="refId">The ID of the reference to remove</param>
83
- public void Remove ( int refId )
83
+ public bool Remove ( int refId )
84
84
{
85
85
if ( ! refCounts . ContainsKey ( refId ) )
86
86
{
87
87
Debug . Log ( "trying to remove refId that doesn't exist: " + refId ) ;
88
- return ;
88
+ return false ;
89
89
}
90
90
91
91
refCounts [ refId ] = refCounts [ refId ] - 1 ;
92
92
93
93
if ( refCounts [ refId ] <= 0 )
94
94
{
95
95
deletedRefs . Add ( refId ) ;
96
+ return true ;
96
97
}
98
+
99
+ return false ;
97
100
}
98
101
99
102
/// <summary>
@@ -118,9 +121,8 @@ public void GarbageCollection()
118
121
if ( fieldValue is IRef )
119
122
{
120
123
int childRefId = ( ( IRef ) fieldValue ) . __refId ;
121
- if ( ! deletedRefs . Contains ( childRefId ) )
124
+ if ( ! deletedRefs . Contains ( childRefId ) && Remove ( childRefId ) )
122
125
{
123
- Remove ( childRefId ) ;
124
126
totalDeletedRefs ++ ;
125
127
}
126
128
}
@@ -131,9 +133,8 @@ public void GarbageCollection()
131
133
( ( ISchemaCollection ) _ref ) . ForEach ( ( key , value ) =>
132
134
{
133
135
int childRefId = ( ( IRef ) value ) . __refId ;
134
- if ( ! deletedRefs . Contains ( childRefId ) )
136
+ if ( ! deletedRefs . Contains ( childRefId ) && Remove ( childRefId ) )
135
137
{
136
- Remove ( childRefId ) ;
137
138
totalDeletedRefs ++ ;
138
139
}
139
140
} ) ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " io.colyseus.sdk" ,
3
- "version" : " 0.16.5 " ,
3
+ "version" : " 0.16.6 " ,
4
4
"displayName" : " Colyseus SDK" ,
5
5
"description" : " Colyseus Multiplayer SDK for Unity" ,
6
6
"unity" : " 2019.1" ,
You can’t perform that action at this time.
0 commit comments