mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-21 18:55:17 +00:00
Shine sync sending might crash the game, try catch it lol
This commit is contained in:
parent
d074f8a5d6
commit
3d4356ccfc
1 changed files with 15 additions and 5 deletions
|
@ -18,10 +18,14 @@ server.ClientJoined += async (c, type) => {
|
|||
};
|
||||
|
||||
async Task ClientSyncShineBag(Client client) {
|
||||
try {
|
||||
foreach (int shine in shineBag.Except((ConcurrentBag<int>) client.Metadata["shineSync"]))
|
||||
await client.Send(new ShinePacket {
|
||||
ShineId = shine
|
||||
});
|
||||
} catch {
|
||||
// errors that can happen when sending will crash the server :)
|
||||
}
|
||||
}
|
||||
|
||||
async void SyncShineBag() {
|
||||
|
@ -130,12 +134,18 @@ CommandHandler.RegisterCommand("flip", args => {
|
|||
});
|
||||
|
||||
CommandHandler.RegisterCommand("shine", args => {
|
||||
const string optionUsage = "Valid options: list";
|
||||
const string optionUsage = "Valid options: list, clear";
|
||||
if (args.Length < 1)
|
||||
return optionUsage;
|
||||
switch (args[0]) {
|
||||
case "list" when args.Length == 1:
|
||||
return $"Shines: {string.Join(", ", shineBag)}";
|
||||
case "clear" when args.Length == 1:
|
||||
shineBag.Clear();
|
||||
foreach (ConcurrentBag<int> playerBag in server.Clients.Select(serverClient => (ConcurrentBag<int>) serverClient.Metadata["shineSync"])) {
|
||||
playerBag.Clear();
|
||||
}
|
||||
return "Cleared shine bags";
|
||||
default:
|
||||
return optionUsage;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue