From 21911dda584e4abda37bf09b74b939c770137014 Mon Sep 17 00:00:00 2001 From: Mustafa Alperen Seki Date: Mon, 10 Apr 2023 14:26:58 +0300 Subject: [PATCH] More SDK changes. --- .editorconfig | 200 +++++++++++++++++++++++++++++++- .gitattributes | 10 ++ .github/workflows/ci.yml | 86 ++++++++++++++ .github/workflows/packaging.yml | 28 +++-- CODE_OF_CONDUCT.md | 4 +- Makefile | 23 +++- launch-dedicated.cmd | 6 +- launch-dedicated.sh | 13 ++- launch-game.cmd | 2 +- launch-game.sh | 2 +- make.ps1 | 82 +++++++------ mod.config | 7 +- omnisharp.json | 5 + utility.cmd | 30 ++++- 14 files changed, 428 insertions(+), 70 deletions(-) create mode 100644 .gitattributes create mode 100644 .github/workflows/ci.yml create mode 100644 omnisharp.json diff --git a/.editorconfig b/.editorconfig index 5538a2b..aa72961 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,17 +1,213 @@ ; Top-most http://editorconfig.org/ file root = true +charset=utf-8 ; Unix-style newlines [*] end_of_line = LF insert_final_newline = true +trim_trailing_whitespace = true -; 4-column tab indentation +; 4-column tab indentation and .NET coding conventions [*.cs] indent_style = tab indent_size = 4 +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = true + +csharp_style_var_elsewhere = true:suggestion +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion + +csharp_prefer_braces = when_multiline:suggestion +csharp_using_directive_placement = outside_namespace:suggestion +csharp_new_line_before_open_brace = all +csharp_space_around_binary_operators = before_and_after + +## Naming styles: + +dotnet_naming_style.camel_case.capitalization = camel_case + +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.i_prefix_pascal_case.capitalization = pascal_case +dotnet_naming_style.i_prefix_pascal_case.required_prefix = I + +## Symbol specifications: + +dotnet_naming_symbols.const_locals.applicable_kinds = local +dotnet_naming_symbols.const_locals.applicable_accessibilities = * +dotnet_naming_symbols.const_locals.required_modifiers = const + +dotnet_naming_symbols.const_fields.applicable_kinds = field +dotnet_naming_symbols.const_fields.applicable_accessibilities = * +dotnet_naming_symbols.const_fields.required_modifiers = const + +dotnet_naming_symbols.static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.static_readonly_fields.applicable_accessibilities = * +dotnet_naming_symbols.static_readonly_fields.required_modifiers = static, readonly + +dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, internal, protected, protected_internal, private_protected +dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly + +dotnet_naming_symbols.private_or_protected_fields.applicable_kinds = field +dotnet_naming_symbols.private_or_protected_fields.applicable_accessibilities = private, protected, private_protected + +dotnet_naming_symbols.interfaces.applicable_kinds = interface +dotnet_naming_symbols.interfaces.applicable_accessibilities = * + +dotnet_naming_symbols.parameters_and_locals.applicable_kinds = parameter, local +dotnet_naming_symbols.parameters_and_locals.applicable_accessibilities = * + +dotnet_naming_symbols.most_symbols.applicable_kinds = namespace, class, struct, enum, field, property, method, local_function, event, delegate, type_parameter +dotnet_naming_symbols.most_symbols.applicable_accessibilities = * + +## Naming rules: + +dotnet_naming_rule.const_locals_should_be_pascal_case.symbols = const_locals +dotnet_naming_rule.const_locals_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.const_locals_should_be_pascal_case.severity = warning + +dotnet_naming_rule.const_fields_should_be_pascal_case.symbols = const_fields +dotnet_naming_rule.const_fields_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.const_fields_should_be_pascal_case.severity = warning + +dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.symbols = static_readonly_fields +dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.static_readonly_fields_should_be_pascal_case.severity = warning + +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = warning + +dotnet_naming_rule.private_or_protected_fields_should_be_camel_case.symbols = private_or_protected_fields +dotnet_naming_rule.private_or_protected_fields_should_be_camel_case.style = camel_case +dotnet_naming_rule.private_or_protected_fields_should_be_camel_case.severity = warning + +dotnet_naming_rule.interfaces_should_be_i_prefix_pascal_case.symbols = interfaces +dotnet_naming_rule.interfaces_should_be_i_prefix_pascal_case.style = i_prefix_pascal_case +dotnet_naming_rule.interfaces_should_be_i_prefix_pascal_case.severity = warning + +dotnet_naming_rule.parameters_and_locals_should_be_camel_case.symbols = parameters_and_locals +dotnet_naming_rule.parameters_and_locals_should_be_camel_case.style = camel_case +dotnet_naming_rule.parameters_and_locals_should_be_camel_case.severity = warning + +dotnet_naming_rule.most_symbols_should_be_pascal_case.symbols = most_symbols +dotnet_naming_rule.most_symbols_should_be_pascal_case.style = pascal_case +dotnet_naming_rule.most_symbols_should_be_pascal_case.severity = warning + +## Formatting: + +# Also handled by StyleCopAnalyzers - SA1024: ColonsMustBeSpacedCorrectly. +csharp_space_after_colon_in_inheritance_clause = true + +# Also handled by StyleCopAnalyzers - SA1024: ColonsMustBeSpacedCorrectly. +csharp_space_before_colon_in_inheritance_clause = true + +# Also handled by StyleCopAnalyzers - SA1000: KeywordsMustBeSpacedCorrectly. +csharp_space_after_keywords_in_control_flow_statements = true + +# Leave code block on single line. +csharp_preserve_single_line_blocks = true + +# Leave statements and member declarations on the same line. +csharp_preserve_single_line_statements = true + +# IDE0049, IDE-only counterpart of StyleCopAnalyzers - SA1121: UseBuiltInTypeAlias. +dotnet_style_predefined_type_for_member_access = true + +# IDE0049, IDE-only counterpart of StyleCopAnalyzers - SA1121: UseBuiltInTypeAlias. +dotnet_style_predefined_type_for_locals_parameters_members = true + +## Others: + +# Show an IDE warning when default access modifiers are explicitly specified. +dotnet_style_require_accessibility_modifiers = omit_if_default:warning + +# Use 'var' instead of explicit type. +dotnet_diagnostic.IDE0007.severity = warning + +# Don't prefer braces (for one liners). +dotnet_diagnostic.IDE0011.severity = silent + +# Object initialization can be simplified / Use object initializer. +dotnet_diagnostic.IDE0017.severity = warning + +# Collection initialization can be simplified +dotnet_diagnostic.IDE0028.severity = warning + +# Simplify 'default' expression +dotnet_diagnostic.IDE0034.severity = warning + +# Modifiers are not ordered. +dotnet_diagnostic.IDE0036.severity = warning + +# Raise a warning on build when default access modifiers are explicitly specified. +dotnet_diagnostic.IDE0040.severity = warning + +# Make field readonly. +dotnet_diagnostic.IDE0044.severity = warning + +# Unused private member. +dotnet_diagnostic.IDE0052.severity = warning + +# Unnecessary value assignment. +dotnet_diagnostic.IDE0059.severity = warning + +# Unused parameter. +dotnet_diagnostic.IDE0060.severity = warning + +# Naming rule violation. +dotnet_diagnostic.IDE1006.severity = warning + +# Avoid unnecessary zero-length array allocations. +dotnet_diagnostic.CA1825.severity = warning + +# Do not use Enumerable methods on indexable collections. Instead use the collection directly. +dotnet_diagnostic.CA1826.severity = warning + +# Count() is used where Any() could be used instead to improve performance. +dotnet_diagnostic.CA1827.severity = warning + +# Use Length/Count property instead of Enumerable.Count method. +dotnet_diagnostic.CA1829.severity = warning + +# Use string.Contains(char) instead of string.Contains(string) with single characters. +dotnet_diagnostic.CA1847.severity = warning + ; 4-column tab indentation [*.yaml] indent_style = tab -indent_size = 4 \ No newline at end of file +indent_size = 4 + +# Use 'Count' property instead of 'Any' method. +dotnet_diagnostic.RCS1080.severity = warning + +# Use read-only auto-implemented property. +dotnet_diagnostic.RCS1170.severity = warning + +# Unnecessary interpolated string. +dotnet_diagnostic.RCS1214.severity = warning + +# Unnecessary usage of verbatim string literal. +dotnet_diagnostic.RCS1192.severity = warning + +# Use pattern matching instead of combination of 'as' operator and null check. +dotnet_diagnostic.RCS1221.severity = warning + +# Expression is always equal to 'true'. +dotnet_diagnostic.RCS1215.severity = warning + +# Use StringComparison when comparing strings. +dotnet_diagnostic.RCS1155.severity = warning + +# Abstract type should not have public constructors. +dotnet_diagnostic.RCS1160.severity = warning + +# Optimize 'Dictionary.ContainsKey' call. +dotnet_diagnostic.RCS1235.severity = warning + +# Call extension method as instance method. +dotnet_diagnostic.RCS1196.severity = warning diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..949fc96 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +# Enforce LF normalization on Windows +*.yaml eol=lf +*.lua eol=lf +*.cs eol=lf +*.csproj eol=lf +*.sln eol=lf +* text=lf + +# Custom for Visual Studio +*.cs diff=csharp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c55fc01 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,86 @@ +name: Continuous Integration + +on: + push: + pull_request: + +jobs: + linux: + name: Linux (.NET 6.0) + runs-on: ubuntu-22.04 + + steps: + - name: Clone Repository + uses: actions/checkout@v3 + + - name: Install .NET 6.0 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '6.0.x' + + - name: Prepare Environment + run: | + . mod.config; + awk '/\r$$/ { exit(1); }' mod.config || (printf "Invalid mod.config format. File must be saved using unix-style (LF, not CRLF or CR) line endings.\n"; exit 1); + + - name: Check Code + run: | + make check + make check-packaging-scripts + + - name: Check Mod + run: | + sudo apt-get install lua5.1 + make check-scripts + make test + + linux-mono: + name: Linux (mono) + runs-on: ubuntu-22.04 + + steps: + - name: Clone Repository + uses: actions/checkout@v3 + + - name: Prepare Environment + run: | + . mod.config; + awk '/\r$$/ { exit(1); }' mod.config || (printf "Invalid mod.config format. File must be saved using unix-style (LF, not CRLF or CR) line endings.\n"; exit 1); + + - name: Check Code + run: | + # check-packaging-scripts does not depend on .net/mono, so is not needed here + mono --version + make RUNTIME=mono check + + - name: Check Mod + run: | + # check-scripts does not depend on .net/mono, so is not needed here + make RUNTIME=mono test + + windows: + name: Windows (.NET 6.0) + runs-on: windows-2019 + + steps: + - name: Clone Repository + uses: actions/checkout@v3 + + - name: Install .NET 6.0 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '6.0.x' + + - name: Check Code + shell: powershell + run: | + # Work around runtime failures on the GH Actions runner + dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org + .\make.ps1 check + + - name: Check Mods + run: | + chocolatey install lua --version 5.1.5.52 + $ENV:Path = $ENV:Path + ";C:\Program Files (x86)\Lua\5.1\" + .\make.ps1 check-scripts + .\make.ps1 test diff --git a/.github/workflows/packaging.yml b/.github/workflows/packaging.yml index 016a5e8..7b4711c 100644 --- a/.github/workflows/packaging.yml +++ b/.github/workflows/packaging.yml @@ -8,14 +8,13 @@ on: jobs: linux: name: Linux AppImages - runs-on: ubuntu-20.04 - + runs-on: ubuntu-22.04 steps: - name: Clone Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install .NET 6.0 - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: dotnet-version: '6.0.x' @@ -26,6 +25,7 @@ jobs: run: | make engine mkdir -p build/linux + sudo apt install libfuse2 ./packaging/linux/buildpackage.sh "${GIT_TAG}" "${PWD}/build/linux" - name: Upload Packages @@ -38,22 +38,21 @@ jobs: file: build/linux/* macos: - name: macOS Disk Images - runs-on: macos-10.15 - + name: macOS Disk Image + runs-on: macos-11 steps: - name: Clone Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install .NET 6.0 - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: dotnet-version: '6.0.x' - name: Prepare Environment run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_ENV} - - name: Package Disk Images + - name: Package Disk Image env: MACOS_DEVELOPER_IDENTITY: ${{ secrets.MACOS_DEVELOPER_IDENTITY }} MACOS_DEVELOPER_CERTIFICATE_BASE64: ${{ secrets.MACOS_DEVELOPER_CERTIFICATE_BASE64 }} @@ -65,7 +64,7 @@ jobs: mkdir -p build/macos ./packaging/macos/buildpackage.sh "${GIT_TAG}" "${PWD}/build/macos" - - name: Upload Packages + - name: Upload Package uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} @@ -76,14 +75,13 @@ jobs: windows: name: Windows Installers - runs-on: ubuntu-20.04 - + runs-on: ubuntu-22.04 steps: - name: Clone Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install .NET 6.0 - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: dotnet-version: '6.0.x' diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 18c4b5e..67894ae 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -56,8 +56,8 @@ further defined and clarified by project maintainers. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by private-messaging a project team member (users with a + in front -of their name) via our IRC channel (#openra on freenode – -[webchat](http://webchat.freenode.net/?channels=openra)). All +of their name) via our IRC channel (#openra on Libera – +[webchat](https://web.libera.chat/#openra)). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/Makefile b/Makefile index cd3b3a3..7dbd192 100644 --- a/Makefile +++ b/Makefile @@ -54,20 +54,31 @@ MSBUILD = msbuild -verbosity:m -nologo DOTNET = dotnet RUNTIME ?= net6 +CONFIGURATION ?= Release +DOTNET_RID = $(shell ${DOTNET} --info | grep RID: | cut -w -f3) +ARCH_X64 = $(shell echo ${DOTNET_RID} | grep x64) ifndef TARGETPLATFORM UNAME_S := $(shell uname -s) UNAME_M := $(shell uname -m) ifeq ($(UNAME_S),Darwin) +ifeq ($(ARCH_X64),) +TARGETPLATFORM = osx-arm64 +else TARGETPLATFORM = osx-x64 +endif else ifeq ($(UNAME_M),x86_64) TARGETPLATFORM = linux-x64 else +ifeq ($(UNAME_M),aarch64) +TARGETPLATFORM = linux-arm64 +else TARGETPLATFORM = unix-generic endif endif endif +endif check-sdk-scripts: @awk '/\r$$/ { exit(1); }' mod.config || (printf "Invalid mod.config format: file must be saved using unix-style (CR, not CRLF) line endings.\n"; exit 1) @@ -136,10 +147,10 @@ all: engine ifeq ($(RUNTIME), mono) @command -v $(MSBUILD) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 6.4."; exit 1) ifneq ("$(MOD_SOLUTION_FILES)","") - @find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:Build -restore -p:Configuration=Release -p:TargetPlatform=$(TARGETPLATFORM) -p:Mono=true \; + @find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:Build -restore -p:Configuration=${CONFIGURATION} -p:TargetPlatform=$(TARGETPLATFORM) -p:Mono=true \; endif else - @find . -maxdepth 1 -name '*.sln' -exec $(DOTNET) build -c Release -p:TargetPlatform=$(TARGETPLATFORM) \; + @find . -maxdepth 1 -name '*.sln' -exec $(DOTNET) build -c ${CONFIGURATION} -p:TargetPlatform=$(TARGETPLATFORM) \; endif clean: engine @@ -168,11 +179,13 @@ endif check: engine ifneq ("$(MOD_SOLUTION_FILES)","") - @echo "Compiling in debug mode..." + @echo "Compiling in Debug mode..." ifeq ($(RUNTIME), mono) - @$(MSBUILD) -t:build -restore -p:Configuration=Debug -p:TargetPlatform=$(TARGETPLATFORM) -p:Mono=true +# Enabling EnforceCodeStyleInBuild and GenerateDocumentationFile as a workaround for some code style rules (in particular IDE0005) being bugged and not reporting warnings/errors otherwise. + @$(MSBUILD) -t:build -restore -p:Configuration=Debug -warnaserror -p:TargetPlatform=$(TARGETPLATFORM) -p:Mono=true -p:EnforceCodeStyleInBuild=true -p:GenerateDocumentationFile=true else - @$(DOTNET) build -c Debug -p:TargetPlatform=$(TARGETPLATFORM) +# Enabling EnforceCodeStyleInBuild and GenerateDocumentationFile as a workaround for some code style rules (in particular IDE0005) being bugged and not reporting warnings/errors otherwise. + @$(DOTNET) build -c Debug -nologo -warnaserror -p:TargetPlatform=$(TARGETPLATFORM) -p:EnforceCodeStyleInBuild=true -p:GenerateDocumentationFile=true endif endif @echo "Checking for explicit interface violations..." diff --git a/launch-dedicated.cmd b/launch-dedicated.cmd index c78a427..58dca9a 100644 --- a/launch-dedicated.cmd +++ b/launch-dedicated.cmd @@ -6,6 +6,7 @@ set Name="Dedicated Server" set ListenPort=1234 set AdvertiseOnline=True set Password="" +set RecordReplays=False set RequireAuthentication=False set ProfileIDBlacklist="" @@ -14,8 +15,11 @@ set ProfileIDWhitelist="" set EnableSingleplayer=False set EnableSyncReports=False set EnableGeoIP=True +set EnableLintChecks=True set ShareAnonymizedIPs=True +set JoinChatDelay=5000 + @echo off setlocal EnableDelayedExpansion @@ -33,7 +37,7 @@ if not exist %ENGINE_DIRECTORY%\bin\OpenRA.exe goto noengine cd %ENGINE_DIRECTORY% :loop -bin\OpenRA.Server.exe Game.Mod=%MOD_ID% Engine.EngineDir=".." Server.Name=%Name% Server.ListenPort=%ListenPort% Server.AdvertiseOnline=%AdvertiseOnline% Server.EnableSingleplayer=%EnableSingleplayer% Server.Password=%Password% Server.RequireAuthentication=%RequireAuthentication% Server.ProfileIDBlacklist=%ProfileIDBlacklist% Server.ProfileIDWhitelist=%ProfileIDWhitelist% Server.EnableSyncReports=%EnableSyncReports% Server.EnableGeoIP=%EnableGeoIP% Server.ShareAnonymizedIPs=%ShareAnonymizedIPs% Engine.SupportDir=%SupportDir% +bin\OpenRA.Server.exe Game.Mod=%MOD_ID% Engine.EngineDir=".." Server.Name=%Name% Server.ListenPort=%ListenPort% Server.AdvertiseOnline=%AdvertiseOnline% Server.EnableSingleplayer=%EnableSingleplayer% Server.Password=%Password% Server.RequireAuthentication=%RequireAuthentication% Server.RecordReplays=%RecordReplays% Server.ProfileIDBlacklist=%ProfileIDBlacklist% Server.ProfileIDWhitelist=%ProfileIDWhitelist% Server.EnableSyncReports=%EnableSyncReports% Server.EnableGeoIP=%EnableGeoIP% Server.ShareAnonymizedIPs=%ShareAnonymizedIPs% Server.EnableLintChecks=%EnableLintChecks% Engine.SupportDir=%SupportDir% Server.JoinChatDelay=%JoinChatDelay% goto loop :noengine diff --git a/launch-dedicated.sh b/launch-dedicated.sh index 44a3a4d..ae52ac8 100755 --- a/launch-dedicated.sh +++ b/launch-dedicated.sh @@ -53,6 +53,7 @@ LAUNCH_MOD="${Mod:-"${MOD_ID}"}" LISTEN_PORT="${ListenPort:-"1234"}" ADVERTISE_ONLINE="${AdvertiseOnline:-"True"}" PASSWORD="${Password:-""}" +RECORD_REPLAYS="${RecordReplays:-"False"}" REQUIRE_AUTHENTICATION="${RequireAuthentication:-"False"}" PROFILE_ID_BLACKLIST="${ProfileIDBlacklist:-""}" @@ -61,8 +62,11 @@ PROFILE_ID_WHITELIST="${ProfileIDWhitelist:-""}" ENABLE_SINGLE_PLAYER="${EnableSingleplayer:-"False"}" ENABLE_SYNC_REPORTS="${EnableSyncReports:-"False"}" ENABLE_GEOIP="${EnableGeoIP:-"True"}" +ENABLE_LINT_CHECKS="${EnableLintChecks:-"True"}" SHARE_ANONYMISED_IPS="${ShareAnonymizedIPs:-"True"}" +JOIN_CHAT_DELAY="${JoinChatDelay:-"5000"}" + SUPPORT_DIR="${SupportDir:-""}" cd "${TEMPLATE_ROOT}" @@ -75,16 +79,21 @@ fi cd "${ENGINE_DIRECTORY}" while true; do - MOD_SEARCH_PATHS="${MOD_SEARCH_PATHS}" ${RUNTIME_LAUNCHER} bin/OpenRA.Server.dll Engine.EngineDir=".." Game.Mod="${LAUNCH_MOD}" \ - Server.Name="${NAME}" Server.ListenPort="${LISTEN_PORT}" \ + MOD_SEARCH_PATHS="${MOD_SEARCH_PATHS}" + ${RUNTIME_LAUNCHER} bin/OpenRA.Server.dll Engine.EngineDir=".." Game.Mod="${LAUNCH_MOD}" \ + Server.Name="${NAME}" \ + Server.ListenPort="${LISTEN_PORT}" \ Server.AdvertiseOnline="${ADVERTISE_ONLINE}" \ Server.Password="${PASSWORD}" \ + Server.RecordReplays="${RECORD_REPLAYS}" \ Server.RequireAuthentication="${REQUIRE_AUTHENTICATION}" \ Server.ProfileIDBlacklist="${PROFILE_ID_BLACKLIST}" \ Server.ProfileIDWhitelist="${PROFILE_ID_WHITELIST}" \ Server.EnableSingleplayer="${ENABLE_SINGLE_PLAYER}" \ Server.EnableSyncReports="${ENABLE_SYNC_REPORTS}" \ Server.EnableGeoIP="${ENABLE_GEOIP}" \ + Server.EnableLintChecks="${ENABLE_LINT_CHECKS}" \ Server.ShareAnonymizedIPs="${SHARE_ANONYMISED_IPS}" \ + Server.JoinChatDelay="${JOIN_CHAT_DELAY}" \ Engine.SupportDir="${SUPPORT_DIR}" done diff --git a/launch-game.cmd b/launch-game.cmd index b3cd456..b9479d6 100644 --- a/launch-game.cmd +++ b/launch-game.cmd @@ -16,7 +16,7 @@ if not exist %ENGINE_DIRECTORY%\bin\OpenRA.exe goto noengine >nul find %ENGINE_VERSION% %ENGINE_DIRECTORY%\VERSION || goto noengine cd %ENGINE_DIRECTORY% -bin\OpenRA.exe Game.Mod=%MOD_ID% Engine.EngineDir=".." Engine.LaunchPath="%TEMPLATE_LAUNCHER%" "Engine.ModSearchPaths=%MOD_SEARCH_PATHS%" "%*" +bin\OpenRA.exe Game.Mod=%MOD_ID% Engine.EngineDir=".." Engine.LaunchPath="%TEMPLATE_LAUNCHER%" Engine.ModSearchPaths="%MOD_SEARCH_PATHS%" "%*" set ERROR=%errorlevel% cd %TEMPLATE_DIR% diff --git a/launch-game.sh b/launch-game.sh index be9749a..e618427 100755 --- a/launch-game.sh +++ b/launch-game.sh @@ -52,4 +52,4 @@ else fi cd "${ENGINE_DIRECTORY}" -${RUNTIME_LAUNCHER} bin/OpenRA.dll Engine.EngineDir=".." Engine.LaunchPath="${TEMPLATE_LAUNCHER}" "Engine.ModSearchPaths=${MOD_SEARCH_PATHS}" Game.Mod="${MOD_ID}" "$@" +${RUNTIME_LAUNCHER} bin/OpenRA.dll Game.Mod="${MOD_ID}" Engine.EngineDir=".." Engine.LaunchPath="${TEMPLATE_LAUNCHER}" Engine.ModSearchPaths="${MOD_SEARCH_PATHS}" "$@" diff --git a/make.ps1 b/make.ps1 index c6704c8..4bf144a 100644 --- a/make.ps1 +++ b/make.ps1 @@ -7,6 +7,7 @@ function All-Command { If (!(Test-Path "*.sln")) { + Write-Host "No custom solution file found. Aborting." -ForegroundColor Red return } @@ -15,7 +16,9 @@ function All-Command return } - dotnet build -c Release --nologo -p:TargetPlatform=win-x64 + Write-Host "Building $modID in" $configuration "configuration..." -ForegroundColor Cyan + dotnet build -c $configuration --nologo -p:TargetPlatform=win-x64 + if ($lastexitcode -ne 0) { Write-Host "Build failed. If just the development tools failed to build, try installing Visual Studio. You may also still be able to run the game." -ForegroundColor Red @@ -30,6 +33,7 @@ function Clean-Command { If (!(Test-Path "*.sln")) { + Write-Host "No custom solution file found - nothing to clean. Aborting." -ForegroundColor Red return } @@ -38,6 +42,8 @@ function Clean-Command return } + Write-Host "Cleaning $modID..." -ForegroundColor Cyan + dotnet clean /nologo Remove-Item ./*/obj -Recurse -ErrorAction Ignore Remove-Item env:ENGINE_DIRECTORY/bin -Recurse -ErrorAction Ignore @@ -110,8 +116,10 @@ function Check-Command return } - Write-Host "Compiling in debug configuration..." -ForegroundColor Cyan - dotnet build -c Debug --nologo -p:TargetPlatform=win-x64 + Write-Host "Compiling $modID in Debug configuration..." -ForegroundColor Cyan + + # Enabling EnforceCodeStyleInBuild and GenerateDocumentationFile as a workaround for some code style rules (in particular IDE0005) being bugged and not reporting warnings/errors otherwise. + dotnet build -c Debug --nologo -warnaserror -p:TargetPlatform=win-x64 -p:EnforceCodeStyleInBuild=true -p:GenerateDocumentationFile=true if ($lastexitcode -ne 0) { Write-Host "Build failed." -ForegroundColor Red @@ -119,10 +127,10 @@ function Check-Command if ((CheckForUtility) -eq 0) { - Write-Host "Checking for explicit interface violations..." -ForegroundColor Cyan + Write-Host "Checking $modID for explicit interface violations..." -ForegroundColor Cyan InvokeCommand "$utilityPath $modID --check-explicit-interfaces" - Write-Host "Checking for incorrect conditional trait interface overrides..." -ForegroundColor Cyan + Write-Host "Checking $modID for incorrect conditional trait interface overrides..." -ForegroundColor Cyan InvokeCommand "$utilityPath $modID --check-conditional-trait-interface-overrides" } } @@ -159,7 +167,7 @@ function CheckForDotnet { if ((Get-Command "dotnet" -ErrorAction SilentlyContinue) -eq $null) { - Write-Host "The 'dotnet' tool is required to compile OpenRA. Please install the .NET 5.0 SDK and try again. https://dotnet.microsoft.com/download/dotnet/5.0" -ForegroundColor Red + Write-Host "The 'dotnet' tool is required to compile OpenRA. Please install the .NET 6.0 SDK and try again. https://dotnet.microsoft.com/download/dotnet/6.0" -ForegroundColor Red return 1 } @@ -168,7 +176,7 @@ function CheckForDotnet function WaitForInput { - echo "Press enter to continue." + Write-Host "Press enter to continue." while ($true) { if ([System.Console]::KeyAvailable) @@ -214,12 +222,12 @@ function ParseConfigFile($fileName) if ($missing) { - echo "Required mod.config variables are missing:" + Write-Host "Required mod.config variables are missing:" foreach ($m in $missing) { - echo " $m" + Write-Host " $m" } - echo "Repair your mod.config (or user.config) and try again." + Write-Host "Repair your mod.config (or user.config) and try again." WaitForInput exit } @@ -244,24 +252,24 @@ function InvokeCommand ############################################################### if ($PSVersionTable.PSVersion.Major -clt 3) { - echo "The makefile requires PowerShell version 3 or higher." - echo "Please download and install the latest Windows Management Framework version from Microsoft." + Write-Host "The makefile requires PowerShell version 3 or higher." -ForegroundColor Red + Write-Host "Please download and install the latest Windows Management Framework version from Microsoft." -ForegroundColor Red WaitForInput } if ($args.Length -eq 0) { - echo "Command list:" - echo "" - echo " all Builds the game, its development tools and the mod dlls." - echo " version Sets the version strings for all mods to the latest" - echo " version for the current Git branch." - echo " clean Removes all built and copied files." - echo " from the mods and the engine directories." - echo " test Tests the mod's MiniYAML for errors." - echo " check Checks .cs files for StyleCop violations." - echo " check-scripts Checks .lua files for syntax errors." - echo "" + Write-Host "Command list:" + Write-Host "" + Write-Host " all Builds the game, its development tools and the mod dlls." + Write-Host " version Sets the version strings for all mods to the latest" + Write-Host " version for the current Git branch." + Write-Host " clean Removes all built and copied files." + Write-Host " from the mods and the engine directories." + Write-Host " test Tests the mod's MiniYAML for errors." + Write-Host " check Checks .cs files for StyleCop violations." + Write-Host " check-scripts Checks .lua files for syntax errors." + Write-Host "" $command = (Read-Host "Enter command").Split(' ', 2) } else @@ -284,8 +292,8 @@ if (Test-Path "user.config") $modID = $env:MOD_ID -$env:MOD_SEARCH_PATHS = (Get-Item -Path ".\" -Verbose).FullName + "\mods,./mods" -$env:ENGINE_DIR = ".." +$env:MOD_SEARCH_PATHS = "./mods,$env:ENGINE_DIRECTORY/mods" +$env:ENGINE_DIR = ".." # Set to potentially be used by the Utility and different than $env:ENGINE_DIRECTORY, which is for the script. # Fetch the engine if required if ($command -eq "all" -or $command -eq "clean" -or $command -eq "check") @@ -303,34 +311,34 @@ if ($command -eq "all" -or $command -eq "clean" -or $command -eq "check") { cd $env:ENGINE_DIRECTORY Invoke-Expression ".\make.cmd $command" - echo "" + Write-Host "" cd $templateDir } elseif ($env:AUTOMATIC_ENGINE_MANAGEMENT -ne "True") { - echo "Automatic engine management is disabled." - echo "Please manually update the engine to version $env:ENGINE_VERSION." + Write-Host "Automatic engine management is disabled." + Write-Host "Please manually update the engine to version $env:ENGINE_VERSION." WaitForInput } else { - echo "OpenRA engine version $env:ENGINE_VERSION is required." + Write-Host "OpenRA engine version $env:ENGINE_VERSION is required." if (Test-Path $env:ENGINE_DIRECTORY) { if ($currentEngine -ne "") { - echo "Deleting engine version $currentEngine." + Write-Host "Deleting engine version $currentEngine." } else { - echo "Deleting existing engine (unknown version)." + Write-Host "Deleting existing engine (unknown version)." } rm $env:ENGINE_DIRECTORY -r } - echo "Downloading engine..." + Write-Host "Downloading engine..." if (Test-Path $env:AUTOMATIC_ENGINE_EXTRACT_DIRECTORY) { @@ -361,13 +369,19 @@ if ($command -eq "all" -or $command -eq "clean" -or $command -eq "check") cd $env:ENGINE_DIRECTORY Invoke-Expression ".\make.cmd version $env:ENGINE_VERSION" Invoke-Expression ".\make.cmd $command" - echo "" + Write-Host "" cd $templateDir } } $utilityPath = $env:ENGINE_DIRECTORY + "/bin/OpenRA.Utility.exe" +$configuration = "Release" +if ($args.Contains("CONFIGURATION=Debug")) +{ + $configuration = "Debug" +} + $execute = $command if ($command.Length -gt 1) { @@ -382,7 +396,7 @@ switch ($execute) "test" { Test-Command } "check" { Check-Command } "check-scripts" { Check-Scripts-Command } - Default { echo ("Invalid command '{0}'" -f $command) } + Default { Write-Host ("Invalid command '{0}'" -f $command) } } # In case the script was called without any parameters we keep the window open diff --git a/mod.config b/mod.config index e4e56ff..0c7b8d1 100644 --- a/mod.config +++ b/mod.config @@ -19,7 +19,7 @@ ENGINE_VERSION="3ca2bb1" # The prefix used for the installer filenames. # - Windows installers will be named as {PACKAGING_INSTALLER_NAME}-{TAG}.exe -# - macOS installers will be named as {PACKAGING_INSTALLER_NAME}-{TAG}.zip +# - macOS installers will be named as {PACKAGING_INSTALLER_NAME}-{TAG}.dmg # - Linux .appimages will be named as {PACKAGING_INSTALLER_NAME}-${TAG}.AppImage PACKAGING_INSTALLER_NAME="SoleSurvivor" @@ -29,6 +29,7 @@ PACKAGING_INSTALLER_NAME="SoleSurvivor" # - macOS .app bundle name # - macOS menu bar # - macOS "About" window +# - macOS disk image title # - Windows installer # - Windows start menu # - Windows desktop shortcut @@ -49,10 +50,6 @@ PACKAGING_FAQ_URL="http://wiki.openra.net/FAQ" # - Windows "Add/Remove Programs" list PACKAGING_AUTHORS="Sole Survivor mod authors" -# Space delimited list of dll files compiled by the mod, which -# should be copied from the bin directory into your installers -PACKAGING_COPY_MOD_BINARIES="OpenRA.Mods.SS.dll" - # If your mod depends on OpenRA.Mods.Cnc.dll from the engine set # this to "True" to package the dll in your installers. # Accepts values "True" or "False". diff --git a/omnisharp.json b/omnisharp.json new file mode 100644 index 0000000..2ba5d8b --- /dev/null +++ b/omnisharp.json @@ -0,0 +1,5 @@ +{ + "RoslynExtensionsOptions": { + "enableAnalyzersSupport": true + } +} diff --git a/utility.cmd b/utility.cmd index 94fa76d..ae6ccb5 100644 --- a/utility.cmd +++ b/utility.cmd @@ -16,6 +16,32 @@ if not exist %ENGINE_DIRECTORY%\bin\OpenRA.exe goto noengine >nul find %ENGINE_VERSION% %ENGINE_DIRECTORY%\VERSION || goto noengine cd %ENGINE_DIRECTORY% +set argC=0 +for %%x in (%*) do set /A argC+=1 + +if %argC% == 0 goto choosemod + +if %argC% == 1 ( + set MOD_ID=%1 + goto loop +) + +if %argC% GEQ 2 ( + @REM This option is for use by other scripts so we don't want any extra output here - before or after. + call bin\OpenRA.Utility.exe %* + EXIT /B 0 +) + +:choosemod +echo ---------------------------------------- +echo. +call bin\OpenRA.Utility.exe +echo Enter --exit to exit +set /P mod="Please enter a modname: OpenRA.Utility.exe " +if /I "%mod%" EQU "--exit" (exit /b) +set MOD_ID=%mod% +echo. + :loop echo. echo ---------------------------------------- @@ -24,12 +50,12 @@ echo Enter a utility command or --exit to exit. echo Press enter to view a list of valid utility commands. echo. -set /P command=Please enter a command: OpenRA.Utility.exe %MOD_ID% +set /P command="Please enter a command: OpenRA.Utility.exe %MOD_ID% " if /I "%command%" EQU "--exit" (cd %TEMPLATE_DIR% & exit /b) echo. echo ---------------------------------------- echo. -echo OpenRA.Utility.exe %MOD_ID% %command% +echo Starting OpenRA.Utility.exe %MOD_ID% %command% call bin\OpenRA.Utility.exe %MOD_ID% %command% goto loop