Skip to content

Commit

Permalink
Merge pull request #298 from CnCNet/develop
Browse files Browse the repository at this point in the history
develop into master
  • Loading branch information
devo1929 authored Jan 27, 2022
2 parents be04535 + 5074cc5 commit 92efae2
Show file tree
Hide file tree
Showing 200 changed files with 11,450 additions and 3,077 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[*]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.cs]
# var preferences
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_when_type_is_apparent = false:suggestion
csharp_style_var_elsewhere = true:suggestion
48 changes: 48 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: build client

on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]

jobs:
build-clients:
runs-on: windows-2019

steps:
- uses: actions/checkout@v2

- name: Create Artifacts Directories
run: mkdir .\Artifacts\YR & mkdir .\Artifacts\Ares & mkdir .\Artifacts\TS
shell: cmd

- name: Build YR
run: BuildYR.bat
shell: cmd
working-directory: ./BuildScripts

- name: Archive YR
run: Get-ChildItem -Path "./Compiled/*" -Recurse | Move-Item -Destination "./Artifacts/YR"

- name: Build Ares
run: BuildAres.bat
shell: cmd
working-directory: ./BuildScripts

- name: Archive Ares
run: Get-ChildItem -Path "./Compiled/*" -Recurse | Move-Item -Destination "./Artifacts/Ares"

- name: Build TS
run: BuildTS.bat
shell: cmd
working-directory: ./BuildScripts

- name: Archive TS
run: Get-ChildItem -Path "./Compiled/*" -Recurse | Move-Item -Destination "./Artifacts/TS"

