Skip to content

Commit 836fc69

Browse files
committed
fixes webgl build by removing the 'dynamic' keyword. fixes TriggerAll()
1 parent ea658ea commit 836fc69

File tree

7 files changed

+32
-31
lines changed

7 files changed

+32
-31
lines changed

Assets/Plugins/Colyseus/Serializer/Schema/Schema.cs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public class DataChange
7272
public byte Op;
7373
public string Field;
7474
public object DynamicIndex;
75-
public dynamic Value;
76-
public dynamic PreviousValue;
75+
public object Value;
76+
public object PreviousValue;
7777
}
7878

7979
public delegate void OnChangeEventHandler(List<DataChange> changes);
@@ -93,7 +93,7 @@ public interface ISchemaCollection
9393
void Clear(ReferenceTracker refs);
9494

9595
System.Type GetChildType();
96-
dynamic GetTypeDefaultValue();
96+
object GetTypeDefaultValue();
9797
bool ContainsKey(object key);
9898

9999
bool HasSchemaChild { get; }
@@ -102,8 +102,8 @@ public interface ISchemaCollection
102102
int Count { get; }
103103
object this[object key] { get; set; }
104104

105-
void SetIndex(int index, dynamic dynamicIndex);
106-
dynamic GetIndex(int index);
105+
void SetIndex(int index, object dynamicIndex);
106+
object GetIndex(int index);
107107
void SetByIndex(int index, object dynamicIndex, object value);
108108

109109
ISchemaCollection Clone();
@@ -112,7 +112,6 @@ public interface ISchemaCollection
112112
public interface IRef
113113
{
114114
int __refId { get; set; }
115-
IRef __parent { get; set; }
116115

117116
object GetByIndex(int index);
118117
void DeleteByIndex(int index);
@@ -129,7 +128,6 @@ public class Schema : IRef
129128
public event OnRemoveEventHandler OnRemove;
130129

131130
public int __refId { get; set; }
132-
public IRef __parent { get; set; }
133131

134132
private ReferenceTracker refs;
135133

@@ -159,7 +157,7 @@ public Schema()
159157
}
160158

161159
/* allow to retrieve property values by its string name */
162-
public dynamic this[string propertyName]
160+
public object this[string propertyName]
163161
{
164162
get
165163
{
@@ -427,7 +425,6 @@ public void Decode(byte[] bytes, Iterator it = null, ReferenceTracker refs = nul
427425
if (value is IRef)
428426
{
429427
((IRef)value).__refId = refId;
430-
((IRef)value).__parent = _ref;
431428
}
432429

433430
if (_ref is Schema)
@@ -453,16 +450,22 @@ public void Decode(byte[] bytes, Iterator it = null, ReferenceTracker refs = nul
453450
}
454451
}
455452

456-
TriggerChanges(allChanges);
453+
TriggerChanges(ref allChanges);
457454

458455
refs.GarbageCollection();
459456
}
460457

461458
public void TriggerAll()
462459
{
460+
//
461+
// first state not received from the server yet.
462+
// nothing to trigger.
463+
//
464+
if (refs == null) { return; }
465+
463466
var allChanges = new OrderedDictionary();
464467
TriggerAllFillChanges(this, ref allChanges);
465-
TriggerChanges(allChanges);
468+
TriggerChanges(ref allChanges);
466469
}
467470

468471
protected void TriggerAllFillChanges(IRef currentRef, ref OrderedDictionary allChanges)
@@ -487,7 +490,7 @@ protected void TriggerAllFillChanges(IRef currentRef, ref OrderedDictionary allC
487490

488491
if (value is IRef)
489492
{
490-
TriggerAllFillChanges(value, ref allChanges);
493+
TriggerAllFillChanges((IRef)value, ref allChanges);
491494
}
492495
}
493496
} else
@@ -513,13 +516,13 @@ protected void TriggerAllFillChanges(IRef currentRef, ref OrderedDictionary allC
513516
}
514517
}
515518

