Skip to content

Commit

Permalink
Check for unused files: Include string table when checking WAV resources
Browse files Browse the repository at this point in the history
Strings with associated WAV resources were ignored when scanning scripts.
  • Loading branch information
Argent77 committed Sep 5, 2024
1 parent 5f562eb commit 99fe6f7
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/org/infinity/check/ResourceUseChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ private void checkCode(String compiledCode, ScriptType type) throws Exception {
for (final ResourceEntry entry : decompiler.getResourcesUsed()) {
unusedResources.remove(entry.getResourceName());
}
for (final int strref : decompiler.getStringRefsUsed()) {
checkSound(strref);
}
}
}

Expand Down Expand Up @@ -331,9 +334,22 @@ private void checkResourceRef(ResourceRef ref) {
* @param ref Reference to entry in string table that contains sound file name
*/
private void checkSound(StringRef ref) {
final int index = ref.getValue();
if (index >= 0) {
final String wav = StringTable.getSoundResource(index);
if (ref != null) {
checkSound(ref.getValue());
}
}

/**
* If string reference has the associated sound, removes this sound from {@link #unusedResources}, otherwise do
* nothing.
* <p>
* This method can be called from several threads
*
* @param ref Reference to entry in string table that contains sound file name
*/
private void checkSound(int strref) {
if (strref >= 0) {
final String wav = StringTable.getSoundResource(strref);
if (!wav.isEmpty()) {
removeEntries(wav + ".WAV");
}
Expand Down

0 comments on commit 99fe6f7

Please sign in to comment.