After the recent update to version 31.00, many people encountered the following warning:
This warning is mostly found in Persistent functions, as everyone follows the official documentation. However, the official documentation has not been updated and no solution has been provided.
I don’t want my game dropping dead after the next engine update. I found some solutions to avoid this risk:
1. First, we need to remove all the <unique>
effect from warning methods
2. Then, We need to add a <transacts>
effect to all DebugString methods
Now the stat type class and module will like this:
You will then notice a mistake in the Record Stat’s method below:
3. In each if()
where an error occurs, add .DebugString()
after the Stat class
That is, not directly comparing classes, but using the Debug function in the class for comparison.
The code snippet after repair:
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# Represents an abstract stat to update using RecordPlayerStat.
# The class has the unique specifier to make instances of the class comparable.
# The class has the computes specifier to be able to instantiate it at module-scope.
# The class has the abstract specifier so it cannot be instantiated directly, and
# requires subclasses to implement any non-initialized functions, like DebugString().
stat_type := class<computes><abstract>:
DebugString()<transacts>:string
# we uses instances of stat_type subclasses instead of the enum type
# so we can add more stat_types after the initial published version of the project.
StatType := module:
round_stat<public> := class<computes>(stat_type):
DebugString<override>()<transacts>:string = "Round Count"
round_win_stat<public> := class<computes>(stat_type):
DebugString<override>()<transacts>:string = "Round Win Count"
# Instances of each stat_type
RoundsCount<public>:round_stat = round_stat{}
RoundWin<public>:round_win_stat = round_win_stat{}
# Manages and updates player_stat_tables for each player.
player_stats_manager := class():
# Return the player_stats_table for the provided Agent.
GetPlayerStats(Agent:agent)<decides><transacts>:player_stats_table=
var PlayerStats:player_stats_table = player_stats_table{}
if:
Player := player[Agent]
PlayerStatsTable := PlayerStatsMap[Player]
set PlayerStats = MakePlayerStatsTable(PlayerStatsTable)
PlayerStats
# Initialize stats for all current players.
InitializeAllPlayers(Players:[]player):void =
for (Player : Players):
InitializePlayer(Player)
# Initialize stats for the given player.
InitializePlayer(Player:player):void=
if:
not PlayerStatsMap[Player]
set PlayerStatsMap[Player] = player_stats_table{}
# Update the given stat for the given player by creating a new
# player_stats_table and setting it in the PlayerStatsMap.
RecordPlayerStat(Agent:agent, Stat:stat_type, ?Score:float = 1200.0, ?Langue: Language = Language.En):void=
if:
Player := player[Agent]
PlayerStatsTable := PlayerStatsMap[Player]
if(Stat.DebugString() = StatType.RoundsCount.DebugString()):
RoundStat := PlayerStatsTable.RoundsCount
set PlayerStatsMap[Player] = player_stats_table:
MakePlayerStatsTable<constructor>(PlayerStatsTable)
RoundsCount := MakeUpdatedPlayerStat(RoundStat, RoundStat.CurrentValue+1)
else if(Stat.DebugString() = StatType.RoundWin.DebugString()):
WinRounds := PlayerStatsTable.WinCount
set PlayerStatsMap[Player] = player_stats_table:
MakePlayerStatsTable<constructor>(PlayerStatsTable)
WinCount := MakeUpdatedPlayerStat(WinRounds, WinRounds.CurrentValue+1)