idz: Rename encoder funcs

Avoid name collision between nouns and verbs.
This commit is contained in:
Tau 2019-05-25 21:43:15 -04:00
parent c2b0bcabc4
commit 9c06d6635f
8 changed files with 26 additions and 26 deletions

View File

@ -1,4 +1,4 @@
export function bitmap(items: Set<number>, nbytes: number): Buffer {
export function encodeBitmap(items: Set<number>, nbytes: number): Buffer {
const buf = Buffer.alloc(nbytes);
for (const item of items) {

View File

@ -1,6 +1,6 @@
import { Car } from "../model/car";
export function car(car: Car): Buffer {
export function encodeCar(car: Car): Buffer {
const buf = Buffer.alloc(0x0060);
buf.writeUInt16LE(car.field_00, 0x0000);

View File

@ -1,6 +1,6 @@
import { Chara } from "../model/chara";
export function chara(chara: Chara): Buffer {
export function encodeChara(chara: Chara): Buffer {
const buf = Buffer.alloc(0x0014);
buf.writeUInt8(chara.gender === "male" ? 0 : 1, 0x00);

View File

@ -1,6 +1,6 @@
import { MissionGrid } from "../model/mission";
export function mission(grids: MissionGrid[]): Buffer {
export function encodeMission(grids: MissionGrid[]): Buffer {
const buf = Buffer.alloc(0x24);
for (let gridNo = 0; gridNo < grids.length; gridNo++) {

View File

@ -1,4 +1,4 @@
import { car } from "./_car";
import { encodeCar } from "./_car";
import { LoadGarageResponse } from "../response/loadGarage";
export function loadGarage(res: LoadGarageResponse): Buffer {
@ -8,7 +8,7 @@ export function loadGarage(res: LoadGarageResponse): Buffer {
buf.writeUInt16LE(res.cars.length, 0x0002);
for (let i = 0; i < res.cars.length; i++) {
car(res.cars[i]).copy(buf, 0x0004 + 0x0060 * i);
encodeCar(res.cars[i]).copy(buf, 0x0004 + 0x0060 * i);
}
return buf;

View File

@ -1,9 +1,9 @@
import iconv = require("iconv-lite");
import { bitmap } from "./_bitmap";
import { car } from "./_car";
import { chara } from "./_chara";
import { mission } from "./_mission";
import { encodeBitmap } from "./_bitmap";
import { encodeCar } from "./_car";
import { encodeChara } from "./_chara";
import { encodeMission } from "./_mission";
import { LoadProfileResponse2 } from "../response/loadProfile";
export function loadProfile2(res: LoadProfileResponse2) {
@ -76,7 +76,7 @@ export function loadProfile2(res: LoadProfileResponse2) {
buf.writeUInt32LE(res.unlocks.lastMileageReward, 0x01e8);
buf.writeUInt16LE(res.unlocks.music, 0x01ec);
buf.writeUInt16LE(0, 0x037c); // Team leader
mission(res.missions.team).copy(buf, 0x038a);
encodeMission(res.missions.team).copy(buf, 0x038a);
buf.writeUInt16LE(0xffff, 0x0388); // [1]
buf.writeUInt32LE(res.aimeId, 0x03b8);
buf.writeUInt32LE(res.mileage, 0x03bc);
@ -89,13 +89,13 @@ export function loadProfile2(res: LoadProfileResponse2) {
iconv.encode(res.name + "\0", "shift_jis").copy(buf, 0x03ee);
buf.writeUInt8(res.story.y, 0x0670);
buf.writeUInt16LE(res.story.x, 0x06bc);
mission(res.missions.solo).copy(buf, 0x06e4);
chara(res.chara).copy(buf, 0x070c);
bitmap(res.titles, 0xb4).copy(buf, 0x720);
encodeMission(res.missions.solo).copy(buf, 0x06e4);
encodeChara(res.chara).copy(buf, 0x070c);
encodeBitmap(res.titles, 0xb4).copy(buf, 0x720);
buf.writeUInt8(res.settings.paperCup, 0x07d9);
buf.writeUInt8(res.settings.gauges, 0x07da);
buf.writeUInt32LE(res.teamId || 0xffffffff, 0x07e0);
car(res.car).copy(buf, 0x0c5c);
encodeCar(res.car).copy(buf, 0x0c5c);
buf.writeUInt32LE(res.carCount, 0x0c58);
// [1] Currently unknown, but if this field is zero then the player will have

View File

@ -1,9 +1,9 @@
import iconv = require("iconv-lite");
import { bitmap } from "./_bitmap";
import { car } from "./_car";
import { chara } from "./_chara";
import { mission } from "./_mission";
import { encodeBitmap } from "./_bitmap";
import { encodeCar } from "./_car";
import { encodeChara } from "./_chara";
import { encodeMission } from "./_mission";
import { LoadProfileResponse3 } from "../response/loadProfile";
export function loadProfile3(res: LoadProfileResponse3) {
@ -76,7 +76,7 @@ export function loadProfile3(res: LoadProfileResponse3) {
buf.writeUInt32LE(res.unlocks.lastMileageReward, 0x0218);
buf.writeUInt16LE(res.unlocks.music, 0x021c);
buf.writeUInt16LE(0, 0x0456); // Team leader
mission(res.missions.team).copy(buf, 0x0460);
encodeMission(res.missions.team).copy(buf, 0x0460);
buf.writeUInt16LE(0xffff, 0x0462); // [1]
buf.writeUInt32LE(res.aimeId, 0x0494);
buf.writeUInt32LE(res.mileage, 0x0498);
@ -89,14 +89,14 @@ export function loadProfile3(res: LoadProfileResponse3) {
iconv.encode(res.name + "\0", "shift_jis").copy(buf, 0x04ca);
buf.writeUInt8(res.story.y, 0x080c);
buf.writeUInt16LE(res.story.x, 0x0828);
mission(res.missions.solo).copy(buf, 0x0858);
chara(res.chara).copy(buf, 0x0880);
bitmap(res.titles, 0xb4).copy(buf, 0x0894);
encodeMission(res.missions.solo).copy(buf, 0x0858);
encodeChara(res.chara).copy(buf, 0x0880);
encodeBitmap(res.titles, 0xb4).copy(buf, 0x0894);
buf.writeUInt8(res.settings.paperCup, 0x094d);
buf.writeUInt8(res.settings.gauges, 0x094e);
buf.writeUInt32LE(res.teamId || 0xffffffff, 0x0954);
buf.writeUInt32LE(res.carCount, 0x0dd0);
car(res.car).copy(buf, 0x0dd4);
encodeCar(res.car).copy(buf, 0x0dd4);
// [1] Currently unknown, but if this field is zero then the player will have
// a "model record" emblem in their profile card.

View File

@ -1,4 +1,4 @@
import { bitmap } from "./_bitmap";
import { encodeBitmap } from "./_bitmap";
import { LoadStockerResponse } from "../response/loadStocker";
export function loadStocker(res: LoadStockerResponse) {
@ -6,7 +6,7 @@ export function loadStocker(res: LoadStockerResponse) {
buf.writeInt16LE(0x00a8, 0x0000);
buf.writeUInt8(res.status, 0x0002);
bitmap(res.backgrounds, 0x24).copy(buf, 0x0003);
encodeBitmap(res.backgrounds, 0x24).copy(buf, 0x0003);
return buf;
}