Skip to content

Commit caf3ae8

Browse files
committed
allow old "overwatch 1" and "overwatch 2" names for default skins
1 parent 77f2dd8 commit caf3ae8

3 files changed

Lines changed: 103 additions & 29 deletions

File tree

DataTool/IQueryParser.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,22 @@ public ParsedArg Combine(ParsedArg? other) {
4141
};
4242
}
4343

44-
public bool ShouldDo(string name, Dictionary<string, TagExpectedValue>? expectedVals = null) {
44+
public bool ShouldDo(string name, Dictionary<string, TagExpectedValue>? expectedVals=null, ReadOnlySpan<string> alternateNames=default) {
4545
name = name.ReplaceLineEndings(""); // Magma\r\nTitan
4646
name = name.Replace("<hy>", ""); // deDE
4747
name = name.Replace("<en>", ""); // thTR
4848
name = name.Replace("<en/>", ""); // thTR
4949

50+
// IsDisallowed promotes spellcheck for the canon name. so we don't need to worry about it anywhere
51+
// else in this function
5052
if (Values.IsDisallowed(name)) {
5153
// if disallowed by name, don't attempt to match tags
5254
return false;
5355
}
56+
// (or if alternate name explicitly disallowed)
57+
if (Values.Disallowed.Matches(alternateNames)) {
58+
return false;
59+
}
5460

5561
if (expectedVals != null) {
5662
foreach (KeyValuePair<string, TagExpectedValue> expectedVal in expectedVals) {
@@ -69,16 +75,16 @@ public bool ShouldDo(string name, Dictionary<string, TagExpectedValue>? expected
6975
}
7076

7177
if (!explicitlyAllowed) {
72-
// if the tag value is not explicitly allowed or disallowed
78+
// if the tag value is not explicitly allowed or disallowed (but is specified)
7379
// try to match by exact unlock name instead
7480
// this helps with owl skins, as the tag is set to "none" by default
7581
// (if we allowed glob, (leagueteam=boston) would match everything due to unspecified Allowed)
76-
return Values.Allowed.MatchesNoGlob(name);
82+
return Values.Allowed.MatchesNoGlob(name) || Values.Allowed.MatchesNoGlob(alternateNames);
7783
}
7884
}
7985
}
8086

81-
return Values.IsAllowed(name);
87+
return Values.Allowed.Matches(name) || Values.Allowed.Matches(alternateNames);
8288
}
8389
}
8490

@@ -129,6 +135,24 @@ public bool Matches(string name) {
129135

130136
return false;
131137
}
138+
139+
public bool MatchesNoGlob(ReadOnlySpan<string> names) {
140+
foreach (var name in names) {
141+
if (MatchesNoGlob(name)) {
142+
return true;
143+
}
144+
}
145+
return false;
146+
}
147+
148+
public bool Matches(ReadOnlySpan<string> names) {
149+
foreach (var name in names) {
150+
if (Matches(name)) {
151+
return true;
152+
}
153+
}
154+
return false;
155+
}
132156

