Skip to content

Commit

Permalink
BaS: removed legacy mod support
Browse files Browse the repository at this point in the history
BaS is now version 1.0 and no longer requires legacy mod support.

Also removed all version specific checks in the installer.

fixes Nexus-Mods/Vortex#16000
  • Loading branch information
IDCs committed Jun 27, 2024
1 parent 6c110e8 commit 9358ef5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 75 deletions.
22 changes: 3 additions & 19 deletions game-bladeandsorcery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,7 @@ function prepareForModding(discovery, api) {
}

async function getOfficialModType(api, discovery = undefined) {
const discoveryPath = (discovery?.path !== undefined)
? discovery.path
: getDiscoveryPath(api);
if (discoveryPath === undefined) {
return Promise.reject(new GameNotDiscoveredException());
}
let gameVersion;
try {
gameVersion = await getGameVersion(discoveryPath, BAS_EXEC);
} catch (err) {
return missingGameJsonError(api, err);
}
//const segments = gameVersion.split('.');
//const ver = segments[0] === '0' ? segments.slice(1).join('.') : gameVersion;
const modType = semver.gte(semver.coerce(gameVersion), semver.coerce('0.8.4'))
? 'bas-official-modtype' : 'bas-legacy-modtype';
return Promise.resolve(modType);
return Promise.resolve('bas-official-modtype');
}

async function getDeployedManaged(context, modType) {
Expand Down Expand Up @@ -423,10 +407,10 @@ function main(context) {
installOfficialMod(files, destinationPath, gameId, progressDelegate, context.api));

context.registerModType('bas-official-modtype', 15, (gameId) => (gameId === GAME_ID),
getOfficialDestination, () => Promise.resolve(false), { name: 'Official Mod (v8.4+)' });
getOfficialDestination, () => Promise.resolve(false), { name: 'Official Mod (v1.0+)' });

context.registerModType('bas-legacy-modtype', 15, (gameId) => (gameId === GAME_ID),
getLegacyDestination, () => Promise.resolve(false), { name: 'Legacy Mod (v8.3 and below)' });
getLegacyDestination, () => Promise.resolve(false), { name: 'Legacy Mod (v0.8.3 and below)' });

let refreshFunc;
context.registerLoadOrderPage({
Expand Down
2 changes: 1 addition & 1 deletion game-bladeandsorcery/info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Game: Blade & Sorcery",
"author": "Black Tree Gaming Ltd.",
"version": "0.2.16",
"version": "0.2.17",
"description": "Support for Blade & Sorcery"
}
72 changes: 17 additions & 55 deletions game-bladeandsorcery/installers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { util } = require('vortex-api');
const { app, remote } = require('electron');
const uniApp = app || remote.app;

const { BAS_EXEC, GAME_ID, MOD_MANIFEST, GameNotDiscoveredException } = require('./common');
const { BAS_EXEC, GAME_ID, MOD_MANIFEST } = require('./common');
const { getModName, checkModGameVersion, getGameVersion,
getMinModVersion, getDiscoveryPath, missingGameJsonError } = require('./util');

Expand Down Expand Up @@ -42,33 +42,21 @@ async function installOfficialMod(files,
}
let isEngineInject;
try {
gameVersion = await getGameVersion(discoveryPath, BAS_EXEC);
minModVersion = await getMinModVersion(discoveryPath, BAS_EXEC);
try {
const relPath = files.find(f => path.basename(f).toLowerCase() === MOD_MANIFEST);
isEngineInject = path.dirname(relPath).startsWith('BladeAndSorcery_Data');
// just validating if the name is valid
await getModName(path.join(destinationPath, relPath), 'Name');
} catch (err) {
// invalid mod name, refuse installation
return {
instructions: [
{
type: 'error',
value: 'fatal',
source: 'This mod is not compatible with Blade&Sorcery version 8.4 and newer.',
},
],
};
}
minModVersion.version = minModVersion.version.toString().replace(',', '.');
}
catch (err) {
return missingGameJsonError(api, err);
}

if (minModVersion === undefined) {
throw new util.DataInvalid('Failed to identify game version');
const relPath = files.find(f => path.basename(f).toLowerCase() === MOD_MANIFEST);
isEngineInject = path.dirname(relPath).startsWith('BladeAndSorcery_Data');
// just validating if the name is valid
await getModName(path.join(destinationPath, relPath), 'Name');
} catch (err) {
// invalid mod name, refuse installation
return {
instructions: [
{
type: 'error',
value: 'fatal',
source: 'This mod is not compatible with Blade&Sorcery version 8.4 and newer.',
},
],
};
}

const usedModNames = [];
Expand All @@ -88,7 +76,6 @@ async function installOfficialMod(files,

usedModNames.push(modName);


// Remove directories and anything that isn't in the rootPath (unless mod type engine inject).
const filtered = files.filter(file =>
(((file.indexOf(rootPath) !== -1) || isEngineInject) && (!file.endsWith(path.sep))));
Expand All @@ -107,34 +94,9 @@ async function installOfficialMod(files,
value: (manifestFiles.length > 1),
})

let modVersion;
try {
modVersion = await checkModGameVersion(destinationPath, minModVersion, manifestFile);
} catch (err) {
return Promise.reject(err);
}

const segments = gameVersion.split('.');
const ver = segments[0] === '0' ? segments.slice(1).join('.') : gameVersion;
if ((process.env.NODE_ENV === 'development') || semver.satisfies(uniApp.getVersion(), '>=1.4.0')) {
// All this bullshit could've been avoided had the game used semantic versioning
// from the get-go.
instructions.push({
type: 'attribute',
key: 'maxGameVersion',
value: (segments[0] === '0')
? (modVersion.modVersion.split('.')[0] === '0')
? semver.coerce(modVersion.modVersion).version
: semver.coerce(`0.${modVersion.modVersion}`).version
: semver.coerce(modVersion.modVersion).version,
})
}

const modTypeInstr = {
type: 'setmodtype',
value: isEngineInject ? 'dinput' : semver.gte(semver.coerce(ver), semver.coerce('8.4'))
? 'bas-official-modtype'
: 'bas-legacy-modtype'
value: isEngineInject ? 'dinput' : 'bas-official-modtype',
}

instructions.push(modTypeInstr);
Expand Down

0 comments on commit 9358ef5

Please sign in to comment.