Skip to content

Commit

Permalink
feat: update opcode script
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyupe committed Oct 8, 2024
1 parent 2604b27 commit b82cb96
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 38 deletions.
1 change: 1 addition & 0 deletions Cafe.Matcha/Constant/MatchaOpcode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ internal static class OpcodeStorage
{ 0x01c3, MatchaOpcode.MarketBoardItemListing },
{ 0x00a0, MatchaOpcode.MarketBoardItemListingCount },
{ 0x0102, MatchaOpcode.MarketBoardItemListingHistory },
{ 0xf010, MatchaOpcode.MarketBoardRequestItemListingInfo },
{ 0x0186, MatchaOpcode.NpcSpawn },
{ 0x00c6, MatchaOpcode.PlayerSetup },
{ 0x024f, MatchaOpcode.PlayerSpawn },
Expand Down
78 changes: 40 additions & 38 deletions utils/update-opcode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const opcodes = [
'MarketBoardItemListing',
'MarketBoardItemListingCount',
'MarketBoardItemListingHistory',
'MarketBoardRequestItemListingInfo',
'NpcSpawn',
'PlayerSetup',
'PlayerSpawn'
Expand Down Expand Up @@ -96,47 +97,48 @@ const outputFromWorker = (list) =>
})
.join('\n')

;(async () => {
const karashiiroData = await fetch(
'https://raw.githubusercontent.com/karashiiro/FFXIVOpcodes/master/opcodes.json'
)
const parsedData = await karashiiroData.json()
; (async () => {
const karashiiroData = await fetch(
'https://raw.githubusercontent.com/karashiiro/FFXIVOpcodes/master/opcodes.json'
)
const parsedData = await karashiiroData.json()

const globalOpcodes = parsedData.find((item) => item.region === 'Global')
const globalOpcodes = parsedData.find((item) => item.region === 'Global')

const cactbotFate = await fetch(
'https://raw.githubusercontent.com/quisquous/cactbot/main/plugin/CactbotEventSource/FateWatcher.cs'
)
const ceDirector =
/cedirector_intl.+\n.+0x30.+\n\s+(0x[0-9a-fA-F]+),?\s*\n\s*\)/.exec(
await cactbotFate.text()
const cactbotFate = await fetch(
'https://raw.githubusercontent.com/quisquous/cactbot/main/plugin/CactbotEventSource/FateWatcher.cs'
)
const ceDirector =
/cedirector_intl.+\n.+0x30.+\n\s+(0x[0-9a-fA-F]+),?\s*\n\s*\)/.exec(
await cactbotFate.text()
)

if (ceDirector) {
globalOpcodes.lists.ServerZoneIpcType.push({
name: '_GH_CEDirector',
opcode: parseOpcode(ceDirector[1])
if (ceDirector) {
globalOpcodes.lists.ServerZoneIpcType.push({
name: '_GH_CEDirector',
opcode: parseOpcode(ceDirector[1])
})
}

const workerData = await fetch(
'https://raw.githubusercontent.com/zhyupe/ffxiv-opcode-worker/master/cn-opcodes.csv'
)
const workerLines = readCsv(await workerData.text(), null, {
header: 0,
skip: 0
})
}

const workerData = await fetch(
'https://raw.githubusercontent.com/zhyupe/ffxiv-opcode-worker/master/cn-opcodes.csv'
)
const workerLines = readCsv(await workerData.text(), null, {
header: 0,
skip: 0
})
const cnOpcodes = workerLines.map(({ Name: name, _ }) => {
const valueColumn = _.reduce((val, content, index) => {
return content ? index : val
}, 0)

return [name, parseOpcode(_[valueColumn])]
})

writeFileSync(
join(__dirname, '../Cafe.Matcha/Constant/MatchaOpcode.cs'),
`// Copyright (c) FFCafe. All rights reserved.
const cnOpcodes = workerLines.map(({ Name: name, Scope: scope, _ }) => {
const valueColumn = _.reduce((val, content, index) => {
return content ? index : val
}, 0)

const isClient = scope === 'ClientZoneIpc'
return [name, (isClient ? 0x8000 : 0) + parseOpcode(_[valueColumn])]
})

writeFileSync(
join(__dirname, '../Cafe.Matcha/Constant/MatchaOpcode.cs'),
`// Copyright (c) FFCafe. All rights reserved.
// Licensed under the AGPL-3.0 license. See LICENSE file in the project root for full license information.
namespace Cafe.Matcha.Constant
Expand All @@ -161,5 +163,5 @@ ${outputFromWorker(cnOpcodes, 'cn')}
}
}
`
)
})()
)
})()

0 comments on commit b82cb96

Please sign in to comment.