1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-27 23:46:45 +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;
/**
* Instrumental and vocal offsets. Optional, defaults to 0.
* Instrumental and vocal offsets.
* Defaults to an empty SongOffsets object.
*/
@:optional
public var offsets:SongOffsets;
public var offsets:Null<SongOffsets>;
/**
* Data relating to the song's gameplay.

View file

@ -12,6 +12,7 @@ import funkin.util.VersionUtil;
using funkin.data.song.migrator.SongDataMigrator;
@:nullSafety
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 var DEFAULT_GENERATEDBY(get, null):String;
public static var DEFAULT_GENERATEDBY(get, never):String;
static function get_DEFAULT_GENERATEDBY():String
{
@ -88,7 +89,7 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
{
try
{
var entry:Song = createEntry(entryId);
var entry:Null<Song> = createEntry(entryId);
if (entry != null)
{
trace(' Loaded entry data: ${entry}');
@ -455,7 +456,7 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
{
variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
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;
}
@ -463,7 +464,7 @@ class SongRegistry extends BaseRegistry<Song, SongMetadata>
{
variation = variation == null ? Constants.DEFAULT_VARIATION : variation;
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;
}

View file

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