vice city online: the bare online core
This commit is contained in:
commit
2f98475c19
256 changed files with 144219 additions and 0 deletions
23
tools/map-icons.ts
Normal file
23
tools/map-icons.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Reads every map icon the game's own script can place (data/main.scm) and writes online/mapicons.json,
|
||||
// so the online map shows all locations although missions do not run. Usage: bun tools/map-icons.ts <game dir>
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
const dir = process.argv[2];
|
||||
if (!dir) throw new Error("usage: bun tools/map-icons.ts <game dir>");
|
||||
const d = readFileSync(`${dir}/data/main.scm`);
|
||||
const OPS = new Set([0x02a7, 0x02a8, 0x04ce, 0x0570]);
|
||||
const seen = new Map<string, { sprite: number; x: number; y: number; z: number }>();
|
||||
for (let i = 0; i + 24 < d.length; i++) {
|
||||
if (!OPS.has(d.readUInt16LE(i))) continue;
|
||||
if (d[i + 2] !== 6 || d[i + 7] !== 6 || d[i + 12] !== 6) continue;
|
||||
const t = d[i + 17];
|
||||
const sprite = t === 4 ? d.readInt8(i + 18) : t === 5 ? d.readInt16LE(i + 18) : t === 1 ? d.readInt32LE(i + 18) : -1;
|
||||
if (sprite <= 0 || sprite > 60) continue;
|
||||
const [x, y, z] = [d.readFloatLE(i + 3), d.readFloatLE(i + 8), d.readFloatLE(i + 13)];
|
||||
if (Math.abs(x) > 3000 || Math.abs(y) > 3000) continue;
|
||||
seen.set(`${sprite}:${Math.round(x)}:${Math.round(y)}`, { sprite, x: +x.toFixed(1), y: +y.toFixed(1), z: +z.toFixed(1) });
|
||||
}
|
||||
const icons = [...seen.values()].sort((a, b) => a.sprite - b.sprite);
|
||||
writeFileSync(`${dir}/online/mapicons.json`, JSON.stringify({ icons }));
|
||||
const count: Record<number, number> = {};
|
||||
for (const c of icons) count[c.sprite] = (count[c.sprite] || 0) + 1;
|
||||
console.log(icons.length, JSON.stringify(count));
|
||||
Loading…
Add table
Add a link
Reference in a new issue