├── .gitattributes ├── .gitignore ├── Fishy.sln ├── Fishy ├── Chat │ ├── CommandHandler.cs │ └── Commands │ │ ├── Info.cs │ │ └── Moderation.cs ├── Dependencies │ ├── libsteam_api.so │ ├── steam_api.dll │ └── steam_api64.dll ├── Event │ └── EventManager.cs ├── Extensions │ ├── ExtensionLoader.cs │ └── FishyExtension.cs ├── Fishy.cs ├── Fishy.csproj ├── Helper │ ├── Extensions.cs │ └── GZip.cs ├── Models │ ├── Actor.cs │ ├── Config.cs │ ├── Packets │ │ ├── ActorRemovePacket.cs │ │ ├── ActorRequestPacket.cs │ │ ├── ActorSpawnPacket.cs │ │ ├── ActorUpdatePacket.cs │ │ ├── BanPacket.cs │ │ ├── ChalkPacket.cs │ │ ├── FPacket.cs │ │ ├── ForceDisconnectPacket.cs │ │ ├── HandshakePacket.cs │ │ ├── HostPacket.cs │ │ ├── KickPacket.cs │ │ ├── LetterPacket.cs │ │ ├── MessagePacket.cs │ │ ├── PingPongPacket.cs │ │ └── ServerClosePacket.cs │ ├── Player.cs │ ├── ScheduledTask.cs │ └── World.cs ├── Plugins │ ├── Fishy.Webserver.deps.json │ ├── Fishy.Webserver.dll │ └── Fishy.Webserver.runtimeconfig.json ├── Program.cs ├── Utils │ ├── ChatLogger.cs │ ├── ChatUtils.cs │ ├── GodotUtils.cs │ ├── NetworkHandler.cs │ ├── Punish.cs │ ├── Spawner.cs │ └── SteamHandler.cs ├── bans.txt └── config.toml ├── FishyWebserver ├── ActionController.cs ├── Authentication.cs ├── Dashboard.cs ├── Fishy.Webserver.csproj ├── FodyWeavers.xml ├── WebserverExtension.cs └── index.html ├── LICENSE.txt └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd 364 | 365 | *.tscn 366 | /Fishy/config.toml 367 | -------------------------------------------------------------------------------- /Fishy.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34330.188 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fishy", "Fishy\Fishy.csproj", "{9FDA0DD9-9DD0-4B68-822D-6C9F4ABECA00}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fishy.Webserver", "FishyWebserver\Fishy.Webserver.csproj", "{8A09A18E-6F40-4641-991E-0AAB7B5483BE}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {9FDA0DD9-9DD0-4B68-822D-6C9F4ABECA00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {9FDA0DD9-9DD0-4B68-822D-6C9F4ABECA00}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {9FDA0DD9-9DD0-4B68-822D-6C9F4ABECA00}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {9FDA0DD9-9DD0-4B68-822D-6C9F4ABECA00}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {8A09A18E-6F40-4641-991E-0AAB7B5483BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {8A09A18E-6F40-4641-991E-0AAB7B5483BE}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {8A09A18E-6F40-4641-991E-0AAB7B5483BE}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {8A09A18E-6F40-4641-991E-0AAB7B5483BE}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {FAC88ADD-4762-482B-830F-0766ED64CE5F} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Fishy/Chat/CommandHandler.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Utils; 2 | using Steamworks; 3 | 4 | namespace Fishy.Chat 5 | { 6 | public enum PermissionLevel 7 | { 8 | Player = 0, 9 | Admin = 1, 10 | Server = 100, 11 | } 12 | 13 | public class CommandHandler 14 | { 15 | public static Dictionary Commands = []; 16 | 17 | public static void AddCommand(Command cmd) 18 | => Commands.Add(cmd.Name, cmd); 19 | 20 | public static void Init() 21 | { 22 | AddCommand(new Commands.HelpCommand()); 23 | AddCommand(new Commands.RulesCommand()); 24 | AddCommand(new Commands.IssueCommand()); 25 | AddCommand(new Commands.ReportCommand()); 26 | AddCommand(new Commands.SpawnCommand()); 27 | AddCommand(new Commands.CodeOnlyCommand()); 28 | AddCommand(new Commands.BanCommand()); 29 | AddCommand(new Commands.KickCommand()); 30 | AddCommand(new Commands.SetAdmin()); 31 | AddCommand(new Commands.RevokeAdmin()); 32 | AddCommand(new Commands.StopCommand()); 33 | } 34 | 35 | public static int GetPermissionLevel(SteamId player) // Temporary, ideally will have ranks 36 | { 37 | if (player == SteamClient.SteamId) // If player is server 38 | return (int)PermissionLevel.Server; 39 | 40 | return Fishy.Config.Admins.Contains(player.ToString()) ? (int)PermissionLevel.Admin : (int)PermissionLevel.Player; 41 | } 42 | 43 | public static bool OnMessage(SteamId from, string message) 44 | { 45 | if (!message.StartsWith('!')) 46 | return false; 47 | 48 | string commandName = message.Remove(0, 1).Split(" ")[0]; 49 | string[] arguments = message.Split(" ").Skip(1).ToArray(); 50 | 51 | if (!Commands.TryGetValue(commandName, out Command? cmd)) 52 | { 53 | ChatUtils.SendChat(from, $"Command \"{commandName}\" does not exist!", "bb1111"); 54 | return true; 55 | } 56 | 57 | if ((int)cmd.PermissionLevel > GetPermissionLevel(from)) 58 | { 59 | ChatUtils.SendChat(from, $"You don't have permission to use \"{commandName}\"!", "bb1111"); 60 | return true; 61 | } 62 | 63 | ChatLogger.Log(new ChatMessage(default, $"Player {from} executed command {commandName} with arguments {string.Join(", ", arguments)}")); 64 | 65 | try 66 | { 67 | cmd.OnUse(from, arguments); 68 | } 69 | catch (Exception ex) 70 | { 71 | Console.WriteLine($"Error occured while running command \"{commandName}\" {ex}"); 72 | } 73 | return true; 74 | } 75 | } 76 | 77 | public abstract class Command 78 | { 79 | public virtual string Name { get; set; } = ""; 80 | public virtual string[] Aliases { get; set; } = []; 81 | public virtual PermissionLevel PermissionLevel { get; set; } = PermissionLevel.Player; 82 | public virtual string Description { get; set; } = ""; 83 | public virtual string Help { get; set; } = ""; 84 | 85 | public virtual void OnUse(SteamId player, string[] arguments) { } 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /Fishy/Chat/Commands/Info.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Utils; 2 | using Steamworks; 3 | namespace Fishy.Chat.Commands 4 | { 5 | internal class HelpCommand : Command 6 | { 7 | public override string Name => "help"; 8 | public override string Description => "Displays this info text"; 9 | public override PermissionLevel PermissionLevel => PermissionLevel.Player; 10 | public override string[] Aliases => []; 11 | public override string Help => ""; 12 | 13 | public override void OnUse(SteamId executor, string[] arguments) 14 | { 15 | ChatUtils.SendChat(executor, "The following commands are available: ", "aaffa1"); 16 | foreach (var item in CommandHandler.Commands) 17 | { 18 | if ((int)item.Value.PermissionLevel > CommandHandler.GetPermissionLevel(executor)) 19 | continue; 20 | ChatUtils.SendChat(executor, $"!{item.Key} - {item.Value.Description}"); 21 | } 22 | } 23 | } 24 | 25 | internal class RulesCommand : Command 26 | { 27 | public override string Name => "rules"; 28 | public override string Description => "Displays the rules"; 29 | public override PermissionLevel PermissionLevel => PermissionLevel.Player; 30 | public override string[] Aliases => []; 31 | public override string Help => ""; 32 | 33 | public override void OnUse(SteamId executor, string[] arguments) 34 | { 35 | ChatUtils.SendChat(executor, $"Rules:", "aabbff"); 36 | for (int i = 0; i < Fishy.Config.Rules.Length; i++) 37 | { 38 | ChatUtils.SendChat(executor, $"{i+1}. {Fishy.Config.Rules[i]}"); 39 | } 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Fishy/Chat/Commands/Moderation.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Models; 2 | using Fishy.Models.Packets; 3 | using Fishy.Utils; 4 | using Steamworks; 5 | using System.Text; 6 | 7 | namespace Fishy.Chat.Commands 8 | { 9 | internal class StopCommand : Command 10 | { 11 | public override string Name => "stop"; 12 | public override string Description => "Shuts down the server"; 13 | public override PermissionLevel PermissionLevel => PermissionLevel.Admin; 14 | public override string[] Aliases => ["halt"]; 15 | public override string Help => "!stop"; 16 | 17 | public override void OnUse(SteamId executor, string[] arguments) 18 | { 19 | Console.WriteLine("Server was halted by " + executor); 20 | 21 | new ServerClosePacket().SendPacket("all", (int)CHANNELS.GAME_STATE); 22 | Fishy.SteamHandler.Lobby.SetJoinable(false); // Prevent takeover of lobby 23 | foreach (var pl in Fishy.Players) // Kick all players 24 | Punish.KickPlayer(pl); 25 | Fishy.SteamHandler.Lobby.Leave(); 26 | Environment.Exit(0); 27 | } 28 | } 29 | 30 | internal class KickCommand : Command 31 | { 32 | public override string Name => "kick"; 33 | public override string Description => "Kick a player"; 34 | public override PermissionLevel PermissionLevel => PermissionLevel.Admin; 35 | public override string[] Aliases => []; 36 | public override string Help => "!kick player"; 37 | 38 | public override void OnUse(SteamId executor, string[] arguments) 39 | { 40 | if (arguments.Length == 0) { ChatUtils.SendChat(executor, Help); return; } 41 | 42 | Player? playerToKick = ChatUtils.FindPlayer(arguments[0]); 43 | 44 | if (playerToKick == null) 45 | return; 46 | 47 | Punish.KickPlayer(playerToKick); 48 | 49 | ChatUtils.SendChat(executor, $"Kicked player {playerToKick.Name} {playerToKick.SteamID}"); 50 | } 51 | } 52 | internal class BanCommand : Command 53 | { 54 | public override string Name => "ban"; 55 | public override string Description => "Ban a player"; 56 | public override PermissionLevel PermissionLevel => PermissionLevel.Admin; 57 | public override string[] Aliases => []; 58 | public override string Help => "!ban player"; 59 | 60 | public override void OnUse(SteamId executor, string[] arguments) 61 | { 62 | if (arguments.Length == 0) { ChatUtils.SendChat(executor, Help); return; } 63 | 64 | Player? playerToBan = ChatUtils.FindPlayer(arguments[0]); 65 | 66 | if (playerToBan == null) 67 | return; 68 | 69 | Punish.BanPlayer(playerToBan); 70 | ChatUtils.SendChat(executor, $"Banned player {playerToBan.Name} {playerToBan.SteamID}"); 71 | } 72 | } 73 | internal class SpawnCommand : Command 74 | { 75 | public override string Name => "spawn"; 76 | public override string Description => "Spawn an entity"; 77 | public override PermissionLevel PermissionLevel => PermissionLevel.Admin; 78 | public override string[] Aliases => []; 79 | public override string Help 80 | { 81 | get 82 | { 83 | StringBuilder result = new StringBuilder(); 84 | result.AppendLine("!spawn type [force]\nAvailable default types: "); 85 | 86 | foreach (string typeName in Actor.ActorTypesByName.Keys) 87 | { 88 | result.AppendLine(typeName); 89 | } 90 | 91 | return result.ToString(); 92 | } 93 | } 94 | 95 | 96 | public override void OnUse(SteamId executor, string[] arguments) 97 | { 98 | if (arguments.Length == 0) { ChatUtils.SendChat(executor, Help); return; } 99 | 100 | string actorTypeName = arguments[0]; 101 | 102 | if (Actor.ActorTypesByName.ContainsKey(actorTypeName)) 103 | { 104 | Spawner.VanillaSpawn(Actor.ActorTypesByName[actorTypeName]); 105 | ChatUtils.SendChat(executor, $"A {actorTypeName} has been spawned!"); 106 | } 107 | else if (arguments.Length > 1 && arguments[1] == "force") 108 | { 109 | Player? player = ChatUtils.FindPlayer(arguments[0]); 110 | Spawner.SpawnActor(new Actor(Spawner.GetFreeId(), actorTypeName, player.Position)); 111 | ChatUtils.SendChat(executor, $"A {actorTypeName} has been spawned!"); 112 | } 113 | else 114 | { 115 | ChatUtils.SendChat(executor, $"No actor with the name {actorTypeName} is known. Add the 'force' argument to try anyway."); 116 | } 117 | } 118 | } 119 | 120 | internal class CodeOnlyCommand : Command 121 | { 122 | public override string Name => "codeonly"; 123 | public override string Description =>"sets lobby type"; 124 | public override PermissionLevel PermissionLevel => PermissionLevel.Admin; 125 | public override string[] Aliases => []; 126 | public override string Help => "!codeonly true/false"; 127 | 128 | public override void OnUse(SteamId executor, string[] arguments) 129 | { 130 | if (arguments.Length == 0) { ChatUtils.SendChat(executor, Help); return; } 131 | 132 | string type = arguments[0] == "true" ? "code_only" : "public"; 133 | 134 | Fishy.SteamHandler.Lobby.SetData("type", type); 135 | 136 | ChatUtils.SendChat(executor, "The lobby type has been set to: " + type); 137 | } 138 | } 139 | 140 | internal class ReportCommand : Command 141 | { 142 | public override string Name => "report"; 143 | public override string Description => "Report a player"; 144 | public override PermissionLevel PermissionLevel => PermissionLevel.Player; 145 | public override string[] Aliases => []; 146 | public override string Help => "!report player reason"; 147 | 148 | public override void OnUse(SteamId executor, string[] arguments) 149 | { 150 | if (arguments.Length < 2) { ChatUtils.SendChat(executor, Help); return; } 151 | 152 | string reportPath = Path.Combine(AppContext.BaseDirectory, Fishy.Config.ReportFolder, DateTime.Now.ToString("ddMMyyyyHHmmss") + arguments[0] + ".txt"); 153 | string report = "Report for user: " + arguments[0]; 154 | 155 | report += "\nReason: " + String.Join(" ", arguments[1..]); 156 | report += "\nChat Log:\n\n"; 157 | 158 | string chatLog = String.Empty; 159 | Player? player = Fishy.Players.FirstOrDefault(p => p.Name.Equals(arguments[0])); 160 | 161 | if (player != null) 162 | chatLog = ChatLogger.GetLog(player.SteamID); 163 | else 164 | chatLog = ChatLogger.GetLog(); 165 | 166 | File.WriteAllText(reportPath, report + ChatLogger.GetLog()); 167 | ChatUtils.SendChat(executor, Fishy.Config.ReportResponse, "b30000"); 168 | } 169 | } 170 | internal class IssueCommand : Command 171 | { 172 | public override string Name => "issue"; 173 | public override string Description =>"Report an issue"; 174 | public override PermissionLevel PermissionLevel => PermissionLevel.Player; 175 | public override string Help => "!issue description"; 176 | public override string[] Aliases => []; 177 | 178 | public override void OnUse(SteamId executor, string[] arguments) 179 | { 180 | if (arguments.Length == 0) { ChatUtils.SendChat(executor, Help); return; }; 181 | 182 | string issuePath = Path.Combine(AppContext.BaseDirectory, Fishy.Config.ReportFolder, DateTime.Now.ToString("ddMMyyyyHHmmss") + "issueReport.txt"); 183 | string issueReport = "Issue Report\n" + String.Join(" ", arguments[0..]); 184 | 185 | File.WriteAllText(issuePath, issueReport); 186 | ChatUtils.SendChat(executor, "Your issues has been received and will be looked at as soon as possible.", "b30000"); 187 | } 188 | } 189 | internal class SetAdmin : Command 190 | { 191 | public override string Name => "setadmin"; 192 | public override string Description => "set a player to admin temporally (CONSOLE ONLY)"; 193 | public override PermissionLevel PermissionLevel => PermissionLevel.Server; 194 | public override string Help => "!setadmin name/steamid"; 195 | public override string[] Aliases => []; 196 | 197 | public override void OnUse(SteamId executor, string[] arguments) 198 | { 199 | if (arguments.Length == 0) { ChatUtils.SendChat(executor, Help); return; }; 200 | Player? player = ChatUtils.FindPlayer(arguments[0]); 201 | if (player == null) 202 | { 203 | ChatUtils.SendChat(executor, $"Couldn't find player\"{arguments[0]}\"!"); 204 | return; 205 | } 206 | if (Fishy.Config.Admins.Contains(player.SteamID.ToString())) 207 | { 208 | ChatUtils.SendChat(executor, $"{player.Name} ({player.SteamID}) is already an admin!", "ffaaaa"); 209 | return; 210 | } 211 | Fishy.Config.Admins.Add(player.SteamID.ToString()); 212 | // Todo save config, might require some config rework too :( 213 | ChatUtils.SendChat(executor, $"Set {player.Name} ({player.SteamID}) to admin!", "aaffaa"); 214 | ChatUtils.BroadcastChat($"{player.Name} ({player.SteamID}) was promoted to admin!", "aaffaa"); 215 | } 216 | } 217 | internal class RevokeAdmin : Command 218 | { 219 | public override string Name => "revokeadmin"; 220 | public override string Description => "revoke a player's admin access (CONSOLE ONLY)"; 221 | public override PermissionLevel PermissionLevel => PermissionLevel.Server; 222 | public override string Help => "!revokeadmin steamid"; 223 | public override string[] Aliases => []; 224 | 225 | public override void OnUse(SteamId executor, string[] arguments) 226 | { 227 | if (arguments.Length == 0) { ChatUtils.SendChat(executor, Help); return; }; 228 | Player? player = ChatUtils.FindPlayer(arguments[0]); 229 | if (player == null) 230 | { 231 | ChatUtils.SendChat(executor, $"Couldn't find player\"{arguments[0]}\"!"); 232 | return; 233 | } 234 | if (!Fishy.Config.Admins.Contains(player.SteamID.ToString())) 235 | { 236 | ChatUtils.SendChat(executor, $"{player.Name} {player.SteamID} is not an admin!", "ffaaaa"); 237 | return; 238 | } 239 | Fishy.Config.Admins.Remove(player.SteamID.ToString()); 240 | // Todo save config, might require some config rework too :( 241 | ChatUtils.SendChat(executor, $"Revoked {player.Name} ({player.SteamID})'s admin!", "aaffaa"); 242 | ChatUtils.BroadcastChat($"{player.Name} ({player.SteamID}) was demoted from admin!", "ffaaaa"); 243 | } 244 | 245 | 246 | } 247 | 248 | } 249 | -------------------------------------------------------------------------------- /Fishy/Dependencies/libsteam_api.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ncrypted-dev/Fishy/6ccb47f2a5ecd3d95d92791aa2e7401260e60be5/Fishy/Dependencies/libsteam_api.so -------------------------------------------------------------------------------- /Fishy/Dependencies/steam_api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ncrypted-dev/Fishy/6ccb47f2a5ecd3d95d92791aa2e7401260e60be5/Fishy/Dependencies/steam_api.dll -------------------------------------------------------------------------------- /Fishy/Dependencies/steam_api64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ncrypted-dev/Fishy/6ccb47f2a5ecd3d95d92791aa2e7401260e60be5/Fishy/Dependencies/steam_api64.dll -------------------------------------------------------------------------------- /Fishy/Event/EventManager.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Models; 2 | using Fishy.Utils; 3 | using Steamworks; 4 | 5 | namespace Fishy.Event 6 | { 7 | 8 | public class EventManager 9 | { 10 | public static event EventHandler OnChatMessage; 11 | internal static void RaiseEvent(EventArgs.ChatMessageEventArgs eventArgs) => OnChatMessage.Invoke(null, eventArgs); 12 | 13 | 14 | public static event EventHandler OnPlayerJoin; 15 | internal static void RaiseEvent(EventArgs.PlayerJoinEventArgs eventArgs) => OnPlayerJoin.Invoke(null, eventArgs); 16 | 17 | 18 | public static event EventHandler OnPlayerLeave; 19 | internal static void RaiseEvent(EventArgs.PlayerLeaveEventArgs eventArgs) => OnPlayerLeave.Invoke(null, eventArgs); 20 | 21 | 22 | public static event EventHandler OnActorSpawn; 23 | internal static void RaiseEvent(EventArgs.ActorSpawnEventArgs eventArgs) => OnActorSpawn.Invoke(null, eventArgs); 24 | 25 | 26 | public static event EventHandler OnActorDespawn; 27 | internal static void RaiseEvent(EventArgs.ActorDespawnEventArgs eventArgs) => OnActorDespawn.Invoke(null, eventArgs); 28 | 29 | 30 | public static event EventHandler OnActorAction; 31 | internal static void RaiseEvent(EventArgs.ActorActionEventArgs eventArgs) => OnActorAction.Invoke(null, eventArgs); 32 | } 33 | } 34 | namespace Fishy.Event.EventArgs 35 | { 36 | public class ActorActionEventArgs(SteamId steamId, string packetAction, Dictionary packetInfo) : System.EventArgs 37 | { 38 | public SteamId SteamId { get; set; } = steamId; 39 | public string PacketAction { get; set; } = packetAction; 40 | 41 | public Dictionary PacketInfo { get; set; } = packetInfo; 42 | 43 | public Dictionary GetParams() 44 | { 45 | if (PacketInfo.ContainsKey("params")) 46 | return (Dictionary)PacketInfo["params"]; 47 | return new Dictionary(); 48 | } 49 | } 50 | 51 | public class ActorSpawnEventArgs(Actor actor) 52 | { 53 | public Actor Actor { get; set; } = actor; 54 | } 55 | 56 | public class ActorDespawnEventArgs(Actor actor) 57 | { 58 | public Actor Actor { get; set; } = actor; 59 | } 60 | 61 | public class ChatMessageEventArgs(SteamId steamId, string message) : System.EventArgs 62 | { 63 | public SteamId SteamId { get; set; } = steamId; 64 | public string Message { get; set; } = message; 65 | 66 | public ChatMessage ChatMessage { get; set; } = new ChatMessage(steamId, message); 67 | } 68 | 69 | public class PlayerJoinEventArgs(Player player) : System.EventArgs 70 | { 71 | public Player Player { get; set; } = player; 72 | } 73 | public class PlayerLeaveEventArgs(Player player) : System.EventArgs 74 | { 75 | public Player Player { get; set; } = player; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Fishy/Extensions/ExtensionLoader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Fishy.Extensions 9 | { 10 | static class ExtensionLoader 11 | { 12 | public static List GetExtensions() 13 | { 14 | List extensions = []; 15 | 16 | string folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"); 17 | List assemblies = []; 18 | 19 | foreach(string file in Directory.GetFiles(folder).Where(f => f.EndsWith(".dll"))) 20 | assemblies.Add(Assembly.LoadFrom(file)); 21 | 22 | foreach (Assembly assembly in assemblies) 23 | { 24 | Type[] types = assembly.GetTypes(); 25 | foreach (Type type in types) 26 | { 27 | if (type.IsClass && type.IsSubclassOf(typeof(FishyExtension))) 28 | { 29 | if (Activator.CreateInstance(type) is FishyExtension extension) 30 | { 31 | extensions.Add(extension); 32 | } 33 | } 34 | } 35 | } 36 | return extensions; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Fishy/Extensions/FishyExtension.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Numerics; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Fishy.Models; 8 | using Fishy.Models.Packets; 9 | using Fishy.Utils; 10 | using Steamworks; 11 | 12 | namespace Fishy.Extensions 13 | { 14 | public abstract class FishyExtension 15 | { 16 | public static List Players { get => Fishy.Players; } 17 | public static List BannedPlayers { get => Fishy.BannedUsers; } 18 | public static List Actors { get => Fishy.Actors; } 19 | public static List ChatLog { get => ChatLogger.ChatLogs; } 20 | 21 | public virtual void OnInit() { } 22 | 23 | 24 | public static Dictionary GetConfigValue(string table) 25 | => Fishy.Config.GetConfigValue(table); 26 | 27 | public static void SendPacketToAll(FPacket packet) 28 | => packet.SendPacket("all", (int)CHANNELS.GAME_STATE); 29 | 30 | public static void SendPacketToPlayer(FPacket packet, SteamId player) 31 | => packet.SendPacket("single", (int)CHANNELS.GAME_STATE, player); 32 | 33 | /// 34 | /// Spawns an actor using the vanilla spawning algorithm. 35 | /// 36 | /// 37 | /// Note that because the spawning algorithm is reimplemented by Fishy, 38 | /// any actors not yet implemented in Fishy will not have a vanilla 39 | /// spawning algorithm. These will need to be spawned with the 40 | /// SpawnActor(string, Vector3, Vector3) overload. 41 | /// 42 | public static void SpawnActor(ActorType type) 43 | { 44 | Spawner.VanillaSpawn(type); 45 | } 46 | 47 | /// 48 | /// Spawns an actor by its name. 49 | /// 50 | /// 51 | /// Bypasses checking whether the actor type is valid, for use in cases 52 | /// where an extension wants to spawn something that hasn't been added 53 | /// to the ActorType enum. 54 | /// 55 | public static void SpawnActor(string type, Vector3 position, Vector3 rotation = default) 56 | { 57 | Spawner.SpawnActor(new Actor(Spawner.GetFreeId(), type, position, rotation)); 58 | } 59 | 60 | public static void KickPlayer(Player player) 61 | => Punish.KickPlayer(player); 62 | public static void BanPlayer(Player player) 63 | => Punish.BanPlayer(player); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Fishy/Fishy.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Chat; 2 | using Fishy.Extensions; 3 | using Fishy.Models; 4 | using Fishy.Models.Packets; 5 | using Fishy.Utils; 6 | using Steamworks; 7 | using System.Numerics; 8 | 9 | namespace Fishy 10 | { 11 | class Fishy 12 | { 13 | internal static Config Config = new(); 14 | internal static World World = new(); 15 | internal static List Players = []; 16 | internal static List Actors = []; 17 | internal static SteamHandler SteamHandler = new(); 18 | internal static NetworkHandler NetworkHandler = new(); 19 | internal static List BannedUsers = []; 20 | public static List> CanvasData = []; 21 | internal static List Extensions = []; 22 | static readonly string configPath = Path.Combine(AppContext.BaseDirectory, "config.toml"); 23 | static readonly string bansPath = Path.Combine(AppContext.BaseDirectory, "bans.txt"); 24 | 25 | public static void Init() 26 | { 27 | 28 | Console.WriteLine("Fishy - Your Dedicated Webfishing Server"); 29 | Console.WriteLine("Starting Server"); 30 | 31 | Console.WriteLine("Reading config file..."); 32 | LoadConfig(); 33 | 34 | Console.WriteLine("Reading world file..."); 35 | LoadWorld(); 36 | 37 | Console.WriteLine("Initializing Steam Client..."); 38 | InitSteam(); 39 | 40 | Console.WriteLine("Reading Banned players..."); 41 | LoadBannedPlayers(); 42 | 43 | Console.WriteLine("Starting NetworkHandler..."); 44 | NetworkHandler.Start(); 45 | Console.WriteLine("NetworkHandler was started successfully"); 46 | 47 | Console.WriteLine("Creating Lobby..."); 48 | SteamHandler.CreateLobby(); 49 | 50 | Console.WriteLine("Registering commands..."); 51 | CommandHandler.Init(); 52 | Console.WriteLine($"{CommandHandler.Commands.Count} Commands were loaded"); 53 | 54 | Console.WriteLine("Loading Extensions..."); 55 | Extensions = ExtensionLoader.GetExtensions(); 56 | foreach(FishyExtension extension in Extensions) 57 | { 58 | Console.WriteLine($"Loading Extension: {extension.GetType()}"); 59 | extension.OnInit(); 60 | } 61 | Console.WriteLine($"{Extensions.Count} Extensions were loaded"); 62 | 63 | Console.WriteLine("Listening for console input..."); 64 | ListenForInput(); 65 | } 66 | 67 | static void ListenForInput() 68 | { 69 | while (true) { 70 | string? message = Console.ReadLine(); 71 | if (!String.IsNullOrEmpty(message)) 72 | { 73 | if (CommandHandler.OnMessage(SteamClient.SteamId, message)) // Suppress message if command ran 74 | continue; 75 | new MessagePacket("Server: " + message).SendPacket("all", (int)CHANNELS.GAME_STATE); 76 | } 77 | } 78 | } 79 | 80 | static void LoadConfig() 81 | { 82 | if (!File.Exists(configPath)) 83 | { 84 | Console.WriteLine("No config file found. (config.toml) Shutting down..."); 85 | Environment.Exit(1); 86 | } 87 | 88 | if (!Config.LoadConfig(configPath)) 89 | { 90 | Console.WriteLine("Error in config file. Shutting down..."); 91 | Environment.Exit(1); 92 | } 93 | Console.WriteLine("Config was read successfully"); 94 | } 95 | 96 | static void LoadWorld() 97 | { 98 | string worldPath = Path.Combine(AppContext.BaseDirectory, "Worlds", Config.World); 99 | if (!File.Exists(worldPath)) 100 | { 101 | Console.WriteLine("No world file found. (main_zone.tscn) Shutting down..."); 102 | Environment.Exit(1); 103 | } 104 | 105 | if (!World.LoadWorld(worldPath)) 106 | { 107 | Console.WriteLine("Error in world file. Shutting down..."); 108 | Environment.Exit(1); 109 | } 110 | Console.WriteLine("Worldfile was read successfully"); 111 | } 112 | 113 | static void LoadBannedPlayers() 114 | { 115 | if (!File.Exists(bansPath)) 116 | File.Create(bansPath); 117 | 118 | using StreamReader banReader = new(bansPath); 119 | while (!banReader.EndOfStream) 120 | BannedUsers.Add(banReader.ReadLine() ?? ""); 121 | 122 | SteamHandler.SetSteamBanList(BannedUsers); 123 | 124 | Console.WriteLine("Bans were read successfully"); 125 | } 126 | 127 | static void InitSteam() 128 | { 129 | string error = SteamHandler.Init(); 130 | if (!String.IsNullOrEmpty(error)) 131 | { 132 | Console.WriteLine("Error Initializing Steam Client. Shutting down..."); 133 | Console.WriteLine("Error: " + error); 134 | Environment.Exit(1); 135 | } 136 | Console.WriteLine("Steam Client was initialized successfully"); 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /Fishy/Fishy.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | PreserveNewest 18 | 19 | 20 | Always 21 | 22 | 23 | Always 24 | libsteam_api.so 25 | 26 | 27 | Always 28 | 29 | 30 | Always 31 | 32 | 33 | Always 34 | steam_api.dll 35 | 36 | 37 | Always 38 | steam_api64.dll 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Fishy/Helper/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | 3 | namespace Fishy.Helper 4 | { 5 | public static class Vector3Extensions 6 | { 7 | public static float Dot(this Vector3 a, Vector3 b) 8 | => a.X * b.X + a.Y * b.Y + a.Z * b.Z; 9 | 10 | public static Vector3 Cross(this Vector3 a, Vector3 b) 11 | { 12 | return new Vector3( 13 | a.Y * b.Z - a.Z * b.Y, 14 | a.Z * b.X - a.X * b.Z, 15 | a.X * b.Y - a.Y * b.X 16 | ); 17 | } 18 | 19 | public static float Magnitude(this Vector3 a) 20 | => (float)Math.Sqrt(a.X * a.X + a.Y * a.Y + a.Z * a.Z); 21 | 22 | public static Vector3 Normalized(this Vector3 a) 23 | { 24 | float magnitude = a.Magnitude(); 25 | if (magnitude == 0) 26 | throw new InvalidOperationException("Cannot normalize a zero vector."); 27 | return a / magnitude; 28 | } 29 | } 30 | 31 | public static class Vector2Extensions 32 | { 33 | public static float Magnitude(this Vector2 a) 34 | => (float)Math.Sqrt(a.X * a.X + a.Y * a.Y); 35 | 36 | 37 | public static Vector2 Normalized(this Vector2 a) 38 | { 39 | float magnitude = a.Magnitude(); 40 | if (magnitude == 0) 41 | throw new InvalidOperationException("Cannot normalize a zero vector."); 42 | return new Vector2(a.X / magnitude, a.Y / magnitude); 43 | } 44 | 45 | public static float Angle(this Vector2 a) 46 | => (float)Math.Atan2(a.Y, a.X); 47 | 48 | public static float AngleInDegrees(this Vector2 a) 49 | => a.Angle() * (180f / (float)Math.PI); 50 | 51 | 52 | public static Vector2 Rotate(this Vector2 a, float angle) 53 | { 54 | float cosTheta = (float)Math.Cos(angle); 55 | float sinTheta = (float)Math.Sin(angle); 56 | 57 | float newX = a.X * cosTheta - a.Y * sinTheta; 58 | float newY = a.X * sinTheta + a.Y * cosTheta; 59 | 60 | return new Vector2(newX, newY); 61 | } 62 | 63 | public static Vector2 RotateInDegrees(this Vector2 a, float angleDegrees) 64 | => a.Rotate(angleDegrees * ((float)Math.PI / 180f)); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /Fishy/Helper/GZip.cs: -------------------------------------------------------------------------------- 1 | using System.IO.Compression; 2 | 3 | namespace Fishy.Helper 4 | { 5 | static class GZip 6 | { 7 | public static byte[] Decompress(byte[] data) 8 | { 9 | try 10 | { 11 | using MemoryStream inputStream = new(data); 12 | using GZipStream gzipStream = new(inputStream, CompressionMode.Decompress); 13 | using MemoryStream outputStream = new(); 14 | gzipStream.CopyTo(outputStream); 15 | return outputStream.ToArray(); 16 | } 17 | catch (Exception e) 18 | { 19 | Console.WriteLine("Error while decompressing GZIP: " + e.Message); 20 | return []; 21 | } 22 | } 23 | 24 | public static byte[] Compress(byte[] data) 25 | { 26 | try 27 | { 28 | using MemoryStream outputStream = new(); 29 | using (GZipStream gzipStream = new(outputStream, CompressionMode.Compress)) 30 | { 31 | gzipStream.Write(data, 0, data.Length); 32 | } 33 | return outputStream.ToArray(); 34 | } 35 | catch (Exception e) 36 | { 37 | Console.WriteLine("Error while compressing GZIP: " + e.Message); 38 | return []; 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Fishy/Models/Actor.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Helper; 2 | using System.Numerics; 3 | 4 | namespace Fishy.Models 5 | { 6 | public enum ActorType 7 | { 8 | NONE, PLAYER, FISH_SPAWN, FISH_SPAWN_ALIEN, RAINCLOUD, METAL_SPAWN, VOID_PORTAL, UNKNOWN 9 | } 10 | 11 | public class Actor 12 | { 13 | public static Dictionary ActorTypesByName = new Dictionary 14 | { 15 | { "none", ActorType.NONE }, 16 | { "player", ActorType.PLAYER }, 17 | { "fish_spawn", ActorType.FISH_SPAWN }, 18 | { "fish_spawn_alien", ActorType.FISH_SPAWN_ALIEN }, 19 | { "metal_spawn", ActorType.METAL_SPAWN }, 20 | { "void_portal", ActorType.VOID_PORTAL }, 21 | }; 22 | 23 | public int InstanceID { get; set; } 24 | public ActorType Type { get; set; } 25 | public string TypeName { get; } 26 | public DateTimeOffset SpawnTime { get; set; } = DateTimeOffset.UtcNow; 27 | 28 | public Vector3 Position { get; set; } 29 | public Vector3 Rotation { get; set; } 30 | 31 | public int DespawnTime { get; set; } = -1; 32 | public bool Despawn { get; set; } = false; 33 | 34 | public Actor(int ID, ActorType type, Vector3 position, Vector3 entRot = default) 35 | { 36 | InstanceID = ID; 37 | Type = type; 38 | TypeName = type.ToString().ToLower(); 39 | Position = position; 40 | if (entRot != default) 41 | Rotation = entRot; 42 | else 43 | Rotation = Vector3.Zero; 44 | } 45 | 46 | public Actor(int ID, string type, Vector3 position, Vector3 entRot = default) 47 | { 48 | InstanceID = ID; 49 | Type = ActorType.UNKNOWN; 50 | TypeName = type.ToString().ToLower(); 51 | Position = position; 52 | if (entRot != default) 53 | Rotation = entRot; 54 | else 55 | Rotation = Vector3.Zero; 56 | } 57 | 58 | public virtual void OnUpdate() { } 59 | 60 | } 61 | 62 | public class RainCloud : Actor 63 | { 64 | public Vector3 toCenter; 65 | public float wanderDirection; 66 | public bool Static = false; 67 | 68 | public RainCloud(int ID, Vector3 entPos) : base(ID, ActorType.RAINCLOUD, Vector3.Zero) 69 | { 70 | Position = entPos; 71 | 72 | toCenter = (Position - new Vector3(30, 40, -50)).Normalized(); 73 | wanderDirection = new Vector2(toCenter.X, toCenter.Z).Angle(); 74 | 75 | Despawn = true; 76 | DespawnTime = 550; 77 | } 78 | 79 | public override void OnUpdate() 80 | { 81 | if (Static) return; 82 | 83 | Vector2 dir = new Vector2(-1, 0).Rotate(wanderDirection) * (0.17f / 6f); 84 | Position += new Vector3(dir.X, 0, dir.Y); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Fishy/Models/Config.cs: -------------------------------------------------------------------------------- 1 | using Tomlyn; 2 | using Tomlyn.Model; 3 | 4 | namespace Fishy.Models 5 | { 6 | public class Config 7 | { 8 | public string ServerName { get; set; } = String.Empty; 9 | public string JoinMessage { get; set; } = String.Empty; 10 | public string[] Rules { get; set; } = []; 11 | public string GameVersion { get; set; } = "1.1"; 12 | public int MaxPlayers { get; set; } = 12; 13 | public bool CodeOnly { get; set; } = false; 14 | public string LobbyCode { get; set; } = "ABCDEF"; 15 | public bool AgeRestricted { get; set; } = false; 16 | public string World { get; set; } = "main_zone.tscn"; 17 | public List Admins { get; set; } = []; 18 | public string ReportFolder { get; set; } = "Reports"; 19 | public string ReportResponse { get; set; } = ""; 20 | public TomlTable Plugins { get; set; } = new(); 21 | 22 | public bool LoadConfig(string configPath) 23 | { 24 | string cfg = File.ReadAllText(configPath); 25 | var toml = Toml.ToModel(cfg); 26 | 27 | bool valid = Toml.TryToModel(cfg, out Config? manager, out _); 28 | if (!valid || manager == null) 29 | return false; 30 | 31 | ServerName = manager.ServerName; 32 | JoinMessage = manager.JoinMessage; 33 | Rules = manager.Rules; 34 | GameVersion = manager.GameVersion; 35 | CodeOnly = manager.CodeOnly; 36 | LobbyCode = manager.LobbyCode; 37 | MaxPlayers = manager.MaxPlayers; 38 | AgeRestricted = manager.AgeRestricted; 39 | World = manager.World; 40 | Admins = manager.Admins; 41 | ReportFolder = manager.ReportFolder; 42 | ReportResponse = manager.ReportResponse; 43 | Plugins = manager.Plugins; 44 | return true; 45 | } 46 | 47 | public Dictionary GetConfigValue(string table) 48 | { 49 | object? tempTable; 50 | bool parsed = Plugins.TryGetValue(table, out tempTable); 51 | if (!parsed || tempTable is not TomlTable) 52 | return []; 53 | 54 | TomlTable tomlTable = tempTable as TomlTable ?? new TomlTable(); 55 | return tomlTable.ToDictionary() ?? []; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/ActorRemovePacket.cs: -------------------------------------------------------------------------------- 1 | namespace Fishy.Models.Packets 2 | { 3 | public class ActorRemovePacket(int id) : FPacket 4 | { 5 | public override string Type { get; set; } = "actor_action"; 6 | public int Actor_ID { get; set; } = id; 7 | public string Action { get; set; } = "queue_free"; 8 | public Dictionary Params { get; set; } = []; 9 | 10 | public override Dictionary ToDictionary() 11 | { 12 | Dictionary spawnPacket = GetType() 13 | .GetProperties() 14 | .ToDictionary(p => p.Name.ToLower(), p => p.GetValue(this) ?? ""); 15 | 16 | spawnPacket["params"] = new Dictionary(); 17 | return spawnPacket; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/ActorRequestPacket.cs: -------------------------------------------------------------------------------- 1 | namespace Fishy.Models.Packets 2 | { 3 | class ActorRequestPacket : FPacket 4 | { 5 | public override string Type { get; set; } = "actor_request_send"; 6 | public ListPacket List {get; set; } = new(); 7 | 8 | public override Dictionary ToDictionary() 9 | { 10 | 11 | Dictionary spawnPacket = GetType() 12 | .GetProperties() 13 | .ToDictionary(p => p.Name.ToLower(), p => p.GetValue(this) ?? ""); 14 | 15 | spawnPacket["list"] = new Dictionary(); 16 | return spawnPacket; 17 | } 18 | } 19 | 20 | 21 | class ListPacket() {} 22 | } 23 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/ActorSpawnPacket.cs: -------------------------------------------------------------------------------- 1 | using Steamworks; 2 | using System.Numerics; 3 | 4 | namespace Fishy.Models.Packets 5 | { 6 | public class ActorSpawnPacket : FPacket 7 | { 8 | public override string Type { get; set; } = "instance_actor"; 9 | public Params Params { get; set; } = new Params(); 10 | 11 | public ActorSpawnPacket(ActorType type, Vector3 pos, int id) 12 | { 13 | this.Params = new Params() { 14 | // TODO: Would probably be better to map the enum to 15 | // webfishing's canonical actor type strings instead of using 16 | // ToString(), but for now this works fine 17 | Actor_Type = type.ToString().ToLower(), 18 | At = pos, 19 | Actor_ID = id 20 | }; 21 | } 22 | 23 | public override Dictionary ToDictionary() 24 | { 25 | Dictionary data = Params.GetType() 26 | .GetProperties() 27 | .ToDictionary(p => p.Name.ToLower(), p => p.GetValue(this.Params) ?? ""); 28 | 29 | Dictionary spawnPacket = GetType() 30 | .GetProperties() 31 | .ToDictionary(p => p.Name.ToLower(), p => p.GetValue(this) ?? ""); 32 | 33 | spawnPacket["params"] = data; 34 | return spawnPacket; 35 | } 36 | } 37 | 38 | public class Params 39 | { 40 | public string Actor_Type { get; set; } = "player"; 41 | public Vector3 At { get; set; } = Vector3.Zero; 42 | public Vector3 Rot { get; set; } = Vector3.Zero; 43 | public string Zone { get; set; } = "main_zone"; 44 | public int Zone_Owner { get; set; } = -1; 45 | public int Actor_ID { get; set; } = 255; 46 | public long Creator_ID { get; set; } = (long)SteamClient.SteamId.Value; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/ActorUpdatePacket.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | 3 | namespace Fishy.Models.Packets 4 | { 5 | public class ActorUpdatePacket(int id, Vector3 pos, Vector3 rot) : FPacket 6 | { 7 | public override string Type { get; set; } = "actor_update"; 8 | public int Actor_ID { get; set; } = id; 9 | public Vector3 Pos { get; set; } = pos; 10 | public Vector3 Rot { get; set; } = rot; 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/BanPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Fishy.Models.Packets 8 | { 9 | class BanPacket : FPacket 10 | { 11 | public override string Type { get; set; } = "ban"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/ChalkPacket.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | 3 | namespace Fishy.Models.Packets 4 | { 5 | public class ChalkPacket : FPacket 6 | { 7 | public override string Type { get; set; } = "chalk_packet"; 8 | public int Canvas_ID { get; set; } = 0; 9 | public Dictionary Data { get; set; } 10 | 11 | public ChalkPacket(int Canvas, Dictionary CanvasData) 12 | { 13 | Canvas_ID = Canvas; 14 | Data = new Dictionary(); 15 | 16 | int i = 0; 17 | 18 | foreach (var entry in CanvasData) 19 | { 20 | var innerData = new Dictionary 21 | { 22 | { 0, entry.Key }, 23 | { 1, entry.Value } 24 | }; 25 | 26 | Data[i] = innerData; 27 | 28 | i++; 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Fishy/Models/Packets/FPacket.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Helper; 2 | using Fishy.Utils; 3 | using Steamworks; 4 | using System.Reflection; 5 | 6 | namespace Fishy.Models.Packets 7 | { 8 | public class FPacket 9 | { 10 | public virtual string Type { get; set; } = ""; 11 | public virtual Dictionary ToDictionary() 12 | { 13 | return GetType() 14 | .GetProperties(BindingFlags.Instance | BindingFlags.Public) 15 | .ToDictionary(p => p.Name.ToLower(), p => p.GetValue(this, null) ?? ""); 16 | } 17 | 18 | public static Dictionary FromBytes(byte[] packet) 19 | => (new GodotUtilReader(packet)).ReadPacket(); 20 | 21 | public static byte[] ToBytes(FPacket packet) 22 | => GZip.Compress(new GodotUtilWriter().ConvertToGodotBytePacket(packet.ToDictionary())); 23 | 24 | public virtual void SendPacket(string target = "all", int channel = 0, SteamId steamId = default) 25 | { 26 | GodotUtilWriter writer = new(); 27 | var data = GZip.Compress(writer.ConvertToGodotBytePacket(this.ToDictionary())); 28 | 29 | if (target == "all") 30 | { 31 | foreach (Friend member in Fishy.SteamHandler.Lobby.Members) 32 | { 33 | if (member.Id != SteamClient.SteamId.Value) 34 | SteamNetworking.SendP2PPacket(member.Id, data, nChannel: channel); 35 | } 36 | } 37 | else 38 | { 39 | SteamNetworking.SendP2PPacket(steamId, data, nChannel: channel); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/ForceDisconnectPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Fishy.Models.Packets 8 | { 9 | class ForceDisconnectPacket (string id) : FPacket 10 | { 11 | public override string Type { get; set; } = "force_disconnect_player"; 12 | public string User_ID { get; set; } = id; 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/HandshakePacket.cs: -------------------------------------------------------------------------------- 1 | using Steamworks; 2 | 3 | namespace Fishy.Models.Packets 4 | { 5 | public class HandshakePacket : FPacket 6 | { 7 | public override string Type { get; set; } = "handshake"; 8 | public string User_ID { get; set; } = SteamClient.SteamId.Value.ToString(); 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/HostPacket.cs: -------------------------------------------------------------------------------- 1 | using Steamworks; 2 | 3 | namespace Fishy.Models.Packets 4 | { 5 | public class HostPacket : FPacket 6 | { 7 | public override string Type { get; set; } = "recieve_host"; 8 | public string Host_ID { get; set; } = SteamClient.SteamId.Value.ToString(); 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/KickPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Fishy.Models.Packets 8 | { 9 | class KickPacket : FPacket 10 | { 11 | public override string Type { get; set; } = "kick"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/LetterPacket.cs: -------------------------------------------------------------------------------- 1 | using Steamworks; 2 | 3 | namespace Fishy.Models.Packets 4 | { 5 | public class LetterPacket(SteamId to, SteamId from, string header, string body, string closing, string user) : FPacket 6 | { 7 | public override string Type { get; set; } = "letter_received"; 8 | public string To { get; set; } = to.Value.ToString(); 9 | public Letter Data { get; set; } = new Letter(to, from, header, body, closing, user); 10 | 11 | public override Dictionary ToDictionary() 12 | { 13 | Dictionary data = Data.GetType() 14 | .GetProperties() 15 | .ToDictionary(p => p.Name.ToLower(), p => p.GetValue(this.Data) ?? ""); 16 | 17 | Dictionary letter = GetType() 18 | .GetProperties() 19 | .ToDictionary(p => p.Name.ToLower(), p => p.GetValue(this) ?? ""); 20 | 21 | letter["data"] = data; 22 | 23 | return letter; 24 | } 25 | } 26 | public class Letter 27 | { 28 | public string To { get; set; } = String.Empty; 29 | public string From { get; set; } = String.Empty; 30 | public string Header { get; set; } = String.Empty; 31 | public string Body { get; set; } = String.Empty; 32 | public string Closing { get; set; } = String.Empty; 33 | public string User { get; set; } = String.Empty; 34 | public double Letter_ID { get; set; } = new Random().Next(); 35 | public Dictionary Items { get; set; } = []; 36 | public Letter(SteamId to, SteamId from, string header, string body, string closing, string user) 37 | { 38 | To = to.Value.ToString(); 39 | From = from.Value.ToString(); 40 | Header = header; 41 | Body = body; 42 | Closing = closing; 43 | User = user; 44 | Letter_ID = new Random().Next(); 45 | Items = []; 46 | } 47 | public Letter() { } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/MessagePacket.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | using Fishy.Utils; 3 | using Steamworks; 4 | 5 | namespace Fishy.Models.Packets 6 | { 7 | public class MessagePacket(string message, string color = "ffffff") : FPacket 8 | { 9 | public override string Type { get; set; } = "message"; 10 | public string Message { get; set; } = message; 11 | public string Color { get; set; } = color; 12 | public bool Local { get; set; } = false; 13 | public Vector3 Position { get; set; } = new Vector3(0f, 0f, 0f); 14 | public string Zone { get; set; } = "main_zone"; 15 | public int Zone_Owner { get; set; } = 1; 16 | 17 | public override void SendPacket(string target = "all", int channel = 0, SteamId steamId = default) 18 | { 19 | base.SendPacket(target, channel, steamId); 20 | if (target != "all") return; 21 | ChatMessage chatMessage = new(SteamClient.SteamId, Message); 22 | ChatLogger.Log(chatMessage); 23 | Event.EventManager.RaiseEvent(new Event.EventArgs.ChatMessageEventArgs(SteamClient.SteamId, Message)); 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/PingPongPacket.cs: -------------------------------------------------------------------------------- 1 | using Steamworks; 2 | 3 | namespace Fishy.Models.Packets 4 | { 5 | class PingPacket : FPacket 6 | { 7 | public override string Type { get; set; } = "request_ping"; 8 | public string Time { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); 9 | public string Sender { get; set; } = SteamClient.SteamId.Value.ToString(); 10 | } 11 | 12 | class PongPacket : FPacket 13 | { 14 | public override string Type { get; set; } = "send_ping"; 15 | public string Time { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(); 16 | public string From { get; set; } = SteamClient.SteamId.Value.ToString(); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Fishy/Models/Packets/ServerClosePacket.cs: -------------------------------------------------------------------------------- 1 | using Steamworks; 2 | 3 | namespace Fishy.Models.Packets 4 | { 5 | class ServerClosePacket : FPacket 6 | { 7 | public override string Type { get; set; } = "server_close"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Fishy/Models/Player.cs: -------------------------------------------------------------------------------- 1 | using Steamworks; 2 | using System.Numerics; 3 | 4 | namespace Fishy.Models 5 | { 6 | public class Player 7 | { 8 | public SteamId SteamID { get; set; } 9 | public string ID { get; set; } 10 | public string Name { get; set; } 11 | public long InstanceID { get; set; } 12 | public Vector3 Position { get; set; } 13 | 14 | 15 | public Player(SteamId id, string name) 16 | { 17 | SteamID = id; 18 | string randomID = new(Enumerable.Range(0, 3).Select(_ => "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[new Random().Next(36)]).ToArray()); 19 | ID = randomID; 20 | Name = name; 21 | 22 | InstanceID = 0; 23 | Position = new Vector3(0, 0, 0); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Fishy/Models/ScheduledTask.cs: -------------------------------------------------------------------------------- 1 | namespace Fishy.Models 2 | { 3 | class ScheduledTask 4 | { 5 | private readonly System.Timers.Timer _timer; 6 | 7 | public ScheduledTask(Action task, int interval) 8 | { 9 | _timer = new(interval) 10 | { 11 | AutoReset = true 12 | }; 13 | _timer.Elapsed += (_, _) => task(); 14 | } 15 | 16 | public void Start() 17 | => _timer.Start(); 18 | 19 | public void Stop() 20 | => _timer.Stop(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Fishy/Models/World.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using System.Numerics; 3 | using System.Text.RegularExpressions; 4 | 5 | namespace Fishy.Models 6 | { 7 | internal class World 8 | { 9 | public List FishSpawns { get; set; } 10 | public List TrashPoints { get; set; } 11 | public List ShorelinePoints { get; set; } 12 | public List HiddenSpots { get; set; } 13 | 14 | public World() 15 | { 16 | FishSpawns = []; 17 | TrashPoints = []; 18 | ShorelinePoints = []; 19 | HiddenSpots = []; 20 | } 21 | 22 | public bool LoadWorld(string filePath) 23 | { 24 | string[] contentLines = File.ReadAllText(filePath).Split("\n"); 25 | for (int i = 0; i < contentLines.Length; i++) 26 | { 27 | Match match = Regex.Match(contentLines[i], @"groups=\[""(.+)""\]\]"); 28 | if (!match.Success) 29 | continue; 30 | 31 | string transformPattern = @"Transform\(.*?,\s*(-?\d+\.?\d*),\s*(-?\d+\.?\d*),\s*(-?\d+\.?\d*)\s*\)"; 32 | 33 | Match matchTransform = Regex.Match(contentLines[i + 1], transformPattern); 34 | if (!matchTransform.Success) 35 | continue; 36 | 37 | Vector3 location = new( 38 | float.Parse(matchTransform.Groups[1].Value, CultureInfo.InvariantCulture), 39 | float.Parse(matchTransform.Groups[2].Value, CultureInfo.InvariantCulture), 40 | float.Parse(matchTransform.Groups[3].Value, CultureInfo.InvariantCulture)); 41 | 42 | switch (match.Groups[1].Value) 43 | { 44 | case "fish_spawn": 45 | FishSpawns.Add(location); 46 | break; 47 | case "shoreline_point": 48 | ShorelinePoints.Add(location); 49 | break; 50 | case "trash_point": 51 | TrashPoints.Add(location); 52 | break; 53 | case "hidden_spot": 54 | HiddenSpots.Add(location); 55 | break; 56 | } 57 | } 58 | return true; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Fishy/Plugins/Fishy.Webserver.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ncrypted-dev/Fishy/6ccb47f2a5ecd3d95d92791aa2e7401260e60be5/Fishy/Plugins/Fishy.Webserver.dll -------------------------------------------------------------------------------- /Fishy/Plugins/Fishy.Webserver.runtimeconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtimeOptions": { 3 | "tfm": "net8.0", 4 | "rollForward": "LatestMinor", 5 | "framework": { 6 | "name": "Microsoft.NETCore.App", 7 | "version": "8.0.0" 8 | }, 9 | "configProperties": { 10 | "System.Reflection.Metadata.MetadataUpdater.IsSupported": false, 11 | "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /Fishy/Program.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Models.Packets; 2 | using Fishy.Utils; 3 | using Steamworks; 4 | 5 | namespace Fishy 6 | { 7 | class Program 8 | { 9 | 10 | static void Main(string[] args) 11 | { 12 | Fishy.Init(); 13 | } 14 | 15 | static void Console_CancelKeyPress(object? sender, ConsoleCancelEventArgs e) 16 | { 17 | Console.WriteLine("Application is closing..."); 18 | 19 | new ServerClosePacket().SendPacket("all", (int)CHANNELS.GAME_STATE); 20 | 21 | Fishy.SteamHandler.Lobby.Leave(); 22 | SteamClient.Shutdown(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Fishy/Utils/ChatLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Steamworks; 7 | 8 | namespace Fishy.Utils 9 | { 10 | class ChatLogger 11 | { 12 | public static List ChatLogs = []; 13 | 14 | public static void Log(ChatMessage message) 15 | { 16 | ChatLogs.Add(message); 17 | if (ChatLogs.Count > 100) 18 | ChatLogs.RemoveAt(0); 19 | Console.WriteLine(message.ToString()); 20 | } 21 | 22 | public static string GetLog(SteamId? user = null) 23 | { 24 | StringBuilder stringBuilder = new(); 25 | 26 | foreach (ChatMessage message in ChatLogs) 27 | { 28 | if (user == null) 29 | { 30 | stringBuilder.AppendLine(message.ToString()); 31 | } 32 | else 33 | { 34 | if (message.UserID.Equals(user.ToString())) 35 | stringBuilder.AppendLine(message.ToString()); 36 | } 37 | } 38 | return stringBuilder.ToString(); 39 | } 40 | } 41 | 42 | public class ChatMessage (SteamId user, string message) 43 | { 44 | public DateTime SentAt { get; set; } = DateTime.Now; 45 | public string UserID { get; set; } = user.ToString(); 46 | public string UserName { get; set; } = Fishy.Players.FirstOrDefault(p => p.SteamID == user, new Models.Player(new SteamId(), "")).Name ?? user.ToString(); 47 | public string Message { get; set; } = message; 48 | 49 | public override string ToString() 50 | { 51 | return $"{SentAt:dd.MM HH:mm:ss} {UserName}({UserID}): {Message}"; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Fishy/Utils/ChatUtils.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Models; 2 | using Fishy.Models.Packets; 3 | using Steamworks; 4 | namespace Fishy.Utils 5 | { 6 | public class ChatUtils 7 | { 8 | public static void SendChat(SteamId steamId, string message, string color="ffffff") 9 | { 10 | if (steamId == SteamClient.SteamId) 11 | { 12 | Console.WriteLine(message); 13 | return; 14 | } 15 | new MessagePacket(message, color).SendPacket("single", (int)CHANNELS.GAME_STATE, steamId); 16 | } 17 | public static void BroadcastChat(string message, string color="ffffff") 18 | { 19 | Console.WriteLine(message); 20 | new MessagePacket(message, color).SendPacket("all", (int)CHANNELS.GAME_STATE); 21 | } 22 | 23 | public static Player? FindPlayer(string name) 24 | { 25 | Player? player; 26 | 27 | // Get Player with exact name match 28 | player = Fishy.Players.FirstOrDefault(p => p.Name == name) ?? null; 29 | 30 | if (player != null) 31 | return player; 32 | 33 | // Try to get Player with SteamID 34 | player = Fishy.Players.FirstOrDefault(p => p.SteamID.ToString() == name) ?? null; 35 | 36 | if (player != null) 37 | return player; 38 | 39 | // Case insensitive search 40 | player = Fishy.Players.FirstOrDefault(p => p.Name.ToLower() == name.ToLower()) ?? null; 41 | 42 | if (player != null) 43 | return player; 44 | 45 | return null; 46 | } 47 | public static Player? FindPlayer(SteamId id) 48 | => Fishy.Players.FirstOrDefault(p => p.SteamID == id) ?? null; 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Fishy/Utils/GodotUtils.cs: -------------------------------------------------------------------------------- 1 | using System.Numerics; 2 | using System.Text; 3 | 4 | namespace Fishy.Utils 5 | { 6 | enum GodotTypes 7 | { 8 | Null = 0, 9 | Bool = 1, 10 | Int = 2, 11 | Float = 3, 12 | String = 4, 13 | Vector2 = 5, 14 | Rect2 = 6, 15 | Vector3 = 7, 16 | Dictionary = 18, 17 | Array = 19 18 | } 19 | 20 | 21 | public class GodotUtilReader(byte[] data) 22 | { 23 | 24 | readonly BinaryReader _binaryReader = new(new MemoryStream(data), Encoding.UTF8); 25 | public byte[] data = data; 26 | 27 | public Dictionary ReadPacket() 28 | { 29 | Dictionary packet = []; 30 | 31 | try 32 | { 33 | int type = _binaryReader.ReadInt32(); 34 | if (type != (int)GodotTypes.Dictionary) 35 | return []; 36 | 37 | packet = ReadDictionary(); 38 | } 39 | catch (Exception e) 40 | { 41 | Console.WriteLine(e.ToString()); 42 | } 43 | 44 | return packet; 45 | } 46 | 47 | private object? ReadNext() 48 | { 49 | int v = _binaryReader.ReadInt32(); 50 | 51 | int type = v & 0xFFFF; 52 | int flags = v >> 16; 53 | 54 | return type switch 55 | { 56 | (int)GodotTypes.Null => null, 57 | (int)GodotTypes.Bool => ReadBool(), 58 | (int)GodotTypes.Int => ReadInt((flags & 1) == 1), 59 | (int)GodotTypes.Float => ReadFloat((flags & 1) == 1), 60 | (int)GodotTypes.String => ReadString(), 61 | (int)GodotTypes.Vector2 => ReadVector2(), 62 | (int)GodotTypes.Vector3 => ReadVector3(), 63 | (int)GodotTypes.Dictionary => ReadDictionary(), 64 | (int)GodotTypes.Array => ReadArray(), 65 | _ => null, 66 | }; 67 | } 68 | 69 | private bool ReadBool() 70 | => _binaryReader.ReadInt32() != 0; 71 | 72 | private double ReadFloat(bool is64) 73 | => is64 ? _binaryReader.ReadDouble() : _binaryReader.ReadSingle(); 74 | 75 | private Vector2 ReadVector2() 76 | => new(_binaryReader.ReadSingle(), _binaryReader.ReadSingle()); 77 | 78 | private Vector3 ReadVector3() 79 | => new(_binaryReader.ReadSingle(), _binaryReader.ReadSingle(), _binaryReader.ReadSingle()); 80 | 81 | private long ReadInt(bool is64) 82 | => is64 ? _binaryReader.ReadInt64() : _binaryReader.ReadInt32(); 83 | 84 | private string ReadString() 85 | { 86 | int stringLength = _binaryReader.ReadInt32(); 87 | char[] chars = _binaryReader.ReadChars(stringLength); 88 | 89 | if (4 - (int)_binaryReader.BaseStream.Position % 4 != 4) 90 | _binaryReader.ReadBytes(4 - (int)_binaryReader.BaseStream.Position % 4); 91 | 92 | return new string(chars); 93 | } 94 | 95 | private Dictionary ReadDictionary() 96 | { 97 | Dictionary dic = []; 98 | int elementCount = _binaryReader.ReadInt32() & 0x7FFFFFFF; 99 | for (int i = 0; i < elementCount; i++) 100 | { 101 | object? keyValue = ReadNext(); 102 | string key; 103 | 104 | if (keyValue == null) 105 | break; 106 | else 107 | key = keyValue.ToString() ?? "Null"; 108 | 109 | object? value = ReadNext() ?? ""; 110 | dic[key] = value; 111 | } 112 | return dic; 113 | } 114 | 115 | private Dictionary ReadArray() 116 | { 117 | Dictionary array = []; 118 | 119 | int elementCount = _binaryReader.ReadInt32() & 0x7FFFFFFF; 120 | 121 | for (int i = 0; i < elementCount; i++) 122 | array[i] = ReadNext() ?? ""; 123 | 124 | return array; 125 | } 126 | } 127 | 128 | 129 | 130 | public class GodotUtilWriter 131 | { 132 | readonly MemoryStream _memoryStream = new(); 133 | readonly BinaryWriter _binaryWriter; 134 | 135 | public GodotUtilWriter() 136 | { 137 | _binaryWriter = new(_memoryStream); 138 | } 139 | 140 | public byte[] ConvertToGodotBytePacket(object packet) 141 | { 142 | Write(packet); 143 | return _memoryStream.ToArray(); 144 | } 145 | 146 | public void Write(object packet) 147 | { 148 | switch (packet) 149 | { 150 | case null: 151 | _binaryWriter.Write(0); break; 152 | case bool b: 153 | WriteAsBool(b); break; 154 | case int i: 155 | WriteAsInt(i); break; 156 | case long l: 157 | WriteAsLong(l); break; 158 | case float f: 159 | WriteAsFloat(f); break; 160 | case double d: 161 | WriteAsDouble(d); break; 162 | case string s: 163 | WriteAsString(s); break; 164 | case Vector2 v2: 165 | WriteAsVector2(v2); break; 166 | case Vector3 v: 167 | WriteAsVector3(v); break; 168 | case Dictionary dictionaryArray: 169 | WriteAsArray(dictionaryArray); break; 170 | case Dictionary dictionary: 171 | WriteAsDictionary(dictionary); break; 172 | default: 173 | Console.WriteLine("Unknow Datatype while writing package!"); 174 | break; 175 | } 176 | } 177 | 178 | private void WriteAsBool(bool b) 179 | { 180 | _binaryWriter.Write((int)GodotTypes.Bool); 181 | _binaryWriter.Write(b ? 1 : 0); 182 | } 183 | 184 | public void WriteAsInt(int i) 185 | { 186 | _binaryWriter.Write((int)GodotTypes.Int); 187 | _binaryWriter.Write(i); 188 | } 189 | 190 | private void WriteAsLong(long l) 191 | { 192 | _binaryWriter.Write(65538); 193 | _binaryWriter.Write(l); 194 | } 195 | 196 | private void WriteAsFloat(float f) 197 | { 198 | _binaryWriter.Write((int)GodotTypes.Float); 199 | _binaryWriter.Write(f); 200 | } 201 | 202 | private void WriteAsDouble(double d) 203 | { 204 | _binaryWriter.Write(65539); 205 | _binaryWriter.Write(d); 206 | } 207 | 208 | private void WriteAsString(string s) 209 | { 210 | _binaryWriter.Write((int)GodotTypes.String); 211 | byte[] bytes = Encoding.UTF8.GetBytes(s); 212 | 213 | _binaryWriter.Write(bytes.Length); 214 | _binaryWriter.Write(bytes); 215 | 216 | int padding = (4 - bytes.Length % 4) % 4; // Calculate padding 217 | 218 | for (int i = 0; i < padding; i++) 219 | _binaryWriter.Write((byte)0); 220 | 221 | } 222 | 223 | private void WriteAsVector2(Vector2 v2) 224 | { 225 | _binaryWriter.Write((int)GodotTypes.Vector2); 226 | _binaryWriter.Write(v2.X); 227 | _binaryWriter.Write(v2.Y); 228 | } 229 | 230 | private void WriteAsVector3(Vector3 v) 231 | { 232 | _binaryWriter.Write((int)GodotTypes.Vector3); 233 | _binaryWriter.Write(v.X); 234 | _binaryWriter.Write(v.Y); 235 | _binaryWriter.Write(v.Z); 236 | } 237 | 238 | private void WriteAsDictionary(Dictionary packet) 239 | { 240 | _binaryWriter.Write((int)GodotTypes.Dictionary); 241 | _binaryWriter.Write(packet.Count); 242 | 243 | foreach (KeyValuePair pair in packet) 244 | { 245 | Write(pair.Key); 246 | Write(pair.Value); 247 | } 248 | } 249 | 250 | private void WriteAsArray(Dictionary packet) 251 | { 252 | _binaryWriter.Write((int)GodotTypes.Array); 253 | _binaryWriter.Write((int)packet.Count); 254 | 255 | for (int i = 0; i < packet.Count; i++) 256 | Write(packet[i]); 257 | } 258 | } 259 | } 260 | -------------------------------------------------------------------------------- /Fishy/Utils/NetworkHandler.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Chat; 2 | using Fishy.Event; 3 | using Fishy.Extensions; 4 | using Fishy.Helper; 5 | using Fishy.Models; 6 | using Fishy.Models.Packets; 7 | using Steamworks; 8 | using Steamworks.Data; 9 | using System.Numerics; 10 | 11 | namespace Fishy.Utils 12 | { 13 | public enum CHANNELS 14 | { 15 | ACTOR_UPDATE, 16 | ACTOR_ACTION, 17 | GAME_STATE, 18 | CHALK, 19 | GUITAR, 20 | ACTOR_ANIMATION, 21 | SPEECH, 22 | } 23 | 24 | class NetworkHandler 25 | { 26 | public static Dictionary PreviousPositions = []; 27 | private static int _actorUpdateCount = 30; 28 | 29 | public void Start() 30 | { 31 | Thread cbThread = new(RunSteamworksUpdate) 32 | { 33 | IsBackground = true 34 | }; 35 | cbThread.Start(); 36 | 37 | Thread thread = new(Listen) 38 | { 39 | IsBackground = true 40 | }; 41 | thread.Start(); 42 | 43 | static void requestPlayerPings() => new PingPacket().SendPacket("all", (int)CHANNELS.GAME_STATE); 44 | ScheduledTask pingTask = new(requestPlayerPings, 5000); 45 | pingTask.Start(); 46 | 47 | ScheduledTask spawnTask = new(Spawner.SpawnIngameEvent, 10000); 48 | spawnTask.Start(); 49 | 50 | ScheduledTask updateTask = new(Update, 100); 51 | updateTask.Start(); 52 | } 53 | 54 | void Listen() 55 | { 56 | while (true) 57 | { 58 | for (int i = 0; i < 6; i++) 59 | { 60 | if (!SteamNetworking.IsP2PPacketAvailable(i)) 61 | continue; 62 | 63 | P2Packet? packet = SteamNetworking.ReadP2PPacket(i); 64 | 65 | if (packet != null) 66 | OnPacketReceived(packet.Value); 67 | } 68 | } 69 | } 70 | 71 | void RunSteamworksUpdate() 72 | { 73 | while (true) 74 | SteamClient.RunCallbacks(); 75 | } 76 | 77 | public static void OnPacketReceived(P2Packet packet) 78 | { 79 | 80 | try 81 | { 82 | if (Punish.IsBanned(packet.SteamId)) // Don't even bother decompressing packet data if player is banned 83 | return; 84 | 85 | byte[] packetData = GZip.Decompress(packet.Data); 86 | Dictionary packetInfo = FPacket.FromBytes(packetData); 87 | if (!packetInfo.TryGetValue("type", out object? value)) 88 | return; 89 | string packetType = (string)value; 90 | 91 | switch (packetType) 92 | { 93 | case "handshake": 94 | new HandshakePacket().SendPacket("single", (int)CHANNELS.GAME_STATE, packet.SteamId); 95 | break; 96 | case "request_ping": 97 | new PongPacket().SendPacket("single", (int)CHANNELS.ACTOR_ACTION, packet.SteamId); 98 | break; 99 | case "new_player_join": 100 | new MessagePacket("Welcome to the server!").SendPacket("single", (int)CHANNELS.GAME_STATE, packet.SteamId); 101 | new MessagePacket(Fishy.Config.JoinMessage).SendPacket("single", (int)CHANNELS.GAME_STATE, packet.SteamId); 102 | if (Fishy.Config.Admins.Contains(packet.SteamId.Value.ToString())) 103 | new MessagePacket("An admin has joined the lobby").SendPacket("all", (int)CHANNELS.GAME_STATE); 104 | SendCanvasData(packet.SteamId); 105 | new HostPacket().SendPacket("all", (int)CHANNELS.GAME_STATE); 106 | break; 107 | case "instance_actor": 108 | Dictionary parameters = (Dictionary)packetInfo["params"]; 109 | if (parameters["actor_type"].ToString() == "player") 110 | { 111 | int index = Fishy.Players.FindIndex(p => p.SteamID.Equals(packet.SteamId)); 112 | if (index == -1) 113 | break; 114 | Fishy.Players[index].InstanceID = (long)parameters["actor_id"]; 115 | } 116 | break; 117 | case "actor_update": 118 | int playerIndex = Fishy.Players.FindIndex(p => p.InstanceID.Equals(packetInfo["actor_id"])); 119 | if (playerIndex == -1) 120 | break; 121 | Fishy.Players[playerIndex].Position = (Vector3)packetInfo["pos"]; 122 | break; 123 | 124 | case "actor_action": 125 | string packetAction = (string)packetInfo["action"]; 126 | if (packetAction == "_sync_create_bubble") 127 | { 128 | string Message = (string)((Dictionary)packetInfo["params"])[0]; 129 | OnChat(Message, packet.SteamId); 130 | } 131 | if ((string)packetInfo["action"] == "_wipe_actor") 132 | { 133 | long actorToWipe = (long)((Dictionary)packetInfo["params"])[0]; 134 | Actor serverInst = Fishy.Actors.First(i => i.InstanceID == actorToWipe); 135 | if (serverInst != null) 136 | { 137 | RemoveServerActor(serverInst); 138 | } 139 | } 140 | EventManager.RaiseEvent(new Event.EventArgs.ActorActionEventArgs(packet.SteamId, packetAction, packetInfo)); 141 | break; 142 | case "request_actors": 143 | List instances = Fishy.Actors; 144 | foreach (Actor actor in instances) 145 | { 146 | new ActorSpawnPacket(actor.Type, actor.Position, actor.InstanceID).SendPacket("single", (int)CHANNELS.GAME_STATE, packet.SteamId); 147 | } 148 | 149 | new ActorRequestPacket().SendPacket("single", (int)CHANNELS.GAME_STATE, packet.SteamId); 150 | break; 151 | case "letter_recieved": 152 | Dictionary data = (Dictionary)packetInfo["data"]; 153 | string body = data["body"].ToString() ?? ""; 154 | CommandHandler.OnMessage(packet.SteamId, body); 155 | break; 156 | case "chalk_packet": 157 | var ChalkPacketData = (Dictionary)packetInfo["data"]; 158 | int CanvasID = Convert.ToInt32(packetInfo["canvas_id"]); 159 | 160 | while (Fishy.CanvasData.Count <= CanvasID) 161 | { 162 | Fishy.CanvasData.Add(null); 163 | } 164 | 165 | if (Fishy.CanvasData[CanvasID] == null) 166 | Fishy.CanvasData[CanvasID] = new Dictionary(); 167 | 168 | foreach (var DataPointObj in ChalkPacketData.Values) 169 | { 170 | Dictionary DataPoint = (Dictionary)DataPointObj; 171 | var chalkLocation = (Vector2)DataPoint[0]; 172 | var chalkColor = Convert.ToInt32(DataPoint[1]); 173 | 174 | if (!Fishy.CanvasData[CanvasID].ContainsKey(chalkLocation)) 175 | Fishy.CanvasData[CanvasID].Add(chalkLocation, chalkColor); 176 | } 177 | break; 178 | default: break; 179 | 180 | } 181 | } catch (Exception ex) { 182 | Console.WriteLine(DateTime.Now.ToString("dd.MM HH:mm:ss") + " Error: " + ex.Message); 183 | } 184 | 185 | } 186 | 187 | static void RemoveServerActor(Actor instance) 188 | { 189 | new ActorRemovePacket(instance.InstanceID).SendPacket("all", (int)CHANNELS.GAME_STATE); 190 | Fishy.Actors.Remove(instance); 191 | } 192 | 193 | 194 | static void OnChat(string message, SteamId id) 195 | { 196 | ChatLogger.Log(new ChatMessage(id, message)); 197 | 198 | if (CommandHandler.OnMessage(id, message)) return; // Suppress message if command ran 199 | 200 | EventManager.RaiseEvent(new Event.EventArgs.ChatMessageEventArgs(id,message)); 201 | } 202 | 203 | 204 | public static void Update() 205 | { 206 | _actorUpdateCount++; 207 | foreach (Actor actor in Fishy.Actors.ToList()) 208 | { 209 | actor.OnUpdate(); 210 | 211 | if (!PreviousPositions.ContainsKey(actor.InstanceID)) 212 | PreviousPositions[actor.InstanceID] = Vector3.Zero; 213 | 214 | if (actor.Position != PreviousPositions[actor.InstanceID] && _actorUpdateCount == 20) 215 | { 216 | PreviousPositions[actor.InstanceID] = actor.Position; 217 | new ActorUpdatePacket(actor.InstanceID, actor.Position, actor.Rotation).SendPacket("all", (int)CHANNELS.GAME_STATE); 218 | } 219 | } 220 | 221 | if (_actorUpdateCount >= 20) 222 | _actorUpdateCount = 0; 223 | } 224 | 225 | 226 | static void SendCanvasData(SteamId id) 227 | { 228 | int i = 0; 229 | 230 | foreach(Dictionary Canvas in Fishy.CanvasData) 231 | { 232 | if (Canvas == null) 233 | { 234 | i++; 235 | continue; 236 | } 237 | 238 | new ChalkPacket(i, Canvas).SendPacket("single", (int)CHANNELS.CHALK, id); 239 | 240 | i++; 241 | } 242 | } 243 | } 244 | } -------------------------------------------------------------------------------- /Fishy/Utils/Punish.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Models; 2 | using Fishy.Models.Packets; 3 | using Steamworks; 4 | 5 | namespace Fishy.Utils 6 | { 7 | class Punish 8 | { 9 | internal static void BanPlayer(Player playerToBan) 10 | { 11 | new BanPacket().SendPacket("single", (int)CHANNELS.GAME_STATE, playerToBan.SteamID); 12 | new ForceDisconnectPacket(playerToBan.SteamID.Value.ToString()).SendPacket("all", (int)CHANNELS.GAME_STATE); 13 | Fishy.SteamHandler.UpdateSteamBanList(playerToBan.SteamID.Value.ToString()); 14 | using StreamWriter writer = new(Path.Combine(AppContext.BaseDirectory, "bans.txt"), true); 15 | writer.WriteLine(playerToBan.SteamID.Value.ToString()); 16 | Fishy.BannedUsers.Add(playerToBan.SteamID.Value.ToString()); 17 | } 18 | 19 | internal static void KickPlayer(Player playerToKick) 20 | => new KickPacket().SendPacket("single", (int)CHANNELS.GAME_STATE, playerToKick.SteamID); 21 | 22 | internal static bool IsBanned(SteamId id) 23 | { 24 | return Fishy.BannedUsers.Contains(id.Value.ToString()); 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Fishy/Utils/Spawner.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Models.Packets; 2 | using Fishy.Models; 3 | using System.Numerics; 4 | 5 | namespace Fishy.Utils 6 | { 7 | public static class Spawner 8 | { 9 | static float _rainChance = 0.0f; 10 | static int _alienCooldown = 16; 11 | static readonly ActorType[] _baseTypes = [ActorType.FISH_SPAWN, ActorType.NONE]; 12 | static readonly Random _random = new(); 13 | 14 | // Vanilla spawn routine, ported from world.gd 15 | public static void SpawnIngameEvent() 16 | { 17 | foreach (Actor instance in Fishy.Actors.ToList()) 18 | { 19 | float instanceAge = DateTimeOffset.UtcNow.ToUnixTimeSeconds() - instance.SpawnTime.ToUnixTimeSeconds(); 20 | if (instance.Despawn && instance.DespawnTime != -1 && instanceAge > instance.DespawnTime) 21 | RemoveActor(instance); 22 | } 23 | 24 | int count = Fishy.Actors.Where(a => a.Type == ActorType.METAL_SPAWN).Count(); 25 | if (count < 7) 26 | VanillaSpawn(ActorType.METAL_SPAWN); 27 | 28 | ActorType type = _baseTypes[_random.Next(0, 2)]; 29 | 30 | _alienCooldown -= 1; 31 | 32 | if (_random.NextSingle() < 0.01 && _random.NextSingle() < 0.4 && _alienCooldown <= 0) 33 | { 34 | type = ActorType.FISH_SPAWN_ALIEN; 35 | _alienCooldown = 16; 36 | } 37 | 38 | if (_random.NextSingle() < _rainChance && _random.NextSingle() < .12f) 39 | { 40 | type = ActorType.RAINCLOUD; 41 | _rainChance = 0; 42 | } 43 | else 44 | if (_random.NextSingle() < .75f) _rainChance += .001f; 45 | 46 | if (_random.NextSingle() < 0.01f && _random.NextSingle() < 0.25) 47 | type = ActorType.VOID_PORTAL; 48 | 49 | if (type == ActorType.NONE || (type == ActorType.FISH_SPAWN && Fishy.Actors.Count > 15)) 50 | return; 51 | 52 | VanillaSpawn(type); 53 | } 54 | 55 | // Spawns an actor according to vanilla spawning mechanics 56 | public static void VanillaSpawn(ActorType type) 57 | { 58 | int id = GetFreeId(); 59 | Vector3 pos; 60 | 61 | switch (type) 62 | { 63 | case ActorType.FISH_SPAWN: 64 | case ActorType.FISH_SPAWN_ALIEN: 65 | pos = Fishy.World.FishSpawns[_random.Next(Fishy.World.FishSpawns.Count)]; 66 | SpawnActor(new Actor(id, type, pos) { Despawn=true, DespawnTime = (type == ActorType.FISH_SPAWN_ALIEN ? 120 : 80)}); 67 | 68 | if (type != ActorType.FISH_SPAWN) 69 | new ActorRemovePacket(id) { Action = "_ready" }.SendPacket("all", (int)CHANNELS.GAME_STATE); 70 | 71 | break; 72 | 73 | case ActorType.RAINCLOUD: 74 | pos = new(_random.Next(-100, 150), 42f, _random.Next(-150, 100)); 75 | SpawnActor(new RainCloud(GetFreeId(), pos)); 76 | break; 77 | 78 | case ActorType.METAL_SPAWN: 79 | pos = Fishy.World.TrashPoints[_random.Next(Fishy.World.TrashPoints.Count)]; 80 | if (_random.NextSingle() < .15f) 81 | pos = Fishy.World.ShorelinePoints[_random.Next(Fishy.World.ShorelinePoints.Count)]; 82 | 83 | SpawnActor(new Actor(GetFreeId(), ActorType.METAL_SPAWN, pos)); 84 | break; 85 | 86 | case ActorType.VOID_PORTAL: 87 | pos = Fishy.World.HiddenSpots[_random.Next(Fishy.World.HiddenSpots.Count)]; 88 | SpawnActor(new Actor(GetFreeId(), ActorType.VOID_PORTAL, pos){ Despawn = true, DespawnTime = 600}); 89 | break; 90 | 91 | default: 92 | break; 93 | } 94 | } 95 | 96 | public static int GetFreeId() 97 | { 98 | int id = _random.Next(); 99 | while (Fishy.Actors.Select(f => f.InstanceID).Contains(id)) 100 | id = _random.Next(); 101 | 102 | return id; 103 | } 104 | 105 | public static void SpawnActor(Actor actor) 106 | { 107 | new ActorSpawnPacket(actor.Type, actor.Position, actor.InstanceID).SendPacket("all", (int)CHANNELS.GAME_STATE); 108 | if (!Fishy.Actors.Contains(actor)) 109 | Fishy.Actors.Add(actor); 110 | Event.EventManager.RaiseEvent(new Event.EventArgs.ActorSpawnEventArgs(actor)); 111 | if (actor.Rotation == default) 112 | return; 113 | new ActorUpdatePacket(actor.InstanceID, actor.Position, actor.Rotation).SendPacket("all", (int)CHANNELS.GAME_STATE); 114 | 115 | } 116 | public static Actor SpawnActor(ActorType type, Vector3 position, Vector3 entRot = default) 117 | { 118 | return SpawnActor(type.ToString().ToLower(), position, entRot); 119 | } 120 | public static Actor SpawnActor(string type, Vector3 position, Vector3 entRot = default) 121 | { 122 | var actor = new Actor(GetFreeId(), type, position, entRot); 123 | SpawnActor(actor); 124 | return actor; 125 | } 126 | 127 | public static void RemoveActor(Actor actor) 128 | { 129 | new ActorRemovePacket(actor.InstanceID).SendPacket("all", (int)CHANNELS.GAME_STATE); 130 | Event.EventManager.RaiseEvent(new Event.EventArgs.ActorDespawnEventArgs(actor)); 131 | Fishy.Actors.Remove(actor); 132 | } 133 | 134 | public static void RemoveActor(int ID) 135 | { 136 | new ActorRemovePacket(ID).SendPacket("all", (int)CHANNELS.GAME_STATE); 137 | for (int i=0; i= Fishy.Actors.Count) 140 | return; 141 | var actor = Fishy.Actors[i]; 142 | if (actor.InstanceID != ID) 143 | continue; 144 | Fishy.Actors.Remove(actor); 145 | return; 146 | } 147 | } 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /Fishy/Utils/SteamHandler.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Models; 2 | using Steamworks; 3 | using Steamworks.Data; 4 | 5 | namespace Fishy.Utils 6 | { 7 | class SteamHandler 8 | { 9 | public Lobby Lobby { get; set; } 10 | 11 | public SteamHandler() 12 | { 13 | SteamMatchmaking.OnLobbyCreated += SteamMatchmaking_OnLobbyCreated; 14 | SteamMatchmaking.OnLobbyMemberJoined += SteamMatchmaking_OnLobbyMemberJoined; 15 | SteamMatchmaking.OnLobbyMemberLeave += SteamMatchmaking_OnLobbyMemberLeave; 16 | SteamNetworking.OnP2PSessionRequest += SteamMatchmaking_OnP2PSessionRequest; 17 | } 18 | 19 | public static string Init() 20 | { 21 | try 22 | { 23 | SteamClient.Init(3146520, false); 24 | return ""; 25 | } 26 | catch (Exception e) { return e.Message; } 27 | } 28 | 29 | public static void CreateLobby() 30 | { 31 | SteamMatchmaking.CreateLobbyAsync(Fishy.Config.MaxPlayers); 32 | } 33 | 34 | void SteamMatchmaking_OnLobbyCreated(Result result, Lobby Lobby) 35 | { 36 | Lobby.SetJoinable(true); 37 | Lobby.SetData("ref", "webfishing_gamelobby"); 38 | Lobby.SetData("name", Fishy.Config.ServerName); 39 | Lobby.SetData("version", Fishy.Config.GameVersion); 40 | Lobby.SetData("code", Fishy.Config.LobbyCode); 41 | Lobby.SetData("type", Fishy.Config.CodeOnly ? "code_only" : "public"); 42 | Lobby.SetData("public", "true"); 43 | Lobby.SetData("banned_players", ""); 44 | Lobby.SetData("age_limit", Fishy.Config.AgeRestricted.ToString().ToLower()); 45 | Lobby.SetData("cap", Fishy.Config.MaxPlayers.ToString()); 46 | Lobby.SetData("lurefilter", "dedicated"); 47 | 48 | SteamNetworking.AllowP2PPacketRelay(true); 49 | 50 | Lobby.SetData("server_browser_value", "0"); 51 | 52 | Console.WriteLine("Lobby Created!"); 53 | Console.WriteLine($"Lobby Code: {Lobby.GetData("code")}"); 54 | 55 | this.Lobby = Lobby; 56 | UpdatePlayerCount(); 57 | } 58 | 59 | void SteamMatchmaking_OnLobbyMemberJoined(Lobby Lobby, Friend userJoining) 60 | { 61 | // Try to stop spammers from spam joining, spammer get scammed! 62 | foreach (var pl in Fishy.Players) 63 | if (pl.SteamID == userJoining.Id) return; 64 | if (Punish.IsBanned(userJoining.Id)) // Well, that's the best I can do 65 | return; 66 | UpdatePlayerCount(); 67 | Player player = new(userJoining.Id, userJoining.Name); 68 | 69 | Console.WriteLine(DateTime.Now.ToString("dd.MM HH:mm:ss") + $" A Player Joined: {userJoining.Name}"); 70 | 71 | Fishy.Players.Add(player); 72 | 73 | Event.EventManager.RaiseEvent(new Event.EventArgs.PlayerJoinEventArgs(player)); 74 | 75 | Console.Title = $"Fishy Server - There are currently {Fishy.Players.Count} Players playing"; 76 | } 77 | 78 | void SteamMatchmaking_OnLobbyMemberLeave(Lobby Lobby, Friend userLeaving) 79 | { 80 | UpdatePlayerCount(); 81 | Console.WriteLine(DateTime.Now.ToString("dd.MM HH:mm:ss") + $" A Player Left: {userLeaving.Name}"); 82 | 83 | Event.EventManager.RaiseEvent(new Event.EventArgs.PlayerLeaveEventArgs(Fishy.Players.First(player => player.SteamID.Equals(userLeaving.Id)))); 84 | 85 | Fishy.Players.RemoveAll(player => player.SteamID.Equals(userLeaving.Id)); 86 | Console.Title = $"Fishy Server - There are currently {Fishy.Players.Count} Players playing"; 87 | } 88 | 89 | void SteamMatchmaking_OnP2PSessionRequest(SteamId id) 90 | { 91 | if (Punish.IsBanned(id)) return; 92 | if (Lobby.Members.Any(player => player.Id.Value.Equals(id))) 93 | SteamNetworking.AcceptP2PSessionWithUser(id); 94 | } 95 | 96 | 97 | private void UpdatePlayerCount() 98 | { 99 | Lobby.SetData("name", Fishy.Config.ServerName); 100 | Lobby.SetData("lobby_name", Fishy.Config.ServerName); 101 | } 102 | 103 | public void UpdateSteamBanList(string bannedPlayerSteamID) 104 | { 105 | if (string.IsNullOrEmpty(bannedPlayerSteamID)) return; 106 | 107 | string banList = Lobby.GetData("banned_players"); 108 | banList = String.IsNullOrEmpty(banList) ? bannedPlayerSteamID : $"{bannedPlayerSteamID},{banList}"; 109 | Lobby.SetData("banned_players", banList); 110 | } 111 | 112 | public void SetSteamBanList(List bannedPlayers) 113 | { 114 | if (bannedPlayers.Count == 0) return; 115 | string banList = String.Join(",", bannedPlayers); 116 | Lobby.SetData("banned_players", banList); 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /Fishy/bans.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ncrypted-dev/Fishy/6ccb47f2a5ecd3d95d92791aa2e7401260e60be5/Fishy/bans.txt -------------------------------------------------------------------------------- /Fishy/config.toml: -------------------------------------------------------------------------------- 1 | # Example config file 2 | server_name = "Dedicated Server [Vanilla][Fishy]" 3 | # Message that the player gets when joining the server 4 | join_message = "This is a Fishy dedicated server - https://github.com/ncrypted-dev/Fishy. Type !rules or !help for further information." 5 | # Define the rules that should be displayed with !rules 6 | rules = ["No Racism, Sexism, Harassment or Hate-Speech", "No spamming", "No griefing (Chalk)", "Mods are allowed as long as they don't impact others"] 7 | game_version = "1.1" 8 | max_players = 12 9 | # If set to true only players who know the lobby_code can join 10 | code_only = true 11 | # Should be a random six letter string 12 | lobby_code = "DEDI12" 13 | age_restricted = false 14 | # Name of the world file in your Worlds folder 15 | world = "main_zone.tscn" 16 | # SteamID of the admins 17 | admins = [""] 18 | # Folder where player reports should be saved 19 | report_folder = "Reports" 20 | # This is the message the players gets after reporting someone 21 | report_response = "Hello, your report has been received and will be looked at as soon as possible. In the meantime we recommend you to hide/block the offending player." 22 | 23 | # This is where certain settings can be set for plugins 24 | [plugins.webserver] 25 | # Username for the webinterface 26 | username = "admin" 27 | # Password - SHA512 hash (default=admin) 28 | password = "c7ad44cbad762a5da0a452f9e854fdc1e0e7a52a38015f23f3eab1d80b931dd472634dfac71cd34ebc35d16ab7fb8a90c81f975113d6c7538dc69dd8de9077ec" -------------------------------------------------------------------------------- /FishyWebserver/ActionController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Fishy.Models; 7 | using Fishy.Models.Packets; 8 | using GenHTTP.Api.Protocol; 9 | using GenHTTP.Modules.Controllers; 10 | using GenHTTP.Modules.Reflection; 11 | 12 | 13 | namespace Fishy.Webserver 14 | { 15 | internal class ActionController 16 | { 17 | [ControllerAction(RequestMethod.Post)] 18 | public void Spawn([FromBody] string actor_type) 19 | { 20 | if (Enum.TryParse(actor_type, true, out ActorType actorType)) 21 | WebserverExtension.SpawnActor(actorType); 22 | } 23 | 24 | [ControllerAction(RequestMethod.Post)] 25 | public void Chat([FromBody] string message) 26 | => WebserverExtension.SendPacketToAll(new MessagePacket("Server: " + message)); 27 | 28 | [ControllerAction(RequestMethod.Post)] 29 | public void Kick([FromBody] string accountId) 30 | { 31 | Player? p = WebserverExtension.Players.First(p => p.SteamID.AccountId.ToString() == accountId); 32 | if (p != null) 33 | WebserverExtension.KickPlayer(p); 34 | } 35 | 36 | [ControllerAction(RequestMethod.Post)] 37 | public void Ban([FromBody] string accountId) 38 | { 39 | Player? p = WebserverExtension.Players.First(p => p.SteamID.AccountId.ToString() == accountId); 40 | if (p != null) 41 | WebserverExtension.BanPlayer(p); 42 | } 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /FishyWebserver/Authentication.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | using System.Text; 3 | using GenHTTP.Api.Content.Authentication; 4 | using GenHTTP.Modules.Authentication.Basic; 5 | 6 | namespace Fishy.Webserver 7 | { 8 | class Authentication 9 | { 10 | public static ValueTask Auth(string user, string password) 11 | { 12 | string hashedPw; 13 | byte[] data = SHA512.HashData(Encoding.UTF8.GetBytes(password)); 14 | hashedPw = GetStringFromHash(data).ToLower(); 15 | 16 | if (user == WebserverExtension.GetUsername() && 17 | hashedPw == WebserverExtension.GetPassword().ToLower()) 18 | return new(new BasicAuthenticationUser(user)); 19 | else 20 | return new(); 21 | } 22 | 23 | private static string GetStringFromHash(byte[] hash) 24 | { 25 | StringBuilder result = new (); 26 | for (int i = 0; i < hash.Length; i++) 27 | { 28 | result.Append(hash[i].ToString("X2")); 29 | } 30 | return result.ToString(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /FishyWebserver/Dashboard.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json; 2 | using Fishy.Models; 3 | using Fishy.Models.Packets; 4 | using Fishy.Utils; 5 | using GenHTTP.Engine.Internal; 6 | using GenHTTP.Modules.Authentication; 7 | using GenHTTP.Modules.Controllers; 8 | using GenHTTP.Modules.Functional; 9 | using GenHTTP.Modules.IO; 10 | using GenHTTP.Modules.Layouting; 11 | using GenHTTP.Modules.Practices; 12 | using GenHTTP.Modules.Reflection; 13 | using GenHTTP.Modules.ServerSentEvents; 14 | 15 | namespace Fishy.Webserver 16 | { 17 | internal class Dashboard 18 | { 19 | internal readonly List MessageToSync = []; 20 | internal readonly Dictionary PlayersToSync = []; 21 | public void Initalize() 22 | { 23 | var mainPage = Content.From(Resource.FromAssembly("index.html")); 24 | var syncEvent = EventSource.Create().Generator(SyncStats); 25 | 26 | var app = Layout.Create() 27 | .Index(mainPage) 28 | .Add("status", syncEvent) 29 | .AddController("action") 30 | .Authentication(Authentication.Auth); 31 | 32 | Host.Create() 33 | .Defaults() 34 | .Handler(app) 35 | .StartAsync(); 36 | } 37 | 38 | 39 | async ValueTask SyncStats(IEventConnection connection) 40 | { 41 | // Resync data on reload 42 | foreach (Player p in WebserverExtension.Players) 43 | await connection.DataAsync(JsonSerializer.Serialize(p), "join"); 44 | 45 | foreach (ChatMessage m in WebserverExtension.ChatLog) 46 | await connection.DataAsync(m.ToString(), "message"); 47 | 48 | // Sync new data while connected 49 | while (connection.Connected) 50 | { 51 | await connection.DataAsync(WebserverExtension.Players.Count, "players"); 52 | await connection.DataAsync(WebserverExtension.BannedPlayers.Count, "banned"); 53 | await connection.DataAsync(WebserverExtension.Actors.Count, "actors"); 54 | 55 | if (MessageToSync.Count > 0) 56 | { 57 | foreach (ChatMessage s in MessageToSync) 58 | await connection.DataAsync(s.ToString(), "message"); 59 | 60 | MessageToSync.Clear(); 61 | } 62 | 63 | if (PlayersToSync.Count > 0) 64 | { 65 | foreach (KeyValuePair p in PlayersToSync) 66 | await connection.DataAsync(JsonSerializer.Serialize(p.Key), p.Value); 67 | 68 | PlayersToSync.Clear(); 69 | } 70 | 71 | await Task.Delay(100); 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /FishyWebserver/Fishy.Webserver.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | true 8 | 9 | True 10 | 11 | 12 | 13 | embedded 14 | 15 | 16 | 17 | embedded 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | Never 27 | 28 | 29 | 30 | 31 | 32 | all 33 | runtime; build; native; contentfiles; analyzers; buildtransitive 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | false 48 | runtime 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /FishyWebserver/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /FishyWebserver/WebserverExtension.cs: -------------------------------------------------------------------------------- 1 | using Fishy.Extensions; 2 | 3 | namespace Fishy.Webserver 4 | { 5 | class WebserverExtension : FishyExtension 6 | { 7 | readonly static Dashboard dashboard = new(); 8 | 9 | public static string GetUsername() 10 | => GetConfigValue("webserver")["username"].ToString() ?? ""; 11 | public static string GetPassword() 12 | => GetConfigValue("webserver")["password"].ToString() ?? ""; 13 | public static void OnChatMessage(object? sender, Event.EventArgs.ChatMessageEventArgs args) 14 | => dashboard.MessageToSync.Add(args.ChatMessage); 15 | public static void OnPlayerJoin(object? sender,Event.EventArgs.PlayerJoinEventArgs args) 16 | => dashboard.PlayersToSync.TryAdd(args.Player, "join"); 17 | public static void OnPlayerLeave(object? sender, Event.EventArgs.PlayerLeaveEventArgs args) 18 | => dashboard.PlayersToSync.TryAdd(args.Player, "leave"); 19 | public override void OnInit() 20 | { 21 | dashboard.Initalize(); 22 | 23 | // Subscribe to events 24 | Event.EventManager.OnChatMessage += OnChatMessage; 25 | Event.EventManager.OnPlayerJoin += OnPlayerJoin; 26 | Event.EventManager.OnPlayerLeave += OnPlayerLeave; 27 | 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /FishyWebserver/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Fishy Dashboard 5 | 6 | 7 | 8 |
9 |
10 |

Fishy - Admin Dashboard

11 |
12 |
13 |
14 |
Players
15 |
16 |
There are 0 players online
17 |
18 |
19 |
20 |
21 |
22 |
Banned Players
23 |
24 |
There are 0 players banned
25 |
26 |
27 |
28 |
29 |
30 |
Actors
31 |
32 |
There are 0 actors loaded
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
Lobby Chat
41 |
42 |
    43 |
44 |
45 |
46 | 47 |
48 |
49 | 50 |
51 |
52 |
53 |
54 |
55 | 56 | 57 | 58 | 59 | 60 |
61 |
62 |
63 |
64 |
Player List
65 |
66 |
    67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Fishy 2 | 3 | Fishy is a "**work in progress**" vanilla dedicated server for Webfishing written in C#. 4 | 5 | > [!WARNING] 6 | > Fishy is in Beta—it's largely stable, but some minor issues may occur, and a few features are still in progress. 7 | 8 | ## Why a dedicated server? 9 | I’ve always loved the concept and style of Webfishing, but there’s one issue that has always bothered me: 10 | Getting disconnected when the host leaves and never being able to finish the nice chat you have just had with some random person. 11 | 12 | **This is where Fishy comes in.** 13 | 14 | ## About Fishy 15 | 16 | Fishy was built entirely from the ground up using a decompiled version of Webfishing, with additional inspiration drawn from [WebFishingCove](https://github.com/DrMeepso/WebFishingCove). 17 | 18 | The primary goal of this project is to create a fully functional vanilla dedicated server. 19 | While mods aren't a primary focus right now, you're welcome to contribute via pull requests if you're interested in exploring that option. 20 | 21 | I’ve made an effort to write clean, maintainable code so that anyone who wants to contribute can easily get involved. 22 | 23 | ## Features 24 | 25 | - Near-complete actor support 26 | - Highly customizable via config.toml 27 | - Player and admin commands 28 | - Extensions support (webserver plugin included) 29 | 30 | ## How to host your own Server 31 | > [!IMPORTANT] 32 | > You will need a second Steam account with the game purchased in order to host your own server. 33 | 34 | 1. **Install Steam** on your server and download Webfishing 35 | 2. **Extract** the main_zone.tscn from the game ([Example Tool](https://github.com/bruvzg/gdsdecomp)) 36 | 3. **Download** Fishy from the Releases page 37 | 4. **Copy** the main_zone.tscn into the Worlds folder 38 | 5. **Modify** the config.toml file to your likings 39 | 6. **Start** Fishy 40 | 41 | **Using the Webserver plugin?** Visit [http://localhost:8080](http://localhost:8080) and log in with the credentials from config.toml 42 | 43 | ## How to create your own Extensions 44 | 45 | - Reference Fishy.dll 46 | - Create a main plugin class inheriting from FishyExtension 47 | - Override functions to add custom logic 48 | - Compile the plugin into a single .dll (e.g., using Costura.Fody) 49 | - Add the .dll to the Plugins folder 50 | 51 | ## Similar Projects 52 | - WebfishingCove 53 | 54 | ## TODO 55 | 56 | As mentioned earlier, feel free to submit pull requests or open issues if you’d like to contribute! :) 57 | 58 | - [x] Complete basic server functionality 59 | - [x] Release Linux builds 60 | - [x] Improve spawning and events 61 | - [ ] Rework conversion between "GodotPackets" and C# 62 | - [x] Improve admin system (Reports, Admin-Commands, Banning/Kicking) 63 | - [ ] Address bug fixes (and even more bug fixes) 64 | 65 | ## License 66 | Copyright (C) 2024 ncrypted.dev 67 | 68 | This program is free software: you can redistribute it and/or modify 69 | it under the terms of the GNU General Public License as published by 70 | the Free Software Foundation, either version 3 of the License, or 71 | (at your option) any later version. 72 | 73 | This program is distributed in the hope that it will be useful, 74 | but WITHOUT ANY WARRANTY; without even the implied warranty of 75 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 76 | GNU General Public License for more details. 77 | 78 | You should have received a copy of the GNU General Public License 79 | along with this program. If not, see . 80 | 81 | ## Support me and my projects 82 | 83 | ### Liberapay 84 | Donate using Liberapay 85 | --------------------------------------------------------------------------------