Skip to content

Commit de67faf

Browse files
Fix respawning for racing (#348)
* Fix respawning for racing * Also fix updating of struct in another place
1 parent 876189a commit de67faf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Uchu.World/Objects/Components/ReplicaComponents/RacingControlComponent.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,11 @@ private async Task OnPlayerLoad(Player player)
230230
RacingPlayerInfo playerInfo;
231231

232232
if (IsPlayerRegistered(player)) {
233-
playerInfo = Players.Find(info => info.Player.Id == player.Id);
233+
var playerInfoIndex = Players.FindIndex(info => info.Player.Id == player.Id);
234+
playerInfo = Players[playerInfoIndex];
234235
playerInfo.Player = player;
235236
playerInfo.PlayerLoaded = true;
237+
Players[playerInfoIndex] = playerInfo;
236238
} else {
237239
playerInfo = new RacingPlayerInfo
238240
{
@@ -378,8 +380,10 @@ private void LoadPlayerCar(Player player)
378380
VehicleId = car,
379381
});
380382

381-
var playerInfo = Players.Find(info => info.Player.Id == player.Id);
382-
playerInfo.Vehicle = car;
383+
var playerInfoIndex = Players.FindIndex(info => info.Player.Id == player.Id);
384+
var tempInfo = Players[playerInfoIndex];
385+
tempInfo.Vehicle = car;
386+
Players[playerInfoIndex] = tempInfo;
383387
}
384388

385389
private void InitRace()

0 commit comments

Comments
 (0)