Skip to content

Commit

Permalink
Removed unnecessary async/await
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcidev committed Aug 27, 2024
1 parent 55b5c32 commit cb3585e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Client.UI/ViewModels/Cards/PlayableCardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ private void OnSpellAurasChanged()
});
}

private async Task UseCardAction()
private Task UseCardAction()
{
if (SelectionType != SelectionType.BasicDamageAttackable && SelectionType != SelectionType.SpellUsable)
return;
return Task.CompletedTask;

var packet = new Packet(CMSGPackets.CardAction).Builder()
.WriteGuidBitStreamInOrder(card.Guid, 4, 3, 2, 7, 1, 6, 0, 5)
Expand All @@ -85,7 +85,7 @@ private async Task UseCardAction()
.WriteGuidByteStreamInOrder(card.Guid, 5, 3, 4)
.Build();

await card.Player.Game.SendPacketAsync(packet);
return card.Player.Game.SendPacketAsync(packet);
}
}
}
22 changes: 11 additions & 11 deletions Client.UI/ViewModels/MainGame/ChatWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private void HandleInvalidCommand()
});
}

private async Task HandleWhisperCommand(string arg)
private Task HandleWhisperCommand(string arg)
{
void FormatSyntaxError()
{
Expand All @@ -204,7 +204,7 @@ void FormatSyntaxError()
if (string.IsNullOrWhiteSpace(arg) || (commandDelimiter <= 0))
{
FormatSyntaxError();
return;
return Task.CompletedTask;
}

string receiverName = arg[..commandDelimiter];
Expand All @@ -213,14 +213,14 @@ void FormatSyntaxError()
if (message.Length == 0)
{
FormatSyntaxError();
return;
return Task.CompletedTask;
}

parent.SetActiveChat(ChatType.Whisper, receiverName, true);
await parent.Game.Chat.SendMessage(message, ChatType.Whisper, receiverName);
return parent.Game.Chat.SendMessage(message, ChatType.Whisper, receiverName);
}

private async Task HandleFriendCommand(string arg)
private Task HandleFriendCommand(string arg)
{
const string addFriend = "add";
const string acceptFriend = "accept";
Expand All @@ -239,7 +239,7 @@ void FormatSyntaxError()
if (string.IsNullOrWhiteSpace(arg) || (commandDelimiter <= 0))
{
FormatSyntaxError();
return;
return Task.CompletedTask;
}

string command = arg[..commandDelimiter];
Expand All @@ -262,24 +262,24 @@ void FormatSyntaxError()
break;
default:
FormatSyntaxError();
return;
return Task.CompletedTask;
}

var packet = new Packet((UInt16)CMSGPackets.UserRelation).Builder()
.Write(name).Write((byte)action).Build();

await parent.Game.SendPacketAsync(packet);
return parent.Game.SendPacketAsync(packet);
}

private async Task HandleBlockCommand(string name, bool block)
private Task HandleBlockCommand(string name, bool block)
{
if (string.IsNullOrWhiteSpace(name))
return;
return Task.CompletedTask;

var packet = new Packet((UInt16)CMSGPackets.UserRelation).Builder()
.Write(name).Write((byte)(block ? UserRelationAction.BlockUser : UserRelationAction.RemoveBlockedUser)).Build();

await parent.Game.SendPacketAsync(packet);
return parent.Game.SendPacketAsync(packet);
}
}
}
4 changes: 2 additions & 2 deletions Client.UI/ViewModels/MainGame/SelectCardsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public SelectCardsViewModel()
SendSelectedCardsCommand = new (SendSelectedCards, () => selectedItems?.Count == 5);
}

private async Task SendSelectedCards()
private Task SendSelectedCards()
{
var packet = new Packet(CMSGPackets.SelectedCards);

packet.Write((byte)selectedItems.Count);
foreach (var card in selectedItems.Cast<SelectableCardViewModel>())
packet.Write(card.Id);

await game.SendPacketAsync(packet);
return game.SendPacketAsync(packet);
}

private void SelectItems(object obj)
Expand Down
6 changes: 3 additions & 3 deletions Client.UI/ViewModels/User/UserListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ private void ReloadBlockedUsers()
});
}

private static async Task HandlerUser(string name, UserRelationAction action)
private static Task HandlerUser(string name, UserRelationAction action)
{
if (string.IsNullOrEmpty(name))
return;
return Task.CompletedTask;

var game = App.GetGame();
var packet = new Packet((UInt16)CMSGPackets.UserRelation).Builder()
.Write(name).Write((byte)action).Build();

await game.SendPacketAsync(packet);
return game.SendPacketAsync(packet);
}
}
}

0 comments on commit cb3585e

Please sign in to comment.