516-
protected void TriggerChanges(OrderedDictionary allChanges)
519+
protected void TriggerChanges(ref OrderedDictionary allChanges)
517520
{
518-
foreach (object key in allChanges.Keys)
521+
foreach (object refId in allChanges.Keys)
519522
{
520-
List<DataChange> changes = (List<DataChange>)allChanges[key];
523+
List<DataChange> changes = (List<DataChange>)allChanges[refId];
521524

522-
IRef _ref = refs.Get((int)key);
525+
IRef _ref = refs.Get((int)refId);
523526
bool isSchema = _ref is Schema;
524527

525528
foreach (DataChange change in changes)

Assets/Plugins/Colyseus/Serializer/Schema/Types/ArraySchema.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public class ArraySchema<T> : ISchemaCollection, IRef
1515
protected Dictionary<int, int> Indexes = new Dictionary<int, int>();
1616

1717
public int __refId { get; set; }
18-
public IRef __parent { get; set; }
1918

2019
public ArraySchema()
2120
{
@@ -27,17 +26,17 @@ public ArraySchema(Dictionary<int, T> items = null)
2726
Items = items ?? new Dictionary<int, T>();
2827
}
2928

30-
public void SetIndex(int index, dynamic dynamicIndex)
29+
public void SetIndex(int index, object dynamicIndex)
3130
{
32-
Indexes[index] = dynamicIndex;
31+
Indexes[index] = (int)dynamicIndex;
3332
}
3433

3534
public void SetByIndex(int index, object dynamicIndex, object value)
3635
{
3736
Items[(int)dynamicIndex] = (T)value;
3837
}
3938

40-
public dynamic GetIndex(int index)
39+
public object GetIndex(int index)
4140
{
4241
int dynamicIndex;
4342

@@ -99,7 +98,7 @@ public System.Type GetChildType()
9998
return typeof(T);
10099
}
101100

102-
public dynamic GetTypeDefaultValue()
101+
public object GetTypeDefaultValue()
103102
{
104103
return default(T);
105104
}

Assets/Plugins/Colyseus/Serializer/Schema/Types/MapSchema.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public class MapSchema<T> : ISchemaCollection, IRef
1616
protected Dictionary<int, string> Indexes = new Dictionary<int, string>();
1717

1818
public int __refId { get; set; }
19-
public IRef __parent { get; set; }
2019

2120
public MapSchema()
2221
{
@@ -28,9 +27,9 @@ public MapSchema(OrderedDictionary items = null)
2827
Items = items ?? new OrderedDictionary();
2928
}
3029

31-
public void SetIndex(int index, dynamic dynamicIndex)
30+
public void SetIndex(int index, object dynamicIndex)
3231
{
33-
Indexes[index] = dynamicIndex;
32+
Indexes[index] = (string) dynamicIndex;
3433
}
3534

3635
public void SetByIndex(int index, object dynamicIndex, object value)
@@ -39,7 +38,7 @@ public void SetByIndex(int index, object dynamicIndex, object value)
3938
Items[dynamicIndex] = (T)value;
4039
}
4140

42-
public dynamic GetIndex(int index)
41+
public object GetIndex(int index)
4342
{
4443
string dynamicIndex;
4544

@@ -50,15 +49,15 @@ public dynamic GetIndex(int index)
5049

5150
public object GetByIndex(int index)
5251
{
53-
string dynamicIndex = GetIndex(index);
52+
string dynamicIndex = (string) GetIndex(index);
5453
return (dynamicIndex != null && Items.Contains(dynamicIndex))
5554
? Items[dynamicIndex]
5655
: GetTypeDefaultValue();
5756
}
5857

5958
public void DeleteByIndex(int index)
6059
{
61-
string dynamicIndex = GetIndex(index);
60+
string dynamicIndex = (string) GetIndex(index);
6261
if (Items.Contains(dynamicIndex))
6362
{
6463
Items.Remove(dynamicIndex);
@@ -82,7 +81,7 @@ public System.Type GetChildType()
8281
return typeof(T);
8382
}
8483

85-
public dynamic GetTypeDefaultValue()
84+
public object GetTypeDefaultValue()
8685
{
8786
return default(T);
8887
}

ProjectSettings/ProjectSettings.asset

1.08 KB
Binary file not shown.

ProjectSettings/ProjectVersion.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
m_EditorVersion: 2020.1.4f1
2-
m_EditorVersionWithRevision: 2020.1.4f1 (fa717bb873ec)
1+
m_EditorVersion: 2020.1.6f1
2+
m_EditorVersionWithRevision: 2020.1.6f1 (fc477ca6df10)
0 Bytes
Binary file not shown.

Server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"dependencies": {
1616
"@colyseus/social": "^0.10.0",
17-
"colyseus": "^0.14.0-alpha.11",
17+
"colyseus": "^0.14.0-alpha.16",
1818
"cors": "^2.8.5",
1919
"express": "^4.13.3",
2020
"express-jwt": "^5.3.1",

0 commit comments

Comments
 (0)