Skip to content

[CHORE] Null safety for 5 more classes #4751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4fa0334
easier script for creating macos universal binaries
ninjamuffin99 Apr 1, 2025
54cd52d
Fix an issue where story mode medals would not be awarded without a p…
EliteMasterEric Apr 1, 2025
17a4be6
Fix highscores not submitting to the website unless they are a person…
EliteMasterEric Apr 1, 2025
3bd79b8
Fix a deprecation warning.
EliteMasterEric Apr 1, 2025
f8b212a
Improve null safety of medal and leaderboard classes.
EliteMasterEric Apr 1, 2025
102ac4b
Fix a bug where restarting the level would add more Tankmen to the ba…
EliteMasterEric Apr 2, 2025
f935526
Update assets submodule
EliteMasterEric Apr 1, 2025
8291fe0
Make the back of ABot's stereo display slightly wider.
EliteMasterEric Apr 2, 2025
c94b3a3
2024 -> 2025 0.6.x changelog date fixins (closes FUNK-1740)
ninjamuffin99 Apr 2, 2025
52be941
Auto Pause -> Pause on Unfocus (was changed before but prob bad merge…
ninjamuffin99 Apr 2, 2025
6262188
data -> data.score
ninjamuffin99 Apr 2, 2025
9b5032e
quick patch for cory
ninjamuffin99 Apr 3, 2025
afb4a3d
Remove some unused/redundant debug hotkeys.
EliteMasterEric Apr 3, 2025
eb9c2c2
Fix Pixo's freeplay AFK animation not playing (properly this time).
EliteMasterEric Apr 3, 2025
c157338
Fix certain characters pixel icons not displaying properly in the cha…
EliteMasterEric Apr 3, 2025
68e9daf
Zero out the ABot visualizer before the song starts.
EliteMasterEric Apr 3, 2025
d31ef12
Use public submodule URLs (would be nice if this was automatic but oh…
EliteMasterEric Apr 4, 2025
a4870af
funkin null safe
Lasercar Apr 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "assets"]
path = assets
url = https://github.com/FunkinCrew/Funkin-assets-secret
url = https://github.com/FunkinCrew/Funkin.assets
[submodule "art"]
path = art
url = https://github.com/FunkinCrew/Funkin-art-secret
url = https://github.com/FunkinCrew/Funkin.art
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ All notable changes will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.2] - 2024-03-31
## [0.6.2] - 2025-03-31
### Added
- 0.6 credits list updated
### Fixed
- Additional shader fix for Stress Pico crashing at the end (was the same issue as Senpai Pico shader error, just in a different shaderfile)

## [0.6.1] - 2024-03-31
## [0.6.1] - 2025-03-31
### Fixed
- Hopefully Senpai Pico/Erect mix shader isn't brokey
- NG API encryption key was added proper, so medals + leaderboards posting should work

## [0.6.0] - 2024-03-31
## [0.6.0] - 2025-03-31
The Pit Stop 2 update!
### Added
- Added six (!) new playable songs! Check them out in the Freeplay menu for their respective characters.
Expand Down
2 changes: 1 addition & 1 deletion art
Submodule art updated 1 files
+17 −0 macos-universal.sh
10 changes: 10 additions & 0 deletions docs/COMPILING_MAC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Mac Compiling Guide + Considerations

