Files
OldThink/Content.Server.Database/Model.cs
Remuchi 5e74f6ae53 Merge branch 'master' of https://github.com/space-wizards/space-station-14 into upstream
# Conflicts:
#	Content.Client/Administration/Managers/ClientAdminManager.cs
#	Content.Client/Administration/Systems/BwoinkSystem.cs
#	Content.Client/Alerts/ClientAlertsSystem.cs
#	Content.Client/Audio/BackgroundAudioSystem.cs
#	Content.Client/CardboardBox/CardboardBoxSystem.cs
#	Content.Client/Chemistry/UI/InjectorStatusControl.cs
#	Content.Client/Chemistry/UI/ReagentDispenserWindow.xaml
#	Content.Client/Chemistry/UI/ReagentDispenserWindow.xaml.cs
#	Content.Client/Clothing/ClientClothingSystem.cs
#	Content.Client/CriminalRecords/CriminalRecordsConsoleBoundUserInterface.cs
#	Content.Client/CriminalRecords/CriminalRecordsConsoleWindow.xaml.cs
#	Content.Client/Decals/Overlays/DecalOverlay.cs
#	Content.Client/DoAfter/DoAfterOverlay.cs
#	Content.Client/Doors/AirlockSystem.cs
#	Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml
#	Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs
#	Content.Client/Launcher/LauncherConnectingGui.xaml
#	Content.Client/Launcher/LauncherConnectingGui.xaml.cs
#	Content.Client/Lobby/LobbyState.cs
#	Content.Client/Lobby/UI/LobbyGui.xaml.cs
#	Content.Client/MainMenu/UI/MainMenuControl.xaml
#	Content.Client/MassMedia/Ui/MiniArticleCardControl.xaml
#	Content.Client/MassMedia/Ui/MiniArticleCardControl.xaml.cs
#	Content.Client/MassMedia/Ui/NewsWriteMenu.xaml
#	Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs
#	Content.Client/Options/UI/Tabs/MiscTab.xaml
#	Content.Client/Options/UI/Tabs/MiscTab.xaml.cs
#	Content.Client/Outline/InteractionOutlineSystem.cs
#	Content.Client/Overlays/ShowSecurityIconsSystem.cs
#	Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs
#	Content.Client/Popups/PopupOverlay.cs
#	Content.Client/Popups/PopupSystem.cs
#	Content.Client/Preferences/ClientPreferencesManager.cs
#	Content.Client/Preferences/UI/HumanoidProfileEditor.xaml
#	Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs
#	Content.Client/StatusIcon/StatusIconOverlay.cs
#	Content.Client/Stylesheets/StyleNano.cs
#	Content.Client/UserInterface/Systems/Bwoink/AHelpUIController.cs
#	Content.Client/UserInterface/Systems/Chat/ChatUIController.cs
#	Content.Server/Access/Systems/IdCardConsoleSystem.cs
#	Content.Server/Administration/Commands/BanCommand.cs
#	Content.Server/Administration/Notes/AdminMessageEui.cs
#	Content.Server/Administration/Notes/AdminNotesSystem.cs
#	Content.Server/Administration/Notes/IAdminNotesManager.cs
#	Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs
#	Content.Server/Administration/Systems/BwoinkSystem.cs
#	Content.Server/Administration/UI/PermissionsEui.cs
#	Content.Server/Antag/AntagSelectionSystem.cs
#	Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs
#	Content.Server/Atmos/Piping/Unary/EntitySystems/GasThermoMachineSystem.cs
#	Content.Server/Chat/Systems/ChatSystem.cs
#	Content.Server/Chemistry/EntitySystems/InjectorSystem.cs
#	Content.Server/Chemistry/EntitySystems/ReagentDispenserSystem.cs
#	Content.Server/Connection/ConnectionManager.cs
#	Content.Server/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs
#	Content.Server/Database/DatabaseRecords.cs
#	Content.Server/Database/ServerDbBase.cs
#	Content.Server/Database/ServerDbManager.cs
#	Content.Server/DeviceLinking/Systems/SignalTimerSystem.cs
#	Content.Server/Doors/Systems/DoorSystem.cs
#	Content.Server/Execution/ExecutionSystem.cs
#	Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
#	Content.Server/Fax/FaxSystem.cs
#	Content.Server/Fluids/EntitySystems/PuddleSystem.Evaporation.cs
#	Content.Server/GameTicking/GameTicker.Replays.cs
#	Content.Server/GameTicking/GameTicker.RoundFlow.cs
#	Content.Server/GameTicking/Rules/Components/ThiefRuleComponent.cs
#	Content.Server/GameTicking/Rules/GameRuleSystem.Utility.cs
#	Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs
#	Content.Server/GameTicking/Rules/RevolutionaryRuleSystem.cs
#	Content.Server/GameTicking/Rules/ThiefRuleSystem.cs
#	Content.Server/GameTicking/Rules/TraitorRuleSystem.cs
#	Content.Server/GameTicking/Rules/ZombieRuleSystem.cs
#	Content.Server/Hands/Systems/HandsSystem.cs
#	Content.Server/Holosign/HolosignSystem.cs
#	Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.cs
#	Content.Server/Info/InfoSystem.cs
#	Content.Server/Kitchen/EntitySystems/SharpSystem.cs
#	Content.Server/Magic/MagicSystem.cs
#	Content.Server/MagicMirror/MagicMirrorSystem.cs
#	Content.Server/Mapping/MappingSystem.cs
#	Content.Server/MassMedia/Systems/NewsSystem.cs
#	Content.Server/Medical/Components/HealthAnalyzerComponent.cs
#	Content.Server/Medical/CrewMonitoring/CrewMonitoringServerSystem.cs
#	Content.Server/Medical/CryoPodSystem.cs
#	Content.Server/Medical/HealthAnalyzerSystem.cs
#	Content.Server/Nutrition/EntitySystems/OpenableSystem.cs
#	Content.Server/Preferences/Managers/ServerPreferencesManager.cs
#	Content.Server/Remotes/DoorRemoteSystem.cs
#	Content.Server/Resist/EscapeInventorySystem.cs
#	Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs
#	Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs
#	Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs
#	Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs
#	Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs
#	Content.Server/Species/Systems/NymphSystem.cs
#	Content.Server/StationEvents/Components/GasLeakRuleComponent.cs
#	Content.Server/StationEvents/EventManagerSystem.cs
#	Content.Server/Store/Systems/StoreSystem.Ui.cs
#	Content.Server/Strip/StrippableSystem.cs
#	Content.Server/VendingMachines/VendingMachineSystem.cs
#	Content.Server/Weapons/Ranged/Systems/GunSystem.cs
#	Content.Shared.Database/LogType.cs
#	Content.Shared/Actions/SharedActionsSystem.cs
#	Content.Shared/Administration/AdminFlags.cs
#	Content.Shared/Administration/SharedBwoinkSystem.cs
#	Content.Shared/Anomaly/SharedAnomalySystem.cs
#	Content.Shared/Bed/Sleep/SharedSleepingSystem.cs
#	Content.Shared/Buckle/SharedBuckleSystem.Strap.cs
#	Content.Shared/Chat/ChatChannel.cs
#	Content.Shared/Chemistry/Components/InjectorComponent.cs
#	Content.Shared/Chemistry/EntitySystems/SharedInjectorSystem.cs
#	Content.Shared/Chemistry/SharedReagentDispenser.cs
#	Content.Shared/Containers/ItemSlot/ItemSlotsComponent.cs
#	Content.Shared/CriminalRecords/Systems/SharedCriminalRecordsConsoleSystem.cs
#	Content.Shared/Cuffs/SharedCuffableSystem.cs
#	Content.Shared/Doors/Systems/SharedDoorSystem.cs
#	Content.Shared/Friction/TileFrictionController.cs
#	Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs
#	Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs
#	Content.Shared/Implants/SharedImplanterSystem.cs
#	Content.Shared/Lock/LockSystem.cs
#	Content.Shared/MedicalScanner/HealthAnalyzerScannedUserMessage.cs
#	Content.Shared/Nutrition/Components/OpenableComponent.cs
#	Content.Shared/Nutrition/EntitySystems/SharedOpenableSystem.cs
#	Content.Shared/Nutrition/EntitySystems/ThirstSystem.cs
#	Content.Shared/Preferences/HumanoidCharacterProfile.cs
#	Content.Shared/Preferences/ICharacterProfile.cs
#	Content.Shared/Projectiles/SharedProjectileSystem.cs
#	Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs
#	Content.Shared/Security/SecurityStatus.cs
#	Content.Shared/Security/Systems/DeployableBarrierSystem.cs
#	Content.Shared/Slippery/SlipperySystem.cs
#	Content.Shared/Species/Systems/ReformSystem.cs
#	Content.Shared/Standing/StandingStateSystem.cs
#	Content.Shared/StatusIcon/StatusIconPrototype.cs
#	Content.Shared/Store/ListingPrototype.cs
#	Content.Shared/VendingMachines/SharedVendingMachineSystem.cs
#	Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
#	README.md
#	Resources/Audio/Ambience/Antag/pirate_start.ogg
#	Resources/Changelog/Changelog.yml
#	Resources/Credits/GitHub.txt
#	Resources/Locale/en-US/criminal-records/criminal-records.ftl
#	Resources/Locale/en-US/escape-menu/ui/options-menu.ftl
#	Resources/Locale/en-US/medical/components/health-analyzer-component.ftl
#	Resources/Locale/en-US/reagents/meta/biological.ftl
#	Resources/Locale/en-US/reagents/meta/fun.ftl
#	Resources/Locale/en-US/reagents/meta/physical-desc.ftl
#	Resources/Locale/en-US/seeds/seeds.ftl
#	Resources/Locale/en-US/wires/wire-names.ftl
#	Resources/Maps/Shuttles/cargo_fland.yml
#	Resources/Maps/core.yml
#	Resources/Maps/europa.yml
#	Resources/Maps/fland.yml
#	Resources/Maps/origin.yml
#	Resources/Maps/saltern.yml
#	Resources/Maps/train.yml
#	Resources/Prototypes/Actions/diona.yml
#	Resources/Prototypes/Atmospherics/gases.yml
#	Resources/Prototypes/Catalog/Cargo/cargo_emergency.yml
#	Resources/Prototypes/Catalog/Cargo/cargo_engines.yml
#	Resources/Prototypes/Catalog/Cargo/cargo_fun.yml
#	Resources/Prototypes/Catalog/Cargo/cargo_security.yml
#	Resources/Prototypes/Catalog/Cargo/cargo_service.yml
#	Resources/Prototypes/Catalog/Cargo/cargo_vending.yml
#	Resources/Prototypes/Catalog/Fills/Boxes/general.yml
#	Resources/Prototypes/Catalog/Fills/Boxes/syndicate.yml
#	Resources/Prototypes/Catalog/Fills/Crates/engines.yml
#	Resources/Prototypes/Catalog/Fills/Items/briefcases.yml
#	Resources/Prototypes/Catalog/Fills/Items/toolboxes.yml
#	Resources/Prototypes/Catalog/Fills/Lockers/dressers.yml
#	Resources/Prototypes/Catalog/Fills/Lockers/heads.yml
#	Resources/Prototypes/Catalog/Fills/Lockers/security.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/bardrobe.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/clothesmate.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/lawdrobe.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/medical.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/medidrobe.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/robotics.yml
#	Resources/Prototypes/Catalog/VendingMachines/Inventories/sec.yml
#	Resources/Prototypes/Catalog/uplink_catalog.yml
#	Resources/Prototypes/Datasets/Names/first_male.yml
#	Resources/Prototypes/Datasets/tips.yml
#	Resources/Prototypes/Entities/Clothing/Hands/colored.yml
#	Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml
#	Resources/Prototypes/Entities/Clothing/Head/hats.yml
#	Resources/Prototypes/Entities/Clothing/OuterClothing/coats.yml
#	Resources/Prototypes/Entities/Clothing/Uniforms/jumpsuits.yml
#	Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
#	Resources/Prototypes/Entities/Mobs/Player/silicon.yml
#	Resources/Prototypes/Entities/Mobs/Species/base.yml
#	Resources/Prototypes/Entities/Mobs/Species/slime.yml
#	Resources/Prototypes/Entities/Mobs/Species/vox.yml
#	Resources/Prototypes/Entities/Objects/Consumable/Drinks/drinks.yml
#	Resources/Prototypes/Entities/Objects/Consumable/Drinks/drinks_bottles.yml
#	Resources/Prototypes/Entities/Objects/Consumable/Food/produce.yml
#	Resources/Prototypes/Entities/Objects/Devices/Electronics/signaller.yml
#	Resources/Prototypes/Entities/Objects/Devices/nuke.yml
#	Resources/Prototypes/Entities/Objects/Devices/pda.yml
#	Resources/Prototypes/Entities/Objects/Fun/toys.yml
#	Resources/Prototypes/Entities/Objects/Materials/Sheets/glass.yml
#	Resources/Prototypes/Entities/Objects/Materials/parts.yml
#	Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml
#	Resources/Prototypes/Entities/Objects/Misc/implanters.yml
#	Resources/Prototypes/Entities/Objects/Misc/kudzu.yml
#	Resources/Prototypes/Entities/Objects/Misc/rubber_stamp.yml
#	Resources/Prototypes/Entities/Objects/Shields/shields.yml
#	Resources/Prototypes/Entities/Objects/Specific/Hydroponics/tools.yml
#	Resources/Prototypes/Entities/Objects/Specific/Medical/handheld_crew_monitor.yml
#	Resources/Prototypes/Entities/Objects/Specific/Medical/healthanalyzer.yml
#	Resources/Prototypes/Entities/Objects/Specific/Robotics/borg_modules.yml
#	Resources/Prototypes/Entities/Objects/Weapons/Bombs/firebomb.yml
#	Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/shotgun.yml
#	Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/shotgun.yml
#	Resources/Prototypes/Entities/Objects/Weapons/Melee/e_sword.yml
#	Resources/Prototypes/Entities/Structures/Decoration/curtains.yml
#	Resources/Prototypes/Entities/Structures/Doors/Airlocks/access.yml
#	Resources/Prototypes/Entities/Structures/Doors/MaterialDoors/material_doors.yml
#	Resources/Prototypes/Entities/Structures/Doors/Windoors/base_structurewindoors.yml
#	Resources/Prototypes/Entities/Structures/Lighting/base_lighting.yml
#	Resources/Prototypes/Entities/Structures/Machines/lathe.yml
#	Resources/Prototypes/Entities/Structures/Machines/vending_machines.yml
#	Resources/Prototypes/Entities/Structures/Specific/Anomaly/anomalies.yml
#	Resources/Prototypes/Entities/Structures/Storage/glass_box.yml
#	Resources/Prototypes/Entities/Structures/Wallmounts/fireaxe_cabinet.yml
#	Resources/Prototypes/Entities/Structures/Wallmounts/switch.yml
#	Resources/Prototypes/Entities/Structures/Walls/asteroid.yml
#	Resources/Prototypes/Entities/Structures/Walls/grille.yml
#	Resources/Prototypes/Entities/Structures/Walls/walls.yml
#	Resources/Prototypes/Entities/Structures/Windows/window.yml
#	Resources/Prototypes/Entities/Structures/stairs.yml
#	Resources/Prototypes/GameRules/events.yml
#	Resources/Prototypes/Hydroponics/seeds.yml
#	Resources/Prototypes/Maps/saltern.yml
#	Resources/Prototypes/Reagents/biological.yml
#	Resources/Prototypes/Reagents/fun.yml
#	Resources/Prototypes/Recipes/Construction/Graphs/utilities/solarpanel.yml
#	Resources/Prototypes/Recipes/Construction/weapons.yml
#	Resources/Prototypes/Recipes/Crafting/improvised.yml
#	Resources/Prototypes/Recipes/Lathes/clothing.yml
#	Resources/Prototypes/Recipes/Reactions/fun.yml
#	Resources/Prototypes/Research/arsenal.yml
#	Resources/Prototypes/Roles/Jobs/Engineering/technical_assistant.yml
#	Resources/Prototypes/Roles/Jobs/Fun/emergencyresponseteam.yml
#	Resources/Prototypes/Roles/Jobs/Medical/medical_intern.yml
#	Resources/Prototypes/Roles/Jobs/Medical/paramedic.yml
#	Resources/Prototypes/Roles/Jobs/Science/research_assistant.yml
#	Resources/Prototypes/Roles/Jobs/Security/detective.yml
#	Resources/Prototypes/Roles/Jobs/Security/security_cadet.yml
#	Resources/Prototypes/Roles/Jobs/departments.yml
#	Resources/Prototypes/Species/human.yml
#	Resources/Prototypes/Species/vox.yml
#	Resources/Prototypes/Stacks/Materials/materials.yml
#	Resources/Prototypes/StatusEffects/health.yml
#	Resources/Prototypes/Tiles/plating.yml
#	Resources/Prototypes/Voice/speech_emote_sounds.yml
#	Resources/Prototypes/Voice/speech_emotes.yml
#	Resources/Prototypes/explosion.yml
#	Resources/Prototypes/game_presets.yml
#	Resources/Prototypes/lobbyscreens.yml
#	Resources/Prototypes/secret_weights.yml
#	Resources/Prototypes/tags.yml
#	Resources/ServerInfo/Guidebook/Jobs.xml
#	Resources/ServerInfo/Guidebook/Science/ArtifactReports.xml
#	Resources/Textures/Clothing/Belt/emt.rsi/meta.json
#	Resources/Textures/Clothing/Head/Hats/beret_medic.rsi/meta.json
#	Resources/Textures/Clothing/Head/Hats/beret_qm.rsi/meta.json
#	Resources/Textures/Clothing/Head/Soft/bluesoft_flipped.rsi/meta.json
#	Resources/Textures/Clothing/Head/Soft/corpsoft_flipped.rsi/meta.json
#	Resources/Textures/Clothing/Head/Soft/greensoft_flipped.rsi/meta.json
#	Resources/Textures/Clothing/Head/Soft/greysoft_flipped.rsi/meta.json
#	Resources/Textures/Clothing/Head/Soft/paramedicsoft_flipped.rsi/meta.json
#	Resources/Textures/Clothing/Mask/neckgaiterred.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/slayer.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Hardsuits/syndicate.rsi/meta.json
#	Resources/Textures/Clothing/OuterClothing/Suits/syndicate.rsi/meta.json
#	Resources/Textures/Clothing/Uniforms/Jumpsuit/qmformal.rsi/meta.json
#	Resources/Textures/Decals/Overlays/greyscale.rsi/checkerNESW.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/checkerNWSE.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/fulltile_overlay.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/halftile_overlay.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/halftile_overlay_180.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/halftile_overlay_270.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/halftile_overlay_90.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/quartertile_overlay.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/quartertile_overlay_180.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/quartertile_overlay_270.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/quartertile_overlay_90.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/threequartertile_overlay.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/threequartertile_overlay_180.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/threequartertile_overlay_270.png
#	Resources/Textures/Decals/Overlays/greyscale.rsi/threequartertile_overlay_90.png
#	Resources/Textures/Interface/Misc/job_icons.rsi/meta.json
#	Resources/Textures/Interface/emotions.svg.192dpi.png.yml
#	Resources/Textures/LobbyScreens/dead-in-space.png.yml
#	Resources/Textures/LobbyScreens/doomed.webp.yml
#	Resources/Textures/LobbyScreens/pharmacy.png.yml
#	Resources/Textures/LobbyScreens/pharmacy.webp.yml
#	Resources/Textures/LobbyScreens/robotics.webp.yml
#	Resources/Textures/LobbyScreens/supermatter.png.yml
#	Resources/Textures/LobbyScreens/susstation.png.yml
#	Resources/Textures/LobbyScreens/warden.png.yml
#	Resources/Textures/LobbyScreens/warden.webp.yml
#	Resources/Textures/Mobs/Customization/human_hair.rsi/meta.json
#	Resources/Textures/Mobs/Effects/brute_damage.rsi/LLeg_Brute_40.png
#	Resources/Textures/Mobs/Effects/brute_damage.rsi/RLeg_Brute_40.png
#	Resources/Textures/Objects/Devices/nuke.rsi/meta.json
#	Resources/Textures/Objects/Devices/nuke.rsi/nuclearbomb_deployed.png
#	Resources/Textures/Objects/Devices/nuke.rsi/nuclearbomb_exploding.png
#	Resources/Textures/Objects/Devices/nuke.rsi/nuclearbomb_timing.png
#	Resources/Textures/Objects/Misc/books.rsi/meta.json
#	Resources/Textures/Objects/Misc/bureaucracy.rsi/paper_stamp-lawyer.png
#	Resources/Textures/Objects/Storage/boxes.rsi/meta.json
#	Resources/Textures/Objects/Tools/t-ray.rsi/tray-off.png
#	Resources/Textures/Objects/Tools/t-ray.rsi/tray-on.png
#	Resources/Textures/Objects/Weapons/Guns/Battery/mini-ebow.rsi/bolt.png
#	Resources/Textures/Structures/Doors/Airlocks/Standard/external.rsi/emergency_open_unlit.png
#	Resources/Textures/Structures/Doors/Airlocks/Standard/shuttle_syndicate.rsi/emergency_open_unlit.png
#	Resources/Textures/Structures/Doors/Windoors/plasma.rsi/emergency_unlit.png
#	Resources/Textures/Structures/Doors/Windoors/uranium.rsi/emergency_unlit.png
#	Resources/Textures/Structures/Power/Generation/Singularity/emitter.rsi/locked.png
#	Resources/Textures/Tiles/attributions.yml
#	Resources/Textures/Tiles/shuttleblue.png
#	Resources/Textures/Tiles/shuttleorange.png
#	Resources/Textures/Tiles/shuttlepurple.png
#	Resources/Textures/Tiles/shuttlered.png
#	Resources/Textures/Tiles/shuttlewhite.png
#	Resources/Textures/White/Fluff/DOOMMAX/cap_cap.rsi/meta.json
#	Resources/Textures/White/Fluff/HSKveez/hardsuit.rsi/meta.json
#	Resources/Textures/White/Fluff/Vtergot/strictgloves.rsi/meta.json
#	Resources/clientCommandPerms.yml
#	Resources/migration.yml
2024-03-26 15:52:23 +07:00

