1인칭 조준점: 리플레이의 선수 조준점 · 사이트 전체 내 조준점 설정 · v1.8.2

- 변환기 Crosshair.cs: BombPlayerState 에 복제된 선수 조준점 프로필(주 · 정조준 · 저격 점 · 이름)을 두 번째 읽기로 읽어 players[].crosshair (바뀐 시각마다 전체 설정). 첫 읽기 필드 목록으로 번호를 찾고 패치로 밀려도 이름이 맞는 자리를 찾는다. --fields 디버그, --self-test 에 자리 찾기 · 기본색 검사
- 사이트 lib/crosshair.ts 그리기 · 발로란트 조준점 코드 읽기, CrosshairPanel: 선수 조준점(없으면 내 조준점) / 모든 선수에 내 조준점, 직접 고치기 · 코드 가져오기 · 선수 조준점 복사
- 1인칭: 정조준 조준점 · 저격 조준경 가운데 점 · 사격/이동 오차로 벌어짐
- 앱 1.8.2 (버전이 바뀌면 리플레이를 다시 변환해 조준점이 생긴다)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-29 20:44:50 +09:00
parent 309974087b
commit 96fb41748b
13 changed files with 794 additions and 40 deletions

4
app/package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "gvr-app",
"version": "1.8.1",
"version": "1.8.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "gvr-app",
"version": "1.8.1",
"version": "1.8.2",
"license": "UNLICENSED",
"dependencies": {
"@discordjs/voice": "^0.19.2",

View File

@@ -1,7 +1,7 @@
{
"name": "gvr-app",
"productName": "겜녹이",
"version": "1.8.1",
"version": "1.8.2",
"description": "겜녹이 (Game Voice Recorder) - 게임 연동 디스코드 음성 기록",
"private": true,
"main": "dist/main.cjs",

View File

@@ -75,7 +75,7 @@
- 사이트 `lib/viewmodel.ts`: 맵과 따로 장면 하나(카메라 공간, 깊이를 지우고 맵 위에 그림). 무기 뿌리 = 팔 뼈 MasterWeapon × 회전 (0.5,−0.5,0.5,0.5) (총구 → 팔 앞, 탄창 → 아래가 되는 축 맞춤, 모든 총 같음). 눈 = 팔 Camera 뼈(대기 자세).
- 자세는 시각만으로: 꺼내기(equips) > 재장전(states ReloadState) > 사격(shots, 60ms 총구 불꽃) > 걷기(0.2초에 30cm 넘게 움직임) > 정조준(ZoomState*) > 대기. 죽었거나 스킬 · 맨손이면 숨긴다.
- 줌: 소총 등 1.25배, 저격총 2.5배(2단 5배) + 조준경 테두리(검은 원 · 가는 십자선), 저격 줌 중에는 팔 · 총을 숨긴다.
- 조준점: 녹색 점 → 발로란트 기본 (흰 선 4개 · 가운데 틈 · 검은 외곽선, `.r3d-cross`).
- 조준점: 녹색 점 → 발로란트 기본 (흰 선 4개 · 가운데 틈 · 검은 외곽선). 1.8.2 부터 선수 조준점 · 내 조준점 (아래).
- 안 한 것: 총소리 · 발소리(Wwise 사운드뱅크라 따로 풀어야 함), HUD 체력 · 탄약(리플레이에 값 없음), 탄흔(맞은 자리 `hits` 로 가능), 스킨(기본 스킨만), 스킬 1인칭 동작, 재장전 중 탄창이 손으로 옮겨 가는 것(소켓 바꾸기라 탄창이 잠깐 안 보임).
## 남은 일
@@ -96,3 +96,13 @@
- 보관: nextcloud `claude/game-voice-recorder/valorant/13.08/` (nextcloud 에서는 `claude/` 폴더 안만 다룬다, 사용자 규칙) (abyss-13.08.tar.gz = glb · scene.json · 미리보기 · usmap · 도구 사본, usmap 단독). 계정은 secrets `nextcloud.192.168.10.10`.
- 실험은 반드시 `systemd-run --user --scope -p MemoryMax=6G -p MemorySwapMax=0` 안에서.
- 디스크: .9 는 150GB 이상 비워 둔다 (사용자 요청). 게임 파일은 다시 받을 수 있으므로 지웠다. 큰 결과물은 nextcloud(.10:8080)로 (로그인 정보 필요).
## 선수 조준점 · 내 조준점 (2026-10-29, v1.8.2)
- 리플레이에 있다: `BombPlayerState` 에 선수마다 조준점 프로필이 복제된다 (관전자에게 보이는 조준점). 파서 형식에는 없어서 `gvr-replay <vrf> --fields` 로 필드 이름을 보고 찾았다.
- 13.08 번호: 39~85 주 조준점, 86~132 정조준, 133~179 (값이 온 적 없음), 180~197 저격 조준경(가운데 점 색 · 크기 · 불투명도 · 표시) · `bUsePrimaryCrosshairForADS` · `bUseAdvancedOptions` · `ProfileName`.
- 묶음 안 순서: 색 BGRA · 사용자 지정 색 BGRA · bUseCustomColor · 외곽선(켬 · 두께 · 색 · 불투명도) · 가운데 점(크기 · 불투명도 · 켬) · … · 안쪽 선 12개 · 바깥쪽 선 12개 (두께 · 길이 · 세로 길이 · 간격 · 세로 따로 · 이동 오차 · 사격 오차 · 최소 오차 · 불투명도 · 켬 · 사격 배율 · 이동 배율).
- 기본값과 다를 때만 오고(색 흰색 255 · 숫자 0 · 끔), 바뀐 것만 다시 온다. 확인: 프로필 이름 "1 4 2 0" 선수 = 불투명도 1 · 길이 4 · 두께 2 · 간격 0, "점" 선수들 = 가운데 점만. 저격 점은 10명 모두 빨강(게임 기본).
- 변환기 `src/Crosshair.cs`: 첫 읽기의 필드 목록에서 기준 번호를 찾고(이름이 모두 맞는 자리, 패치로 밀리면 ±80 안에서 찾음, 못 찾으면 조준점 없이 변환) 이 필드만 읽는 두 번째 읽기 (`IncludedPaths`, 어비스 리플레이 +0.4초). 출력 `players[].crosshair` = 바뀐 시각마다 전체 설정 (`t · name · primary · ads · sniper · adsFromPrimary · advanced`, color 는 실제 보이는 색).
- 사이트 `lib/crosshair.ts` (그리기 · 발로란트 조준점 코드 읽기) · `components/CrosshairPanel.tsx`: 1인칭 "조준점" 버튼 → 선수 조준점(없으면 내 조준점) / 모든 선수에 내 조준점, 내 조준점 직접 고치기 · 코드 가져오기 · 선수 조준점 복사. 설정은 브라우저 `gvr.settings.v1` `crosshair`.
- 정조준(저격총 아님) 중에 고급 설정 + 정조준 조준점 따로면 ads, 저격 줌은 조준경 가운데 점. 사격 오차 · 이동 오차 켠 선은 쏜 뒤 0.35초 · 걷는 동안 벌어진다 (총마다 다른 실제 퍼짐이 아니라 대략).
- 옛 리플레이 JSON 에는 없다. 앱은 버전이 바뀌면 다시 변환하므로 1.8.2 로 올리면 다음에 열 때 생긴다.

View File

@@ -0,0 +1,166 @@
import { useEffect, useRef, useState } from 'react';
import { settings, useSettings } from '../store/settings';
import { CROSS_COLORS, DEFAULT_CROSSHAIR, drawCrosshair, parseCrosshairCode, prepCanvas, type CrossLines, type CrossSet, type CrosshairAt, type CrosshairProfile } from '../lib/crosshair';
/** 조준점 미리보기 (어두운 바탕) */
function Preview({ set }: { set: CrossSet }) {
const ref = useRef<HTMLCanvasElement>(null);
useEffect(() => {
const g = ref.current && prepCanvas(ref.current);
if (g) drawCrosshair(g.ctx, g.cx, g.cy, set);
}, [set]);
return <canvas ref={ref} className="r3d-xprev" aria-label="조준점 미리보기" />;
}
function Range({ label, value, min, max, step, onChange }: { label: string; value: number; min: number; max: number; step: number; onChange: (v: number) => void }) {
return (
<label className="r3d-xrow">
<span>{label}</span>
<input type="range" min={min} max={max} step={step} value={value} onChange={(e) => onChange(Number(e.target.value))} />
<span className="mono">{step < 1 ? value.toFixed(2) : value}</span>
</label>
);
}
function Check({ label, value, onChange }: { label: string; value: boolean; onChange: (v: boolean) => void }) {
return (
<label className="r3d-xcheck">
<input type="checkbox" checked={value} onChange={(e) => onChange(e.target.checked)} /> {label}
</label>
);
}
function LinesEdit({ title, l, maxOffset, onChange }: { title: string; l: CrossLines; maxOffset: number; onChange: (l: CrossLines) => void }) {
const up = (p: Partial<CrossLines>) => onChange({ ...l, ...p, ...(p.length != null ? { vLength: p.length } : {}) });
return (
<fieldset className="r3d-xset">
<legend>
<Check label={title} value={l.on} onChange={(on) => up({ on })} />
</legend>
{l.on && (
<>
<Range label="불투명도" value={l.opacity} min={0} max={1} step={0.05} onChange={(opacity) => up({ opacity })} />
<Range label="길이" value={l.length} min={0} max={20} step={1} onChange={(length) => up({ length })} />
<Range label="두께" value={l.thickness} min={0} max={10} step={1} onChange={(thickness) => up({ thickness })} />
<Range label="간격" value={l.offset} min={0} max={maxOffset} step={1} onChange={(offset) => up({ offset })} />
<Check label="이동 오차" value={l.moveError} onChange={(moveError) => up({ moveError })} />
<Check label="사격 오차" value={l.fireError} onChange={(fireError) => up({ fireError })} />
</>
)}
</fieldset>
);
}
/**
* 1인칭 조준점 설정: 선수 조준점을 쓸지, 사이트 전체에 쓰는 내 조준점 (직접 고치기 · 발로란트 조준점 코드 가져오기).
* 설정은 이 브라우저에 저장한다
*/
export default function CrosshairPanel({ playerName, player, hasAny, onClose }: { playerName: string | null; player: CrosshairAt | null; hasAny: boolean; onClose: () => void }) {
const cfg = useSettings().crosshair;
const mine = cfg.mine;
const [code, setCode] = useState(cfg.code ?? '');
const [err, setErr] = useState<string | null>(null);
const save = (p: Partial<typeof cfg>) => settings.set({ crosshair: { ...cfg, ...p } });
const setMine = (m: CrosshairProfile, c?: string) => save({ mine: m, code: c });
// 직접 고치면 정조준 조준점도 같이 (발로란트 '정조준에도 주 조준점')
const upSet = (p: Partial<CrossSet>) => {
const primary = { ...mine.primary, ...p };
setMine({ ...mine, primary, ads: primary, adsFromPrimary: true });
};
const presetIdx = CROSS_COLORS.findIndex((c) => c.hex === mine.primary.color.toLowerCase());
const importCode = () => {
const p = parseCrosshairCode(code);
if (!p) {
setErr('조준점 코드 형식이 아닙니다 (예: 0;P;c;5;h;0;0l;4;0o;2;0a;1;0f;0;1b;0)');
return;
}
setErr(null);
setMine(p, code.trim());
};
const s = mine.primary;
return (
<div className="r3d-xpanel" role="dialog" aria-label="조준점 설정">
<div className="r3d-xhead">
<b>조준점</b>
<button className="chip" onClick={onClose} aria-label="닫기">
✕
</button>
</div>
<label className="r3d-xcheck">
<input type="radio" name="xmode" checked={cfg.usePlayer} onChange={() => save({ usePlayer: true })} /> 선수 조준점 (리플레이에 없으면 내 조준점)
</label>
<label className="r3d-xcheck">
<input type="radio" name="xmode" checked={!cfg.usePlayer} onChange={() => save({ usePlayer: false })} /> 모든 선수에 내 조준점
</label>
{player ? (
<div className="r3d-xplayer">
<Preview set={player.primary} />
<div>
<div className="small">
{playerName ?? '이 선수'} 조준점{player.name ? <span className="muted"> · {player.name}</span> : null}
</div>
<button className="chip" onClick={() => setMine({ primary: player.primary, ads: player.ads, sniper: player.sniper, adsFromPrimary: player.adsFromPrimary, advanced: player.advanced })}>
내 조준점으로 복사
</button>
</div>
</div>
) : (
<div className="muted small">
{hasAny ? '이 선수는 조준점 기록이 없어 내 조준점을 씁니다.' : '이 리플레이에는 선수 조준점 기록이 없어 내 조준점을 씁니다. 게임 PC 앱을 1.8.2 이상으로 올리면 리플레이를 열 때 다시 변환해 기록이 생깁니다.'}
</div>
)}
<div className="r3d-xmine">
<div className="r3d-xhead">
<b className="small">내 조준점</b>
<button className="chip" onClick={() => setMine(DEFAULT_CROSSHAIR)} title="발로란트 기본 조준점으로">
기본값
</button>
</div>
<Preview set={s} />
<div className="r3d-xcode">
<input value={code} onChange={(e) => setCode(e.target.value)} placeholder="발로란트 조준점 코드 붙여넣기" aria-label="조준점 코드" onKeyDown={(e) => e.key === 'Enter' && importCode()} />
<button className="chip" onClick={importCode}>
가져오기
</button>
</div>
{err && <div className="small r3d-xerr">{err}</div>}
<label className="r3d-xrow">
<span>색</span>
<select value={presetIdx >= 0 ? presetIdx : -1} onChange={(e) => Number(e.target.value) >= 0 && upSet({ color: CROSS_COLORS[Number(e.target.value)].hex })}>
{CROSS_COLORS.map((c, i) => (
<option key={c.hex} value={i}>
{c.name}
</option>
))}
<option value={-1}>사용자 지정</option>
</select>
<input type="color" value={s.color} onChange={(e) => upSet({ color: e.target.value })} aria-label="사용자 지정 색" />
</label>
<fieldset className="r3d-xset">
<legend>
<Check label="외곽선" value={s.outline} onChange={(outline) => upSet({ outline })} />
</legend>
{s.outline && (
<>
<Range label="불투명도" value={s.outlineOpacity} min={0} max={1} step={0.05} onChange={(outlineOpacity) => upSet({ outlineOpacity })} />
<Range label="두께" value={s.outlineThickness} min={1} max={6} step={1} onChange={(outlineThickness) => upSet({ outlineThickness })} />
</>
)}
</fieldset>
<fieldset className="r3d-xset">
<legend>
<Check label="가운데 점" value={s.dot} onChange={(dot) => upSet({ dot })} />
</legend>
{s.dot && (
<>
<Range label="불투명도" value={s.dotOpacity} min={0} max={1} step={0.05} onChange={(dotOpacity) => upSet({ dotOpacity })} />
<Range label="두께" value={s.dotSize} min={1} max={6} step={1} onChange={(dotSize) => upSet({ dotSize })} />
</>
)}
</fieldset>
<LinesEdit title="안쪽 선" l={s.inner} maxOffset={20} onChange={(inner) => upSet({ inner })} />
<LinesEdit title="바깥쪽 선" l={s.outer} maxOffset={40} onChange={(outer) => upSet({ outer })} />
</div>
</div>
);
}

View File

@@ -10,6 +10,8 @@ import { equipAt, equipLabel, equipTracks, indexAt, isDead, roundAt, samplePath,
import { findMap3d, loadMap3d, mapMaterial, worldMatrix } from '../lib/map3d';
import { AgentRig, isGun, loadAgent, loadAnims, loadWeapon, weaponCat } from '../lib/agents3d';
import { Viewmodel, viewmodelIndex } from '../lib/viewmodel';
import { crossFor, crosshairAt, drawCrosshair, drawSniperDot, prepCanvas } from '../lib/crosshair';
import CrosshairPanel from './CrosshairPanel';
import { buildAnimIndex, rigInput } from '../lib/replayAnim';
import { abilityLook, type AbilityLook } from '../lib/abilities';
import { loadVfxDb, vfxCoverage, VfxObject, type Place, type VfxDb } from '../lib/vfx';
@@ -133,6 +135,12 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
const [ceilNow, setCeilNow] = useState<number | null>(null);
// 1인칭 저격총 조준경 (줌 중)
const [scoped, setScoped] = useState(false);
// 1인칭 조준점 (그리는 캔버스 · 설정 창)
const crossRef = useRef<HTMLCanvasElement>(null);
const xhairRef = useRef(cfg.crosshair);
xhairRef.current = cfg.crosshair;
const [xOpen, setXOpen] = useState(false);
const hasCrosshairs = useMemo(() => replay.players.some((p) => !!p.crosshair?.length), [replay]);
// 바닥(미니맵) 높이: 선수 높이의 하위 5% (떨어져 죽은 기록은 뺀다)
const zBase = useMemo(() => {
@@ -929,6 +937,20 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
vm.set(chr, fp.kind!);
vm.pose(fp.input);
}
// 조준점: 선수 조준점(설정에 따라) 또는 내 조준점. 저격총 줌은 조준경 가운데 점, 정조준은 정조준 조준점
const g = crossRef.current && prepCanvas(crossRef.current);
if (g) {
const xc = xhairRef.current;
const prof = (xc.usePlayer ? crosshairAt(replay.players[selIdx].crosshair, t) : null) ?? xc.mine;
if (sc) drawSniperDot(g.ctx, g.cx, g.cy, prof.sniper);
else {
const shot = fp?.input.shotMs;
drawCrosshair(g.ctx, g.cx, g.cy, crossFor(prof, !!fp && fp.zoom > 0), {
fire: shot != null && shot < 350 ? 1 - shot / 350 : 0,
move: fp?.input.walkMs != null ? 1 : 0,
});
}
}
} else if (mode === 'free') {
euler.set(free.pitch, free.yaw, 0, 'YXZ');
camera.quaternion.setFromEuler(euler);
@@ -1054,13 +1076,14 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
</div>
)}
{cam === 'fp' && scoped && <div className="r3d-scope" />}
{cam === 'fp' && !scoped && (
<div className="r3d-cross" aria-hidden>
<i />
<i />
<i />
<i />
</div>
{cam === 'fp' && <canvas ref={crossRef} className="r3d-xcanvas" aria-hidden />}
{cam === 'fp' && xOpen && (
<CrosshairPanel
playerName={selInfo?.name ?? null}
player={sel != null ? crosshairAt(replay.players[sel].crosshair, ui.t) : null}
hasAny={hasCrosshairs}
onClose={() => setXOpen(false)}
/>
)}
{cam === 'free' && <div className="r3d-hud bl muted small">끌기: 둘러보기 · W A S D: 이동 · Q / E: 아래 / 위 · Shift: 빠르게 (화면을 한 번 누른 뒤)</div>}
{selInfo && cam !== 'free' && (
@@ -1128,6 +1151,11 @@ export default function ReplayViewer({ m, replay, sync }: Props) {
</button>
))}
</span>
{cam === 'fp' && (
<button className={`chip${xOpen ? ' on' : ''}`} onClick={() => setXOpen((o) => !o)} aria-pressed={xOpen} title="1인칭 조준점: 선수 조준점 · 내 조준점 설정">
조준점
</button>
)}
{cam === 'top' && (
<button className="chip" onClick={() => resetCam.current()} title="카메라 처음 위치로">
전체 보기

View File

@@ -0,0 +1,230 @@
/**
* 발로란트 조준점: 리플레이의 선수 조준점(변환기 players[].crosshair) · 사이트 전체 조준점 설정 · 조준점 코드 · 그리기.
* 크기는 발로란트 설정 값 그대로 화면 픽셀로 그린다.
*/
export interface CrossLines {
on: boolean;
length: number;
/** 세로 길이 (따로 쓰지 않으면 length 와 같다) */
vLength: number;
thickness: number;
offset: number;
opacity: number;
moveError: boolean;
fireError: boolean;
moveScale: number;
fireScale: number;
}
export interface CrossSet {
/** 보이는 색 #rrggbb */
color: string;
outline: boolean;
outlineThickness: number;
outlineOpacity: number;
dot: boolean;
dotSize: number;
dotOpacity: number;
inner: CrossLines;
outer: CrossLines;
}
export interface SniperDot {
color: string;
dot: boolean;
dotSize: number;
dotOpacity: number;
}
export interface CrosshairProfile {
primary: CrossSet;
ads: CrossSet;
sniper: SniperDot;
/** 정조준에도 주 조준점 */
adsFromPrimary: boolean;
advanced: boolean;
}
/** 리플레이 기록: t(ms) 부터 이 설정 */
export interface CrosshairAt extends CrosshairProfile {
t: number;
name: string;
}
/** 발로란트 색 목록 (조준점 코드 c 번호 순, 8 = 사용자 지정) */
export const CROSS_COLORS: { name: string; hex: string }[] = [
{ name: '흰색', hex: '#ffffff' },
{ name: '초록색', hex: '#00ff00' },
{ name: '연두색', hex: '#7fff00' },
{ name: '황록색', hex: '#dfff00' },
{ name: '노란색', hex: '#ffff00' },
{ name: '청록색', hex: '#00ffff' },
{ name: '분홍색', hex: '#ff00ff' },
{ name: '빨간색', hex: '#ff0000' },
];
const INNER: CrossLines = { on: true, length: 6, vLength: 6, thickness: 2, offset: 3, opacity: 0.8, moveError: false, fireError: true, moveScale: 1, fireScale: 1 };
const OUTER: CrossLines = { on: true, length: 2, vLength: 2, thickness: 2, offset: 10, opacity: 0.35, moveError: true, fireError: true, moveScale: 1, fireScale: 1 };
const SET: CrossSet = { color: '#ffffff', outline: true, outlineThickness: 1, outlineOpacity: 0.5, dot: false, dotSize: 2, dotOpacity: 1, inner: INNER, outer: OUTER };
/** 발로란트 기본 조준점 */
export const DEFAULT_CROSSHAIR: CrosshairProfile = {
primary: SET,
ads: SET,
sniper: { color: '#ff0000', dot: true, dotSize: 1, dotOpacity: 0.75 },
adsFromPrimary: true,
advanced: false,
};
/** t 시점 선수 조준점 (그 전이면 첫 기록, 기록이 없으면 null) */
export function crosshairAt(list: CrosshairAt[] | null | undefined, t: number): CrosshairAt | null {
if (!list?.length) return null;
let c = list[0];
for (const x of list) {
if (x.t > t) break;
c = x;
}
return c;
}
/** 지금 쓸 조준점 묶음: 정조준(저격총 아님) 중이고 정조준 조준점을 따로 쓰면 ads */
export function crossFor(p: CrosshairProfile, ads: boolean): CrossSet {
return ads && p.advanced && !p.adsFromPrimary ? p.ads : p.primary;
}
const num = (v: string | undefined, d: number) => {
const n = v == null ? NaN : Number(v);
return Number.isFinite(n) ? n : d;
};
/**
* 발로란트 조준점 코드 (설정 → 조준점 → 프로필 내보내기, 예: 0;P;c;5;h;0;0l;4;0o;2;0a;1;0f;0;1b;0) → 설정.
* 코드에 없는 값은 발로란트 기본값. 형식이 아니면 null
*/
export function parseCrosshairCode(code: string): CrosshairProfile | null {
const tok = code.trim().split(';').map((s) => s.trim());
if (tok.length < 1 || !/^\d+$/.test(tok[0])) return null;
const sec: Record<'G' | 'P' | 'A' | 'S', Record<string, string>> = { G: {}, P: {}, A: {}, S: {} };
let cur: keyof typeof sec = 'G';
for (let i = 1; i < tok.length; i++) {
const k = tok[i];
if (k === 'P' || k === 'A' || k === 'S') {
cur = k;
continue;
}
if (!k) continue;
if (i + 1 >= tok.length) return null;
sec[cur][k] = tok[++i];
}
const color = (s: Record<string, string>, d: string) => {
const c = num(s.c, -1);
if ((c === 8 || s.b === '1') && /^[0-9a-fA-F]{6}/.test(s.u ?? '')) return `#${s.u.slice(0, 6).toLowerCase()}`;
return CROSS_COLORS[c]?.hex ?? d;
};
const lines = (s: Record<string, string>, p: '0' | '1', d: CrossLines): CrossLines => {
const length = num(s[p + 'l'], d.length);
return {
on: s[p + 'b'] !== '0' && (s[p + 'b'] === '1' || d.on),
length,
vLength: s[p + 'g'] === '1' ? num(s[p + 'v'], length) : length,
thickness: num(s[p + 't'], d.thickness),
offset: num(s[p + 'o'], d.offset),
opacity: num(s[p + 'a'], d.opacity),
moveError: s[p + 'm'] != null ? s[p + 'm'] === '1' : d.moveError,
fireError: s[p + 'f'] != null ? s[p + 'f'] === '1' : d.fireError,
moveScale: num(s[p + 's'], d.moveScale),
fireScale: num(s[p + 'e'], d.fireScale),
};
};
const set = (s: Record<string, string>): CrossSet => ({
color: color(s, SET.color),
outline: s.h != null ? s.h === '1' : SET.outline,
outlineThickness: num(s.t, SET.outlineThickness),
outlineOpacity: num(s.o, SET.outlineOpacity),
dot: s.d != null ? s.d === '1' : SET.dot,
dotSize: num(s.z, SET.dotSize),
dotOpacity: num(s.a, SET.dotOpacity),
inner: lines(s, '0', INNER),
outer: lines(s, '1', OUTER),
});
const S = sec.S;
const sd = DEFAULT_CROSSHAIR.sniper;
return {
primary: set(sec.P),
ads: set(sec.A),
sniper: {
color: color(S, sd.color),
dot: S.d != null ? S.d === '1' : sd.dot,
dotSize: num(S.s, sd.dotSize),
dotOpacity: num(S.o, sd.dotOpacity),
},
adsFromPrimary: sec.G.p !== '0',
advanced: sec.G.s === '1',
};
}
/** 사격 · 이동으로 벌어지는 정도 (픽셀): fire 0..1 (막 쏨 = 1), move 0..1 */
export interface Spread {
fire: number;
move: number;
}
const FIRE_PX = 6;
const MOVE_PX = 4;
function rgba(hex: string, a: number) {
const n = parseInt(hex.slice(1, 7), 16);
return `rgba(${(n >> 16) & 255},${(n >> 8) & 255},${n & 255},${Math.max(0, Math.min(1, a))})`;
}
/** (cx, cy) 를 가운데로 조준점을 그린다. 크기는 CSS 픽셀 (ctx 는 devicePixelRatio 로 미리 늘려 둔다) */
export function drawCrosshair(ctx: CanvasRenderingContext2D, cx: number, cy: number, s: CrossSet, spread: Spread = { fire: 0, move: 0 }) {
const rects: [number, number, number, number, number][] = [];
const line = (l: CrossLines) => {
if (!l.on || l.opacity <= 0 || l.thickness <= 0) return;
const gap = l.offset + (l.fireError ? spread.fire * FIRE_PX * l.fireScale : 0) + (l.moveError ? spread.move * MOVE_PX * l.moveScale : 0);
const th = l.thickness;
if (l.length > 0) {
rects.push([cx - gap - l.length, cy - th / 2, l.length, th, l.opacity]);
rects.push([cx + gap, cy - th / 2, l.length, th, l.opacity]);
}
if (l.vLength > 0) {
rects.push([cx - th / 2, cy - gap - l.vLength, th, l.vLength, l.opacity]);
rects.push([cx - th / 2, cy + gap, th, l.vLength, l.opacity]);
}
};
line(s.outer);
line(s.inner);
if (s.dot && s.dotSize > 0 && s.dotOpacity > 0) rects.push([cx - s.dotSize / 2, cy - s.dotSize / 2, s.dotSize, s.dotSize, s.dotOpacity]);
// 픽셀 경계에 맞춘다 (두께 1 · 2 선이 흐려지지 않게)
const px = rects.map(([x, y, w, h, a]) => [Math.round(x), Math.round(y), Math.max(1, Math.round(w)), Math.max(1, Math.round(h)), a] as const);
if (s.outline && s.outlineThickness > 0 && s.outlineOpacity > 0) {
const o = s.outlineThickness;
ctx.fillStyle = rgba('#000000', s.outlineOpacity);
for (const [x, y, w, h] of px) ctx.fillRect(x - o, y - o, w + o * 2, h + o * 2);
}
for (const [x, y, w, h, a] of px) {
ctx.fillStyle = rgba(s.color, a);
ctx.fillRect(x, y, w, h);
}
}
/** 저격총 조준경 가운데 점 */
export function drawSniperDot(ctx: CanvasRenderingContext2D, cx: number, cy: number, d: SniperDot) {
if (!d.dot || d.dotSize <= 0 || d.dotOpacity <= 0) return;
ctx.fillStyle = rgba(d.color, d.dotOpacity);
ctx.beginPath();
ctx.arc(cx, cy, Math.max(1, d.dotSize * 2), 0, Math.PI * 2);
ctx.fill();
}
/** 캔버스를 화면 크기 · devicePixelRatio 에 맞추고 지운 뒤 가운데 좌표 */
export function prepCanvas(c: HTMLCanvasElement): { ctx: CanvasRenderingContext2D; cx: number; cy: number } | null {
const ctx = c.getContext('2d');
if (!ctx) return null;
const dpr = window.devicePixelRatio || 1;
const w = c.clientWidth;
const h = c.clientHeight;
if (c.width !== Math.round(w * dpr) || c.height !== Math.round(h * dpr)) {
c.width = Math.round(w * dpr);
c.height = Math.round(h * dpr);
}
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
ctx.clearRect(0, 0, w, h);
return { ctx, cx: Math.floor(w / 2), cy: Math.floor(h / 2) };
}

View File

@@ -1,4 +1,5 @@
import type { KillData, MatchDetail } from '@gvr/shared';
import type { CrosshairAt } from './crosshair';
/**
* tools/replay-extract (gvr-replay v1 · v2) 출력. t 는 리플레이 시작부터 ms, 좌표는 게임 월드 단위(cm).
@@ -14,7 +15,13 @@ export interface ReplayFile {
recordedAt: number;
durationMs: number;
sampleMs: number;
players: { puuid: string | null; character: string | null; track: { t: number[]; x: number[]; y: number[]; z: number[]; yaw: number[]; pitch: number[]; f?: number[] } }[];
players: {
puuid: string | null;
character: string | null;
track: { t: number[]; x: number[]; y: number[]; z: number[]; yaw: number[]; pitch: number[]; f?: number[] };
/** 조준점 설정이 바뀐 시각마다 전체 설정 (변환기 1.8.2~, 옛 JSON 은 없다) */
crosshair?: CrosshairAt[] | null;
}[];
rounds: { num: number; buy: number; combat: number; end: number }[];
phases: [number, number][];
/** [t, killer, victim, deathAnim(v2, deathAnims 번호 · -1)] */

View File

@@ -1,4 +1,5 @@
import { useSyncExternalStore } from 'react';
import { DEFAULT_CROSSHAIR, type CrosshairProfile } from '../lib/crosshair';
export type SfxKind = 'click' | 'play' | 'kill' | 'round' | 'chime';
export interface Settings {
@@ -10,6 +11,8 @@ export interface Settings {
normalize: boolean;
/** 녹음 재생 음량 0..2 (1 = 원래 크기) */
playVolume: number;
/** 3D 리플레이 1인칭 조준점: usePlayer 면 리플레이에 있는 선수 조준점(없으면 mine), 아니면 항상 mine */
crosshair: { usePlayer: boolean; mine: CrosshairProfile; code?: string };
/** 기본값을 바꾼 횟수 (예전에 저장한 설정을 한 번만 새 기본값으로 맞춘다) */
defaultsRev?: number;
}
@@ -24,6 +27,7 @@ const DEFAULTS: Settings = {
continuous: true,
normalize: true,
playVolume: 1,
crosshair: { usePlayer: true, mine: DEFAULT_CROSSHAIR },
defaultsRev: 1,
};
@@ -32,7 +36,7 @@ function load(): Settings {
const raw = localStorage.getItem(KEY);
if (!raw) return DEFAULTS;
const v = JSON.parse(raw) as Partial<Settings>;
const out = { ...DEFAULTS, ...v, sfx: { ...DEFAULTS.sfx, ...(v.sfx ?? {}) } };
const out = { ...DEFAULTS, ...v, sfx: { ...DEFAULTS.sfx, ...(v.sfx ?? {}) }, crosshair: { ...DEFAULTS.crosshair, ...(v.crosshair ?? {}) } };
// 예전 사이트는 설정을 하나만 바꿔도 효과음 켜짐/꺼짐을 전부 저장했다: 새 기본값(두 알림 끄기)을 한 번 적용
if ((v.defaultsRev ?? 0) < 1) {
out.sfx = { ...out.sfx, play: false, chime: false };

View File

@@ -4084,44 +4084,114 @@ button.match:hover {
border-radius: 6px;
padding: 3px 6px;
}
/* 1인칭 조준점: 발로란트 기본 (흰 안쪽 선 4개 · 가운데 틈 · 검은 외곽선) */
.r3d-cross {
/* 1인칭 조준점 (lib/crosshair.ts 가 그린다): 화면 가운데 */
.r3d-stage canvas.r3d-xcanvas {
position: absolute;
left: 50%;
top: 50%;
width: 0;
height: 0;
width: 240px;
height: 240px;
margin: -120px 0 0 -120px;
pointer-events: none;
z-index: 2;
z-index: 3;
cursor: default;
}
.r3d-cross i {
/* 조준점 설정 창 */
.r3d-xpanel {
position: absolute;
background: #fff;
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
z-index: 4;
right: 10px;
bottom: 10px;
width: min(320px, calc(100% - 20px));
max-height: calc(100% - 20px);
overflow-y: auto;
padding: 10px 12px;
border-radius: 10px;
background: rgba(8, 14, 20, 0.92);
border: 1px solid var(--line);
display: flex;
flex-direction: column;
gap: 6px;
font-size: 13px;
}
.r3d-cross i:nth-child(1),
.r3d-cross i:nth-child(2) {
width: 2px;
height: 6px;
left: -1px;
.r3d-xhead {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.r3d-cross i:nth-child(1) {
top: -9px;
.r3d-xcheck {
display: flex;
align-items: center;
gap: 6px;
cursor: pointer;
}
.r3d-cross i:nth-child(2) {
top: 3px;
.r3d-xplayer {
display: flex;
align-items: center;
gap: 10px;
}
.r3d-cross i:nth-child(3),
.r3d-cross i:nth-child(4) {
width: 6px;
height: 2px;
top: -1px;
.r3d-xplayer > div {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 4px;
}
.r3d-cross i:nth-child(3) {
left: -9px;
.r3d-stage canvas.r3d-xprev {
width: 72px;
height: 72px;
flex: none;
border-radius: 8px;
background: #3a4651;
cursor: default;
}
.r3d-cross i:nth-child(4) {
left: 3px;
.r3d-xmine {
display: flex;
flex-direction: column;
gap: 6px;
border-top: 1px solid var(--line);
padding-top: 8px;
}
.r3d-xmine > .r3d-xprev {
align-self: center;
}
.r3d-xcode {
display: flex;
gap: 6px;
}
.r3d-xcode input {
flex: 1;
min-width: 0;
font-family: var(--font-mono);
font-size: 12px;
}
.r3d-xerr {
color: #ff9aa5;
}
.r3d-xrow {
display: grid;
grid-template-columns: 56px 1fr auto;
align-items: center;
gap: 6px;
}
.r3d-xrow input[type='range'] {
width: 100%;
accent-color: var(--accent);
}
.r3d-xrow .mono {
min-width: 30px;
text-align: right;
}
.r3d-xset {
border: 1px solid var(--line);
border-radius: 8px;
padding: 4px 8px 6px;
display: flex;
flex-direction: column;
gap: 4px;
}
.r3d-xset legend {
padding: 0 4px;
}
/* 저격총 줌: 둥근 조준경 밖은 검게, 가는 십자선 */
.r3d-scope {

View File

@@ -62,6 +62,9 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
[GeneratedRegex(@"^Default__(GameObject_|Patch_|Pawn_|Projectile_|TimedBomb_C$)")]
private static partial Regex ObjectClass();
/// PlayerState 액터 → 선수 puuid
public string? SubjectOfState(uint state) => _subjectByState.GetValueOrDefault(state);
public void Emit(ReplayEvent e)
{
switch (e)

View File

@@ -0,0 +1,195 @@
using System.Text.Json;
using Replay.Encoding.Archives;
using Replay.Models.Descriptors;
using Replay.Models.Events;
using Replay.Unreal.Parsing;
using Replay.Valorant;
using Replay.Valorant.Descriptors;
namespace GvrReplay;
/// <summary>
/// 선수 조준점 설정. BombPlayerState 에 선수마다 조준점 프로필(주 조준점 · 정조준 · 저격 조준경 · 프로필 이름)이 복제된다
/// (관전자에게 보이는 조준점). 파서의 BombPlayerState 형식에는 이 필드가 없어서, 첫 번째 읽기에서 받은 필드 목록으로
/// 번호(handle)를 찾고 이 필드만 읽는 두 번째 읽기를 한다.
/// 필드는 기본값(색 흰색 255 · 숫자 0 · 끔)과 다를 때만 오고, 바뀐 필드만 다시 온다.
/// </summary>
public static class Crosshair
{
public const string StatePath = "/Game/GameModes/Bomb/BombPlayerState.BombPlayerState_C";
// 13.08 · 13.09 에서 주 조준점 색(B)의 번호. 패치로 앞에 필드가 늘면 이름이 맞는 곳으로 옮겨 찾는다
private const int KnownBase = 39;
private static readonly string[] Lines =
[
"LineThickness", "LineLength", "LineLengthVertical", "LineOffset", "bAllowVertScaling", "bShowMovementError",
"bShowShootingError", "bShowMinError", "Opacity", "bShowLines", "FiringErrorScale", "MovementErrorScale",
];
private static readonly string?[] Cross =
[
"B", "G", "R", "A", "B", "G", "R", "A", "bUseCustomColor", "bHasOutline", "OutlineThickness", "B", "G", "R", "A",
"OutlineOpacity", "CenterDotSize", "CenterDotOpacity", "bDisplayCenterDot", "bFadeCrosshairWithFiringError",
"bShowSpectatedPlayerCrosshair", null, "bFixMinErrorAcrossWeapons", .. Lines, .. Lines,
];
private static readonly string?[] Sniper =
[
"B", "G", "R", "A", "B", "G", "R", "A", "CenterDotSize", "CenterDotOpacity", "bDisplayCenterDot", null,
"bUsePrimaryCrosshairForADS", null, null, "bUseAdvancedOptions", null, "ProfileName",
];
/// 기준 번호부터의 (이름, 열쇠). 세 번째 조준점 묶음(번호 94~140)은 값이 오는 것을 본 적이 없어 읽지 않는다
private static readonly (string? Name, string? Key)[] Layout = BuildLayout();
private static (string?, string?)[] BuildLayout()
{
var o = new List<(string?, string?)>();
string?[] lineKeys = ["thickness", "length", "vLength", "offset", "allowVert", "moveError", "fireError", "minError", "opacity", "on", "fireScale", "moveScale"];
string?[] crossKeys =
[
"cb", "cg", "cr", null, "ub", "ug", "ur", null, "useCustom", "outline", "outlineThickness", null, null, null, null,
"outlineOpacity", "dotSize", "dotOpacity", "dot", null, null, null, null,
.. lineKeys.Select(k => "i." + k), .. lineKeys.Select(k => "o." + k),
];
foreach (var prefix in new[] { "p.", "a.", null })
for (var i = 0; i < Cross.Length; i++)
o.Add(prefix is null ? (null, null) : (Cross[i], crossKeys[i] is { } k ? prefix + k : null));
string?[] sniperKeys = ["s.cb", "s.cg", "s.cr", null, null, null, null, null, "s.dotSize", "s.dotOpacity", "s.dot", null, "adsFromPrimary", null, null, "advanced", null, "name"];
for (var i = 0; i < Sniper.Length; i++) o.Add((Sniper[i], sniperKeys[i]));
return [.. o];
}
/// <summary>필드 목록(번호 → 이름)에서 조준점 기준 번호. 이름이 하나라도 어긋나면 그 자리는 아니다. 못 찾으면 null</summary>
public static int? FindBase(IReadOnlyDictionary<int, string> names)
{
int? best = null;
var bestHits = 0;
for (var d = 0; d <= 80; d++)
foreach (var b in d == 0 ? new[] { KnownBase } : new[] { KnownBase + d, KnownBase - d })
{
if (b < 0) continue;
var hits = 0;
var bad = false;
foreach (var (h, name) in names)
{
var i = h - b;
if (i < 0 || i >= Layout.Length || Layout[i].Name is not { } want) continue;
if (want != name) { bad = true; break; }
hits++;
}
// 프로필 이름 + 몇 개 이상 맞아야 한다 (조준점을 하나도 안 바꾼 경기면 필드가 거의 안 온다)
if (!bad && hits > bestHits && names.GetValueOrDefault(b + Layout.Length - 1) == "ProfileName")
{
best = b;
bestHits = hits;
}
}
return bestHits >= 3 ? best : null;
}
/// <summary>두 번째 읽기: PlayerState 액터 → 조준점이 바뀐 시각마다 전체 설정</summary>
public static Dictionary<uint, List<CrosshairAt>> Read(string path, ValorantReplayReadResult first)
{
var group = first.ExportGroups.FirstOrDefault(g => g.PathName == StatePath);
if (group is null) return [];
var names = new Dictionary<int, string>();
foreach (var f in group.Fields)
if (f.Name is { } n) names[(int)f.Handle] = n;
if (FindBase(names) is not { } b) return [];
var keyByHandle = new Dictionary<int, string>();
var fields = new List<FieldDescriptor>();
for (var i = 0; i < Layout.Length; i++)
{
if (Layout[i] is not { Name: { } name, Key: { } key }) continue;
var h = b + i;
keyByHandle[h] = key;
fields.Add(new FieldDescriptor
{
Handle = (uint)h,
ExportName = name,
PropertyName = key,
Categories = ExportCategory.GameState,
Decoder = name == "ProfileName" ? PrimitiveDecoders.FString
: name.Length == 1 ? PrimitiveDecoders.Byte
: name.StartsWith('b') ? PrimitiveDecoders.Bool
: PrimitiveDecoders.Float,
});
}
// 기본 목록(경로 별칭 · 하위 객체 등 읽기에 필요)에서 BombPlayerState 만 조준점 필드로 바꾼다 (같은 경로는 나중 것이 쓰인다)
var catalog = ValorantDescriptors.CreateCatalog();
catalog.Add(new ExportGroupDescriptor(StatePath, ExportCategory.GameState, ExportGroupKind.Actor, fields: fields));
var sink = new Sink(keyByHandle);
var profile = new ParseProfile
{
EnabledCategories = ExportCategory.All,
CaptureDiagnosticFields = true,
IncludedPaths = [StatePath],
};
using var file = File.OpenRead(path);
using var archive = new FBinaryArchive(file);
new ValorantReplayReader(null, sink, profile, catalog).Read(archive);
return sink.Result;
}
private sealed class Sink(Dictionary<int, string> keyByHandle) : IReplayEventSink
{
private readonly Dictionary<uint, Dictionary<string, object>> _now = [];
public Dictionary<uint, List<CrosshairAt>> Result { get; } = [];
public void Emit(ReplayEvent e)
{
if (e is not ExportGroupReceived x || x.ExportGroupPath != StatePath || x.DiagnosticFields.Count == 0) return;
if (!_now.TryGetValue(x.ActorNetGuid, out var v)) _now[x.ActorNetGuid] = v = [];
var changed = false;
foreach (var f in x.DiagnosticFields)
{
if (!keyByHandle.TryGetValue(f.Handle, out var key)) continue;
object val = f.Value.Kind switch
{
DecodedFieldValueKind.Bool => f.Value.BoolValue,
DecodedFieldValueKind.Byte => (int)f.Value.ByteValue,
DecodedFieldValueKind.Float => Math.Round(f.Value.FloatValue, 3),
DecodedFieldValueKind.String => (f.Value.StringValue ?? "").TrimEnd('\0'),
_ => null!,
};
if (val is null) continue;
v[key] = val;
changed = true;
}
if (!changed) return;
var t = (int)Math.Round(x.TimeSeconds * 1000.0);
var at = Snapshot(t, v);
if (!Result.TryGetValue(x.ActorNetGuid, out var list)) Result[x.ActorNetGuid] = list = [];
// 같은 시각에 나눠 온 것은 하나로, 바뀐 것이 없으면 넣지 않는다
if (list.Count > 0 && list[^1].T == t) list.RemoveAt(list.Count - 1);
if (list.Count > 0 && Same(list[^1], at)) return;
list.Add(at);
}
}
private static bool Same(CrosshairAt a, CrosshairAt b) =>
JsonSerializer.Serialize(a with { T = 0 }, ReplayJson.Options) == JsonSerializer.Serialize(b with { T = 0 }, ReplayJson.Options);
public static CrosshairAt Snapshot(int t, IReadOnlyDictionary<string, object> v)
{
// 오지 않은 필드는 기본값: 색 255 · 숫자 0 · 끔
int C(string k) => v.TryGetValue(k, out var o) ? (int)o : 255;
double F(string k) => v.TryGetValue(k, out var o) ? (double)o : 0;
bool B(string k) => v.TryGetValue(k, out var o) && (bool)o;
string Hex(string p) => $"#{C(p + "r"):x2}{C(p + "g"):x2}{C(p + "b"):x2}";
CrossLines L(string p) => new(B(p + "on"), F(p + "length"), B(p + "allowVert") ? F(p + "vLength") : F(p + "length"),
F(p + "thickness"), F(p + "offset"), F(p + "opacity"), B(p + "moveError"), B(p + "fireError"), F(p + "moveScale"), F(p + "fireScale"));
CrossSet S(string p) => new(Hex(p + (B(p + "useCustom") ? "u" : "c")), B(p + "outline"), F(p + "outlineThickness"), F(p + "outlineOpacity"),
B(p + "dot"), F(p + "dotSize"), F(p + "dotOpacity"), L(p + "i."), L(p + "o."));
return new CrosshairAt(t, v.TryGetValue("name", out var n) ? (string)n : "", S("p."), S("a."),
new SniperDot(Hex("s.c"), B("s.dot"), F("s.dotSize"), F("s.dotOpacity")), B("adsFromPrimary"), B("advanced"));
}
}
/// 조준점 설정 (t 부터). ads 는 adsFromPrimary 가 꺼져 있을 때 정조준에 쓴다. 크기는 발로란트 설정 값 그대로 (화면 픽셀)
public sealed record CrosshairAt(int T, string Name, CrossSet Primary, CrossSet Ads, SniperDot Sniper, bool AdsFromPrimary, bool Advanced);
/// color 는 실제로 보이는 색 (사용자 지정 색을 쓰면 그 색)
public sealed record CrossSet(string Color, bool Outline, double OutlineThickness, double OutlineOpacity, bool Dot, double DotSize, double DotOpacity, CrossLines Inner, CrossLines Outer);
/// vLength 는 세로 길이를 따로 쓰지 않으면 length 와 같다
public sealed record CrossLines(bool On, double Length, double VLength, double Thickness, double Offset, double Opacity, bool MoveError, bool FireError, double MoveScale, double FireScale);
public sealed record SniperDot(string Color, bool Dot, double DotSize, double DotOpacity);

View File

@@ -53,6 +53,8 @@ public sealed class ReplayPlayer
public string? Character { get; set; }
/// 이동 기록. 열 별 배열 (같은 길이): t, x, y, z, yaw(도), pitch(도)
public PlayerTrack Track { get; set; } = new();
/// 조준점 설정이 바뀐 시각마다 전체 설정 (시간 순). 리플레이에 없으면 null
public List<CrosshairAt>? Crosshair { get; set; }
}
public sealed class PlayerTrack

View File

@@ -1,7 +1,8 @@
// gvr-replay: 발로란트 리플레이(.vrf) → 사이트 재생기용 JSON (형식 gvr-replay v2)
// gvr-replay <file.vrf> <out.json> [--hz 10]
// gvr-replay <file.vrf> --stats (디버그: 액터 종류별 개수)
// gvr-replay --self-test (회귀 검사: 무기 주인 시간표)
// gvr-replay <file.vrf> --fields (디버그: 복제 필드 목록 <경로\t이름>, 번호 순)
// gvr-replay --self-test (회귀 검사: 무기 주인 시간표 · 조준점 필드 자리)
// 성공하면 종료 코드 0 과 함께 stdout 마지막 줄에 {"ok":true,...} 요약을 쓴다. 실패는 1 과 {"ok":false,"error":...}
using System.Diagnostics;
using System.Text.Json;
@@ -36,6 +37,21 @@ public static class Program
// 선수를 모르는 기록(-1)은 건너뛴다
var o3 = EquipOwners.Build([(1000, 4u, 5), (2000, 4u, -1)]);
Eq("모르는 선수 건너뜀", EquipOwners.At(o3, 4, 3000), 5);
// 조준점 필드 자리: 13.08 번호 그대로 · 앞에 필드가 2개 늘어난 패치 · 이름이 어긋나면 못 찾음
Dictionary<int, string> Names(int b) => new()
{
[b] = "B", [b + 8] = "bUseCustomColor", [b + 23] = "LineThickness", [b + 35] = "LineThickness",
[b + 70] = "LineThickness", [b + 153] = "bUsePrimaryCrosshairForADS", [b + 158] = "ProfileName", [b - 13] = "AssignedTeamState",
};
Eq("조준점 자리 13.08", Crosshair.FindBase(Names(39)) ?? -1, 39);
Eq("조준점 자리 +2", Crosshair.FindBase(Names(41)) ?? -1, 41);
var wrong = Names(39);
wrong[39 + 23] = "LineOffset";
Eq("조준점 이름 어긋남", Crosshair.FindBase(wrong) ?? -1, -1);
// 기본값: 오지 않은 색은 흰색, 사용자 지정 색을 쓰면 그 색
var cs = Crosshair.Snapshot(0, new Dictionary<string, object> { ["p.cb"] = 0, ["p.cg"] = 0, ["a.useCustom"] = true, ["a.ur"] = 0 });
if (cs.Primary.Color != "#ff0000") fails.Add($"주 조준점 색: {cs.Primary.Color} (기대 #ff0000)");
if (cs.Ads.Color != "#00ffff") fails.Add($"정조준 사용자 지정 색: {cs.Ads.Color} (기대 #00ffff)");
foreach (var f in fails) Console.Error.WriteLine("FAIL " + f);
Console.WriteLine(JsonSerializer.Serialize(new { ok = fails.Count == 0, selfTest = true, failed = fails.Count }));
return fails.Count == 0 ? 0 : 1;
@@ -66,6 +82,13 @@ public static class Program
var result = ValorantReplayReader.CreateDefault(null, enricher, profile).Read(archive);
enricher.Complete();
var info = result.Metadata.ReplayInfo;
if (args[1] == "--fields")
{
foreach (var g in result.ExportGroups)
foreach (var f in g.Fields)
Console.WriteLine(g.PathName + "\t" + f.Name);
return 0;
}
if (stats)
{
collector.PrintStats();
@@ -76,6 +99,21 @@ public static class Program
FDateTimeToUnixMs(info.Timestamp),
info.LengthInMs,
hz);
// 선수 조준점 (두 번째 읽기). 못 읽어도 나머지 변환은 그대로 쓴다
var crosshairs = 0;
try
{
foreach (var (state, list) in Crosshair.Read(input, result))
if (collector.SubjectOfState(state) is { } subject && replay.Players.FirstOrDefault(p => p.Puuid == subject) is { } pl)
{
pl.Crosshair = list;
crosshairs++;
}
}
catch (Exception e)
{
Console.Error.WriteLine("조준점 읽기 실패: " + e.Message);
}
var tmp = args[1] + ".tmp";
using (var fs = File.Create(tmp))
JsonSerializer.Serialize(fs, replay, ReplayJson.Options);
@@ -89,6 +127,7 @@ public static class Program
players = replay.Players.Count,
rounds = replay.Rounds.Count,
kills = replay.Kills.Count,
crosshairs,
elapsedMs = sw.ElapsedMilliseconds,
status = result.Status.ToString(),
warnings = result.TotalDiagnosticCount,