Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions .github/workflows/config-serving-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,16 @@ jobs:
deploy-config:
if: github.repository == 'beyond-all-reason/bar-lobby'
runs-on: ubuntu-latest
env:
CONFIG_URL: https://lobby-config.beyondallreason.dev/config.json
steps:
- uses: actions/checkout@v4

- name: Push config
env:
CONFIG_URL: https://lobby-config.beyondallreason.dev/config.json
run: |
# TODO: Just an empty config for now, to show that workflow works,
# replace with real path from validated config.json.
cat > config.json <<EOF
{
"configUrl": "$CONFIG_URL"
}
EOF
CURL_OPTS=(-sS --fail-with-body --connect-timeout 10 --max-time 30 --retry 3 --retry-connrefused)
IDTOKEN="$(curl "${CURL_OPTS[@]}" -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=$CONFIG_URL" | jq -r '.value')"
curl "${CURL_OPTS[@]}" -X PUT "$CONFIG_URL" \
-H "Authorization: Bearer $IDTOKEN" \
--data @config.json
--data @./remoteConfig/config.json
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
- name: Type check
run: npm run typecheck

- name: Validate committed config
run: npm run validate-config

- name: Lint check
run: npm run lint

Expand Down
1 change: 1 addition & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ path = [
"AUTHORS",
"PULL_REQUEST_TEMPLATE.md",
"playwright.config.ts",
"remoteConfig/config.json",
]
precedence = "aggregate"
SPDX-FileCopyrightText = "NONE"
Expand Down
1 change: 1 addition & 0 deletions lang/dev/lobby.json
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@
"debugSidebar": {
"debugSandbox": "Duebg Snbodax",
"openSettingsFile": "Oepn Setngits Flie",
"openConfigFile": "Oepn Cionfg Flie",
"openAssetsDir": "Oepn Aessts Dir",
"openStateDir": "Oepn Satte Dir",
"openStartScript": "Oepn Lasett Strat Sipcrt",
Expand Down
1 change: 1 addition & 0 deletions lang/en/lobby.json
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@
"debugSidebar": {
"debugSandbox": "Debug Sandbox",
"openSettingsFile": "Open Settings File",
"openConfigFile": "Open Config File",
"openAssetsDir": "Open Assets Dir",
"openStateDir": "Open State Dir",
"openStartScript": "Open Latest Start Script",
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
"typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false",
"typecheck:web": "vue-tsc --noEmit -p tsconfig.web.json --composite false",
"typecheck": "concurrently \"npm run typecheck:node\" \"npm run typecheck:web\"",
"checks": "concurrently \"npm run typecheck:web\" \"npm run typecheck:node\" \"npm run lint\" \"npm run format:check\"",
"validate-config": "node --import=tsx tools/validate-config.ts",
"checks": "concurrently \"npm run typecheck:web\" \"npm run typecheck:node\" \"npm run lint\" \"npm run format:check\" \"npm run validate-config\"",
"generate-default-config": "node --import=tsx tools/generate-default-config.ts && prettier ./config.json --write",
"generate-i18n-assets": "node --import=tsx tools/generate-dev-locale.ts && node --import=tsx tools/generate-i18n-asset-files.ts && npm run format",
"generate-i18n-assets:check": "npm run generate-i18n-assets && git diff --exit-code -- src/renderer/assets/languages",
"start:multi": "node --import=tsx tools/launch-clients.ts"
Expand Down
1 change: 1 addition & 0 deletions remoteConfig/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "configUrl": "https://lobby-config.beyondallreason.dev/config.json" }
18 changes: 2 additions & 16 deletions src/main/config/content-sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,7 @@
// SPDX-License-Identifier: MIT

import axios from "axios";

export const contentSources = {
rapid: {
host: "repos-cdn.beyondallreason.dev",
game: "byar",
},
gameGithub: {
owner: "beyond-all-reason",
repo: "Beyond-All-Reason",
},
engineGitHub: {
owner: "beyond-all-reason",
repo: "spring",
},
};
import { configService } from "@main/services/config.service";

export interface EngineReleaseInfo {
filename: string;
Expand All @@ -34,7 +20,7 @@ export interface EngineReleaseInfo {

const findEngineReleaseUrl = (engineVersion: string) => {
const archStr = process.platform === "win32" ? "engine_windows64" : "engine_linux64";
const url = new URL("https://files-cdn.beyondallreason.dev/find");
const url = new URL(configService.getConfig().engineReleaseUrl);
url.searchParams.set("category", archStr);
url.searchParams.set("springname", engineVersion);
return url;
Expand Down
8 changes: 0 additions & 8 deletions src/main/config/default-maps.ts

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/config/default-versions.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/content/content-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { mapProvider } from "@main/content/maps/map-provider";
import { contentUsage } from "@main/content/content-usage";
import { findPrdBinary } from "@main/content/pr-downloader";
import { CONTENT_RETENTION_DAYS, MIN_FREE_BYTES_TO_ACQUIRE } from "@main/config/content-policy";
import { DEFAULT_ENGINE_VERSION } from "@main/config/default-versions";
import { configService } from "@main/services/config.service";
import { getAssetsPath } from "@main/config/app";
import { formatBytes, freeBytes } from "@main/utils/disk-space";
import { logger } from "@main/utils/logger";
Expand Down Expand Up @@ -276,7 +276,7 @@ class ContentAPI {

if (this.missing(refs).some((ref) => ref.type !== "engine") && !findPrdBinary()) {
log.info("No pr-downloader available, acquiring the default engine first");
await this.ensure([{ type: "engine", id: DEFAULT_ENGINE_VERSION }]);
await this.ensure([{ type: "engine", id: configService.getConfig().defaultEngineVersion }]);
}

const acquisitions = await Promise.allSettled(this.missing(refs).map((ref) => this.track(this.queue.enqueue("acquire", ref), ref)));
Expand Down
12 changes: 6 additions & 6 deletions src/main/content/engine/engine-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { extract7z } from "@main/utils/extract-7z";
import { getEngineReleaseInfo } from "@main/config/content-sources";
import { AbstractContentAPI } from "@main/content/abstract-content";
import { getEnginePath } from "@main/config/app";
import { DEFAULT_ENGINE_VERSION } from "@main/config/default-versions";
import { configService } from "@main/services/config.service";
import { compareEngineVersions, isCompatibleEngineVersion } from "@main/content/engine/engine-version-order";
import { holdChecksums } from "@main/utils/checksums";

Expand Down Expand Up @@ -62,7 +62,7 @@ export class EngineProvider extends AbstractContentAPI<string, EngineVersion> {
}

public getDefaultEngine() {
return this.availableVersions.get(DEFAULT_ENGINE_VERSION);
return this.availableVersions.get(configService.getConfig().defaultEngineVersion);
}

public getInstalledVersionsNewestFirst() {
Expand All @@ -78,17 +78,17 @@ export class EngineProvider extends AbstractContentAPI<string, EngineVersion> {
}

protected checkIfDefaultIsNew() {
if (!this.availableVersions.has(DEFAULT_ENGINE_VERSION)) {
this.availableVersions.set(DEFAULT_ENGINE_VERSION, {
id: DEFAULT_ENGINE_VERSION,
if (!this.availableVersions.has(configService.getConfig().defaultEngineVersion)) {
this.availableVersions.set(configService.getConfig().defaultEngineVersion, {
id: configService.getConfig().defaultEngineVersion,
ais: [],
installed: false,
});
}
}

public async downloadEngine(version?: string) {
const engineVersion = version || DEFAULT_ENGINE_VERSION;
const engineVersion = version || configService.getConfig().defaultEngineVersion;
try {
if (this.isVersionInstalled(engineVersion)) {
return;
Expand Down
6 changes: 3 additions & 3 deletions src/main/content/game/game-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { parseLuaTable } from "@main/utils/parse-lua-table";
import { parseLuaOptions } from "@main/utils/parse-lua-options";
import { logger } from "@main/utils/logger";
import assert from "assert";
import { contentSources } from "@main/config/content-sources";
import { configService } from "@main/services/config.service";
import { DownloadInfo } from "@main/content/downloads";
import { getGameFiles } from "@main/content/game/game-files";
import { LuaOptionSection } from "@main/content/game/lua-options";
Expand Down Expand Up @@ -56,7 +56,7 @@ export class GameProvider extends PrDownloaderAPI<string, GameVersion> {
// we can easily check if a version is installed from its md5
protected async initLookupTables() {
try {
const versionsGzPath = path.join(getRapidIndexPath(), contentSources.rapid.host, contentSources.rapid.game, "versions.gz");
const versionsGzPath = path.join(getRapidIndexPath(), configService.getConfig().rapidHost, configService.getConfig().rapidGame, "versions.gz");
const versionsGz = await fs.promises.readFile(versionsGzPath);
const versions = await promisify(zlib.gunzip)(versionsGz);
const versionsStr = versions.toString().trim();
Expand Down Expand Up @@ -188,7 +188,7 @@ export class GameProvider extends PrDownloaderAPI<string, GameVersion> {
}
}

public async downloadGame(gameVersion = `${contentSources.rapid.game}:test`) {
public async downloadGame(gameVersion = `${configService.getConfig().rapidGame}:test`) {
return this.downloadGames([gameVersion]);
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/content/game/pool-cdn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ import { Downloader } from "@main/content/abstract-content";
import { downloadSlots } from "@main/content/download-slots";
import { removeFromArray } from "$/jaz-ts-utils/object";
import { extract7z } from "@main/utils/extract-7z";
import { configService } from "@main/services/config.service";

const log = logger("pool-cdn.ts");

export class PoolCdnDownloader extends Downloader {
cdnUrl = "https://pool-init.beyondallreason.dev";
poolDataUrl = `${this.cdnUrl}/data.7z`;

/**
* Download and extract pool data from the pool CDN.
*
Expand All @@ -45,7 +43,7 @@ export class PoolCdnDownloader extends Downloader {
this.downloadStarted(downloadInfo);

const dlFilePath = path.join(getAssetsPath(), "data.7z");
const dl = new DownloaderHelper(this.poolDataUrl, getAssetsPath(), {
const dl = new DownloaderHelper(`${configService.getConfig().initialPoolDataUrl}/data.7z`, getAssetsPath(), {
fileName: "data.7z",
timeout: 10000,
retry: { maxRetries: 3, delay: 1000 },
Expand Down
7 changes: 4 additions & 3 deletions src/main/content/pr-downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { DownloadInfo } from "./downloads";
import { AbstractContentAPI } from "./abstract-content";
import { engineProvider } from "./engine/engine-provider";
import { logger } from "@main/utils/logger";
import { configService } from "@main/services/config.service";
import { getAssetsPath, getEnginePath, getCaCertPath, getPackagePath } from "@main/config/app";
import { holdChecksums } from "@main/utils/checksums";

Expand Down Expand Up @@ -82,9 +83,9 @@ export abstract class PrDownloaderAPI<ID, T> extends AbstractContentAPI<ID, T> {
const prdProcess = spawn(`${prBinaryPath}`, ["--filesystem-writepath", getAssetsPath(), ...downloadArgs], {
env: {
...process.env,
PRD_RAPID_USE_STREAMER: "false",
PRD_RAPID_REPO_MASTER: "https://repos-cdn.beyondallreason.dev/repos.gz",
PRD_HTTP_SEARCH_URL: "https://files-cdn.beyondallreason.dev/find",
PRD_RAPID_USE_STREAMER: configService.getConfig().prdRapidUseStreamer,
PRD_RAPID_REPO_MASTER: configService.getConfig().prdRapidRepoMaster,
PRD_HTTP_SEARCH_URL: configService.getConfig().prdHttpSearchUrl,
...(caCertPath && !process.env.PRD_SSL_CERT_FILE && { PRD_SSL_CERT_FILE: caCertPath }),
},
});
Expand Down
95 changes: 2 additions & 93 deletions src/main/game/springsettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,103 +7,12 @@ import * as os from "os";
import * as path from "path";
import { WRITE_DATA_PATH } from "@main/config/app";
import { logger } from "@main/utils/logger";
import { configService } from "@main/services/config.service";

const log = logger("main/game/springsettings.ts");

const SPRINGSETTINGS_PATH = path.join(WRITE_DATA_PATH, "springsettings.cfg");

// Default engine settings for BAR, sourced from:
// https://github.com/beyond-all-reason/BYAR-Chobby/blob/master/dist_cfg/config.json
const BAR_SPRINGSETTINGS_DEFAULTS: Record<string, string | number> = {
AdvUnitShading: 1,
AdvMapShading: 1,
AdvSky: 0,
AllowDeferredMapRendering: 1,
AllowDeferredModelRendering: 1,
BuildWarnings: 0,
BumpWaterBlurReflection: 1,
BumpWaterDepthBits: 16,
BumpWaterShoreWaves: 1,
BumpWaterTexSizeReflection: 1024,
CamTimeExponent: 4.0,
CamTimeFactor: 1.0,
CrossAlpha: 0,
CubeTexSpecularExponent: 100,
CubeTexGenerateMipMaps: 1,
CubeTexSizeReflection: 1024,
DisplayDebugPrefixConsole: 0,
DualScreenMiniMapOnLeft: 1,
FPSFOV: 90,
FeatureDrawDistance: 10000,
FeatureFadeDistance: 10000,
ForceDisableShaders: 0,
Fullscreen: 0,
FullscreenEdgeMove: 1,
GrassDetail: 0,
GroundDecals: 2,
GroundDetail: 200,
GroundScarAlphaFade: 1,
HangTimeout: 30,
HardwareCursor: 1,
InitialNetworkTimeout: 0,
LODScale: 1.0,
LODScaleReflection: 1.0,
LODScaleRefraction: 1.0,
LODScaleShadow: 1.0,
LuaGarbageCollectionMemLoadMult: 2.0,
LogFlush: 0,
LuaShaders: 1,
LoadingMT: 0,
MaxParticles: 20000,
MaxSounds: 256,
MaximumTransmissionUnit: 0,
MaxTextureAtlasSizeX: 8192,
MaxTextureAtlasSizeZ: 8192,
MiddleClickScrollSpeed: -0.005,
MinimapOnLeft: 1,
MouseDragScrollThreshold: 0.3,
MoveWarnings: 0,
MSAA: 1,
MSAALevel: 4,
NormalMapping: 1,
ReconnectTimeout: 0,
Roam: 1,
ReflectiveWater: 3,
ScrollWheelSpeed: -20,
Shadows: 1,
ShadowMapSize: 2048,
ShowClock: 0,
ShowFps: 0,
ShowSpeed: 0,
SmoothLines: 1,
TreeRadius: 1000,
UnitIconDist: 160,
UnitLodDist: 999999,
UnitIconsAsUI: 1,
UnitIconScaleUI: 1.05,
UnitIconFadeVanish: 2700,
UnitIconFadeStart: 3000,
UnitIconFadeAmount: 0.1,
UsePBO: 1,
Water: 4,
WindowedEdgeMove: 1,
WindowPosX: 0,
WindowPosY: 0,
snd_general: 100,
snd_volmaster: 30,
snd_volmusic: 30,
snd_airAbsorption: 0.35,
ui_opacity: 0.6,
UseNetMessageSmoothingBuffer: 0,
NetworkLossFactor: 2,
MaxDynamicModelLights: 0,
LinkOutgoingBandwidth: 262144,
LinkIncomingSustainedBandwidth: 1048576,
LinkIncomingPeakBandwidth: 1048576,
LinkIncomingMaxPacketRate: 2048,
DemoFileExtension: "barreplay,sdfz",
};

function readSettings(filePath: string): Map<string, string> {
const settings = new Map<string, string>();
let fileContent = "";
Expand Down Expand Up @@ -135,7 +44,7 @@ export function applyDefaultSpringsettings(): void {
fs.mkdirSync(path.dirname(SPRINGSETTINGS_PATH), { recursive: true });
const settings = readSettings(SPRINGSETTINGS_PATH);
let changed = false;
for (const [key, value] of Object.entries(BAR_SPRINGSETTINGS_DEFAULTS)) {
for (const [key, value] of Object.entries(configService.getConfig().springSettings)) {
if (!settings.has(key)) {
settings.set(key, String(value));
changed = true;
Expand Down
Loading
Loading