Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekeris committed Aug 27, 2020
1 parent 50d2f92 commit e9abc34
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 7 deletions.
Binary file modified .vs/Slovo/v16/.suo
Binary file not shown.
1 change: 1 addition & 0 deletions Slovo/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 16 additions & 7 deletions Slovo/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ await Task.Run(async () =>
{
Action action = () =>
{
TemplateTextBox.Text = ssp.start.Template;
GMComboBox.SelectedIndex = ssp.start.GameMode;

GMComboBox.Enabled = false;
StartButton.Enabled = false;
TemplateTextBox.ReadOnly = true;
Expand All @@ -146,7 +149,8 @@ await Task.Run(async () =>
HistoryListBox.Items.Clear();
foreach (MessagePacket mpa in hp.messagePackets)
{
HistoryDict.Add(mpa.Word, mpa);
if (!HistoryDict.ContainsKey(mpa.Word))
HistoryDict.Add(mpa.Word, mpa);
MessageTextBox.AutoCompleteCustomSource.Add(mpa.ToAutoComplete());
HistoryListBox.Items.Add(mpa);
}
Expand Down Expand Up @@ -266,12 +270,13 @@ private Task ServerMonitor()
{
formatter.Serialize(stream, sa);
ssp.Secret = rsa.Encrypt(stream.ToArray(), RSAEncryptionPadding.OaepSHA256);
ssp.guid = user.guid;
ssp.GameRun = GameStarted;
}
ssp.guid = user.guid;
ssp.GameRun = GameStarted;
Action action = () =>
{
ClientsList.Items.Add(user);
ssp.start = new StartPacket(GMComboBox.SelectedIndex, TemplateTextBox.Text);
};
Invoke(action);
user.SendObject(ssp);
Expand Down Expand Up @@ -337,6 +342,7 @@ await Task.Run(() =>
);
User user = new User();
user.ServerSetUserSocket(newConnection);
Thread.Sleep(100);
if (dr == DialogResult.Yes)
{
user.ServerSendMessage("True");
Expand Down Expand Up @@ -377,10 +383,10 @@ private void SendButtonCheck()
private async void JoinButton_Click(object sender, EventArgs e)
{
IAmServer = false;
HostButton.Enabled = false;
JoinButton.Enabled = false;
if (IPAddress.TryParse(IpTextBox.Text, out IPAddress ip))
{
HostButton.Enabled = false;
JoinButton.Enabled = false;
localUser = new User();
localUser.socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
localUser.socket.Connect(ip, int.Parse(PortTextBox.Text));
Expand Down Expand Up @@ -495,7 +501,7 @@ private async void SendButton_Click(object sender, EventArgs e)
bool sent = false;
bool find = false;
bool correct = false;
if ((GMComboBox.SelectedIndex == 0) && (HistoryListBox.Items.Count > 0))
if ((GMComboBox.SelectedIndex == 0) && (HistoryListBox.Items.Count > 0) && (MessageTextBox.TextLength > 0))
{
for (int i = HistoryListBox.Items.Count - 1; i >= 0; i--)
{
Expand Down Expand Up @@ -535,6 +541,7 @@ await Task.Run(() =>
p = SendButton.Location;
SendButton.BackColor = Color.Red;
SendButton.FlatStyle = FlatStyle.Popup;
SendButton.Enabled = false;
};
Action move = () =>
{
Expand All @@ -545,6 +552,7 @@ await Task.Run(() =>
SendButton.BackColor = Color.FromArgb(225, 225, 225);
SendButton.FlatStyle = FlatStyle.Standard;
SendButton.Location = p;
SendButton.Enabled = true;
};
Invoke(change);
for (i = 0; i < 20; i++)
Expand Down Expand Up @@ -683,8 +691,9 @@ private void GMComboBox_SelectedIndexChanged(object sender, EventArgs e)

private void MessageTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsLetter(e.KeyChar) && (e.KeyChar != 8))
if (!char.IsLetter(e.KeyChar) && (e.KeyChar != 8) && (e.KeyChar != '-'))
e.Handled = true;
e.KeyChar = char.ToLower(e.KeyChar);
}

private void NameTextBox_KeyPress(object sender, KeyPressEventArgs e)
Expand Down
1 change: 1 addition & 0 deletions Slovo/Packets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ServerSecretPacket
public byte[] Secret;
public Guid guid;
public bool GameRun;
public StartPacket start;
}

[Serializable]
Expand Down
Binary file modified Slovo/bin/Debug/Slovo.exe
Binary file not shown.
Binary file modified Slovo/bin/Debug/Slovo.pdb
Binary file not shown.
Binary file modified Slovo/obj/Debug/Slovo.csproj.GenerateResource.cache
Binary file not shown.
Binary file modified Slovo/obj/Debug/Slovo.csprojAssemblyReference.cache
Binary file not shown.
Binary file modified Slovo/obj/Debug/Slovo.exe
Binary file not shown.
Binary file modified Slovo/obj/Debug/Slovo.pdb
Binary file not shown.

0 comments on commit e9abc34

Please sign in to comment.