There's a few extra considerations when compiling FNF for Mac that *we* have to handle when creating a wider release.
- [Creating a Universal Binary](#creating-a-universal-binary)
- Code-signing
- Notarizing

## Creating a Universal Binary

Run the `art/macos-universal.sh` script, which automatically compiles release versions of both arm64 and x86 of Funkin. You can also see there for reference of how it's done.
1 change: 1 addition & 0 deletions source/funkin/Highscore.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package funkin;
/**
* A core class which handles tracking score and combo for the current song.
*/
@:nullSafety
class Highscore
{
/**
Expand Down
26 changes: 19 additions & 7 deletions source/funkin/InitState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import funkin.api.newgrounds.NewgroundsClient;
*
* It should not contain any sprites or rendering.
*/
@:nullSafety
class InitState extends FlxState
{
/**
Expand Down Expand Up @@ -306,7 +307,7 @@ class InitState extends FlxState
*/
function startSong(songId:String, difficultyId:String = 'normal'):Void
{
var songData:funkin.play.song.Song = funkin.data.song.SongRegistry.instance.fetchEntry(songId);
var songData:Null<funkin.play.song.Song> = funkin.data.song.SongRegistry.instance.fetchEntry(songId);

if (songData == null)
{
Expand Down Expand Up @@ -343,6 +344,7 @@ class InitState extends FlxState
PlayStatePlaylist.campaignId = 'weekend1';
}

@:nullSafety(Off) // Cannot unify?
LoadingState.loadPlayState(
{
targetSong: songData,
Expand All @@ -357,7 +359,7 @@ class InitState extends FlxState
*/
function startLevel(levelId:String, difficultyId:String = 'normal'):Void
{
var currentLevel:funkin.ui.story.Level = funkin.data.story.level.LevelRegistry.instance.fetchEntry(levelId);
var currentLevel:Null<funkin.ui.story.Level> = funkin.data.story.level.LevelRegistry.instance.fetchEntry(levelId);

if (currentLevel == null)
{
Expand All @@ -373,17 +375,27 @@ class InitState extends FlxState
PlayStatePlaylist.isStoryMode = true;
PlayStatePlaylist.campaignScore = 0;

var targetSongId:String = PlayStatePlaylist.playlistSongIds.shift();
var targetSongId:Null<String> = PlayStatePlaylist.playlistSongIds.shift();

var targetSong:funkin.play.song.Song = SongRegistry.instance.fetchEntry(targetSongId);
var targetSong:Null<funkin.play.song.Song> = null;

if (targetSongId != null) targetSong = SongRegistry.instance.fetchEntry(targetSongId);

if (targetSongId == null)
{
startGameNormally();
return;
}

@:nullSafety(Off)
LoadingState.loadPlayState(
{
targetSong: targetSong,
targetDifficulty: difficultyId,
});
}

@:nullSafety(Off) // Meh, remove when flixel.system.debug.log.LogStyle is null safe
function setupFlixelDebug():Void
{
//
Expand Down Expand Up @@ -463,17 +475,17 @@ class InitState extends FlxState
#end
}

function defineSong():String
function defineSong():Null<String>
{
return MacroUtil.getDefine('SONG');
}

function defineLevel():String
function defineLevel():Null<String>
{
return MacroUtil.getDefine('LEVEL');
}

function defineDifficulty():String
function defineDifficulty():Null<String>
{
return MacroUtil.getDefine('DIFFICULTY');
}
Expand Down
3 changes: 2 additions & 1 deletion source/funkin/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import openfl.utils.AssetType;
/**
* A core class which handles determining asset paths.
*/
@:nullSafety
class Paths
{
static var currentLevel:Null<String> = null;
Expand Down Expand Up @@ -136,7 +137,7 @@ class Paths
* @param withExtension if it should return with the audio file extension `.mp3` or `.ogg`.
* @return String
*/
public static function inst(song:String, ?suffix:String = '', ?withExtension:Bool = true):String
public static function inst(song:String, ?suffix:String = '', withExtension:Bool = true):String
{
var ext:String = withExtension ? '.${Constants.EXT_SOUND}' : '';
return 'songs:assets/songs/${song.toLowerCase()}/Inst$suffix$ext';
Expand Down
6 changes: 6 additions & 0 deletions source/funkin/PlayerSettings.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ import flixel.util.FlxSignal.FlxTypedSignal;
/**
* A core class which represents the current player(s) and their controls and other configuration.
*/
@:nullSafety
class PlayerSettings
{
// TODO: Finish implementation of second player.
public static var numPlayers(default, null) = 0;
public static var numAvatars(default, null) = 0;
// TODO: Making both of these null makes a lot of errors with the controls.
// That'd explain why unplugging input devices can cause the game to crash?
@:nullSafety(Off)
public static var player1(default, null):PlayerSettings;
@:nullSafety(Off)
public static var player2(default, null):PlayerSettings;

public static var onAvatarAdd(default, null) = new FlxTypedSignal<PlayerSettings->Void>();
Expand Down Expand Up @@ -70,6 +75,7 @@ class PlayerSettings
/**
* Forcibly destroy the PlayerSettings singletons for each player.
*/
@:nullSafety(Off)
public static function reset():Void
{
player1 = null;
Expand Down
11 changes: 6 additions & 5 deletions source/funkin/Preferences.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import funkin.save.Save;
/**
* A core class which provides a store of user-configurable, globally relevant values.
*/
@:nullSafety
class Preferences
{
/**
Expand Down Expand Up @@ -44,7 +45,7 @@ class Preferences

static function get_naughtyness():Bool
{
return Save?.instance?.options?.naughtyness;
return Save?.instance?.options?.naughtyness ?? true;
}

static function set_naughtyness(value:Bool):Bool
Expand All @@ -63,7 +64,7 @@ class Preferences

static function get_downscroll():Bool
{
return Save?.instance?.options?.downscroll;
return Save?.instance?.options?.downscroll ?? false;
}

static function set_downscroll(value:Bool):Bool
Expand Down Expand Up @@ -101,7 +102,7 @@ class Preferences

static function get_zoomCamera():Bool
{
return Save?.instance?.options?.zoomCamera;
return Save?.instance?.options?.zoomCamera ?? true;
}

static function set_zoomCamera(value:Bool):Bool
Expand All @@ -120,7 +121,7 @@ class Preferences

static function get_debugDisplay():Bool
{
return Save?.instance?.options?.debugDisplay;
return Save?.instance?.options?.debugDisplay ?? false;
}

static function set_debugDisplay(value:Bool):Bool
Expand Down Expand Up @@ -180,7 +181,7 @@ class Preferences

static function get_unlockedFramerate():Bool
{
return Save?.instance?.options?.unlockedFramerate;
return Save?.instance?.options?.unlockedFramerate ?? false;
}

static function set_unlockedFramerate(value:Bool):Bool
Expand Down
1 change: 1 addition & 0 deletions source/funkin/api/newgrounds/Events.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import io.newgrounds.objects.events.Result;
/**
* Use Newgrounds to perform basic telemetry. Ignore if not logged in to Newgrounds.
*/
@:nullSafety
class Events
{
// Only allow letters, numbers, spaces, dashes, and underscores.
Expand Down
29 changes: 18 additions & 11 deletions source/funkin/api/newgrounds/Leaderboards.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,33 @@ package funkin.api.newgrounds;
import io.newgrounds.Call.CallError;
import io.newgrounds.objects.ScoreBoard as LeaderboardData;
import io.newgrounds.objects.events.Outcome;
import io.newgrounds.utils.ScoreBoardList;

class Leaderboards
{
public static function listLeaderboardData():Map<Leaderboard, LeaderboardData>
{
if (NewgroundsClient.instance.leaderboards == null)
var leaderboardList:Null<ScoreBoardList> = NewgroundsClient.instance.leaderboards;
if (leaderboardList == null)
{
trace('[NEWGROUNDS] Not logged in, cannot fetch medal data!');
return [];
}
else
{
var result:Map<Leaderboard, LeaderboardData> = [];

var result:Map<Leaderboard, LeaderboardData> = [];
for (leaderboardId in leaderboardList.keys())
{
var leaderboardData = leaderboardList.get(leaderboardId);
if (leaderboardData == null) continue;

for (leaderboardId in NewgroundsClient.instance.leaderboards.keys())
{
var leaderboardData = NewgroundsClient.instance.leaderboards.get(leaderboardId);
if (leaderboardData == null) continue;
// A little hacky, but it works.
result.set(cast leaderboardId, leaderboardData);
}

// A little hacky, but it works.
result.set(cast leaderboardId, leaderboardData);
return result;
}

return result;
}

/**
Expand All @@ -42,7 +46,10 @@ class Leaderboards

if (NewgroundsClient.instance.isLoggedIn())
{
var leaderboardData = NewgroundsClient.instance.leaderboards.get(leaderboard.getId());
var leaderboardList = NewgroundsClient.instance.leaderboards;
if (leaderboardList == null) return;

var leaderboardData:Null<LeaderboardData> = leaderboardList.get(leaderboard.getId());
if (leaderboardData != null)
{
leaderboardData.postScore(score, function(outcome:Outcome<CallError>):Void {
Expand Down
Loading
Loading