Skip to content

Commit c29011b

Browse files
authored
Merge pull request #121 from jaglitegrann/bug/BitReader-ReadObjectPacked-string-and-IBitWritable
Fix two bitReader read bugs.
2 parents 336bed4 + ce4ffbd commit c29011b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

MLAPI/NetworkingManagerComponents/Binary/BitReader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public object ReadObjectPacked(Type type)
108108
if (type == typeof(double))
109109
return ReadDoublePacked();
110110
if (type == typeof(string))
111-
return ReadStringPacked();
111+
return ReadStringPacked().ToString();
112112
if (type == typeof(bool))
113113
return ReadBool();
114114
if (type == typeof(Vector2))
@@ -127,14 +127,14 @@ public object ReadObjectPacked(Type type)
127127
return ReadRotation(3);
128128
if (type == typeof(char))
129129
return ReadCharPacked();
130-
if (type == typeof(IBitWritable))
130+
if (type.IsEnum)
131+
return ReadInt32Packed();
132+
if (typeof(IBitWritable).IsAssignableFrom(type))
131133
{
132134
object instance = Activator.CreateInstance(type);
133135
((IBitWritable)instance).Read(this.source);
134136
return instance;
135137
}
136-
if (type.IsEnum)
137-
return ReadInt32Packed();
138138

139139
throw new ArgumentException("BitReader cannot read type " + type.Name);
140140
}

0 commit comments

Comments
 (0)