1011 lines
36 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Net;
using System.Text.Json;
using Content.Shared.Database;
using Microsoft.EntityFrameworkCore;
using NpgsqlTypes;
namespace Content.Server.Database
{
public abstract class ServerDbContext : DbContext
{
protected ServerDbContext(DbContextOptions options) : base(options)
{
}
public DbSet<Preference> Preference { get; set; } = null!;
public DbSet<Profile> Profile { get; set; } = null!;
public DbSet<AssignedUserId> AssignedUserId { get; set; } = null!;
public DbSet<Player> Player { get; set; } = default!;
public DbSet<Admin> Admin { get; set; } = null!;
public DbSet<AdminRank> AdminRank { get; set; } = null!;
public DbSet<Round> Round { get; set; } = null!;
public DbSet<Server> Server { get; set; } = null!;
public DbSet<AdminLog> AdminLog { get; set; } = null!;
public DbSet<AdminLogPlayer> AdminLogPlayer { get; set; } = null!;
public DbSet<Whitelist> Whitelist { get; set; } = null!;
public DbSet<ServerBan> Ban { get; set; } = default!;
public DbSet<ServerUnban> Unban { get; set; } = default!;
public DbSet<ServerBanExemption> BanExemption { get; set; } = default!;
public DbSet<ConnectionLog> ConnectionLog { get; set; } = default!;
public DbSet<ServerBanHit> ServerBanHit { get; set; } = default!;
public DbSet<ServerRoleBan> RoleBan { get; set; } = default!;
public DbSet<ServerRoleUnban> RoleUnban { get; set; } = default!;
public DbSet<PlayTime> PlayTime { get; set; } = default!;
public DbSet<UploadedResourceLog> UploadedResourceLog { get; set; } = default!;
public DbSet<AdminNote> AdminNotes { get; set; } = null!;
public DbSet<AdminWatchlist> AdminWatchlists { get; set; } = null!;
public DbSet<AdminMessage> AdminMessages { get; set; } = null!;
public DbSet<PlayerReputation> PlayerReputations { get; set; } = default!; // WD edit
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Preference>()
.HasIndex(p => p.UserId)
.IsUnique();
modelBuilder.Entity<Profile>()
.HasIndex(p => new {p.Slot, PrefsId = p.PreferenceId})
.IsUnique();
modelBuilder.Entity<Antag>()
.HasIndex(p => new {HumanoidProfileId = p.ProfileId, p.AntagName})
.IsUnique();
modelBuilder.Entity<Trait>()
.HasIndex(p => new {HumanoidProfileId = p.ProfileId, p.TraitName})
.IsUnique();
modelBuilder.Entity<Job>()
.HasIndex(j => j.ProfileId);
modelBuilder.Entity<Job>()
.HasIndex(j => j.ProfileId, "IX_job_one_high_priority")
.IsUnique()
.HasFilter("priority = 3");
modelBuilder.Entity<Job>()
.HasIndex(j => new { j.ProfileId, j.JobName })
.IsUnique();
modelBuilder.Entity<AssignedUserId>()
.HasIndex(p => p.UserName)
.IsUnique();
// Can't have two usernames with the same user ID.
modelBuilder.Entity<AssignedUserId>()
.HasIndex(p => p.UserId)
.IsUnique();
modelBuilder.Entity<Admin>()
.HasOne(p => p.AdminRank)
.WithMany(p => p!.Admins)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<AdminFlag>()
.HasIndex(f => new {f.Flag, f.AdminId})
.IsUnique();
modelBuilder.Entity<AdminRankFlag>()
.HasIndex(f => new {f.Flag, f.AdminRankId})
.IsUnique();
modelBuilder.Entity<AdminLog>()
.HasKey(log => new {log.RoundId, log.Id});
modelBuilder.Entity<AdminLog>()
.Property(log => log.Id);
modelBuilder.Entity<AdminLog>()
.HasIndex(log => log.Date);
modelBuilder.Entity<PlayTime>()
.HasIndex(v => new { v.PlayerId, Role = v.Tracker })
.IsUnique();
modelBuilder.Entity<AdminLogPlayer>()
.HasOne(player => player.Player)
.WithMany(player => player.AdminLogs)
.HasForeignKey(player => player.PlayerUserId)
.HasPrincipalKey(player => player.UserId);
modelBuilder.Entity<AdminLogPlayer>()
.HasIndex(p => p.PlayerUserId);
modelBuilder.Entity<Round>()
.HasIndex(round => round.StartDate);
modelBuilder.Entity<Round>()
.Property(round => round.StartDate)
.HasDefaultValue(default(DateTime));
modelBuilder.Entity<AdminLogPlayer>()
.HasKey(logPlayer => new {logPlayer.RoundId, logPlayer.LogId, logPlayer.PlayerUserId});
modelBuilder.Entity<ServerBan>()
.HasIndex(p => p.PlayerUserId);
modelBuilder.Entity<ServerBan>()
.HasIndex(p => p.Address);
modelBuilder.Entity<ServerBan>()
.HasIndex(p => p.PlayerUserId);
modelBuilder.Entity<ServerUnban>()
.HasIndex(p => p.BanId)
.IsUnique();
modelBuilder.Entity<ServerBan>().ToTable(t =>
t.HasCheckConstraint("HaveEitherAddressOrUserIdOrHWId", "address IS NOT NULL OR player_user_id IS NOT NULL OR hwid IS NOT NULL"));
// Ban exemption can't have flags 0 since that wouldn't exempt anything.
// The row should be removed if setting to 0.
modelBuilder.Entity<ServerBanExemption>().ToTable(t =>
t.HasCheckConstraint("FlagsNotZero", "flags != 0"));
modelBuilder.Entity<ServerRoleBan>()
.HasIndex(p => p.PlayerUserId);
modelBuilder.Entity<ServerRoleBan>()
.HasIndex(p => p.Address);
modelBuilder.Entity<ServerRoleBan>()
.HasIndex(p => p.PlayerUserId);
modelBuilder.Entity<ServerRoleUnban>()
.HasIndex(p => p.BanId)
.IsUnique();
modelBuilder.Entity<ServerRoleBan>().ToTable(t =>
t.HasCheckConstraint("HaveEitherAddressOrUserIdOrHWId", "address IS NOT NULL OR player_user_id IS NOT NULL OR hwid IS NOT NULL"));
modelBuilder.Entity<Player>()
.HasIndex(p => p.UserId)
.IsUnique();
modelBuilder.Entity<Player>()
.HasIndex(p => p.LastSeenUserName);
modelBuilder.Entity<ConnectionLog>()
.HasIndex(p => p.UserId);
modelBuilder.Entity<ConnectionLog>()
.Property(p => p.ServerId)
.HasDefaultValue(0);
modelBuilder.Entity<ConnectionLog>()
.HasOne(p => p.Server)
.WithMany(p => p.ConnectionLogs)
.OnDelete(DeleteBehavior.SetNull);
// SetNull is necessary for created by/edited by-s here,
// so you can safely delete admins (GDPR right to erasure) while keeping the notes intact
modelBuilder.Entity<AdminNote>()
.HasOne(note => note.Player)
.WithMany(player => player.AdminNotesReceived)
.HasForeignKey(note => note.PlayerUserId)
.HasPrincipalKey(player => player.UserId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<AdminNote>()
.HasOne(version => version.CreatedBy)
.WithMany(author => author.AdminNotesCreated)
.HasForeignKey(note => note.CreatedById)
.HasPrincipalKey(author => author.UserId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<AdminNote>()
.HasOne(version => version.LastEditedBy)
.WithMany(author => author.AdminNotesLastEdited)
.HasForeignKey(note => note.LastEditedById)
.HasPrincipalKey(author => author.UserId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<AdminNote>()
.HasOne(version => version.DeletedBy)
.WithMany(author => author.AdminNotesDeleted)
.HasForeignKey(note => note.DeletedById)
.HasPrincipalKey(author => author.UserId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<AdminWatchlist>()
.HasOne(note => note.Player)
.WithMany(player => player.AdminWatchlistsReceived)
.HasForeignKey(note => note.PlayerUserId)
.HasPrincipalKey(player => player.UserId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<AdminWatchlist>()
.HasOne(version => version.CreatedBy)
.WithMany(author => author.AdminWatchlistsCreated)
.HasForeignKey(note => note.CreatedById)
.HasPrincipalKey(author => author.UserId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<AdminWatchlist>()
.HasOne(version => version.LastEditedBy)
.WithMany(author => author.AdminWatchlistsLastEdited)
.HasForeignKey(note => note.LastEditedById)
.HasPrincipalKey(author => author.UserId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<AdminWatchlist>()
.HasOne(version => version.DeletedBy)
.WithMany(author => author.AdminWatchlistsDeleted)
.HasForeignKey(note => note.DeletedById)
.HasPrincipalKey(author => author.UserId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<AdminMessage>()
.HasOne(note => note.Player)
.WithMany(player => player.AdminMessagesReceived)
.HasForeignKey(note => note.PlayerUserId)
.HasPrincipalKey(player => player.UserId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<AdminMessage>()
.HasOne(version => version.CreatedBy)
.WithMany(author => author.AdminMessagesCreated)
.HasForeignKey(note => note.CreatedById)
.HasPrincipalKey(author => author.UserId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<AdminMessage>()
.HasOne(version => version.LastEditedBy)
.WithMany(author => author.AdminMessagesLastEdited)
.HasForeignKey(note => note.LastEditedById)
.HasPrincipalKey(author => author.UserId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<AdminMessage>()
.HasOne(version => version.DeletedBy)
.WithMany(author => author.AdminMessagesDeleted)
.HasForeignKey(note => note.DeletedById)
.HasPrincipalKey(author => author.UserId)
.OnDelete(DeleteBehavior.SetNull);
// A message cannot be "dismissed" without also being "seen".
modelBuilder.Entity<AdminMessage>().ToTable(t =>
t.HasCheckConstraint("NotDismissedAndSeen",
"NOT dismissed OR seen"));
modelBuilder.Entity<ServerBan>()
.HasOne(ban => ban.CreatedBy)
.WithMany(author => author.AdminServerBansCreated)
.HasForeignKey(ban => ban.BanningAdmin)
.HasPrincipalKey(author => author.UserId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<ServerBan>()
.HasOne(ban => ban.LastEditedBy)
.WithMany(author => author.AdminServerBansLastEdited)
.HasForeignKey(ban => ban.LastEditedById)
.HasPrincipalKey(author => author.UserId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<ServerRoleBan>()
.HasOne(ban => ban.CreatedBy)
.WithMany(author => author.AdminServerRoleBansCreated)
.HasForeignKey(ban => ban.BanningAdmin)
.HasPrincipalKey(author => author.UserId)
.OnDelete(DeleteBehavior.SetNull);
modelBuilder.Entity<ServerRoleBan>()
.HasOne(ban => ban.LastEditedBy)
.WithMany(author => author.AdminServerRoleBansLastEdited)
.HasForeignKey(ban => ban.LastEditedById)
.HasPrincipalKey(author => author.UserId)
.OnDelete(DeleteBehavior.SetNull);
}
public virtual IQueryable<AdminLog> SearchLogs(IQueryable<AdminLog> query, string searchText)
{
return query.Where(log => EF.Functions.Like(log.Message, "%" + searchText + "%"));
}
public abstract int CountAdminLogs();
}
// WD start
public class PlayerReputation
{
public int Id { get; set; }
public Guid UserId { get; set; }
public float Reputation { get; set; }
}
// WD end
public class Preference
{
// NOTE: on postgres there SHOULD be an FK ensuring that the selected character slot always exists.
// I had to use a migration to implement it and as a result its creation is a finicky mess.
// Because if I let EFCore know about it it would explode on a circular reference.
// Also it has to be DEFERRABLE INITIALLY DEFERRED so that insertion of new preferences works.
// Also I couldn't figure out how to create it on SQLite.
public int Id { get; set; }
public Guid UserId { get; set; }
public int SelectedCharacterSlot { get; set; }
public string AdminOOCColor { get; set; } = null!;
public List<Profile> Profiles { get; } = new();
}
public class Profile
{
public int Id { get; set; }
public int Slot { get; set; }
[Column("char_name")] public string CharacterName { get; set; } = null!;
public string ClownName { get; set; } = null!;
public string MimeName { get; set; } = null!;
public string BorgName { get; set; } = null!;
public string FlavorText { get; set; } = null!;
public int Age { get; set; }
public string Sex { get; set; } = null!;
public string Gender { get; set; } = null!;
//WD-EDIT
public string BodyType { get; set; } = null!;
public string Voice { get; set; } = null!;
//WD-EDIT
public string Species { get; set; } = null!;
[Column(TypeName = "jsonb")] public JsonDocument? Markings { get; set; } = null!;
public string HairName { get; set; } = null!;
public string HairColor { get; set; } = null!;
public string FacialHairName { get; set; } = null!;
public string FacialHairColor { get; set; } = null!;
public string EyeColor { get; set; } = null!;
public string SkinColor { get; set; } = null!;
public string Clothing { get; set; } = null!;
public string Backpack { get; set; } = null!;
public int SpawnPriority { get; set; } = 0;
public List<Job> Jobs { get; } = new();
public List<Antag> Antags { get; } = new();
public List<Trait> Traits { get; } = new();
[Column("pref_unavailable")] public DbPreferenceUnavailableMode PreferenceUnavailable { get; set; }
public int PreferenceId { get; set; }
public Preference Preference { get; set; } = null!;
}
public class Job
{
public int Id { get; set; }
public Profile Profile { get; set; } = null!;
public int ProfileId { get; set; }
public string JobName { get; set; } = null!;
public DbJobPriority Priority { get; set; }
}
public enum DbJobPriority
{
// These enum values HAVE to match the ones in JobPriority in Content.Shared
Never = 0,
Low = 1,
Medium = 2,
High = 3
}
public class Antag
{
public int Id { get; set; }
public Profile Profile { get; set; } = null!;
public int ProfileId { get; set; }
public string AntagName { get; set; } = null!;
}
public class Trait
{
public int Id { get; set; }
public Profile Profile { get; set; } = null!;
public int ProfileId { get; set; }
public string TraitName { get; set; } = null!;
}
public enum DbPreferenceUnavailableMode
{
// These enum values HAVE to match the ones in PreferenceUnavailableMode in Shared.
StayInLobby = 0,
SpawnAsOverflow,
}
public class AssignedUserId
{
public int Id { get; set; }
public string UserName { get; set; } = null!;
public Guid UserId { get; set; }
}
[Table("player")]
public class Player
{
public int Id { get; set; }
// Permanent data
public Guid UserId { get; set; }
public DateTime FirstSeenTime { get; set; }
// Data that gets updated on each join.
public string LastSeenUserName { get; set; } = null!;
public DateTime LastSeenTime { get; set; }
public IPAddress LastSeenAddress { get; set; } = null!;
public byte[]? LastSeenHWId { get; set; }
// Data that changes with each round
public List<Round> Rounds { get; set; } = null!;
public List<AdminLogPlayer> AdminLogs { get; set; } = null!;
public DateTime? LastReadRules { get; set; }
public List<AdminNote> AdminNotesReceived { get; set; } = null!;
public List<AdminNote> AdminNotesCreated { get; set; } = null!;
public List<AdminNote> AdminNotesLastEdited { get; set; } = null!;
public List<AdminNote> AdminNotesDeleted { get; set; } = null!;
public List<AdminWatchlist> AdminWatchlistsReceived { get; set; } = null!;
public List<AdminWatchlist> AdminWatchlistsCreated { get; set; } = null!;
public List<AdminWatchlist> AdminWatchlistsLastEdited { get; set; } = null!;
public List<AdminWatchlist> AdminWatchlistsDeleted { get; set; } = null!;
public List<AdminMessage> AdminMessagesReceived { get; set; } = null!;
public List<AdminMessage> AdminMessagesCreated { get; set; } = null!;
public List<AdminMessage> AdminMessagesLastEdited { get; set; } = null!;
public List<AdminMessage> AdminMessagesDeleted { get; set; } = null!;
public List<ServerBan> AdminServerBansCreated { get; set; } = null!;
public List<ServerBan> AdminServerBansLastEdited { get; set; } = null!;
public List<ServerRoleBan> AdminServerRoleBansCreated { get; set; } = null!;
public List<ServerRoleBan> AdminServerRoleBansLastEdited { get; set; } = null!;
}
[Table("whitelist")]
public class Whitelist
{
[Required, Key] public Guid UserId { get; set; }
}
public class Admin
{
[Key] public Guid UserId { get; set; }
public string? Title { get; set; }
public int? AdminRankId { get; set; }
public AdminRank? AdminRank { get; set; }
public List<AdminFlag> Flags { get; set; } = default!;
public string? AdminServer { get; set; }
}
public class AdminFlag
{
public int Id { get; set; }
public string Flag { get; set; } = default!;
public bool Negative { get; set; }
public Guid AdminId { get; set; }
public Admin Admin { get; set; } = default!;
}
public class AdminRank
{
public int Id { get; set; }
public string Name { get; set; } = default!;
public List<Admin> Admins { get; set; } = default!;
public List<AdminRankFlag> Flags { get; set; } = default!;
}
public class AdminRankFlag
{
public int Id { get; set; }
public string Flag { get; set; } = default!;
public int AdminRankId { get; set; }
public AdminRank Rank { get; set; } = default!;
}
public class Round
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public DateTime StartDate { get; set; }
public List<Player> Players { get; set; } = default!;
public List<AdminLog> AdminLogs { get; set; } = default!;
[ForeignKey("Server")] public int ServerId { get; set; }
public Server Server { get; set; } = default!;
}
public class Server
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Name { get; set; } = default!;
[InverseProperty(nameof(Round.Server))]
public List<Round> Rounds { get; set; } = default!;
[InverseProperty(nameof(ConnectionLog.Server))]
public List<ConnectionLog> ConnectionLogs { get; set; } = default!;
}
[Index(nameof(Type))]
public class AdminLog
{
[Key, ForeignKey("Round")] public int RoundId { get; set; }
[Key]
public int Id { get; set; }
public Round Round { get; set; } = default!;
[Required] public LogType Type { get; set; }
[Required] public LogImpact Impact { get; set; }
[Required] public DateTime Date { get; set; }
[Required] public string Message { get; set; } = default!;
[Required, Column(TypeName = "jsonb")] public JsonDocument Json { get; set; } = default!;
public List<AdminLogPlayer> Players { get; set; } = default!;
}
public class AdminLogPlayer
{
[Required, Key] public int RoundId { get; set; }
[Required, Key] public int LogId { get; set; }
[Required, Key, ForeignKey("Player")] public Guid PlayerUserId { get; set; }
public Player Player { get; set; } = default!;
[ForeignKey("RoundId,LogId")] public AdminLog Log { get; set; } = default!;
}
// Used by SS14.Admin
public interface IBanCommon<TUnban> where TUnban : IUnbanCommon
{
int Id { get; set; }
Guid? PlayerUserId { get; set; }
NpgsqlInet? Address { get; set; }
byte[]? HWId { get; set; }
DateTime BanTime { get; set; }
DateTime? ExpirationTime { get; set; }
string Reason { get; set; }
NoteSeverity Severity { get; set; }
Guid? BanningAdmin { get; set; }
TUnban? Unban { get; set; }
}
// Used by SS14.Admin
public interface IUnbanCommon
{
int Id { get; set; }
int BanId { get; set; }
Guid? UnbanningAdmin { get; set; }
DateTime UnbanTime { get; set; }
}
/// <summary>
/// Flags for use with <see cref="ServerBanExemption"/>.
/// </summary>
[Flags]
public enum ServerBanExemptFlags
{
// @formatter:off
None = 0,
/// <summary>
/// Ban is a datacenter range, connections usually imply usage of a VPN service.
/// </summary>
Datacenter = 1 << 0,
/// <summary>
/// Ban only matches the IP.
/// </summary>
/// <remarks>
/// Intended use is for users with shared connections. This should not be used as an alternative to <see cref="Datacenter"/>.
/// </remarks>
IP = 1 << 1,
// @formatter:on
}
/// <summary>
/// A ban from playing on the server.
/// If an incoming connection matches any of UserID, IP, or HWID, they will be blocked from joining the server.
/// </summary>
/// <remarks>
/// At least one of UserID, IP, or HWID must be given (otherwise the ban would match nothing).
/// </remarks>
[Table("server_ban"), Index(nameof(PlayerUserId))]
public class ServerBan : IBanCommon<ServerUnban>
{
public int Id { get; set; }
[ForeignKey("Round")]
public int? RoundId { get; set; }
public Round? Round { get; set; }
/// <summary>
/// The user ID of the banned player.
/// </summary>
public Guid? PlayerUserId { get; set; }
[Required] public TimeSpan PlaytimeAtNote { get; set; }
/// <summary>
/// CIDR IP address range of the ban. The whole range can match the ban.
/// </summary>
public NpgsqlInet? Address { get; set; }
/// <summary>
/// Hardware ID of the banned player.
/// </summary>
public byte[]? HWId { get; set; }
/// <summary>
/// The time when the ban was applied by an administrator.
/// </summary>
public DateTime BanTime { get; set; }
/// <summary>
/// The time the ban will expire. If null, the ban is permanent and will not expire naturally.
/// </summary>
public DateTime? ExpirationTime { get; set; }
/// <summary>
/// The administrator-stated reason for applying the ban.
/// </summary>
public string Reason { get; set; } = null!;
/// <summary>
/// The severity of the incident
/// </summary>
public NoteSeverity Severity { get; set; }
/// <summary>
/// User ID of the admin that applied the ban.
/// </summary>
[ForeignKey("CreatedBy")]
public Guid? BanningAdmin { get; set; }
public Player? CreatedBy { get; set; }
/// <summary>
/// User ID of the admin that last edited the note
/// </summary>
[ForeignKey("LastEditedBy")]
public Guid? LastEditedById { get; set; }
public Player? LastEditedBy { get; set; }
/// <summary>
/// When the ban was last edited
/// </summary>
public DateTime? LastEditedAt { get; set; }
/// <summary>
/// Optional flags that allow adding exemptions to the ban via <see cref="ServerBanExemption"/>.
/// </summary>
public ServerBanExemptFlags ExemptFlags { get; set; }
/// <summary>
/// If present, an administrator has manually repealed this ban.
/// </summary>
public ServerUnban? Unban { get; set; }
/// <summary>
/// Whether this ban should be automatically deleted from the database when it expires.
/// </summary>
/// <remarks>
/// This isn't done automatically by the game,
/// you will need to set up something like a cron job to clear this from your database,
/// using a command like this:
/// psql -d ss14 -c "DELETE FROM server_ban WHERE auto_delete AND expiration_time &lt; NOW()"
/// </remarks>
public bool AutoDelete { get; set; }
/// <summary>
/// Whether to display this ban in the admin remarks (notes) panel
/// </summary>
public bool Hidden { get; set; }
public List<ServerBanHit> BanHits { get; set; } = null!;
public string? ServerName { get; set; }
}
/// <summary>
/// An explicit repeal of a <see cref="ServerBan"/> by an administrator.
/// Having an entry for a ban neutralizes it.
/// </summary>
[Table("server_unban")]
public class ServerUnban : IUnbanCommon
{
[Column("unban_id")] public int Id { get; set; }
/// <summary>
/// The ID of ban that is being repealed.
/// </summary>
public int BanId { get; set; }
/// <summary>
/// The ban that is being repealed.
/// </summary>
public ServerBan Ban { get; set; } = null!;
/// <summary>
/// The admin that repealed the ban.
/// </summary>
public Guid? UnbanningAdmin { get; set; }
/// <summary>
/// The time the ban repealed.
/// </summary>
public DateTime UnbanTime { get; set; }
}
/// <summary>
/// An exemption for a specific user to a certain type of <see cref="ServerBan"/>.
/// </summary>
/// <example>
/// Certain players may need to be exempted from VPN bans due to issues with their ISP.
/// We would tag all VPN bans with <see cref="ServerBanExemptFlags.Datacenter"/>,
/// and then add an exemption for these players to this table with the same flag.
/// They will only be exempted from VPN bans, other bans (if they manage to get any) will still apply.
/// </example>
[Table("server_ban_exemption")]
public sealed class ServerBanExemption
{
/// <summary>
/// The UserID of the exempted player.
/// </summary>
[Key]
public Guid UserId { get; set; }
/// <summary>
/// The ban flags to exempt this player from.
/// If any bit overlaps <see cref="ServerBan.ExemptFlags"/>, the ban is ignored.
/// </summary>
public ServerBanExemptFlags Flags { get; set; }
}
[Table("connection_log")]
public class ConnectionLog
{
public int Id { get; set; }
public Guid UserId { get; set; }
public string UserName { get; set; } = null!;
public DateTime Time { get; set; }
public IPAddress Address { get; set; } = null!;
public byte[]? HWId { get; set; }
public ConnectionDenyReason? Denied { get; set; }
/// <summary>
/// ID of the <see cref="Server"/> that the connection was attempted to.
/// </summary>
/// <remarks>
/// <para>
/// The default value of this column is set to <c>0</c>, which is the ID of the "<c>unknown</c>" server.
/// This is intended for old entries (that didn't track this) and if the server name isn't configured.
/// </para>
/// </remarks>
public int ServerId { get; set; }
public List<ServerBanHit> BanHits { get; set; } = null!;
public Server Server { get; set; } = null!;
}
public enum ConnectionDenyReason : byte
{
Ban = 0,
Whitelist = 1,
Full = 2,
Panic = 3,
}
public class ServerBanHit
{
public int Id { get; set; }
public int BanId { get; set; }
public int ConnectionId { get; set; }
public ServerBan Ban { get; set; } = null!;
public ConnectionLog Connection { get; set; } = null!;
}
[Table("server_role_ban"), Index(nameof(PlayerUserId))]
public sealed class ServerRoleBan : IBanCommon<ServerRoleUnban>
{
public int Id { get; set; }
public int? RoundId { get; set; }
public Round? Round { get; set; }
public Guid? PlayerUserId { get; set; }
[Required] public TimeSpan PlaytimeAtNote { get; set; }
public NpgsqlInet? Address { get; set; }
public byte[]? HWId { get; set; }
public DateTime BanTime { get; set; }
public DateTime? ExpirationTime { get; set; }
public string Reason { get; set; } = null!;
public NoteSeverity Severity { get; set; }
[ForeignKey("CreatedBy")] public Guid? BanningAdmin { get; set; }
public Player? CreatedBy { get; set; }
[ForeignKey("LastEditedBy")] public Guid? LastEditedById { get; set; }
public Player? LastEditedBy { get; set; }
public DateTime? LastEditedAt { get; set; }
public ServerRoleUnban? Unban { get; set; }
public bool Hidden { get; set; }
public string RoleId { get; set; } = null!;
public string? ServerName { get; set; }
}
[Table("server_role_unban")]
public sealed class ServerRoleUnban : IUnbanCommon
{
[Column("role_unban_id")] public int Id { get; set; }
public int BanId { get; set; }
public ServerRoleBan Ban { get; set; } = null!;
public Guid? UnbanningAdmin { get; set; }
public DateTime UnbanTime { get; set; }
}
[Table("play_time")]
public sealed class PlayTime
{
[Required, Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required, ForeignKey("player")]
public Guid PlayerId { get; set; }
public string Tracker { get; set; } = null!;
public TimeSpan TimeSpent { get; set; }
}
[Table("uploaded_resource_log")]
public sealed class UploadedResourceLog
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public DateTime Date { get; set; }
public Guid UserId { get; set; }
public string Path { get; set; } = string.Empty;
public byte[] Data { get; set; } = default!;
}
[Index(nameof(PlayerUserId))]
public class AdminNote
{
[Required, Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; }
[ForeignKey("Round")] public int? RoundId { get; set; }
public Round? Round { get; set; }
[ForeignKey("Player")] public Guid? PlayerUserId { get; set; }
public Player? Player { get; set; }
[Required] public TimeSpan PlaytimeAtNote { get; set; }
[Required, MaxLength(4096)] public string Message { get; set; } = string.Empty;
[Required] public NoteSeverity Severity { get; set; }
[ForeignKey("CreatedBy")] public Guid? CreatedById { get; set; }
public Player? CreatedBy { get; set; }
[Required] public DateTime CreatedAt { get; set; }
[ForeignKey("LastEditedBy")] public Guid? LastEditedById { get; set; }
public Player? LastEditedBy { get; set; }
[Required] public DateTime? LastEditedAt { get; set; }
public DateTime? ExpirationTime { get; set; }
public bool Deleted { get; set; }
[ForeignKey("DeletedBy")] public Guid? DeletedById { get; set; }
public Player? DeletedBy { get; set; }
public DateTime? DeletedAt { get; set; }
public bool Secret { get; set; }
}
[Index(nameof(PlayerUserId))]
public class AdminWatchlist
{
[Required, Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; }
[ForeignKey("Round")] public int? RoundId { get; set; }
public Round? Round { get; set; }
[ForeignKey("Player")] public Guid? PlayerUserId { get; set; }
public Player? Player { get; set; }
[Required] public TimeSpan PlaytimeAtNote { get; set; }
[Required, MaxLength(4096)] public string Message { get; set; } = string.Empty;
[ForeignKey("CreatedBy")] public Guid? CreatedById { get; set; }
public Player? CreatedBy { get; set; }
[Required] public DateTime CreatedAt { get; set; }
[ForeignKey("LastEditedBy")] public Guid? LastEditedById { get; set; }
public Player? LastEditedBy { get; set; }
[Required] public DateTime? LastEditedAt { get; set; }
public DateTime? ExpirationTime { get; set; }
public bool Deleted { get; set; }
[ForeignKey("DeletedBy")] public Guid? DeletedById { get; set; }
public Player? DeletedBy { get; set; }
public DateTime? DeletedAt { get; set; }
}
[Index(nameof(PlayerUserId))]
public class AdminMessage
{
[Required, Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; }
[ForeignKey("Round")] public int? RoundId { get; set; }
public Round? Round { get; set; }
[ForeignKey("Player")]
public Guid? PlayerUserId { get; set; }
public Player? Player { get; set; }
[Required] public TimeSpan PlaytimeAtNote { get; set; }
[Required, MaxLength(4096)] public string Message { get; set; } = string.Empty;
[ForeignKey("CreatedBy")] public Guid? CreatedById { get; set; }
public Player? CreatedBy { get; set; }
[Required] public DateTime CreatedAt { get; set; }
[ForeignKey("LastEditedBy")] public Guid? LastEditedById { get; set; }
public Player? LastEditedBy { get; set; }
public DateTime? LastEditedAt { get; set; }
public DateTime? ExpirationTime { get; set; }
public bool Deleted { get; set; }
[ForeignKey("DeletedBy")] public Guid? DeletedById { get; set; }
public Player? DeletedBy { get; set; }
public DateTime? DeletedAt { get; set; }
/// <summary>
/// Whether the message has been seen at least once by the player.
/// </summary>
public bool Seen { get; set; }
/// <summary>
/// Whether the message has been dismissed permanently by the player.
/// </summary>
public bool Dismissed { get; set; }
}
}