diff --git a/schema/init/idz.sql b/schema/init/idz.sql index 9285375..845cd1a 100644 --- a/schema/init/idz.sql +++ b/schema/init/idz.sql @@ -120,7 +120,8 @@ create table "idz"."story_cell_state" ( "row_no" integer not null, "col_no" integer not null, "a" smallint not null, - "b" smallint not null + "b" smallint not null, + constraint story_cell_state_uq unique ("profile_id", "row_no", "col_no") ); create table "idz"."free_car" ( diff --git a/src/idz/db/chara.ts b/src/idz/db/chara.ts index 4349747..560ba77 100644 --- a/src/idz/db/chara.ts +++ b/src/idz/db/chara.ts @@ -61,6 +61,8 @@ export class SqlCharaRepository implements FacetRepository { "field_0A", "field_0C", "field_0E", + "title", + "background", ]) .toParams(); diff --git a/src/idz/db/story.ts b/src/idz/db/story.ts index 99db2c0..0dd216e 100644 --- a/src/idz/db/story.ts +++ b/src/idz/db/story.ts @@ -50,7 +50,7 @@ export class SqlStoryRepository implements FacetRepository { const { rows } = await this._conn.query(loadCellSql); for (const row of rows) { - const cell = result.rows[row.row_no].cells[row.cell_no]; + const cell = result.rows[row.row_no].cells[row.col_no]; cell.a = row.a; cell.b = row.b; @@ -102,7 +102,8 @@ export class SqlStoryRepository implements FacetRepository { b: cell.b, }) .onConflict("profile_id", "row_no", "col_no") - .doUpdate("a", "b"); + .doUpdate(["a", "b"]) + .toParams(); await this._conn.query(cellSql); } diff --git a/src/idz/handler/saveTimeAttack.ts b/src/idz/handler/saveTimeAttack.ts index f49438c..296c2f3 100644 --- a/src/idz/handler/saveTimeAttack.ts +++ b/src/idz/handler/saveTimeAttack.ts @@ -6,12 +6,17 @@ export async function saveTimeAttack( w: Repositories, req: SaveTimeAttackRequest ): Promise { - // Override client time since we might be doing some maintenance window - // avoidance time warping stuff + // Non time-attack credits still call this method, but they pass some + // bullshit payload that we need to ignore. - await w - .timeAttack() - .save(req.profileId, { ...req.payload, timestamp: new Date() }); + if (req.payload.totalTime > 0) { + // Override client time since we might be doing some maintenance window + // avoidance time warping stuff + + await w + .timeAttack() + .save(req.profileId, { ...req.payload, timestamp: new Date() }); + } return { type: "save_time_attack_res", diff --git a/src/startup.ts b/src/startup.ts index 02b3684..136ca8f 100644 --- a/src/startup.ts +++ b/src/startup.ts @@ -1,4 +1,5 @@ import express = require("express"); +import iconv = require("iconv-lite"); import read = require("raw-body"); import { unzipSync } from "zlib"; @@ -57,7 +58,9 @@ app.use(async function(req, res, next) { res.set("content-type", "text/plain"); - return send_.apply(res, [str]); + const bin = iconv.encode(str, "shift_jis"); + + return send_.apply(res, [bin]); }; return next();