1
0
mirror of synced 2024-11-27 23:40:48 +01: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 # JetBrains Rider
*.sln.iml *.sln.iml
.idea
TakoTako/Executables/TJAConvert.exe TakoTako/Executables/TJAConvert.exe

View File

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

View File

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

View File

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