Fix v3 story

This commit is contained in:
Tau 2019-05-08 18:29:49 -04:00
parent 2f48efdbb9
commit 2a365651a8
3 changed files with 15 additions and 12 deletions

View File

@ -31,7 +31,7 @@ export class SqlStoryRepository implements FacetRepository<Story> {
rows: new Array<StoryRow>(),
};
for (let i = 0; i < 9; i++) {
for (let i = 0; i < 27; i++) {
const row: StoryRow = { cells: new Array<StoryCell>() };
for (let j = 0; j < 9; j++) {

View File

@ -12,15 +12,15 @@ saveProfile3.msgLen = 0x0a70;
export function saveProfile3(buf: Buffer): SaveProfileRequest2 {
const storyRows = new Array();
/* Story seems to have changed somewhat
// Story layout has changed somewhat...
for (let i = 0; i < 9; i++) {
for (let i = 0; i < 27; i++) {
const cells = new Array();
const rowOffset = 0xXXXX + i * 0x3c;
const rowOffset = 0x01ac + i * 0x18;
for (let j = 0; j < 9; j++) {
const a = buf.readUInt32LE(rowOffset + 0x04 + j * 4);
const b = buf.readUInt16LE(rowOffset + 0x28 + j * 2);
const a = buf.readUInt8(rowOffset + 0x00 + j);
const b = buf.readUInt8(rowOffset + 0x09 + j);
const cell = { a, b };
cells.push(cell);
@ -30,7 +30,6 @@ export function saveProfile3(buf: Buffer): SaveProfileRequest2 {
storyRows.push(row);
}
*/
const coursePlays = new Map<CourseNo, number>();

View File

@ -34,16 +34,20 @@ export function loadProfile3(res: LoadProfileResponse3) {
}
}
for (let i = 0; i < 9 && i < res.story.rows.length; i++) {
// Not sure it actually goes up to 27, but there seem to be 512 bytes of
// 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];
const rowOffset = 0x0256 + i * 0x26;
const rowOffset = 0x0256 + i * 0x13;
for (let j = 0; j < 9 && j < row.cells.length; j++) {
const cell = row.cells[j];
const cellOffset = rowOffset + j * 4;
const cellOffset = rowOffset + j * 2;
buf.writeUInt16LE(cell.a, cellOffset + 0);
buf.writeUInt16LE(cell.b, cellOffset + 2);
buf.writeUInt8(cell.a, cellOffset + 0);
buf.writeUInt8(cell.b, cellOffset + 1);
}
}