- uses: actions/upload-artifact@v2
name: Upload Artifacts
with:
name: artifacts
path: ./Artifacts
52 changes: 52 additions & 0 deletions .github/workflows/pr-build-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: automatic comment on pull request
on:
workflow_run:
workflows: ['build client']
types: [completed]
jobs:
pr_comment:
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
with:
# This snippet is public-domain, taken from
# https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml
script: |
const {owner, repo} = context.repo;
const run_id = ${{github.event.workflow_run.id}};
const pull_head_sha = '${{github.event.workflow_run.head_sha}}';
const pull_user_id = ${{github.event.sender.id}};
const issue_number = await (async () => {
const pulls = await github.pulls.list({owner, repo});
for await (const {data} of github.paginate.iterator(pulls)) {
for (const pull of data) {
if (pull.head.sha === pull_head_sha && pull.user.id === pull_user_id) {
return pull.number;
}
}
}
})();
if (issue_number) {
core.info(`Using pull request ${issue_number}`);
} else {
return core.error(`No matching pull request found`);
}
const {data: {artifacts}} = await github.actions.listWorkflowRunArtifacts({owner, repo, run_id});
if (!artifacts.length) {
return core.error(`No artifacts found`);
}
let body = `Nightly build for this pull request:\n`;
for (const art of artifacts) {
body += `\n* [${art.name}.zip](https://nightly.link/${owner}/${repo}/actions/artifacts/${art.id}.zip)`;
}
body += `\nThis comment is automatic and is meant to allow guests to get latest automatic builds without registering. It is updated on every successful build.`;
const {data: comments} = await github.issues.listComments({repo, owner, issue_number});
const existing_comment = comments.find((c) => c.user.login === 'github-actions[bot]');
if (existing_comment) {
core.info(`Updating comment ${existing_comment.id}`);
await github.issues.updateComment({repo, owner, comment_id: existing_comment.id, body});
} else {
core.info(`Creating a comment`);
await github.issues.createComment({repo, owner, issue_number, body});
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.project
.idea/

# Visual Studion tiedostoja
*/[Ee]xported[Oo]bj/
Expand All @@ -25,3 +26,5 @@ Icon?

# Dolphin
.directory

.idea/
4 changes: 4 additions & 0 deletions BuildScripts/BuildAres.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off

call BuildGame AresRelease

4 changes: 0 additions & 4 deletions BuildScripts/BuildDTA.bat

This file was deleted.

4 changes: 0 additions & 4 deletions BuildScripts/BuildMO.bat

This file was deleted.

4 changes: 0 additions & 4 deletions BuildScripts/BuildTI.bat

This file was deleted.

13 changes: 12 additions & 1 deletion BuildScripts/CopyCompiled.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mkdir Windows
mkdir XNA
cd OpenGL
mkdir x86
mkdir x64
cd ..

REM Setting up paths
Expand All @@ -25,13 +26,15 @@ set xnaBinaries="..\..\..\..\Compiled\Binaries\XNA\"
echo(
echo Common

cd ..\..\DXMainClient\bin\Windows\Release\
cd ..\..\DXMainClient\bin\SharpDX\Release\

copy DTAUpdater.dll %commonBinaries%DTAUpdater.dll
copy Ionic.Zip.dll %commonBinaries%Ionic.Zip.dll
copy Rampastring.Tools.dll %commonBinaries%Rampastring.Tools.dll
copy Newtonsoft.Json.dll %commonBinaries%Newtonsoft.Json.dll
copy DiscordRPC.dll %commonBinaries%DiscordRPC.dll
copy lzo.net.dll %commonBinaries%lzo.net.dll
copy OpenMcdf.dll %commonBinaries%OpenMcdf.dll

echo Windows
copy DTAClient.exe %cr%clientdx.exe
Expand All @@ -58,6 +61,14 @@ copy DTAConfig.dll %oglBinaries%DTAConfig.dll
copy MonoGame.Framework.dll %oglBinaries%MonoGame.Framework.dll
copy ..\..\..\..\References\WindowsGL\x86\SDL2.dll %oglBinaries%x86\SDL2.dll
copy ..\..\..\..\References\WindowsGL\x86\soft_oal.dll %oglBinaries%x86\soft_oal.dll
copy ..\..\..\..\References\WindowsGL\x86\libopenal.so.1 %oglBinaries%x86\libopenal.so.1
copy ..\..\..\..\References\WindowsGL\x86\libSDL2-2.0.so.0 %oglBinaries%x86\libSDL2-2.0.so.0
copy ..\..\..\..\References\WindowsGL\x64\SDL2.dll %oglBinaries%x64\SDL2.dll
copy ..\..\..\..\References\WindowsGL\x64\soft_oal.dll %oglBinaries%x64\soft_oal.dll
copy ..\..\..\..\References\WindowsGL\x64\libopenal.so.1 %oglBinaries%x64\libopenal.so.1
copy ..\..\..\..\References\WindowsGL\x64\libSDL2-2.0.so.0 %oglBinaries%x64\libSDL2-2.0.so.0
copy ..\..\..\..\References\WindowsGL\libopenal.1.dylib %oglBinaries%libopenal.1.dylib
copy ..\..\..\..\References\WindowsGL\libSDL2-2.0.0.dylib %oglBinaries%libSDL2-2.0.0.dylib
copy Rampastring.XNAUI.dll %oglBinaries%Rampastring.XNAUI.dll

echo XNA
Expand Down
10 changes: 4 additions & 6 deletions ClientCore/CCIniFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ protected override void ApplyBaseIni()
string basedOn = GetStringValue("INISystem", "BasedOn", string.Empty);
if (!string.IsNullOrEmpty(basedOn))
{
string path = string.Empty;
string path;
if (basedOn.Contains("$THEME_DIR$"))
{
path = basedOn.Replace("$THEME_DIR$\\", ProgramConstants.GetResourcePath());
}
path = basedOn.Replace("$THEME_DIR$", ProgramConstants.GetResourcePath().TrimEnd(new char[] { '/', '\\' }));
else
path = Path.GetDirectoryName(FileName) + "\\" + basedOn;
path = Path.GetDirectoryName(FileName) + "/" + basedOn;

// Consolidate with the INI file that this INI file is based on
if (!File.Exists(path))
Logger.Log(FileName + ": Base INI file not found! " + path);

CCIniFile baseIni = new CCIniFile(path);
ConsolidateIniFiles(baseIni, this);
this.Sections = baseIni.Sections;
Sections = baseIni.Sections;
}
}
}
Expand Down
57 changes: 46 additions & 11 deletions ClientCore/ClientConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace ClientCore
public class ClientConfiguration
{
private const string GENERAL = "General";
private const string AUDIO = "Audio";
private const string SETTINGS = "Settings";
private const string LINKS = "Links";

Expand Down Expand Up @@ -119,11 +120,31 @@ public void RefreshSettings()

#endregion

#region Audio options

public float SoundGameLobbyJoinCooldown => DTACnCNetClient_ini.GetSingleValue(AUDIO, "SoundGameLobbyJoinCooldown", 0.25f);

public float SoundGameLobbyLeaveCooldown => DTACnCNetClient_ini.GetSingleValue(AUDIO, "SoundGameLobbyLeaveCooldown", 0.25f);

public float SoundMessageCooldown => DTACnCNetClient_ini.GetSingleValue(AUDIO, "SoundMessageCooldown", 0.25f);

public float SoundPrivateMessageCooldown => DTACnCNetClient_ini.GetSingleValue(AUDIO, "SoundPrivateMessageCooldown", 0.25f);

public float SoundGameLobbyGetReadyCooldown => DTACnCNetClient_ini.GetSingleValue(AUDIO, "SoundGameLobbyGetReadyCooldown", 5.0f);

public float SoundGameLobbyReturnCooldown => DTACnCNetClient_ini.GetSingleValue(AUDIO, "SoundGameLobbyReturnCooldown", 1.0f);

#endregion

#endregion

#region Game options

public string Sides => gameOptions_ini.GetStringValue(GENERAL, "Sides", "GDI,Nod,Allies,Soviet");
public string Sides => gameOptions_ini.GetStringValue(GENERAL, nameof(Sides), "GDI,Nod,Allies,Soviet");

public string InternalSideIndices => gameOptions_ini.GetStringValue(GENERAL, nameof(InternalSideIndices), string.Empty);

public string SpectatorInternalSideIndex => gameOptions_ini.GetStringValue(GENERAL, nameof(SpectatorInternalSideIndex), string.Empty);

#endregion

Expand Down Expand Up @@ -157,7 +178,7 @@ public void RefreshSettings()

public string BattleFSFileName => clientDefinitionsIni.GetStringValue(SETTINGS, "BattleFSFileName", "BattleFS.ini");

public string MapEditorExePath => clientDefinitionsIni.GetStringValue(SETTINGS, "MapEditorExePath", "FinalSun\\FinalSun.exe");
public string MapEditorExePath => clientDefinitionsIni.GetStringValue(SETTINGS, "MapEditorExePath", "FinalSun/FinalSun.exe");

public string UnixMapEditorExePath => clientDefinitionsIni.GetStringValue(SETTINGS, "UnixMapEditorExePath", Instance.MapEditorExePath);

Expand All @@ -173,7 +194,7 @@ public void RefreshSettings()

public string CreditsURL => clientDefinitionsIni.GetStringValue(SETTINGS, "CreditsURL", "http://www.moddb.com/mods/the-dawn-of-the-tiberium-age/tutorials/credits#Rampastring");

public string FinalSunIniPath => clientDefinitionsIni.GetStringValue(SETTINGS, "FSIniPath", "FinalSun\\FinalSun.ini");
public string FinalSunIniPath => clientDefinitionsIni.GetStringValue(SETTINGS, "FSIniPath", "FinalSun/FinalSun.ini");

public int MaxNameLength => clientDefinitionsIni.GetIntValue(SETTINGS, "MaxNameLength", 16);

Expand Down Expand Up @@ -210,7 +231,7 @@ public string GetThemePath(string themeName)

public string ExtraExeCommandLineParameters => clientDefinitionsIni.GetStringValue(SETTINGS, "ExtraCommandLineParams", string.Empty);

public string MPMapsIniPath => clientDefinitionsIni.GetStringValue(SETTINGS, "MPMapsPath", "INI\\MPMaps.ini");
public string MPMapsIniPath => clientDefinitionsIni.GetStringValue(SETTINGS, "MPMapsPath", "INI/MPMaps.ini");

public string KeyboardINI => clientDefinitionsIni.GetStringValue(SETTINGS, "KeyboardINI", "Keyboard.ini");

Expand Down Expand Up @@ -252,19 +273,22 @@ public string GetGameExecutableName()

public bool UseClientRandomStartLocations => clientDefinitionsIni.GetBooleanValue(SETTINGS, "UseClientRandomStartLocations", false);

public bool ProcessScreenshots
#if MO
=> clientDefinitionsIni.GetBooleanValue(SETTINGS, "ProcessScreenshots", true);
#else
=> false;
#endif

/// <summary>
/// Returns the name of the game executable file that is used on
/// Linux and macOS.
/// </summary>
public string UnixGameExecutableName => clientDefinitionsIni.GetStringValue(SETTINGS, "UnixGameExecutableName", "wine-dta.sh");

/// <summary>
/// List of files that are not distributed but required to play.
/// </summary>
public string[] RequiredFiles => clientDefinitionsIni.GetStringValue(SETTINGS, "RequiredFiles", String.Empty).Split(',');

/// <summary>
/// List of files that can interfere with the mod functioning.
/// </summary>
public string[] ForbiddenFiles => clientDefinitionsIni.GetStringValue(SETTINGS, "ForbiddenFiles", String.Empty).Split(',');

#endregion

public OSVersion GetOperatingSystemVersion()
Expand Down Expand Up @@ -296,4 +320,15 @@ public OSVersion GetOperatingSystemVersion()
return OSVersion.UNKNOWN;
}
}

/// <summary>
/// An exception that is thrown when a client configuration file contains invalid or
/// unexpected settings / data or required settings / data are missing.
/// </summary>
public class ClientConfigurationException : Exception
{
public ClientConfigurationException(string message) : base(message)
{
}
}
}
Loading

0 comments on commit 92efae2

Please sign in to comment.