Skip to content

Commit

Permalink
Add support for caution text & number type patches
Browse files Browse the repository at this point in the history
  • Loading branch information
aixxe committed May 29, 2024
1 parent 4802ba0 commit f9cdc3b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 27 deletions.
32 changes: 22 additions & 10 deletions amalgamate.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,28 @@ for (const patchFile of fs.readdirSync(INPUT_DIR))

for (const item of JSON.parse(contents))
{
output.push({
dateCode: 0,
description: item.description,
gameCode: item.gameCode,
name: item.name,
patches: item.patches,
preset: false,
type: item.type,
peIdentifier: path.basename(patchFile, '.json'),
});
let patch = {};

patch.dateCode = 0;
patch.description = item.description;

if (item.caution)
patch.caution = item.caution;

patch.gameCode = item.gameCode;
patch.name = item.name;

if (item.patches)
patch.patches = item.patches;

if (item.patch)
patch.patch = item.patch;

patch.preset = false;
patch.type = item.type;
patch.peIdentifier = path.basename(patchFile, '.json');

output.push(patch);
}
}

Expand Down
53 changes: 36 additions & 17 deletions lib/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,46 @@ export const parsePatcherFile = (file) =>
*/
export const convertToSpicePatch = (patch, prefix, dll) =>
{
if ('type' in patch && patch.type === 'number')
return console.warn(`Number patch '${patch.name}' can not be converted, skipping...`);
let result = {};

let result = { name: patch.name, description: patch.tooltip || '', gameCode: prefix };
result.name = patch.name;
result.description = patch.tooltip || '';

if ('type' in patch && patch.type === 'union')
{
result.type = 'union';
result.patches = [];
if (patch.danger)
result.caution = patch.danger || '';

for (const item of patch.patches)
result.gameCode = prefix;

if ('type' in patch)
{
if (patch.type === 'union')
{
result.patches.push({
name: item.name,
type: 'union',
patch: {
dllName: dll,
data: formatPatchBytes(item.patch),
offset: patch.offset,
}
});
result.type = 'union';
result.patches = [];

for (const item of patch.patches)
{
result.patches.push({
name: item.name,
type: 'union',
patch: {
dllName: dll,
data: formatPatchBytes(item.patch),
offset: patch.offset,
}
});
}
}
else if (patch.type === 'number')
{
result.type = 'number';
result.patch = {
dllName: dll,
offset: patch.offset,
min: patch.min,
max: patch.max,
size: patch.size,
};
}
}
else
Expand Down

0 comments on commit f9cdc3b

Please sign in to comment.