0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-21 18:55:17 +00:00
Commit graph

226 commits

Author SHA1 Message Date
Aubrey
6ec213b4be Update TagPacket.cs 2024-06-21 15:24:31 -06:00
Robin C. Ladiges
3affb59eb9 fix: tag seeking command send new state to all players 2024-06-21 15:24:31 -06:00
Robin C. Ladiges
7a055be9cf fix: tag time command send new time to all players 2024-06-21 15:24:31 -06:00
Robin C. Ladiges
d69d9b8296 fix: let tag start also send the new role to the actual players
Broadcast() with a sender never sends the packet to the sender.
Therefore only other players got informed about the new role.
But never the actual player that is supposed to change to that role.
2024-06-21 15:24:31 -06:00
Robin C. Ladiges
fb55820e2b fix: properly handling minutes
Seconds are only one byte big and not two, so the Minutes start at byte 3 and not 4.
2024-06-21 15:24:31 -06:00
Robin C. Ladiges
bec6dde076 refac the "speedrun" mode
By not detecting new saves correctly before, players were sent all moons while still being in cap kingdom.
Having those moons made the game crash if the cutscenes from cap to cascade were skipped.

Changes:
- Rename: `speedrun => `disableShineSync`.
- Correctly detect new saves by scenario 1 instead of 0.
- Let all stages that are not cap in scenario 1 enable shine sync again (e.g. for switching back to an older save).
- Only disable shine sync once and not on every stage change (e.g. when entering cap overworld again and again).
- Disable shine bag clearing by default, option to enable it again via `Shines/ClearOnNewSaves` (for speedruns).
- Persist shines after clearing (otherwise a server crash/restart might load old moons from a previous run and sync them).
- Clear only once per player till reaching cascade (otherwise collected moons might be cleared mid-run).
- Reduce delay from 15s to 2s (even w/o a delay I couldn't reproduce a crash, but keeping it feels safer).
- Only enable shine sync again after the delay, the delay was circumvented before by other tasks triggering shine sync earlier.
2024-06-21 14:53:56 -06:00
Robin C. Ladiges
497b5b44d6 fix: KeyNotFoundException
KeyNotFoundException: The given key 'time' was not present in the dictionary.
2024-04-27 17:11:13 -04:00
Robin C. Ladiges
4de654b6e4 ignore & crash instead of disconnect clients after reaching the MaxPlayers limit
Otherwise they'll enter an endless disconnect-reconnnect loop spamming the server with new TCP connections.
2024-04-27 15:14:38 -04:00
Robin C. Ladiges
082e480b1e crash ignored players
Otherwise they keep sending all their packets (including positional updates) to the server which costs bandwidth and processing power.
2024-04-27 15:14:38 -04:00
Robin C. Ladiges
9511d07f09 send server init after the client init
To make service discovery by internet scan bots harder.
2024-04-27 15:14:38 -04:00
Robin C. Ladiges
dc20a9c831 small refactorings
- use brackets when possible
- set client.Id and client.Name earlier
- use client.Id instead of header.Id
- rename firstConn to isClientNew
2024-04-27 15:14:38 -04:00
Robin C. Ladiges
61e6fcf2a3 new setting: Shines/Excluded
To exclude specific shines to be synced to other clients.

Pre-initialized with shine 496 (Moon Shards in the Sand) that causes people to get stuck in front of the inverted pyramid.

This commit fixes issue #31
2024-04-27 14:46:43 -04:00
Robin C. Ladiges
20ee74d0d6 fix: construct tag packet instead of caching it in memory
Because the tag packet received from the client could have an UpdateType that isn't both State and Time.
(Though currently the client always updates both together.)
2024-04-27 14:45:41 -04:00
Robin C. Ladiges
dd0de0da78 build binary files via docker 2023-09-05 17:23:18 -06:00
Robin C. Ladiges
d6a8df448c
Refactoring ban command (#48)
* rename command: `ban ...` => `ban player ...`

To enable adding other subcommands starting with `ban`.

Moving ban list and crash related code into its own class to tidy the Program class up.

Change Id values of the crash cmds, to fit into the 16 byte max length imposed by ChangeStagePacket.IdSize.

* add command: `ban ip <ipv4-address>`

To add an IPv4 address to the ban list.

* add command: `ban profile <profile-id>`

To add a profile ID to the ban list.

* add command: `unban ip <ipv4-address>`

To remove a banned IPv4 address from the ban list.

* add command: `unban profile <profile-id>`

To remove a banned profile ID from the ban list.

* add commands: `ban enable` and `ban disable`

To set the value of `BanList.Enabled` to `true` or `false` without editing the `settings.json` file.

* add command: `ban list`

To show the current ban list settings.

* fix: actually working ban functionality

Changes:
- ignore new sockets from banned IP addresses way earlier.
- ignore all packets by banned profiles.

Intentionally keeping the connection open instead of d/c banned clients.
This is to prevent endless server logs due to automatically reconnecting clients.

Before:
Reconnecting clients aren't entering `ClientJoined` and therefore the d/c is only working on first connections.
Effectively banned clients got a d/c and then automatically reconnected again without getting a d/c again.
Therefore allowing them to play normally.

* use SortedSet instead of List for settings

To enforce unique entries and maintain a stable order inside of the `settings.json`.

* add commands: `ban stage <stage-name>` and `unban stage <stage-name>`

To kick players from the server when they enter a banned stage.

<stage-name> can also be a kingdom alias, which bans/unbans all stages in that kingdom.

Because we aren't banning the player, d/c them would be no good, because of the client auto reconnect.
Instead send them the crash and ignore all packets by them until they d/c on their own.

This is an alternative solution for issue #43.

* Update Server.cs

---------

Co-authored-by: Sanae <32604996+Sanae6@users.noreply.github.com>
2023-09-05 17:14:54 -06:00
Robin C. Ladiges
86c79177fd fix: synchronization issues
- Send empty `TagPacket` and `CapturePacket` on new connections, to reset old data back that other players might still have in their puppet from an
earlier connection.
- Cache and send `CostumePacket`, `CapturePacket`, `TagPacket`, `GamePacket` and `PlayerPacket` to (re-)connecting players.
- Clear Metadata cache for existing clients that connect fresh (after a game restart).
2023-09-05 16:51:58 -06:00
Robin C. Ladiges
1e9d334d6f fix: wrong kingdom values and order like presented in-game 2023-07-25 14:10:54 -06:00
Robin C. Ladiges
71bb96bf1e verify stage values for send and sendall
Changes:
- Moved alias mapping from Constants.cs to Stages.cs.
- Added `odyssey` as an alias.
- Hardcoded all known stage values.
- Verfify that the stage input is either a alias or a known stage name.
- Added an option to append `!` to a stage name to force sending even if the stage is not known (e.g. for custom kingdoms).

Before it only checked that it was a known alias or that it contained `Stage` or `Zone`.
That made it impossible to send players to`MoonWorldShopRoom` and `MoonWorldSphinxRoom`.
And a typo would have resulted in a game crash.
2023-03-22 16:50:38 -06:00
Robin C. Ladiges
47fc1527bf fix: don't process and broadcast shine packets when shine sync is disabled
The breaks make the function return true, which causes the shine packets to be broadcasted to all connected clients.
Returning false will prevent the broadcast of the current shine packet.

Note: If shines are enabled, the clients will receive every shine twice.
Once from the `SyncShineBag();` and then a second time from the default broadcast caused by the remaining breaks.
We should probably replace every `break;` with `return false;` here?
2022-12-16 13:18:07 -06:00
Robin C. Ladiges
a0642e6a30 fix: only send shines to connected clients and save only after sending
otherwise it will save that the client got it to the bag and then fail sending it, therefore forever preventing the client to get the shine.
2022-12-16 13:18:07 -06:00
Robin C. Ladiges
f0d837190a only warn about the Discord channel settings when a Token is set
Servers that don't use Discord (default settings) don't need to be warned about not setting Discord channels.
2022-10-10 19:37:37 -06:00
Robin C. Ladiges
122a3cd80d fix: don't output empty player IDs or RemoteEndPoints in the log
Make and use a copy of the RemoteEndPoint at the start of the HandleSocket method.
Because in some cases when the socket is disposed, the RemoteEndPoint inside of it is cleared and isn't available for the following disconnect log entries.
Also: port scanners on the internet don't introduce themselves with a name and ID.

(cherry picked from commit 2f4cd0509a)
2022-10-10 11:13:32 -06:00
Robin C. Ladiges
69cef89953 fix: on reconnect do not disconnect the new client
Currently when a client connects that is already there,
the old socket is closed, and the code tries to reuse the existing client object by exchanging its socket.

Reusing the same client object and just changing its socket does cause issues though with copies of the client in other threads.
In the situations that I could reproduce, it always disconnected both sockets, the old one and then the new one.

Instead I make a copy of the client object, use the new socket, remove the old object and add the new object to the collection.

(cherry picked from commit 9e6c312c8e)
2022-10-10 11:12:28 -06:00
Robin C. Ladiges
6285abfc4e slightly increase docker build
The restore command doesn't need the full source code, but just the .csproj files.

(cherry picked from commit 391d020385)
2022-10-10 11:10:19 -06:00
Robin C. Ladiges
472c8856bc move the client.CurrentCostume update to the PacketHandler and log the packet
(cherry picked from commit 47505dbdd5)
2022-10-10 11:09:39 -06:00
Robin C. Ladiges
53442b598e only start listening for clients once everything is initialized
Otherwise clients might connect to the server before everything is ready for them.
E.g. when restarting the server, the clients will immediately try to reconnect.

Clients might connect before the `PacketHandler` is initialized, which results in some packets not being processed by the server correctly.

Same goes for the commands: Discord might send in commands before all commands were added to the `CommandHandler`.

Without the `ClientJoined` action, clients might even be allowed to connect if they are on the banlist.
(Though without this initialization they or regular clients might be broken in some ways?)

(cherry picked from commit 92e540aaa6)
2022-10-10 11:08:38 -06:00
Robin C. Ladiges
92d4bdd195 better DiscordBot channel exceptions
currently it always outputs `Failed to get log channel \"{Config.CommandChannel}\"` regardless if the error was with the command channel or the log channel.

