diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 000000000..cd398190e
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,64 @@
+###############################################################################
+# Set default behavior to automatically normalize line endings.
+###############################################################################
+* text=auto
+*.md text
+
+###############################################################################
+# Set default behavior for command prompt diff.
+#
+# This is need for earlier builds of msysgit that does not have it on by
+# default for csharp files.
+# Note: This is only used by command line
+###############################################################################
+*.cs text diff=csharp
+
+###############################################################################
+# Set the merge driver for project and solution files
+#
+# Merging from the command prompt will add diff markers to the files if there
+# are conflicts (Merging from VS is not affected by the settings below, in VS
+# the diff markers are never inserted). Diff markers may cause the following
+# file extensions to fail to load in VS. An alternative would be to treat
+# these files as binary and thus will always conflict and require user
+# intervention with every merge. To do so, just uncomment the entries below
+###############################################################################
+#*.sln merge=binary
+#*.csproj merge=binary
+#*.vbproj merge=binary
+#*.vcxproj merge=binary
+#*.vcproj merge=binary
+#*.dbproj merge=binary
+#*.fsproj merge=binary
+#*.lsproj merge=binary
+#*.wixproj merge=binary
+#*.modelproj merge=binary
+#*.sqlproj merge=binary
+#*.wwaproj merge=binary
+
+###############################################################################
+# behavior for image files
+#
+# image files are treated as binary by default.
+###############################################################################
+#*.jpg binary
+#*.png binary
+#*.gif binary
+
+###############################################################################
+# diff behavior for common document formats
+#
+# Convert binary document formats to text before diffing them. This feature
+# is only available from the command line. Turn it on by uncommenting the
+# entries below.
+###############################################################################
+#*.doc diff=astextplain
+#*.DOC diff=astextplain
+#*.docx diff=astextplain
+#*.DOCX diff=astextplain
+#*.dot diff=astextplain
+#*.DOT diff=astextplain
+#*.pdf diff=astextplain
+#*.PDF diff=astextplain
+#*.rtf diff=astextplain
+#*.RTF diff=astextplain
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 000000000..06cb15ebc
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,12 @@
+# These are supported funding model platforms
+
+github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
+patreon: openperpetuum
+open_collective: # Replace with a single Open Collective username
+ko_fi: # Replace with a single Ko-fi username
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 000000000..8da04976c
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,59 @@
+name: OpenPerpetuum Server Compile
+
+on:
+ push:
+ branches: [ "Development" ]
+ pull_request:
+ branches: [ "Development" ]
+ workflow_dispatch:
+ inputs:
+ debug_enabled:
+ type: boolean
+ description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
+ required: false
+ default: false
+
+jobs:
+
+ build:
+
+ strategy:
+ matrix:
+ configuration: [Debug, Release]
+
+ runs-on: windows-2019 # For a list of available runner types, refer to
+ # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
+
+ env:
+ Solution_Name: Perpetuum.sln # Replace with your solution name, i.e. MyWpfApp.sln.
+ Configuration: ${{ matrix.configuration }}
+ Workspace: ${{ github.workspace }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
+ - name: Setup MSBuild.exe
+ uses: microsoft/setup-msbuild@v2
+
+ # Restore the application to populate the obj folder with RuntimeIdentifiers
+ - name: Restore&Build the application for (${{ matrix.configuration }})
+ run: |
+ nuget restore
+ msbuild ${{ env.Solution_Name }} -p:Configuration=${{ env.Configuration }}
+
+ # Enable tmate debugging of manually-triggered workflows if the input option was provided
+ # this allows us to debug the file paths
+ - name: Setup tmate session
+ uses: mxschmitt/action-tmate@v3
+ if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled && always()}}
+
+ - name: Upload a Build Artifact for (${{ matrix.configuration }})
+ uses: actions/upload-artifact@v4
+ with:
+ name: Perpetuum-Server-${{ github.sha }}.${{ matrix.configuration }}
+ path: ${{ env.Workspace }}/bin/x64/${{ env.Configuration }}/Perpetuum.Server
+ if: ${{ github.event_name == 'push'}}
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..d58682c18
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,262 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+project.fragment.lock.json
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Comment the next line if you want to checkin your web deploy settings
+# but database connection strings (with potential passwords) will be unencrypted
+#*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+/PerpetuumTests
+.nuget/nuget.exe
diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe
deleted file mode 100644
index 8d13fd88c..000000000
Binary files a/.nuget/NuGet.exe and /dev/null differ
diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets
index d3befdac2..45f68dfc1 100644
--- a/.nuget/NuGet.targets
+++ b/.nuget/NuGet.targets
@@ -12,8 +12,8 @@
true
-
- false
+
+ true
@@ -117,9 +117,9 @@
try {
OutputFilename = Path.GetFullPath(OutputFilename);
- Log.LogMessage("Downloading latest version of NuGet.exe...");
+ Log.LogMessage("Downloading latest version of nuget.exe...");
WebClient webClient = new WebClient();
- webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
+ webClient.DownloadFile("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", OutputFilename);
return true;
}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..55c6c4b50
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,44 @@
+# Contributing to OpenPerpetuumServer
+
+We generally follow a simplified gitflow model, with some coupling to other repository states, like the OPDB.
+
+To contribute:
+ - Branch from the most recent Development
+ - Commit your code, push and submit a Pull Request to Development
+
+Your code will be reviewed and merged if it does the following.
+Either:
+ - Addresses or implements an OP-Project identified bug, feature, or change.
+ - Enhances, optimizes, or extends existing functionality.
+ - Refactors that improves maintainability of the codebase.
+
+Your code must:
+ - Not break style conventions within the codebase.
+ - Be neither ungrokable, insufficiently documented (self-/comments) nor otherwise unmaintainable by other experienced developers.
+ - Not introduce, change, or manipulate game mechanics outside the scope of OP-Project issue cards.
+ - Not introduce, exploit, or otherwise attempt to introduce vulnerabilities to compromise game integrity or user data.
+
+Reviewers will point out when these tenets are not followed, but it will save everyone time if you adhere to these rules the first time.
+
+Special Notes:
+The PerpetuumServer is highly coupled in some instances to DB state. The OPDB has its own patching source control model which you should learn and follow. If your pull request also requires database changes:
+ - Submit your PR to the server, and another PR of your SQL patch to the OPDB development branch
+ - **Include a comment in the PR note that the server and DB patch are interdependent**
+
+## Org-Project: cross repo issue tracking
+As mentioned above, all action items are collected in one kanban board for Server related development. These issues should be pointed to with all PR's made. A PR should address at most one issue. When a server change requires a DB change, use the issue too as a mechanism to indicate the coupling.
+[See issues here](https://github.com/orgs/OpenPerpetuum/projects/2)
+
+## Code of Conduct
+
+Your code, comments, commit messages, and everything you do on the internet will reflect on you and how others perceive you. Act accordingly.
+Trolling, harassment or abusive behaviour of any kind will not be tolerated.
+This is an open source, volunteer project. Respect people's time and privacy.
+
+## The Team
+
+We have a github group (fancy!) which is a subset of our full project team and includes all of our active contributing development team members and some design members.
+To join, hop on the discord, or find our volunteer survey, and speak with a member of the team.
+
+Warning: we do have standards. You will have to actually have to do something to get on the team.
+Reading this is the first step, let us know you managed to get this far.
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index f3cfd2a7c..547922963 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,3 +1,7 @@
+----------------------------------------------------------------------------------
+Perpetuum - LICENSE
+----------------------------------------------------------------------------------
+
MIT License
Copyright (c) 2018 Perpetuum
@@ -19,3 +23,30 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+
+----------------------------------------------------------------------------------
+OpenPerpetuum - LICENSE
+----------------------------------------------------------------------------------
+
+MIT License
+
+Copyright (c) 2018-2022 OpenPerpetuum
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software. All copies or substantial portions
+of the Software will include attributions to the Open Perpetuum Project.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Perpetuum.sln b/Perpetuum.sln
index a4f3593a4..bab491d9c 100644
--- a/Perpetuum.sln
+++ b/Perpetuum.sln
@@ -26,6 +26,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perpetuum.AdminTool", "src\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perpetuum.Bootstrapper", "src\Perpetuum.Bootstrapper\Perpetuum.Bootstrapper.csproj", "{E113962C-AD5D-4F17-8D08-656221CBD2D4}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perpetuum.ServerService", "src\Perpetuum.ServerService\Perpetuum.ServerService.csproj", "{9C77CE95-825E-4BB1-9129-66835BDB8C96}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -108,6 +110,18 @@ Global
{E113962C-AD5D-4F17-8D08-656221CBD2D4}.Release|x64.Build.0 = Release|Any CPU
{E113962C-AD5D-4F17-8D08-656221CBD2D4}.Release|x86.ActiveCfg = Release|Any CPU
{E113962C-AD5D-4F17-8D08-656221CBD2D4}.Release|x86.Build.0 = Release|Any CPU
+ {9C77CE95-825E-4BB1-9129-66835BDB8C96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9C77CE95-825E-4BB1-9129-66835BDB8C96}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9C77CE95-825E-4BB1-9129-66835BDB8C96}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {9C77CE95-825E-4BB1-9129-66835BDB8C96}.Debug|x64.Build.0 = Debug|Any CPU
+ {9C77CE95-825E-4BB1-9129-66835BDB8C96}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {9C77CE95-825E-4BB1-9129-66835BDB8C96}.Debug|x86.Build.0 = Debug|Any CPU
+ {9C77CE95-825E-4BB1-9129-66835BDB8C96}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9C77CE95-825E-4BB1-9129-66835BDB8C96}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9C77CE95-825E-4BB1-9129-66835BDB8C96}.Release|x64.ActiveCfg = Release|Any CPU
+ {9C77CE95-825E-4BB1-9129-66835BDB8C96}.Release|x64.Build.0 = Release|Any CPU
+ {9C77CE95-825E-4BB1-9129-66835BDB8C96}.Release|x86.ActiveCfg = Release|Any CPU
+ {9C77CE95-825E-4BB1-9129-66835BDB8C96}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/README.md b/README.md
index 7ae3e95a7..727a73102 100644
Binary files a/README.md and b/README.md differ
diff --git a/opp-server.jpeg b/opp-server.jpeg
new file mode 100644
index 000000000..531d18376
Binary files /dev/null and b/opp-server.jpeg differ
diff --git a/src/Perpetuum.AdminTool/LocalServerRunner.cs b/src/Perpetuum.AdminTool/LocalServerRunner.cs
index 602101bdf..18161f893 100644
--- a/src/Perpetuum.AdminTool/LocalServerRunner.cs
+++ b/src/Perpetuum.AdminTool/LocalServerRunner.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
@@ -17,6 +18,8 @@ public class LocalServerRunner
private bool _stopProbing;
private LogHandler _log;
private LocalServerState _localServerState;
+
+ private Dictionary _loadedConfig;
public LocalServerState State
{
get => _localServerState;
@@ -93,13 +96,25 @@ public void Run(string gameRoot, string pathToExecutable)
// save localserverinfo file
SaveLocalServerInfo(gameRoot, pathToExecutable);
- var listeningPort = GetPortFromIni(gameRoot);
+ _loadedConfig = ReadConfigFromDisk(gameRoot);
+
+ var listeningPort = _loadedConfig["listenerPort"];
if (listeningPort <= 0)
{
_log.StatusError($"Wasn't able to get listening port from {PERPETUUMINIFILE}. No port probe is started.");
return;
}
+ var adminOnlyMode = _loadedConfig["adminOnlyMode"];
+ if (!adminOnlyMode)
+ {
+ _log.Log("AdminOnlyMode: Disabled (Default)");
+ }
+ else
+ {
+ _log.Log("AdminOnlyMode: Enabled");
+ }
+
//RunNetStatProbe(listeningPort);
RunSocketProbe(listeningPort);
}
@@ -335,26 +350,29 @@ private string NextIndicatorText()
return _indicatorPhases[_indicatorTextIndex];
}
- private int GetPortFromIni(string gameRoot)
+ private Dictionary ReadConfigFromDisk(string gameRoot)
{
var perpetuumIni = Path.Combine(gameRoot, PERPETUUMINIFILE);
if (!File.Exists(perpetuumIni))
{
- _log.StatusError($"{PERPETUUMINIFILE} was not found in game root {gameRoot} folder. Check your settings!" );
- return -1;
+ _log.StatusError($"{PERPETUUMINIFILE} was not found in game root {gameRoot} folder. Check your settings!");
}
var json = File.ReadAllText(perpetuumIni);
- var portData = JsonConvert.DeserializeAnonymousType(json,new
+ var listenerPort = JsonConvert.DeserializeAnonymousType(json, new
{
ListenerPort = -1,
});
+ var adminOnlyMode = JsonConvert.DeserializeAnonymousType(json, new
+ {
+ StartServerInAdminOnlyMode = false,
+ });
- _log.Log($"Relay port loaded from {PERPETUUMINIFILE}: {portData.ListenerPort}");
+ Dictionary result = new Dictionary();
+ result.Add("listenerPort", listenerPort.ListenerPort);
+ result.Add("adminOnlyMode", adminOnlyMode.StartServerInAdminOnlyMode);
- return portData.ListenerPort;
+ return result;
}
-
-
}
}
diff --git a/src/Perpetuum.Bootstrapper/PerpetuumBootstrapper.cs b/src/Perpetuum.Bootstrapper/PerpetuumBootstrapper.cs
index e93e9d1a7..c71b95cdf 100644
--- a/src/Perpetuum.Bootstrapper/PerpetuumBootstrapper.cs
+++ b/src/Perpetuum.Bootstrapper/PerpetuumBootstrapper.cs
@@ -1,18 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Data.SqlClient;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Net.Sockets;
-using System.Numerics;
-using System.Reflection;
-using System.Runtime;
-using System.Runtime.Caching;
-using System.Text;
-using System.Threading;
-using System.Transactions;
-using Autofac;
+using Autofac;
using Autofac.Builder;
using Autofac.Core;
using Newtonsoft.Json;
@@ -39,6 +25,7 @@
using Perpetuum.IO;
using Perpetuum.Items;
using Perpetuum.Items.Ammos;
+using Perpetuum.Items.Helpers;
using Perpetuum.Items.Templates;
using Perpetuum.Log;
using Perpetuum.Log.Formatters;
@@ -76,7 +63,14 @@
using Perpetuum.RequestHandlers.Zone.PBS;
using Perpetuum.RequestHandlers.Zone.StatsMapDrawing;
using Perpetuum.Robots;
+using Perpetuum.Services;
using Perpetuum.Services.Channels;
+using Perpetuum.Services.Channels.ChatCommands;
+using Perpetuum.Services.Daytime;
+using Perpetuum.Services.EventServices;
+using Perpetuum.Services.EventServices.EventMessages;
+using Perpetuum.Services.EventServices.EventProcessors;
+using Perpetuum.Services.EventServices.EventProcessors.NpcSpawnEventHandlers;
using Perpetuum.Services.ExtensionService;
using Perpetuum.Services.HighScores;
using Perpetuum.Services.Insurance;
@@ -97,15 +91,19 @@
using Perpetuum.Services.ProductionEngine.Facilities;
using Perpetuum.Services.ProductionEngine.ResearchKits;
using Perpetuum.Services.Relay;
+using Perpetuum.Services.Relics;
using Perpetuum.Services.RiftSystem;
+using Perpetuum.Services.RiftSystem.StrongholdRifts;
using Perpetuum.Services.Sessions;
using Perpetuum.Services.Social;
using Perpetuum.Services.Sparks;
using Perpetuum.Services.Sparks.Teleports;
using Perpetuum.Services.Standing;
using Perpetuum.Services.Steam;
+using Perpetuum.Services.Strongholds;
using Perpetuum.Services.TechTree;
using Perpetuum.Services.Trading;
+using Perpetuum.Services.Weather;
using Perpetuum.Threading.Process;
using Perpetuum.Units;
using Perpetuum.Units.DockingBases;
@@ -116,14 +114,21 @@
using Perpetuum.Zones.CombatLogs;
using Perpetuum.Zones.Decors;
using Perpetuum.Zones.Effects;
+using Perpetuum.Zones.Effects.ZoneEffects;
using Perpetuum.Zones.Eggs;
using Perpetuum.Zones.Environments;
using Perpetuum.Zones.Gates;
using Perpetuum.Zones.Intrusion;
+using Perpetuum.Zones.LandMines;
using Perpetuum.Zones.NpcSystem;
using Perpetuum.Zones.NpcSystem.Flocks;
using Perpetuum.Zones.NpcSystem.Presences;
+using Perpetuum.Zones.NpcSystem.Presences.ExpiringStaticPresence;
+using Perpetuum.Zones.NpcSystem.Presences.GrowingPresences;
+using Perpetuum.Zones.NpcSystem.Presences.InterzonePresences;
using Perpetuum.Zones.NpcSystem.Presences.PathFinders;
+using Perpetuum.Zones.NpcSystem.Presences.RandomExpiringPresence;
+using Perpetuum.Zones.NpcSystem.Reinforcements;
using Perpetuum.Zones.NpcSystem.SafeSpawnPoints;
using Perpetuum.Zones.PBS;
using Perpetuum.Zones.PBS.ArmorRepairers;
@@ -139,6 +144,7 @@
using Perpetuum.Zones.PlantTools;
using Perpetuum.Zones.ProximityProbes;
using Perpetuum.Zones.PunchBags;
+using Perpetuum.Zones.RemoteControl;
using Perpetuum.Zones.Scanning.Ammos;
using Perpetuum.Zones.Scanning.Modules;
using Perpetuum.Zones.Scanning.Results;
@@ -155,6 +161,19 @@
using Perpetuum.Zones.Training;
using Perpetuum.Zones.Training.Reward;
using Perpetuum.Zones.ZoneEntityRepositories;
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Numerics;
+using System.Reflection;
+using System.Runtime;
+using System.Runtime.Caching;
+using System.Text;
+using System.Threading;
using ChangeAmmo = Perpetuum.RequestHandlers.ChangeAmmo;
using CorporationDocumentConfig = Perpetuum.RequestHandlers.Corporations.CorporationDocumentConfig;
using EquipAmmo = Perpetuum.RequestHandlers.EquipAmmo;
@@ -170,23 +189,22 @@
using UnpackItems = Perpetuum.RequestHandlers.UnpackItems;
using UnstackAmount = Perpetuum.RequestHandlers.UnstackAmount;
-
namespace Perpetuum.Bootstrapper
{
- class EntityAggregateServices : IEntityServices
+ internal class EntityAggregateServices : IEntityServices
{
public IEntityFactory Factory { get; set; }
public IEntityDefaultReader Defaults { get; set; }
public IEntityRepository Repository { get; set; }
}
- class RobotTemplateServicesImpl : IRobotTemplateServices
+ internal class RobotTemplateServicesImpl : IRobotTemplateServices
{
public IRobotTemplateReader Reader { get; set; }
public IRobotTemplateRelations Relations { get; set; }
}
- class TeleportStrategyFactoriesImpl : ITeleportStrategyFactories
+ internal class TeleportStrategyFactoriesImpl : ITeleportStrategyFactories
{
public TeleportWithinZone.Factory TeleportWithinZoneFactory { get; set; }
public TeleportToAnotherZone.Factory TeleportToAnotherZoneFactory { get; set; }
@@ -202,51 +220,58 @@ public class PerpetuumBootstrapper
public void Start()
{
- var s = _container.Resolve();
+ IHostStateService s = _container.Resolve();
s.State = HostState.Starting;
}
public void Stop()
{
- var s = _container.Resolve();
+ IHostStateService s = _container.Resolve();
s.State = HostState.Stopping;
}
public void Stop(TimeSpan delay)
{
- var m = _container.Resolve();
+ HostShutDownManager m = _container.Resolve();
m.Shutdown(delay);
}
+ public IContainer GetContainer()
+ {
+ return _container;
+ }
+
public void WaitForStop()
{
- var are = new AutoResetEvent(false);
+ AutoResetEvent are = new AutoResetEvent(false);
- var s = _container.Resolve();
+ IHostStateService s = _container.Resolve();
s.StateChanged += (sender, state) =>
{
if (state == HostState.Off)
- are.Set();
+ {
+ _ = are.Set();
+ }
};
- are.WaitOne();
+ _ = are.WaitOne();
}
public void WriteCommandsToFile(string path)
{
- var sb = new StringBuilder();
+ StringBuilder sb = new StringBuilder();
- foreach (var command in GetCommands().OrderBy(c => c.Text))
+ foreach (Command command in GetCommands().OrderBy(c => c.Text))
{
- sb.AppendLine($"{command.Text},{command.AccessLevel}");
+ _ = sb.AppendLine($"{command.Text},{command.AccessLevel}");
}
-
- File.WriteAllText(path,sb.ToString());
+
+ File.WriteAllText(path, sb.ToString());
}
public IEnumerable GetCommands()
{
- return typeof(Commands).GetFields(BindingFlags.Static | BindingFlags.Public).Select(info => (Command)info.GetValue(null));
+ return typeof(Commands).GetFields(BindingFlags.Static | BindingFlags.Public).Select(info => (Command)info.GetValue(null));
}
public void Init(string gameRoot)
@@ -256,7 +281,7 @@ public void Init(string gameRoot)
_container = _builder.Build();
Logger.Current = _container.Resolve>();
- var config = _container.Resolve();
+ GlobalConfiguration config = _container.Resolve();
_container.Resolve().State = HostState.Init;
@@ -265,10 +290,9 @@ public void Init(string gameRoot)
Logger.Info($"GC Latency mode: {GCSettings.LatencyMode}");
Logger.Info($"Vector is hardware accelerated: {Vector.IsHardwareAccelerated}");
- Db.TransactionScopeFactory = _container.Resolve>();
Db.DbQueryFactory = _container.Resolve>();
- using (var connection = _container.Resolve()()) { Logger.Info($"Database: {connection.Database}"); }
+ using (System.Data.IDbConnection connection = _container.Resolve()()) { Logger.Info($"Database: {connection.Database}"); }
InitGame(_container);
@@ -303,7 +327,6 @@ public void Init(string gameRoot)
MissionTarget.RobotTemplateRelations = _container.Resolve();
MissionTarget.MissionTargetInProgressFactory = _container.Resolve();
-
MissionTargetRewardCalculator.Init(_container.Resolve());
MissionTargetSuccessInfoGenerator.Init(_container.Resolve());
MissionBonus.Init(_container.Resolve());
@@ -332,38 +355,46 @@ public void Init(string gameRoot)
switch (state)
{
case HostState.Stopping:
- {
- _container.Resolve().Stop();
- NatDiscoverer.ReleaseAll();
- sender.State = HostState.Off;
- break;
- }
+ {
+ _container.Resolve().Stop();
+ NatDiscoverer.ReleaseAll();
+ sender.State = HostState.Off;
+ break;
+ }
case HostState.Starting:
- {
- _container.Resolve().Start();
- sender.State = HostState.Online;
- break;
- }
+ {
+ _container.Resolve().Start();
+ sender.State = HostState.Online;
+ break;
+ }
}
};
DefaultCorporationDataCache.LoadAll();
_container.Resolve().CacheMissionData();
+ // initialize our markets.
+ // this is dependent on all zones being loaded.
+ _container.Resolve().Init();
+ _container.Resolve().Init();
+
+
}
public bool TryInitUpnp(out bool success)
{
success = false;
- var config = _container.Resolve();
+ GlobalConfiguration config = _container.Resolve();
if (!config.EnableUpnp)
+ {
return false;
+ }
try
{
- var discoverer = new NatDiscoverer();
+ NatDiscoverer discoverer = new NatDiscoverer();
NatDiscoverer.ReleaseAll();
- var natDevice = discoverer.DiscoverDeviceAsync().Result;
+ NatDevice natDevice = discoverer.DiscoverDeviceAsync().Result;
if (natDevice == null)
{
Logger.Error("[UPNP] NAT device not found!");
@@ -372,7 +403,7 @@ public bool TryInitUpnp(out bool success)
void Map(int port)
{
- var task = natDevice.CreatePortMapAsync(new Mapping(Protocol.Tcp,port,port)).ContinueWith(t =>
+ System.Threading.Tasks.Task task = natDevice.CreatePortMapAsync(new Mapping(Protocol.Tcp, port, port)).ContinueWith(t =>
{
Logger.Info($"[UPNP] Port mapped: {port}");
});
@@ -381,7 +412,7 @@ void Map(int port)
Map(config.ListenerPort);
- foreach (var zone in _container.Resolve().Zones)
+ foreach (IZone zone in _container.Resolve().Zones)
{
Map(zone.Configuration.ListenerPort);
}
@@ -402,12 +433,12 @@ void Map(int port)
private static void InitGame(IComponentContext container)
{
//the current host has to clean up things in the onlinehost table, and other runtime tables
- Db.Query().CommandText("initServer").ExecuteNonQuery();
+ _ = Db.Query().CommandText("initServer").ExecuteNonQuery();
- var globalConfiguration = container.Resolve();
+ GlobalConfiguration globalConfiguration = container.Resolve();
if (!string.IsNullOrEmpty(globalConfiguration.PersonalConfig))
{
- Db.Query().CommandText(globalConfiguration.PersonalConfig).ExecuteNonQuery();
+ _ = Db.Query().CommandText(globalConfiguration.PersonalConfig).ExecuteNonQuery();
Logger.Info("Personal sp executed:" + globalConfiguration.PersonalConfig);
}
@@ -424,31 +455,30 @@ private IRegistrationBuilder(TimeSpan.FromSeconds(7));
- RegisterAutoActivate(TimeSpan.FromMinutes(5));
- //RegisterAutoActivate(TimeSpan.FromHours(10));
- RegisterAutoActivate(TimeSpan.FromHours(1));
-// RegisterAutoActivate(TimeSpan.FromSeconds(10));
- RegisterAutoActivate(TimeSpan.FromMinutes(5));
- RegisterAutoActivate(TimeSpan.FromMinutes(10));
- RegisterAutoActivate(TimeSpan.FromMinutes(10));
+ _ = RegisterAutoActivate(TimeSpan.FromSeconds(7));
+ _ = RegisterAutoActivate(TimeSpan.FromMinutes(5));
+ _ = RegisterAutoActivate(TimeSpan.FromHours(1));
+ _ = RegisterAutoActivate(TimeSpan.FromMinutes(5));
+ _ = RegisterAutoActivate(TimeSpan.FromMinutes(10));
+ _ = RegisterAutoActivate(TimeSpan.FromMinutes(10));
+ _ = RegisterAutoActivate(TimeSpan.FromHours(7));
}
private void RegisterCommands()
{
- foreach (var command in GetCommands())
+ foreach (Command command in GetCommands())
{
- _builder.RegisterInstance(command).As().Keyed(command.Text.ToUpper());
+ _ = _builder.RegisterInstance(command).As().Keyed(command.Text.ToUpper());
}
- _builder.Register>(x =>
+ _ = _builder.Register>(x =>
{
- var ctx = x.Resolve();
- return (commandText =>
+ IComponentContext ctx = x.Resolve();
+ return commandText =>
{
commandText = commandText.ToUpper();
return ctx.IsRegisteredWithKey(commandText) ? ctx.ResolveKeyed(commandText) : null;
- });
+ };
});
}
@@ -466,263 +496,268 @@ private void InitContainer(string gameRoot)
RegisterChannelTypes();
RegisterMtProducts();
RegisterRifts();
+ RegisterRelics();
RegisterEffects();
RegisterIntrusions();
RegisterZones();
RegisterPBS();
- _builder.Register>(x =>
+ _ = _builder.Register>(x =>
{
return name => new MemoryCache(name);
});
- _builder.RegisterType().AsSelf().As();
- _builder.Register(c =>
+ _ = _builder.RegisterType().AsSelf().As();
+ _ = _builder.Register(c =>
{
- var cache = new MemoryCache("CharacterProfiles");
+ MemoryCache cache = new MemoryCache("CharacterProfiles");
return new CachedReadOnlyRepository(cache, c.Resolve());
- }).AsSelf().As>().SingleInstance();
+ }).AsSelf().As>().SingleInstance();
- _builder.RegisterType().As();
+ _ = _builder.RegisterType().As();
- _builder.RegisterType().As();
- _builder.RegisterType().OnActivated(e =>
+ _ = _builder.RegisterType().As();
+ _ = _builder.RegisterType().OnActivated(e =>
{
e.Instance.Init();
}).As().SingleInstance();
- _builder.RegisterType().As().AutoActivate().OnActivated(e =>
+ _ = _builder.RegisterType().As().AutoActivate().OnActivated(e =>
{
e.Context.Resolve().AddProcess(e.Instance.ToAsync().AsTimed(TimeSpan.FromHours(1)));
}).SingleInstance();
- _builder.RegisterType().As();
- _builder.RegisterType().As();
- _builder.RegisterType().As();
+ _ = _builder.RegisterType().As();
+ _ = _builder.RegisterType().As();
+ _ = _builder.RegisterType().As();
+ _ = _builder.RegisterType().As().SingleInstance().AutoActivate();
- _builder.RegisterType().AsSelf().As();
+ _ = _builder.RegisterType().AsSelf().As();
- _builder.RegisterType().As().SingleInstance();
+ _ = _builder.RegisterType().As().SingleInstance();
InitRelayManager();
- _builder.Register(c => new FileSystem(gameRoot)).As();
- _builder.Register(c =>
+ _ = _builder.Register(c => new FileSystem(gameRoot)).As();
+ _ = _builder.Register(c =>
{
- var fileManager = c.Resolve();
- var settingsFile = fileManager.ReadAllText("perpetuum.ini");
- var configuration = JsonConvert.DeserializeObject(settingsFile);
+ IFileSystem fileManager = c.Resolve();
+ string settingsFile = fileManager.ReadAllText("perpetuum.ini");
+ GlobalConfiguration configuration = JsonConvert.DeserializeObject(settingsFile);
configuration.GameRoot = gameRoot;
return configuration;
}).SingleInstance();
- _builder.RegisterType();
- _builder.RegisterType().As();
- _builder.RegisterType().As().SingleInstance();
+ _ = _builder.RegisterType().SingleInstance();
+
+ _ = _builder.RegisterType();
+ _ = _builder.RegisterType().As();
+ _ = _builder.RegisterType().As().SingleInstance();
- _builder.Register(c =>
+ _ = _builder.Register(c =>
{
- var config = c.Resolve();
+ GlobalConfiguration config = c.Resolve();
return config.Corporation;
}).As();
- _builder.RegisterType().As().SingleInstance();
- _builder.Register(c => new ProcessManager(TimeSpan.FromMilliseconds(50))).As().SingleInstance();
+ _ = _builder.RegisterType().As().SingleInstance();
+ _ = _builder.Register(c => new ProcessManager(TimeSpan.FromMilliseconds(50))).As().SingleInstance();
- _builder.Register(x =>
+ _ = _builder.Register(x =>
{
- var connectionString = x.Resolve().ConnectionString;
- return (() => new SqlConnection(connectionString));
+ string connectionString = x.Resolve().ConnectionString;
+ return () => new SqlConnection(connectionString);
});
- _builder.RegisterType();
-
- _builder.Register(x =>
- {
- return new TransactionScope(TransactionScopeOption.Required, new TransactionOptions
- {
- IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
- });
- });
+ _ = _builder.RegisterType();
- _builder.RegisterType();
+ _ = _builder.RegisterType();
- _builder.RegisterType().As().SingleInstance();
- _builder.RegisterType();
+ _ = _builder.RegisterType().As().SingleInstance();
+ _ = _builder.RegisterType();
- _builder.RegisterType().As().SingleInstance().OnActivated(e => e.Instance.Init());
- _builder.RegisterType().SingleInstance();
- _builder.RegisterType().SingleInstance();
+ _ = _builder.RegisterType().As().SingleInstance().OnActivated(e => e.Instance.Init());
+ _ = _builder.RegisterType().SingleInstance();
+ _ = _builder.RegisterType(); // this doesn't appear to be something that should be a singleton.
- _builder.RegisterType().As().SingleInstance();
- _builder.RegisterType().As();
+ _ = _builder.RegisterType().As().SingleInstance();
+ _ = _builder.RegisterType().As();
- _builder.RegisterType().As().SingleInstance();
+ _ = _builder.RegisterType().As().SingleInstance();
- _builder.RegisterType().As();
+ _ = _builder.RegisterType().As();
- _builder.RegisterType().As();
- _builder.RegisterType().AsSelf().As();
- _builder.RegisterType();
- _builder.Register(x =>
+ _ = _builder.RegisterType().As();
+ _ = _builder.RegisterType().AsSelf().As();
+ _ = _builder.RegisterType();
+ _ = _builder.Register(x =>
{
- var ctx = x.Resolve();
- return ((character, type) =>
+ IComponentContext ctx = x.Resolve();
+ return (character, type) =>
{
return ctx.Resolve(new TypedParameter(typeof(Character), character),
new TypedParameter(typeof(TransactionType), type));
- });
+ };
});
- _builder.RegisterType().AsSelf();
- _builder.Register(x => x.Resolve(TypedParameter.From(0))).Named("nullcharacter").SingleInstance();
+ _ = _builder.RegisterType().AsSelf();
+ _ = _builder.Register(x => x.Resolve(TypedParameter.From(0))).Named("nullcharacter").SingleInstance();
- _builder.Register(x =>
+ _ = _builder.Register(x =>
{
- var ctx = x.Resolve();
- return (id =>
+ IComponentContext ctx = x.Resolve();
+ return id =>
{
- if (id == 0)
- return ctx.ResolveNamed("nullcharacter");
-
- return ctx.Resolve(TypedParameter.From(id));
- });
+ return id == 0 ? ctx.ResolveNamed("nullcharacter") : ctx.Resolve(TypedParameter.From(id));
+ };
});
- _builder.RegisterType();
- _builder.RegisterType().As();
- _builder.RegisterType().As().SingleInstance();
+ _ = _builder.RegisterType();
+ _ = _builder.RegisterType().As();
+ _ = _builder.RegisterType().As().SingleInstance();
- _builder.RegisterType();
- _builder.RegisterType().As();
+ _ = _builder.RegisterType();
+ _ = _builder.RegisterType().As();
- _builder.Register(x =>
+ _ = _builder.Register(x =>
{
- var cfg = x.Resolve();
+ GlobalConfiguration cfg = x.Resolve();
return new SteamManager(cfg.SteamAppID, cfg.SteamKey);
}).As();
}
private void RegisterChannelTypes()
{
- _builder.RegisterType().As();
- _builder.RegisterType().As();
- _builder.RegisterType().As();
- _builder.RegisterType().As().SingleInstance();
-
- RegisterRequestHandler(Commands.ChannelCreate);
- RegisterRequestHandler(Commands.ChannelList);
- RegisterRequestHandler(Commands.ChannelMyList);
- RegisterRequestHandler(Commands.ChannelJoin);
- RegisterRequestHandler(Commands.ChannelLeave);
- RegisterRequestHandler(Commands.ChannelKick);
- RegisterRequestHandler(Commands.ChannelTalk);
- RegisterRequestHandler(Commands.ChannelSetMemberRole);
- RegisterRequestHandler(Commands.ChannelSetPassword);
- RegisterRequestHandler(Commands.ChannelSetTopic);
- RegisterRequestHandler(Commands.ChannelBan);
- RegisterRequestHandler(Commands.ChannelRemoveBan);
- RegisterRequestHandler(Commands.ChannelGetBannedMembers);
- RegisterRequestHandler(Commands.ChannelGlobalMute);
- RegisterRequestHandler(Commands.ChannelGetMutedCharacters);
- RegisterRequestHandler(Commands.ChannelCreateForTerminals);
+ _ = _builder.RegisterType().As();
+ _ = _builder.RegisterType().As();
+ _ = _builder.RegisterType().As