Skip to content

Commit

Permalink
Changed audio source log generation such that it includes pre-existin…
Browse files Browse the repository at this point in the history
…g cries.
  • Loading branch information
Nifyr committed Dec 19, 2022
1 parent 420fb67 commit 941b54a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
21 changes: 21 additions & 0 deletions DataParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,27 @@ private static void CommitGlobalMetadata()

private static void CommitAudio()
{
gameData.audioSourceLog ??= fileManager.GetAudioSourceLog();
gameData.audioSourceLog.Clear();
Dictionary<uint, WwiseObject> lookup = gameData.audioData.objectsByID;

foreach (Pokemon p in gameData.personalEntries)
{
IEnumerable<string> eventNames = PokemonInserter.GetWwiseEvents(p.dexID, p.formID).Take(5);
foreach (string eventName in eventNames)
{
uint eventID = FNV132(eventName);
if (!lookup.TryGetValue(eventID, out WwiseObject ewo)) continue;
Event e = (Event)ewo;
ActionPlay ap = (ActionPlay)lookup[e.actionIDs.First()];
WwiseObject swo = lookup[ap.idExt];
if (swo is not Sound)
continue;
Sound s = (Sound)swo;
gameData.audioSourceLog.Append(eventName + "" + s.bankSourceData.mediaInformation.sourceID + "\n");
}
}

fileManager.CommitAudio();
}

Expand Down
3 changes: 1 addition & 2 deletions FileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
using static ImpostersOrdeal.GlobalData;
using SmartPoint.AssetAssistant;
using System.Configuration;
using System.Threading.Tasks;
using System.Text;
using System.Security.Cryptography;

namespace ImpostersOrdeal
{
Expand Down Expand Up @@ -555,6 +553,7 @@ public StringBuilder GetAudioSourceLog()
FileData fd = new();
fd.fileLocation = audioPath + "\\AudioSources.txt";
fd.gamePath = logPath;
fd.fileSource = FileSource.App;
fileArchive[logPath] = fd;
return new("");
}
Expand Down
10 changes: 5 additions & 5 deletions PokemonInserter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,6 @@ private void UpdateAudioBank(List<(int, int)> uniqueIDs, out (uint, uint) source
gameData.audioData.objectsByID[newEventID] = newE;
hc.loadedItem.Add(newE);
}
gameData.audioSourceLog ??= fileManager.GetAudioSourceLog();
gameData.audioSourceLog.Append(eventNames[0] + "" + sourceID.Item2 + "\n");
}

private uint NextUInt32(WwiseData wd)
Expand Down Expand Up @@ -1060,7 +1058,9 @@ public void UpdateUIMasterdatas(List<(int, int)> uniqueIDs,
}
}

private static List<string> GetWwiseEvents(int uniqueID)
public static List<string> GetWwiseEvents(int uniqueID) => GetWwiseEvents((ushort)(uniqueID / 10000), uniqueID / 100 % 100);

public static List<string> GetWwiseEvents(ushort dexID, int formID)
{
List<string> events = new();
string[] prefixes = new string[]
Expand All @@ -1069,8 +1069,8 @@ private static List<string> GetWwiseEvents(int uniqueID)
};
foreach (string p in prefixes)
for (int i = 0; i < 5; i++)
events.Add(p + "_" + (uniqueID / 10000).ToString("D3") + "_" +
(uniqueID / 100 % 100).ToString("D2") + "_" + i.ToString("D2"));
events.Add(p + "_" + dexID.ToString("D3") + "_" +
formID.ToString("D2") + "_" + i.ToString("D2"));
return events;
}

Expand Down

0 comments on commit 941b54a

Please sign in to comment.