await Run(); doesn't need to be in a try-catch block, because it has a try-catch block itself in it.
2022-09-07 10:36:57 -06:00
Robin C. Ladiges
c41499f953 remove unused label
git cherry-pick accidentially picked up a line from another commit for the JSON API
2022-09-07 10:35:26 -06:00
Robin C. Ladiges
76fc4a80a6 only broadcast the DisconnectPacket if the client was connected
Otherwise port scans, banned players or clients failing to initialize correctly,
will cause the server to send unnecessary packets to all connected clients.

They currently are informed about a disconnect for a client that hasn't even connected correctly.

(cherry picked from commit 4b04a3d5be)
2022-09-07 10:35:26 -06:00
Jack Baron
e14616030c move clear task 2022-09-05 18:56:24 -06:00
Jack Baron
24a34c35a1 ignore file not found errors 2022-09-05 18:56:24 -06:00
TheUbMunster
783b876e09 You can run commands in the command channel or log channel 2022-08-22 18:58:42 -06:00
TheUbMunster
4d743b3e1b Made changes for pr, cleaned up formatting 2022-08-22 18:58:42 -06:00
TheUbMunster
67a740dec9 By default bot does not respond to dm with error message 2022-08-22 18:58:42 -06:00
TheUbMunster
4c4ce35f14 Removed some log messages as they would trigger before prefix checking, would start spamming the server if they remained 2022-08-22 18:58:42 -06:00
TheUbMunster
86fb18962f Differentiated command channel and log channel 2022-08-22 18:58:42 -06:00
TheUbMunster
06e3b5d40a Made debug message simpler 2022-08-22 18:58:42 -06:00
TheUbMunster
02f936816c Clarified log message 2022-08-22 18:58:42 -06:00
TheUbMunster
82e94334c9 added log message that prints the channel the command came from and the channel commands are accepted from 2022-08-22 18:58:42 -06:00
TheUbMunster
b6e634ada4 changed isPrivate check to type check of "is DiscordDmChannel" 2022-08-22 18:58:42 -06:00
TheUbMunster
d828a704c1 Updated with Sanae's no private channel logic.
Behavior: No DM'ing commands under any circumstance
if Config.LogChannel == null, commands can be in any non-private channel
if Config.LogChannel != null, commands can only be in the log channel
2022-08-22 18:58:42 -06:00
TheUbMunster
08d1020770 You can no longer dm a bot for a command (has been tested) 2022-08-22 18:58:42 -06:00
Sanae
9c01f30c5e Add the ability to disable shine sync 2022-08-20 23:31:31 -06:00
Piplup
cee8bd580f cleared up some confusion 2022-08-10 15:04:00 -06:00
Piplup
fa1db28037 added PersistShines 2022-08-10 15:04:00 -06:00
raym55
c86be55717 PIPERS 2022-08-10 15:03:34 -06:00
Piplup
31361d54ca a little change to the readme 2022-08-02 18:01:59 -06:00
Piplup
427acbcf88 updated readme with tty inputs 2022-08-02 18:01:59 -06:00
Piplup
75eea98d8e added TTY input 2022-08-02 18:01:59 -06:00
Sanae
e7a3347a37
Merge pull request #19 from TheUbMunster/restart-command 2022-07-29 13:19:04 -06:00