idz: Push story geometry down into codecs
Sparsify the data model returned from the repository layer. Different versions of the game can have drastically different dimensions for the story data grid, so handling those dimensions is best done in the encoders themselves.
This commit is contained in:
@@ -37,14 +37,22 @@ export function loadProfile2(res: LoadProfileResponse) {
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < 9 && i < res.story.rows.length; i++) {
|
||||
const row = res.story.rows[i];
|
||||
for (let i = 0; i < 9; i++) {
|
||||
const row = res.story.rows.get(i);
|
||||
const rowOffset = 0x0228 + i * 0x26;
|
||||
|
||||
for (let j = 0; j < 9 && j < row.cells.length; j++) {
|
||||
const cell = row.cells[j];
|
||||
if (row === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let j = 0; j < 9; j++) {
|
||||
const cell = row.cells.get(j);
|
||||
const cellOffset = rowOffset + j * 4;
|
||||
|
||||
if (cell === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
buf.writeUInt16LE(cell.a, cellOffset + 0);
|
||||
buf.writeUInt16LE(cell.b, cellOffset + 2);
|
||||
}
|
||||
|
||||
@@ -37,14 +37,22 @@ export function loadProfile3(res: LoadProfileResponse) {
|
||||
// space for story cells, and 27 rows * 19 bytes per row = 513 bytes, which
|
||||
// is the max that will fit (the final byte of each row is unused).
|
||||
|
||||
for (let i = 0; i < 27 && i < res.story.rows.length; i++) {
|
||||
const row = res.story.rows[i];
|
||||
for (let i = 0; i < 27; i++) {
|
||||
const row = res.story.rows.get(i);
|
||||
const rowOffset = 0x0256 + i * 0x13;
|
||||
|
||||
for (let j = 0; j < 9 && j < row.cells.length; j++) {
|
||||
const cell = row.cells[j];
|
||||
if (row === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let j = 0; j < 9; j++) {
|
||||
const cell = row.cells.get(j);
|
||||
const cellOffset = rowOffset + j * 2;
|
||||
|
||||
if (cell === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
buf.writeUInt8(cell.a, cellOffset + 0);
|
||||
buf.writeUInt8(cell.b, cellOffset + 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user