1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-06-21 10:01:32 +00:00

Fix an issue where Song offsets would be null rather than zero.

This commit is contained in:
EliteMasterEric 2024-01-14 06:46:58 -05:00
parent 75dfed8229
commit 549d461172
3 changed files with 9 additions and 7 deletions

View file

@ -38,10 +38,11 @@ class SongMetadata implements ICloneable<SongMetadata>
public var looped:Bool; public var looped:Bool;
/** /**
* Instrumental and vocal offsets. Optional, defaults to 0. * Instrumental and vocal offsets.
* Defaults to an empty SongOffsets object.
*/ */
@:optional @:optional
public var offsets:SongOffsets; public var offsets:Null<SongOffsets>;
/** /**
* Data relating to the song's gameplay. * Data relating to the song's gameplay.

View file

@ -12,6 +12,7 @@ import funkin.util.VersionUtil;
using funkin.data.song.migrator.SongDataMigrator; using funkin.data.song.migrator.SongDataMigrator;
@:nullSafety
class SongRegistry extends BaseRegistry<Song, SongMetadata> class SongRegistry extends BaseRegistry<Song, SongMetadata>
{ {
/** /**
@ -31,7 +32,7 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
public static final SONG_MUSIC_DATA_VERSION_RULE:thx.semver.VersionRule = "2.0.x"; public static final SONG_MUSIC_DATA_VERSION_RULE:thx.semver.VersionRule = "2.0.x";
public static var DEFAULT_GENERATEDBY(get, null):String; public static var DEFAULT_GENERATEDBY(get, never):String;
static function get_DEFAULT_GENERATEDBY():String static function get_DEFAULT_GENERATEDBY():String
{ {
@ -88,7 +89,7 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
{ {
try try
{ {
var entry:Song = createEntry(entryId); var entry:Null<Song> = createEntry(entryId);
if (entry != null) if (entry != null)
{ {
trace(' Loaded entry data: ${entry}'); trace(' Loaded entry data: ${entry}');
@ -455,7 +456,7 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
{ {
variation = variation == null ? Constants.DEFAULT_VARIATION : variation; variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
var entryStr:Null<String> = loadEntryMetadataFile(id, variation)?.contents; var entryStr:Null<String> = loadEntryMetadataFile(id, variation)?.contents;
var entryVersion:thx.semver.Version = VersionUtil.getVersionFromJSON(entryStr); var entryVersion:Null<thx.semver.Version> = VersionUtil.getVersionFromJSON(entryStr);
return entryVersion; return entryVersion;
} }
@ -463,7 +464,7 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
{ {
variation = variation == null ? Constants.DEFAULT_VARIATION : variation; variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
var entryStr:Null<String> = loadEntryChartFile(id, variation)?.contents; var entryStr:Null<String> = loadEntryChartFile(id, variation)?.contents;
var entryVersion:thx.semver.Version = VersionUtil.getVersionFromJSON(entryStr); var entryVersion:Null<thx.semver.Version> = VersionUtil.getVersionFromJSON(entryStr);
return entryVersion; return entryVersion;
} }

View file

@ -174,7 +174,7 @@ class Song implements IPlayStateScriptedClass implements IRegistryEntry<SongMeta
difficulty.timeChanges = metadata.timeChanges; difficulty.timeChanges = metadata.timeChanges;
difficulty.looped = metadata.looped; difficulty.looped = metadata.looped;
difficulty.generatedBy = metadata.generatedBy; difficulty.generatedBy = metadata.generatedBy;
difficulty.offsets = metadata.offsets; difficulty.offsets = metadata?.offsets ?? new SongOffsets();
difficulty.difficultyRating = metadata.playData.ratings.get(diffId) ?? 0; difficulty.difficultyRating = metadata.playData.ratings.get(diffId) ?? 0;
difficulty.album = metadata.playData.album; difficulty.album = metadata.playData.album;