1
0
mirror of synced 2024-09-23 19:08:21 +02:00

Move uniqueId from CustomSong to SongInstance

This commit is contained in:
goaaats 2022-02-08 13:28:34 +01:00
parent 6144c64f18
commit 29f08bc9be
No known key found for this signature in database
GPG Key ID: 49E2AA8C6A76498B
4 changed files with 12 additions and 12 deletions

1
.gitignore vendored
View File

@ -396,5 +396,6 @@ FodyWeavers.xsd
# JetBrains Rider
*.sln.iml
.idea
TakoTako/Executables/TJAConvert.exe

View File

@ -379,29 +379,29 @@ public class MusicPatch
if (isTjaSong)
{
// For TJAs, we need to hash the TJA file.
song.uniqueId = song.tjaFileHash;
song.UniqueId = song.tjaFileHash;
if (song.uniqueId == 0)
if (song.UniqueId == 0)
throw new Exception("Converted TJA had no hash.");
}
else
{
// For official songs, we can just use the hash of the song internal name.
song.uniqueId = (int)(MurmurHash2.Hash(song.id) & 0xFFFF_FFF);
song.UniqueId = (int)(MurmurHash2.Hash(song.id) & 0xFFFF_FFF);
}
if (song.uniqueId <= SaveDataMax)
song.uniqueId += SaveDataMax;
if (song.UniqueId <= SaveDataMax)
song.UniqueId += SaveDataMax;
if (uniqueIdToSong.ContainsKey(song.uniqueId))
if (uniqueIdToSong.ContainsKey(song.UniqueId))
{
throw new Exception($"Song \"{song.id}\" has collision with \"{uniqueIdToSong[song.uniqueId].id}\", bailing out...");
throw new Exception($"Song \"{song.id}\" has collision with \"{uniqueIdToSong[song.UniqueId].id}\", bailing out...");
}
customSongsList.Add(song);
idToSong[song.id] = song;
uniqueIdToSong[song.uniqueId] = song;
Log.LogInfo($"Added{(isTjaSong ? " TJA" : "")} Song {song.songName.text}({song.uniqueId})");
uniqueIdToSong[song.UniqueId] = song;
Log.LogInfo($"Added{(isTjaSong ? " TJA" : "")} Song {song.songName.text}({song.UniqueId})");
}
}
@ -463,7 +463,7 @@ public class MusicPatch
continue;
musicInfoAccessors.Add(new MusicDataInterface.MusicInfoAccesser(
song.uniqueId,
song.UniqueId, // From SongInstance, as we always recalculate it now
song.id,
$"song_{song.id}",
song.order,
@ -1884,5 +1884,6 @@ public class MusicPatch
{
public string FolderPath;
public string SongName;
public int UniqueId;
}
}

View File

@ -204,7 +204,6 @@ namespace TJAConvert
{
var musicInfo = new CustomSong
{
uniqueId = metadata.Title.GetHashCode(),
id = tjaHash.ToString(),
order = 0,
genreNo = (int) metadata.Genre,

View File

@ -11,7 +11,6 @@ namespace TakoTako.Common
public class CustomSong
{
// Song Details
[DataMember] public int uniqueId;
[DataMember] public string id;
[DataMember] public int order;
[DataMember] public int genreNo;