diff --git a/amalgamate.js b/amalgamate.js index 0eeeaa6..938718b 100644 --- a/amalgamate.js +++ b/amalgamate.js @@ -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); } } diff --git a/lib/convert.js b/lib/convert.js index ed02fc4..62ab5dc 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -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