Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.

Commit 701a838

Browse files
author
Nikita Fediuchin
committed
Fixed username from bytes method, moved players and rooms to the NetworkLibrary
1 parent ade9ffb commit 701a838

File tree

14 files changed

+113
-572
lines changed

14 files changed

+113
-572
lines changed

Credentials/Username.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,28 @@ public Username(string value)
5050
/// </summary>
5151
public Username(BinaryReader binaryReader)
5252
{
53+
var length = 0;
5354
var username = Encoding.ASCII.GetString(binaryReader.ReadBytes(ByteSize));
5455

55-
for (int i = 0; i < ByteSize; i++)
56+
while(length < ByteSize)
5657
{
57-
if (username[i] == '\0')
58-
{
59-
if (!IsValidLength(i))
60-
throw new ArgumentException("Incorrect username length");
58+
if (username[length] == '\0')
59+
break;
6160

62-
username = username.Substring(0, i);
61+
length++;
62+
}
63+
64+
if (!IsValidLength(length))
65+
throw new ArgumentException("Incorrect username length");
6366

64-
if (!IsValidLetters(username))
65-
throw new ArgumentException("Incorrect username letters");
67+
if(length < ByteSize)
68+
username = username.Substring(0, length);
69+
70+
if (!IsValidLetters(username))
71+
throw new ArgumentException("Incorrect username letters");
6672

67-
value = username;
68-
return;
69-
}
70-
};
73+
value = username;
74+
return;
7175
}
7276

7377
/// <summary>

Games/Players/IPlayer.cs

Lines changed: 0 additions & 27 deletions
This file was deleted.

Games/Players/IPlayerDatabase.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

Games/Players/IPlayerFactory.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

Games/Players/Player.cs

Lines changed: 0 additions & 127 deletions
This file was deleted.

Games/Players/PlayerDictionary.cs

Lines changed: 0 additions & 47 deletions
This file was deleted.

Games/Players/PlayerDiskDatabase.cs

Lines changed: 0 additions & 67 deletions
This file was deleted.

Games/Players/PlayerFactory.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)