변환기: 무기 상태의 주인을 그 시각 주인으로 (마지막 주인이 과거 상태까지 덮어쓰던 것) · gvr-replay --self-test 회귀 검사 · CI 에서 실행 · v1.8.1
어비스 13.08 리플레이: 상태 16,974줄 중 1,189줄의 주인이 바뀜, 그중 그 시각 들고 있던 무기와 맞는 비율 24% → 75% Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
4
app/package-lock.json
generated
4
app/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "gvr-app",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "gvr-app",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@discordjs/voice": "^0.19.2",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "gvr-app",
|
||||
"productName": "겜녹이",
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"description": "겜녹이 (Game Voice Recorder) - 게임 연동 디스코드 음성 기록",
|
||||
"private": true,
|
||||
"main": "dist/main.cjs",
|
||||
|
||||
@@ -460,10 +460,10 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
|
||||
equips.Add([e.T, e.P, EquipKind(e.Name)]);
|
||||
}
|
||||
|
||||
// 무기 · 스킬 상태: 장비 액터 → 선수 (인벤토리 기록, 없으면 Instigator)
|
||||
var equipOwner = new Dictionary<uint, int>();
|
||||
foreach (var (_, ch, eq) in _equips)
|
||||
if (indexByCharacter.TryGetValue(ch, out var pi)) equipOwner[eq] = pi;
|
||||
// 무기 · 스킬 상태: 장비 액터 → 그 시각의 선수 (인벤토리 기록, 없으면 Instigator).
|
||||
// 무기는 떨어뜨리고 주울 수 있어서 마지막 주인이 아니라 상태가 생긴 때의 주인을 쓴다
|
||||
var equipOwners = EquipOwners.Build(_equips.Select(e => (e.T, e.Equip, indexByCharacter.TryGetValue(e.Character, out var p) ? p : -1)));
|
||||
var fallbackOwner = new Dictionary<uint, int>();
|
||||
var stateKinds = new List<string>();
|
||||
var stateKindIndex = new Dictionary<string, int>();
|
||||
var states = new List<int[]>();
|
||||
@@ -474,7 +474,12 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
|
||||
if (st is "InactiveState" or "ZoomStateDisabled") continue;
|
||||
if (lastState.TryGetValue(eq, out var ls) && ls == st) continue;
|
||||
lastState[eq] = st;
|
||||
if (!equipOwner.TryGetValue(eq, out var pi)) { pi = OwnerOf(eq); if (pi < 0) continue; equipOwner[eq] = pi; }
|
||||
var pi = EquipOwners.At(equipOwners, eq, t);
|
||||
if (pi < 0)
|
||||
{
|
||||
if (!fallbackOwner.TryGetValue(eq, out pi)) fallbackOwner[eq] = pi = OwnerOf(eq);
|
||||
if (pi < 0) continue;
|
||||
}
|
||||
var name = _equipName.TryGetValue(eq, out var en) ? en : _archetypeByActor.TryGetValue(eq, out var ea) ? Simplify(ea) : null;
|
||||
if (name is null) continue;
|
||||
if (!stateKindIndex.TryGetValue(st, out var sk)) { sk = stateKinds.Count; stateKinds.Add(st); stateKindIndex[st] = sk; }
|
||||
@@ -510,3 +515,32 @@ public sealed partial class Collector(int sampleMs) : IReplayEventSink
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>장비 액터의 주인 시간표: 인벤토리 기록 (t, 장비, 선수) → 시각별 주인</summary>
|
||||
public static class EquipOwners
|
||||
{
|
||||
public static Dictionary<uint, List<(int T, int Player)>> Build(IEnumerable<(int T, uint Equip, int Player)> rows)
|
||||
{
|
||||
var d = new Dictionary<uint, List<(int, int)>>();
|
||||
foreach (var (t, eq, p) in rows.OrderBy(r => r.T))
|
||||
{
|
||||
if (p < 0) continue;
|
||||
if (!d.TryGetValue(eq, out var l)) d[eq] = l = [];
|
||||
l.Add((t, p));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
/// <summary>t 시각 주인: t 이하 마지막 기록, 첫 기록보다 앞이면 첫 주인. 기록이 없으면 -1</summary>
|
||||
public static int At(Dictionary<uint, List<(int T, int Player)>> owners, uint eq, int t)
|
||||
{
|
||||
if (!owners.TryGetValue(eq, out var l) || l.Count == 0) return -1;
|
||||
var who = l[0].Player;
|
||||
foreach (var (rt, p) in l)
|
||||
{
|
||||
if (rt > t) break;
|
||||
who = p;
|
||||
}
|
||||
return who;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// gvr-replay: 발로란트 리플레이(.vrf) → 사이트 재생기용 JSON (형식 gvr-replay v2)
|
||||
// gvr-replay <file.vrf> <out.json> [--hz 10]
|
||||
// gvr-replay <file.vrf> --stats (디버그: 액터 종류별 개수)
|
||||
// gvr-replay --self-test (회귀 검사: 무기 주인 시간표)
|
||||
// 성공하면 종료 코드 0 과 함께 stdout 마지막 줄에 {"ok":true,...} 요약을 쓴다. 실패는 1 과 {"ok":false,"error":...}
|
||||
using System.Diagnostics;
|
||||
using System.Text.Json;
|
||||
@@ -13,8 +14,36 @@ namespace GvrReplay;
|
||||
|
||||
public static class Program
|
||||
{
|
||||
/// <summary>회귀 검사 (리플레이 파일 없이): 무기를 넘겨받아도 넘기기 전 상태는 이전 주인 것</summary>
|
||||
private static int SelfTest()
|
||||
{
|
||||
var fails = new List<string>();
|
||||
void Eq(string name, int got, int want)
|
||||
{
|
||||
if (got != want) fails.Add($"{name}: {got} (기대 {want})");
|
||||
}
|
||||
// 선수 0 이 1초에 들고 2초에 재장전, 10초에 선수 1 이 주움
|
||||
var o = EquipOwners.Build([(1000, 7u, 0), (10000, 7u, 1)]);
|
||||
Eq("주기 전 재장전(2초)", EquipOwners.At(o, 7, 2000), 0);
|
||||
Eq("주운 순간(10초)", EquipOwners.At(o, 7, 10000), 1);
|
||||
Eq("주운 뒤(12초)", EquipOwners.At(o, 7, 12000), 1);
|
||||
Eq("첫 기록 전(0.5초)", EquipOwners.At(o, 7, 500), 0);
|
||||
Eq("기록 없는 장비", EquipOwners.At(o, 8, 2000), -1);
|
||||
// 같은 시각 순서가 뒤섞여 들어와도 시간 순으로
|
||||
var o2 = EquipOwners.Build([(5000, 9u, 2), (1000, 9u, 3)]);
|
||||
Eq("순서 섞임(3초)", EquipOwners.At(o2, 9, 3000), 3);
|
||||
Eq("순서 섞임(6초)", EquipOwners.At(o2, 9, 6000), 2);
|
||||
// 선수를 모르는 기록(-1)은 건너뛴다
|
||||
var o3 = EquipOwners.Build([(1000, 4u, 5), (2000, 4u, -1)]);
|
||||
Eq("모르는 선수 건너뜀", EquipOwners.At(o3, 4, 3000), 5);
|
||||
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;
|
||||
}
|
||||
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
if (args.Length == 1 && args[0] == "--self-test") return SelfTest();
|
||||
if (args.Length < 2)
|
||||
{
|
||||
Console.Error.WriteLine("사용법: gvr-replay <file.vrf> <out.json> [--hz 10] | gvr-replay <file.vrf> --stats");
|
||||
|
||||
@@ -151,6 +151,9 @@ try {
|
||||
$exe = Join-Path $tx 'out\win\gvr-replay.exe'
|
||||
if (-not (Test-Path $exe)) { throw 'gvr-replay.exe 없음' }
|
||||
"gvr-replay.exe $([math]::Round((Get-Item $exe).Length / 1MB, 1)) MB"
|
||||
# 회귀 검사 (리플레이 파일 없이: 무기 주인 시간표 등)
|
||||
& $exe --self-test
|
||||
if ($LASTEXITCODE -ne 0) { throw "gvr-replay --self-test exit $LASTEXITCODE" }
|
||||
# 실제 13.08 리플레이 변환 (호스트가 serve/ 에 둔 시험 파일, 없으면 건너뜀)
|
||||
$vrf = Join-Path $OutDir '4145f041-7d83-4785-ac4b-b532154f14a4.vrf'
|
||||
try { Invoke-WebRequest -Uri 'http://10.0.2.2:8099/gvr-test.vrf' -OutFile $vrf -UseBasicParsing -TimeoutSec 600 } catch { Remove-Item $vrf -Force -ErrorAction SilentlyContinue; "시험 리플레이 없음: $($_.Exception.Message)" }
|
||||
|
||||
Reference in New Issue
Block a user