Browse Source

Fix `PlayersAPI`'s deallocation bugs

pull/8/head
Anton Tarasenko 3 years ago
parent
commit
c06656a8dc
  1. 2
      sources/Players/Events/PlayerAPI_OnNewPlayer_Signal.uc
  2. 12
      sources/Players/PlayersAPI.uc

2
sources/Players/Events/PlayerAPI_OnNewPlayer_Signal.uc

@ -26,7 +26,7 @@ public final function Emit(EPlayer newPlayer)
nextSlot = GetNextSlot(); nextSlot = GetNextSlot();
while (nextSlot != none) while (nextSlot != none)
{ {
PlayerAPI_OnNewPlayer_Slot(nextSlot).connect(EPlayer(newPlayer.Copy())); PlayerAPI_OnNewPlayer_Slot(nextSlot).connect(newPlayer);
nextSlot = GetNextSlot(); nextSlot = GetNextSlot();
} }
CleanEmptySlots(); CleanEmptySlots();

12
sources/Players/PlayersAPI.uc

@ -72,8 +72,6 @@ protected function Finalizer()
* void <slot>(EPlayer newPlayer) * void <slot>(EPlayer newPlayer)
* *
* @param handle Base `EPlayer` interface for the newly connected player. * @param handle Base `EPlayer` interface for the newly connected player.
* Each handler will receive its own copy of `EPlayer` that has to
* be deallocated.
*/ */
/* SIGNAL */ /* SIGNAL */
public function PlayerAPI_OnNewPlayer_Slot OnNewPlayer( public function PlayerAPI_OnNewPlayer_Slot OnNewPlayer(
@ -93,7 +91,7 @@ public function PlayerAPI_OnNewPlayer_Slot OnNewPlayer(
* the disconnected player. * the disconnected player.
*/ */
/* SIGNAL */ /* SIGNAL */
public function PlayerAPI_OnLostPlayer_Slot OnLostPlayerHandle( public function PlayerAPI_OnLostPlayer_Slot OnLostPlayer(
AcediaObject receiver) AcediaObject receiver)
{ {
ConnectToConnectionService(); ConnectToConnectionService();
@ -185,10 +183,10 @@ private final function ConnectToConnectionService()
private final function AnnounceNewPlayer( private final function AnnounceNewPlayer(
ConnectionService.Connection newConnection) ConnectionService.Connection newConnection)
{ {
if (onNewPlayerSignal == none) { local EPlayer newPlayer;
return; newPlayer = FromController(newConnection.controllerReference);
} onNewPlayerSignal.Emit(newPlayer);
onNewPlayerSignal.Emit(FromController(newConnection.controllerReference)); _.memory.Free(newPlayer);
} }
private final function AnnounceLostPlayer( private final function AnnounceLostPlayer(

Loading…
Cancel
Save