Shemp's LBRS run (14 Oct 2026) was saved as 46:38 instead of 1:54:00 by v1.26.0's timer bug, and could not be removed: boards only take faster times and members re-share their bests. - Rankings > 5-mans, a run's page (board or Your runs): "Wrong time? withdraw this run", asks first. Off your boards and best times; Your runs keeps it marked withdrawn. - WhoDidItDB.runsWithdrawn: R:Merge refuses a withdrawn run for good (channel, download, own PC). - Realm channel record W (key~secs~names): only from a member of the group, 5 per sender per 10 minutes, 200 kept per realm (your groups' always; ones that took a run off before ones that never did). Taking one makes nobody send; members re-send theirs when someone asks (Q). Older clients ignore W. - Masters' WhoDidIt_Runs.txt drops withdrawn runs and writes W5 lines; Publish-RaidTimes publishes them under the R5 consent rule; R:Seed applies them. - Translations for the new text; zh/ko font subsets rebuilt. Checked offline: replay of the whole case on LuaHost (real Data, Board, Dungeons per simulated PC, a 1.26.0 client from git, Publish-RaidTimes in a temp tree), 63 checks pass; LuaCheck passes on every changed file. Not tried in game. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
137 lines
8.0 KiB
PowerShell
Vendored
137 lines
8.0 KiB
PowerShell
Vendored
<#
|
|
Publish-RaidTimes - for the WhoDidIt maintainer: puts every guild's raid
|
|
times into the download, so a fresh install shows full Rankings at once
|
|
(even while the master is offline) and the master feed only has to send
|
|
what's newer.
|
|
|
|
It reads the sync helper's file (CustomData\WhoDidIt_Chronicle.txt),
|
|
keeps the guilds' kill and clear times (C / K, and C2 / K2 since the raid
|
|
scaling change) and the raid details (L), leaves out your own characters'
|
|
personal bests (PC / PK), adds the 5-man runs your WhoDidIt saved
|
|
(CustomData\WhoDidIt_Runs.txt, R5 lines) whose members were all seen
|
|
sharing them (a run lists its members by name, and this file goes into the
|
|
public repository), writes RaidTimes.lua and commits and pushes it.
|
|
Needs git with push access to the repository.
|
|
|
|
Run it now and then (weekly is plenty): the older the snapshot, the more
|
|
the feed has to send a fresh install.
|
|
Publish-RaidTimes.ps1 write, commit and push
|
|
Publish-RaidTimes.ps1 -NoPush only write RaidTimes.lua
|
|
Publish-RaidTimes.ps1 -Force publish even if it looks much smaller
|
|
Publish-RaidTimes.ps1 -Auto (the sync helper, weekly) skip unless main has nothing
|
|
unpushed of yours - it never pushes your own commits
|
|
#>
|
|
param([switch]$NoPush, [switch]$Force, [switch]$Auto)
|
|
$ErrorActionPreference = "Stop"
|
|
$repo = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
|
$wow = (Resolve-Path (Join-Path $PSScriptRoot "..\..\..\..")).Path
|
|
$src = Join-Path $wow "CustomData\WhoDidIt_Chronicle.txt"
|
|
$dst = Join-Path $repo "RaidTimes.lua"
|
|
|
|
if (-not (Test-Path -LiteralPath $src)) {
|
|
Write-Host "Nothing to publish: the sync helper hasn't written $src yet."
|
|
return
|
|
}
|
|
$lines = ([IO.File]::ReadAllText($src) -replace "`r`n", "`n") -split "`n"
|
|
$head = $lines[0] -split '\|'
|
|
if ($head[0] -ne "WDICHRON" -or $head[5] -ne "ok") { throw "The helper's file isn't a finished sync (header: $($lines[0])) - try again after its next sync." }
|
|
$synced = [long]$head[2]
|
|
$server = $head[3]
|
|
|
|
# only these kinds of line, and each one plain text (it goes inside a Lua [[ ]] string)
|
|
$keep = New-Object System.Collections.Generic.List[string]
|
|
$counts = @{}
|
|
foreach ($l in $lines) {
|
|
$t = ($l -split '\|')[0]
|
|
if ($t -notin "C", "K", "C2", "K2", "L") { continue }
|
|
if ($l -match '\[\[|\]\]|[\x00-\x08\x0b-\x1f]') { throw "A line can't be stored safely, not publishing: $l" }
|
|
$keep.Add($l)
|
|
$counts[$t] = 1 + [int]$counts[$t]
|
|
}
|
|
# 5-man runs, only where every member is named with their consent: your WhoDidIt writes
|
|
# R5|realm|key|group|secs|date|deaths|faction|members|splits|named|ok
|
|
# where ok lists the members it saw share the run themselves (their own vote, or the run
|
|
# sent by them on the realm channel: they have WhoDidIt with sharing on). A run with
|
|
# anyone else in it (a player without WhoDidIt can't say yes) stays out, and so does an
|
|
# older line without ok. Published as the first 11 fields, as WhoDidIt reads them.
|
|
$runsFile = Join-Path $wow "CustomData\WhoDidIt_Runs.txt"
|
|
if (Test-Path -LiteralPath $runsFile) {
|
|
foreach ($l in (([IO.File]::ReadAllText($runsFile) -replace "`r`n", "`n") -split "`n")) {
|
|
$p = $l -split '\|'
|
|
if ($p[0] -ne "R5" -or $p.Count -ne 12) { continue }
|
|
if ($l -match '\[\[|\]\]|[\x00-\x1f]' -or $p[4] -notmatch '^\d+$' -or $p[5] -notmatch '^\d+$') { continue } # (WhoDidIt checks the rest when it loads them)
|
|
$ok = @($p[11] -split ',' | Where-Object { $_ -ne "" })
|
|
$names = @($p[8] -split ',' | ForEach-Object { ($_ -split ':')[0] } | Where-Object { $_ -ne "" })
|
|
if ($names.Count -eq 0) { continue }
|
|
$all = $true
|
|
foreach ($n in $names) { if ($ok -cnotcontains $n) { $all = $false; break } }
|
|
if (-not $all) { $counts["R5 left out"] = 1 + [int]$counts["R5 left out"]; continue }
|
|
$keep.Add(($p[0..10] -join '|'))
|
|
$counts["R5"] = 1 + [int]$counts["R5"]
|
|
}
|
|
# withdrawn 5-man runs (a member took a wrong time off the boards; WhoDidIt doesn't write
|
|
# the run itself any more): W5|realm|key|secs|names|ok, published as the first 5 fields
|
|
# under the same rule, so the download takes the run off PCs that got it from an earlier one
|
|
foreach ($l in (([IO.File]::ReadAllText($runsFile) -replace "`r`n", "`n") -split "`n")) {
|
|
$p = $l -split '\|'
|
|
if ($p[0] -ne "W5" -or $p.Count -ne 6) { continue }
|
|
if ($l -match '\[\[|\]\]|[\x00-\x1f]' -or $p[3] -notmatch '^\d+$') { continue }
|
|
$ok = @($p[5] -split ',' | Where-Object { $_ -ne "" })
|
|
$names = @($p[4] -split ',' | Where-Object { $_ -ne "" })
|
|
if ($names.Count -eq 0) { continue }
|
|
$all = $true
|
|
foreach ($n in $names) { if ($ok -cnotcontains $n) { $all = $false; break } }
|
|
if (-not $all) { continue }
|
|
$keep.Add(($p[0..4] -join '|'))
|
|
$counts["W5"] = 1 + [int]$counts["W5"]
|
|
}
|
|
}
|
|
$times = [int]$counts["C"] + [int]$counts["K"]
|
|
$now = 0
|
|
if (Test-Path -LiteralPath $dst) {
|
|
$now = ([regex]::Matches([IO.File]::ReadAllText($dst), '(?m)^[CK]\|')).Count
|
|
}
|
|
if (-not $Force -and ($times -lt 100 -or $times -lt [math]::Floor($now / 2))) {
|
|
throw "Only $times guild times (published now: $now). That looks wrong, so it isn't published. -Force publishes it anyway."
|
|
}
|
|
|
|
$when = [DateTimeOffset]::FromUnixTimeSeconds($synced).ToString("yyyy-MM-dd HH:mm") + " UTC"
|
|
$o = New-Object System.Text.StringBuilder
|
|
[void]$o.AppendLine("-- Every guild's raid times, as of the WhoDidIt maintainer's sync of $when, so a")
|
|
[void]$o.AppendLine("-- fresh install shows full Rankings at once; the master feed sends what's newer.")
|
|
[void]$o.AppendLine("-- From Chronicle's public API (chronicleclassic.com). Generated by tools\Publish-RaidTimes.ps1 - do not edit.")
|
|
[void]$o.AppendLine("-- C / K: a guild's best clear / kill; C2 / K2: the same since the 6 Oct raid scaling change; L: a raid's bosses;")
|
|
[void]$o.AppendLine("-- R5: a 5-man group's best run, only for groups whose members all share their runs with WhoDidIt;")
|
|
[void]$o.AppendLine("-- W5: such a run a member withdrew (a time the timer got wrong).")
|
|
[void]$o.AppendLine("WDI_RAIDTIMES = { synced = $synced, server = `"$server`", text = [[")
|
|
foreach ($l in $keep) { [void]$o.AppendLine($l) }
|
|
[void]$o.AppendLine("]] }")
|
|
[IO.File]::WriteAllText($dst, $o.ToString(), (New-Object Text.UTF8Encoding($false)))
|
|
Write-Host ("RaidTimes.lua: {0} clears, {1} kills, {2} / {3} since the scaling change, {4} raid details, {5} 5-man runs ({6} left out: not every member seen sharing), {7} withdrawn, synced {8} ({9:N0} KB)." -f `
|
|
[int]$counts["C"], [int]$counts["K"], [int]$counts["C2"], [int]$counts["K2"], [int]$counts["L"], [int]$counts["R5"], [int]$counts["R5 left out"], [int]$counts["W5"], $when, ((Get-Item $dst).Length / 1KB))
|
|
if ($NoPush) { return }
|
|
|
|
Push-Location $repo
|
|
$ErrorActionPreference = "Continue" # git prints line-ending warnings on stderr
|
|
try {
|
|
$branch = (git rev-parse --abbrev-ref HEAD 2>$null)
|
|
if ($branch -ne "main") { throw "The repository is on '$branch', not main - switch to main first." }
|
|
if ($Auto) {
|
|
git fetch -q origin main 2>$null
|
|
$ahead = [int](git rev-list --count origin/main..HEAD 2>$null)
|
|
if ($ahead -gt 0) { Write-Host "Skipped: main has $ahead commit(s) of yours not pushed yet, and this would push them. Next try in a day."; return }
|
|
}
|
|
git pull -q --rebase --autostash origin main 2>$null
|
|
if ($LASTEXITCODE -ne 0) { throw "git pull failed - fix that first (nothing was committed)" }
|
|
git add RaidTimes.lua 2>$null
|
|
git diff --cached --quiet -- RaidTimes.lua
|
|
if ($LASTEXITCODE -eq 0) { Write-Host "No change since the last publish."; return }
|
|
git commit -q -m "Raid times snapshot ($when)" -- RaidTimes.lua 2>$null
|
|
if ($LASTEXITCODE -ne 0) { throw "git commit failed" }
|
|
git push -q origin main 2>$null
|
|
if ($LASTEXITCODE -ne 0) { throw "git push failed - check you can push to the repository" }
|
|
Write-Host "Published: a fresh install of WhoDidIt now starts with these raid times."
|
|
} finally {
|
|
Pop-Location
|
|
}
|