133157
public ParsedNameSet Union(ParsedNameSet other) {
134158
var output = new ParsedNameSet();
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.IO;
3+
using System.Linq;
4+
using DataTool.DataModels;
5+
using DataTool.Flag;
6+
using DataTool.Helper;
7+
using DataTool.ToolLogic.Extract;
8+
9+
namespace DataTool.ToolLogic.Dump {
10+
[Tool("dump-pw2-name-guids",
11+
Description = "Dump ow2 skin name guids",
12+
CustomFlags = typeof(ExtractFlags),
13+
IsSensitive = true)]
14+
public class DumpHeroOW2SkinNameGUIDs : ITool {
15+
public void Parse(ICLIFlags toolFlags) {
16+
var flags = (ExtractFlags)toolFlags;
17+
if (flags.OutputPath == null)
18+
throw new Exception("no output path");
19+
20+
var outputPath = Path.Combine(flags.OutputPath, "LocalizedNamesMapping");
21+
IO.CreateDirectorySafe(outputPath);
22+
23+
using var output = new StreamWriter(Path.Combine(outputPath, "OW2Skins.csv"));
24+
25+
foreach (var hero in Helpers.GetHeroes().Values) {
26+
if (!hero.IsHero) continue;
27+
28+
// (this is intended to be run on 2026 builds, so the name is "Overwatch" now)
29+
var defaultSkin = new ProgressionUnlocks(hero.STU).LevelUnlocks!.First().Unlocks.Single(x => x.GetName() == "Overwatch");
30+
31+
output.WriteLine($"0x{defaultSkin.STU.m_name.GUID.GUID:X16} ; {hero.Name}");
32+
}
33+
}
34+
}
35+
}

DataTool/ToolLogic/Extract/ExtractHeroUnlocks.cs

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ protected override void QueryHelp(List<QueryType> types) {
114114
base.QueryHelp(types);
115115

116116
Log("\r\nExample commands: ");
117-
Log($"{indent + 1}\"Lúcio|skin=Overwatch 1\"");
117+
Log($"{indent + 1}\"Lúcio|skin=Overwatch Classic\"");
118118
Log($"{indent + 1}\"Tracer|skin=Track and Field\"");
119119
Log($"{indent + 1}\"Reinhardt|emote=*\"");
120120
Log($"{indent + 1}\"Junker Queen|victorypose=*\"");
@@ -351,6 +351,28 @@ public static void SaveUnlock(
351351
}
352352
}
353353

354+
// todo: add previous zhCN name for ow1 skins: "守望先锋"
355+
// but for whatever reason, ow1 and ow2 skins on rcn+zhCN are all called "守望先锋" now
356+
// needs to be fixed first
357+
private static string[] OW1SkinAlternateNames = [
358+
"Overwatch 1", // old en
359+
"オーバーウォッチ 1", // old jp
360+
"오버워치 1", // old kr
361+
"《鬥陣特攻》",
362+
/* todo, */
363+
"Classic", // old rcn-en
364+
"Overwatch Classic" // new en
365+
];
366+
private static string[] OW2SkinAlternateNames = [
367+
"Overwatch 2", // old en
368+
"オーバーウォッチ 2", // old jp
369+
"오버워치 2", // old kr
370+
"《鬥陣特攻2》",
371+
"守望先锋归来", // old rcn-cn
372+
"Valorous", // old rcn-en
373+
"Overwatch", // new en
374+
];
375+
354376
private static bool ShouldDo(Unlock unlock, IgnoreCaseDict<ParsedArg>? config, Dictionary<string, TagExpectedValue>? tags, UnlockType unlockType) {
355377
if (unlock.Type != unlockType) return false;
356378

@@ -362,32 +384,25 @@ private static bool ShouldDo(Unlock unlock, IgnoreCaseDict<ParsedArg>? config, D
362384
if (!config.TryGetValue(typeLower, out var configForType)) {
363385
return false;
364386
}
365-
366-
if (configForType.ShouldDo(unlock.GetName(), tags)) {
367-
return true;
368-
}
369387

370-
// todo: decide if i want to ship this
371-
// different extracted name from query is confusing
372-
// and polluting the spellcheck with these names is also confusing
373-
// maybe it could be precise locale mapping instead
374-
375-
// todo: add previous zhCN name for ow1 skins: "守望先锋"
376-
// but for whatever reason, ow1 and ow2 skins on rcn+zhCN are all called "守望先锋" now
377-
// needs to be fixed first
378-
/*ReadOnlySpan<string> alternateNames = unlock.GetSTU().m_name.GUID.GUID switch {
379-
0x0DE00000000024D4 =>
380-
["Overwatch 1", "オーバーウォッチ 1", "오버워치 1", "《鬥陣特攻》", "Classic"],
381-
0x0DE000000000CB5F =>
382-
["Overwatch 2", "オーバーウォッチ 2", "오버워치 2", "《鬥陣特攻2》", "守望先锋归来", "Valorous"],
388+
// todo: different extracted name from query is confusing (log?)
389+
// todo: if there are issues with dup names (cn, for now), maybe it could be a precise locale mapping using data instead
390+
ReadOnlySpan<string> alternateNames = unlock.GetSTU().m_name.GUID.GUID switch {
391+
0x0DE00000000024D4 => OW1SkinAlternateNames,
392+
0x0DE000000000CB5F => OW2SkinAlternateNames, // shared
393+
0x0DE0000000022DAB => OW2SkinAlternateNames, // echo, freja
394+
0x0DE00000000179D3 => OW2SkinAlternateNames, // lw
395+
0x0DE000000001B41C => OW2SkinAlternateNames, // mauga
396+
0x0DE000000001AE12 => OW2SkinAlternateNames, // illari
397+
0x0DE000000001CAC5 => OW2SkinAlternateNames, // venture
398+
0x0DE00000000204E3 => OW2SkinAlternateNames, // hazard
399+
0x0DE0000000020A28 => OW2SkinAlternateNames, // juno
400+
0x0DE000000002B1D8 => OW2SkinAlternateNames, // vendetta
401+
0x0DE0000000029E6A => OW2SkinAlternateNames, // anran
402+
0x0DE000000002A7CC => OW2SkinAlternateNames, // jetpack cat
383403
_ => []
384404
};
385-
foreach (var alternateName in alternateNames) {
386-
if (configForType.ShouldDo(alternateName, tags)) {
387-
return true;
388-
}
389-
}*/
390-
391-
return false;
405+
406+
return configForType.ShouldDo(unlock.GetName(), tags, alternateNames);
392407
}
393408
}

0 commit comments

Comments
 (0)