Skip to content

Commit

Permalink
feat(clientdb): add ZoneMusicRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenoak committed Jan 15, 2024
1 parent b73759c commit d379c6d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
Binary file added fixture/clientdb/ZoneMusic.dbc
Binary file not shown.
24 changes: 24 additions & 0 deletions src/lib/clientdb/record/ZoneMusicRecord.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as io from '@wowserhq/io';
import ClientDbRecord from '../ClientDbRecord.js';

const recordIo = io.struct({
id: io.int32le,
'setName.string': io.uint32le,
silenceIntervalMin: io.array(io.int32le, { size: 2 }),
silenceIntervalMax: io.array(io.int32le, { size: 2 }),
sounds: io.array(io.int32le, { size: 2 }),
});

class ZoneMusicRecord extends ClientDbRecord {
setName: string;
silenceIntervalMin: number;
silenceIntervalMax: number;
sounds: number[];

constructor() {
super(recordIo);
}
}

export default ZoneMusicRecord;
export { ZoneMusicRecord };
1 change: 1 addition & 0 deletions src/lib/clientdb/records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './record/LightRecord.js';
export * from './record/LightFloatBandRecord.js';
export * from './record/LightIntBandRecord.js';
export * from './record/LightParamsRecord.js';
export * from './record/ZoneMusicRecord.js';
10 changes: 10 additions & 0 deletions src/spec/clientdb/ClientDb.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, expect, test } from 'vitest';
import ClientDb from '../../lib/clientdb/ClientDb.js';
import LightRecord from '../../lib/clientdb/record/LightRecord.js';
import AreaTableRecord from '../../lib/clientdb/record/AreaTableRecord.js';
import ZoneMusicRecord from '../../lib/clientdb/record/ZoneMusicRecord.js';

describe('ClientDb', () => {
describe('load', () => {
Expand All @@ -13,6 +14,15 @@ describe('ClientDb', () => {
expect(record.lightParamsId).toEqual([14, 15, 494, 15, 4, 0, 0, 0]);
});

test('should load dbc with non-localized strings from valid file', () => {
const dbc = new ClientDb(ZoneMusicRecord).load('./fixture/clientdb/ZoneMusic.dbc');
const record = dbc.getRecordByIndex(1);

expect(record.id).toBe(2);
expect(record.setName).toBe('Zone-EvilForest');
expect(record.sounds).toEqual([2524, 2534]);
});

test('should load dbc with localized strings from valid file', () => {
const dbc = new ClientDb(AreaTableRecord).load('./fixture/clientdb/AreaTable.dbc');
const record = dbc.getRecordByIndex(1);
Expand Down

0 comments on commit d379c6d

Please sign in to comment.