Skip to content

Commit

Permalink
fix: handle N/A
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyupe committed Mar 5, 2024
1 parent da86e91 commit 0518de2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@
"url": "https://github.com/zhyupe/ffxiv-opcode-worker/issues"
},
"homepage": "https://github.com/zhyupe/ffxiv-opcode-worker#readme",
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"prettier": {
"singleQuote": true,
"semi": false
}
}
49 changes: 36 additions & 13 deletions worker/machina-wrapper-json/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ const output = {}
const existsOpcode = new Set()
const specialValues = {}

for (let { Name: name, Scope: scope, TeamCraft: altname, [csvVersion]: opcode } of table) {
if (!name || !opcode) {
for (let {
Name: name,
Scope: scope,
TeamCraft: altname,
[csvVersion]: opcode,
} of table) {
if (!name || !opcode || opcode === '#N/A') {
continue
}

Expand All @@ -43,11 +48,18 @@ for (let { Name: name, Scope: scope, TeamCraft: altname, [csvVersion]: opcode }

output[scope].push({
name: altname || name,
opcode
opcode,
})
}

const scopes = ['ServerLobbyIpc', 'ClientLobbyIpc', 'ServerZoneIpc', 'ClientZoneIpc', 'ServerChatIpc', 'ClientChatIpc']
const scopes = [
'ServerLobbyIpc',
'ClientLobbyIpc',
'ServerZoneIpc',
'ClientZoneIpc',
'ServerChatIpc',
'ClientChatIpc',
]
const tab = ` `

const opcodeFile = join(workspace, 'FFXIVOpcodes/Ipcs_cn.cs')
Expand All @@ -56,21 +68,31 @@ const constantFile = join(workspace, 'FFXIVConstants/CN.cs')
fs.mkdirpSync(dirname(opcodeFile))
fs.mkdirpSync(dirname(constantFile))

fs.writeFileSync(opcodeFile, `// Generated by https://github.com/zhyupe/ffxiv-opcode-worker
fs.writeFileSync(
opcodeFile,
`// Generated by https://github.com/zhyupe/ffxiv-opcode-worker
namespace FFXIVOpcodes.CN
{
${scopes.map(key => `${tab}public enum ${key}Type : ushort
${scopes
.map(
(key) => `${tab}public enum ${key}Type : ushort
${tab}{
${(output[key] || []).sort((a, b) => a.name.localeCompare(b.name))
.map(({ name, opcode }) => `${tab}${tab}${name} = ${opcode},`).join('\n')
${(output[key] || [])
.sort((a, b) => a.name.localeCompare(b.name))
.map(({ name, opcode }) => `${tab}${tab}${name} = ${opcode},`)
.join('\n')}
${tab}};`
)
.join('\n\n')}
}
${tab}};`).join('\n\n')}
}
`)
`
)

const offset = parseOpcode(specialValues.InventoryHandlerOffset) + 7
fs.writeFileSync(constantFile, `// Generated by https://github.com/zhyupe/ffxiv-opcode-worker
fs.writeFileSync(
constantFile,
`// Generated by https://github.com/zhyupe/ffxiv-opcode-worker
using System.Collections.Generic;
namespace FFXIVConstants
Expand All @@ -85,4 +107,5 @@ ${tab}${tab}${tab}{ "InventoryOperationBaseValue", 0x${formatOpcode(offset)} },
${tab}${tab}};
${tab}}
}
`)
`
)

0 comments on commit 0518de2

Please sign in to comment.