mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-22 03:05:16 +00:00
Potentially fix scenario shine sync for first moon
This commit is contained in:
parent
46bae93502
commit
4dee13a9d7
1 changed files with 20 additions and 4 deletions
|
@ -17,6 +17,7 @@ server.ClientJoined += (c, _) => {
|
|||
c.Metadata["loadedSave"] = false;
|
||||
c.Metadata["scenario"] = 0;
|
||||
c.Metadata["2d"] = false;
|
||||
c.Metadata["speedrun"] = false;
|
||||
foreach (Client client in server.Clients.Where(client => client.Metadata.ContainsKey("lastGamePacket")).ToArray()) {
|
||||
try {
|
||||
Task.WaitAll(c.Send((GamePacket) client.Metadata["lastGamePacket"]!, client));
|
||||
|
@ -28,7 +29,7 @@ server.ClientJoined += (c, _) => {
|
|||
|
||||
c.PacketTransformer += (_, packet) => {
|
||||
if (Settings.Instance.Scenario.MergeEnabled && packet is GamePacket gamePacket) {
|
||||
gamePacket.ScenarioNum = (byte?) c.Metadata["scenario"] ?? 0;
|
||||
gamePacket.ScenarioNum = (byte?) c.Metadata["scenario"] ?? 200;
|
||||
return gamePacket;
|
||||
}
|
||||
|
||||
|
@ -38,6 +39,7 @@ server.ClientJoined += (c, _) => {
|
|||
|
||||
async Task ClientSyncShineBag(Client client) {
|
||||
try {
|
||||
if ((bool?) client.Metadata["speedrun"] ?? false) return;
|
||||
ConcurrentBag<int> clientBag = (ConcurrentBag<int>) (client.Metadata["shineSync"] ??= new ConcurrentBag<int>());
|
||||
foreach (int shine in shineBag.Except(clientBag).ToArray()) {
|
||||
clientBag.Add(shine);
|
||||
|
@ -77,6 +79,17 @@ server.PacketHandler = (c, p) => {
|
|||
c.Metadata["scenario"] = gamePacket.ScenarioNum;
|
||||
c.Metadata["2d"] = gamePacket.Is2d;
|
||||
c.Metadata["lastGamePacket"] = gamePacket;
|
||||
switch (gamePacket.Stage) {
|
||||
case "CapWorldHomeStage" when gamePacket.ScenarioNum == 0:
|
||||
c.Metadata["speedrun"] = true;
|
||||
ConcurrentBag<int> clientBag = (ConcurrentBag<int>) (c.Metadata["shineSync"] ??= new ConcurrentBag<int>());
|
||||
clientBag.Clear();
|
||||
break;
|
||||
case "WaterfallWorldHomeStage" when gamePacket.ScenarioNum > 0:
|
||||
c.Metadata["speedrun"] = false;
|
||||
ClientSyncShineBag(c);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TagPacket tagPacket: {
|
||||
|
@ -175,7 +188,7 @@ CommandHandler.RegisterCommand("sendall", args => {
|
|||
});
|
||||
|
||||
CommandHandler.RegisterCommand("scenario", args => {
|
||||
const string optionUsage = "Valid options: merge <true/false>";
|
||||
const string optionUsage = "Valid options: merge [true/false]";
|
||||
if (args.Length < 1)
|
||||
return optionUsage;
|
||||
switch (args[0]) {
|
||||
|
@ -188,6 +201,9 @@ CommandHandler.RegisterCommand("scenario", args => {
|
|||
|
||||
return optionUsage;
|
||||
}
|
||||
case "merge" when args.Length == 1: {
|
||||
return $"Scenario merging is {(Settings.Instance.Scenario.MergeEnabled)}";
|
||||
}
|
||||
default:
|
||||
return optionUsage;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue