발로란트 맵 3D: 모든 맵을 Riot CDN 에서 바로 추출해 3D 리플레이에 붙임 · 매핑 업데이트 자동 적용
- tools/map-extract (C#, CUE4Parse 고정 커밋): 게임 파일을 받지 않고 매니페스트 조각만 HTTP Range 로 읽어 맵 22개(일반 13 · 팀 데스매치 5 · 스커미시 3 · 어빌리티 드래프트)를 월드 좌표 glb 로. 3.1분 · 587MB 받음 - scripts/pack.py (gltfpack -cc + gzip, 맵당 0.5~4.6MB) · update.sh (uedb 매핑 · 라이브 패치 확인 → 매핑 보관 → 추출 → .5 data/maps3d 반영) · install.sh (systemd 사용자 타이머 30분, 메모리 6GB 상한) - 사이트 서버: GET /site/maps3d* (로그인 필요, gzip 그대로). CSP 에 'wasm-unsafe-eval' (meshopt 압축 풀기만) - 3D 재생기: 맵 3D 위에 선수 표시, 천장 자르기(자동 · 없음 · 직접), 높이 색칠. 맵이 없거나 실패하면 미니맵 - 리플레이 칸: 리플레이를 아직 안 보내는 앱 버전이면 그렇게 안내 - 테스트: maps3d.test.ts 2개, CSP 테스트 갱신 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
124
tools/map-extract/src/Program.cs
Normal file
124
tools/map-extract/src/Program.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using Serilog;
|
||||
using System.Diagnostics;
|
||||
using System.Text.RegularExpressions;
|
||||
using CUE4Parse;
|
||||
using CUE4Parse.Compression;
|
||||
using CUE4Parse.Encryption.Aes;
|
||||
using CUE4Parse.FileProvider;
|
||||
using CUE4Parse.MappingsProvider.Usmap;
|
||||
using CUE4Parse.UE4.Objects.Core.Misc;
|
||||
using CUE4Parse.UE4.Versions;
|
||||
using GvrMapExtract;
|
||||
|
||||
// gvr-map-extract: 발로란트 맵 3D 모양을 Riot CDN 에서 바로 뽑는다 (게임 설치 · 전체 다운로드 없음)
|
||||
//
|
||||
// gvr-map-extract ls <정규식> [개수] 파일 목록
|
||||
// gvr-map-extract maps 맵 목록 (코드 이름 · 레벨 수)
|
||||
// gvr-map-extract extract <출력 폴더> [맵...] 맵마다 <코드>.glb (UE 월드 좌표 cm, 위치 + 삼각형) + <코드>.json
|
||||
//
|
||||
// 환경변수
|
||||
// GVR_USMAP 매핑 파일 (.usmap, 필수: 13.08 부터 패키지에 형 정보가 없다). uedb.dev 에서 받는다
|
||||
// GVR_MANIFEST 매니페스트 URL (없으면 지금 라이브 패치를 Riot 설정에서 찾는다)
|
||||
// GVR_CACHE_MB 받은 조각을 메모리에 둘 크기 (기본 1500)
|
||||
// GVR_OODLE Oodle 라이브러리 경로 (없으면 실행 파일 옆, 없으면 받는다)
|
||||
|
||||
Serilog.Log.Logger = new Serilog.LoggerConfiguration().MinimumLevel.Error().WriteTo.Console().CreateLogger();
|
||||
CUE4ParseLog.UseLogger(Serilog.Log.Logger);
|
||||
|
||||
const string AesKey = "0x4BE71AF2459CF83899EC9DC2CB60E22AC4B3047E0211034BBABE9D174C069DD6"; // 발로란트 공개 키 (모든 패치 같음)
|
||||
const string BundleBase = "https://valorant.secure.dyn.riotcdn.net/channels/public/bundles";
|
||||
const string Patchlines = "https://clientconfig.rpg.riotgames.com/api/v1/config/public?namespace=keystone.products.valorant.patchlines";
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
Console.Error.WriteLine("사용법: gvr-map-extract ls <정규식> | maps | extract <출력 폴더> [맵...] | manifest");
|
||||
return 2;
|
||||
}
|
||||
var sw = Stopwatch.StartNew();
|
||||
var store = new CdnStore(BundleBase, long.Parse(Environment.GetEnvironmentVariable("GVR_CACHE_MB") ?? "1500") << 20);
|
||||
var manifestUrl = Environment.GetEnvironmentVariable("GVR_MANIFEST") ?? await LiveManifest(store);
|
||||
if (args[0] == "manifest")
|
||||
{
|
||||
Console.WriteLine(manifestUrl);
|
||||
return 0;
|
||||
}
|
||||
var rman = Rman.Parse(await store.GetBytes(manifestUrl));
|
||||
Console.Error.WriteLine($"매니페스트 {manifestUrl} 파일 {rman.Files.Count}");
|
||||
|
||||
var oodle = Environment.GetEnvironmentVariable("GVR_OODLE") ?? Path.Combine(AppContext.BaseDirectory, OodleHelper.OodleFileName);
|
||||
await OodleHelper.InitializeAsync(oodle);
|
||||
var versions = new VersionContainer(EGame.GAME_Valorant);
|
||||
var provider = new StreamedFileProvider("VALORANT", versions, StringComparer.OrdinalIgnoreCase);
|
||||
provider.Initialize();
|
||||
foreach (var f in rman.Files.Values.Where(f => f.Path.StartsWith("ShooterGame/Content/Paks/", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var ext = Path.GetExtension(f.Path).ToLowerInvariant();
|
||||
if (ext == ".utoc")
|
||||
provider.RegisterRandomAccessVfs(new CdnArchive(store, f, versions), null, open =>
|
||||
rman.Files.TryGetValue(open, out var c) ? new CdnArchive(store, c, versions) : throw new FileNotFoundException(open));
|
||||
else if (ext == ".pak")
|
||||
provider.RegisterRandomAccessVfs(new CdnArchive(store, f, versions), null, null);
|
||||
}
|
||||
provider.SubmitKey(new FGuid(), new FAesKey(AesKey));
|
||||
provider.PostMount();
|
||||
var usmap = Environment.GetEnvironmentVariable("GVR_USMAP");
|
||||
if (usmap != null) provider.MappingsContainer = new FileUsmapTypeMappingsProvider(usmap);
|
||||
Console.Error.WriteLine($"파일 {provider.Files.Count} · 묶음 {provider.MountedVfs.Count} (못 연 것 {provider.UnloadedVfs.Count}) · 받은 양 {store.DownloadedBytes >> 20}MB · {sw.Elapsed.TotalSeconds:F0}초");
|
||||
|
||||
switch (args[0])
|
||||
{
|
||||
case "ls":
|
||||
{
|
||||
var re = new Regex(args[1], RegexOptions.IgnoreCase);
|
||||
foreach (var k in provider.Files.Keys.Where(k => re.IsMatch(k)).OrderBy(k => k).Take(args.Length > 2 ? int.Parse(args[2]) : 200)) Console.WriteLine(k);
|
||||
break;
|
||||
}
|
||||
case "levels":
|
||||
foreach (var (lvl, cls, props) in MapScene.StreamingLevels(provider, args[1]))
|
||||
Console.WriteLine($"{lvl}\t{cls}\t{props}");
|
||||
break;
|
||||
case "maps":
|
||||
foreach (var m in MapScene.FindMaps(provider, Console.Error.WriteLine)) Console.WriteLine($"{m.Code}\t{m.MapUrl}\t{m.Levels.Count}\t{string.Join(',', m.Levels.Select(Path.GetFileNameWithoutExtension))}");
|
||||
break;
|
||||
case "extract":
|
||||
{
|
||||
var outDir = args[1];
|
||||
Directory.CreateDirectory(outDir);
|
||||
var want = args.Skip(2).ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
var maps = MapScene.FindMaps(provider, Console.Error.WriteLine).Where(m => want.Count == 0 || want.Contains(m.Code)).ToList();
|
||||
var failed = 0;
|
||||
foreach (var m in maps)
|
||||
{
|
||||
var t0 = sw.Elapsed;
|
||||
var d0 = store.DownloadedBytes;
|
||||
try
|
||||
{
|
||||
var r = MapScene.Build(provider, m);
|
||||
r.WriteGlb(Path.Combine(outDir, m.Code + ".glb"));
|
||||
r.WriteInfo(Path.Combine(outDir, m.Code + ".json"), manifestUrl, usmap);
|
||||
Console.WriteLine($"{m.Code}: 배치 {r.Placements} · 메시 {r.Meshes} · 삼각형 {r.Triangles} · 빠짐 {r.Skipped} · 실패 {r.Failed} · 받은 양 {(store.DownloadedBytes - d0) >> 20}MB · {(sw.Elapsed - t0).TotalSeconds:F0}초");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
failed++;
|
||||
Console.WriteLine($"{m.Code}: 실패 {e.GetType().Name} {e.Message}");
|
||||
}
|
||||
GC.Collect();
|
||||
}
|
||||
Console.WriteLine($"끝: 맵 {maps.Count - failed}/{maps.Count} · 받은 양 {store.DownloadedBytes >> 20}MB ({store.Requests}번) · {sw.Elapsed.TotalMinutes:F1}분");
|
||||
return failed == 0 ? 0 : 1;
|
||||
}
|
||||
default:
|
||||
Console.Error.WriteLine("모르는 명령 " + args[0]);
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
|
||||
static async Task<string> LiveManifest(CdnStore store)
|
||||
{
|
||||
var json = System.Text.Json.JsonDocument.Parse(await store.GetBytes(Patchlines));
|
||||
var live = json.RootElement.GetProperty("keystone.products.valorant.patchlines.live");
|
||||
foreach (var c in live.GetProperty("platforms").GetProperty("win").GetProperty("configurations").EnumerateArray())
|
||||
if (c.TryGetProperty("patch_url", out var u)) return u.GetString()!;
|
||||
throw new InvalidOperationException("라이브 매니페스트를 못 찾음");
|
||||
}
|
||||
Reference in New Issue
Block a user