Skip to content

Commit

Permalink
nwn_erf_tlkify: log skipped translations as INFO so the user knows wh…
Browse files Browse the repository at this point in the history
…at's up
  • Loading branch information
niv committed Sep 21, 2018
1 parent 4f674de commit ea970f7
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/nwn_erf_tlkify.nim
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ var translations: CritBitTree[StrRef]
var newTranslations = 0
var latestStrref = StrRef 0

# Strings we skipped. We track them so we don't log them twice.
var skippedTranslations: CritBitTree[void]

proc trackSkipped(str: string): void =
let strl = str.toLowerAscii
if not skippedTranslations.contains(strl):
skippedTranslations.incl(strl)
info "SKIP: ", str

proc translate(str: string): StrRef =
if str.len > 0:
if not translations.hasKey(str):
Expand Down Expand Up @@ -77,19 +86,25 @@ proc tlkify(gin: var GffStruct) =
continue

if exolocstr.strRef == -1 and exolocstr.entries.len > 0:
doAssert(exolocstr.entries.len == 1) # we can only do english, sorry.
doAssert(exolocstr.entries.hasKey(0))
doAssert(StrRef(exolocstr.strRef) == BadStrRef)
doAssert(exolocstr.entries.len == 1,
"exolocstring has multiple languages, but we can only do one language")
doAssert(exolocstr.entries.hasKey(0),
"exolocstring has non-english language string")
doAssert(StrRef(exolocstr.strRef) == BadStrRef,
"exolocstring already has a strref AND english override data")
let str = exolocstr.entries[0]

if str.len > 0 and not textsToIgnore.contains(str):
let rewriteStrRef = translate(str) + 16777216
doAssert(rewriteStrRef != BadStrRef)
doAssert(rewriteStrRef != BadStrRef, "failed to assign strref")
exolocstr.entries.clear
exolocstr.strRef = int rewriteStrRef

assert(val.getValue(GffCExoLocString).strRef == exolocstr.strRef)

elif str.len > 0:
trackSkipped(str)

proc tlkify(ein: Erf, outFile: string) =
writeErf(newFileStream(outFile, fmWrite),
ein.fileType, ein.locStrings,
Expand Down

0 comments on commit ea970f7

Please sign in to comment.