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) {
|
async Task ClientSyncShineBag(Client client) {
|
||||||
foreach (int shine in shineBag.Except((ConcurrentBag<int>) client.Metadata["shineSync"]))
|
try {
|
||||||
await client.Send(new ShinePacket {
|
foreach (int shine in shineBag.Except((ConcurrentBag<int>) client.Metadata["shineSync"]))
|
||||||
ShineId = shine
|
await client.Send(new ShinePacket {
|
||||||
});
|
ShineId = shine
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
// errors that can happen when sending will crash the server :)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async void SyncShineBag() {
|
async void SyncShineBag() {
|
||||||
|
@ -130,12 +134,18 @@ CommandHandler.RegisterCommand("flip", args => {
|
||||||
});
|
});
|
||||||
|
|
||||||
CommandHandler.RegisterCommand("shine", args => {
|
CommandHandler.RegisterCommand("shine", args => {
|
||||||
const string optionUsage = "Valid options: list";
|
const string optionUsage = "Valid options: list, clear";
|
||||||
if (args.Length < 1)
|
if (args.Length < 1)
|
||||||
return optionUsage;
|
return optionUsage;
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case "list" when args.Length == 1:
|
case "list" when args.Length == 1:
|
||||||
return $"Shines: {string.Join(", ", shineBag)}";
|
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:
|
default:
|
||||||
return optionUsage;
|
return optionUsage;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue