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();
while (nextSlot != none)
{
PlayerAPI_OnNewPlayer_Slot(nextSlot).connect(EPlayer(newPlayer.Copy()));
PlayerAPI_OnNewPlayer_Slot(nextSlot).connect(newPlayer);
nextSlot = GetNextSlot();
}
CleanEmptySlots();

12
sources/Players/PlayersAPI.uc

@ -72,8 +72,6 @@ protected function Finalizer()
* void <slot>(EPlayer newPlayer)
*
* @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 */
public function PlayerAPI_OnNewPlayer_Slot OnNewPlayer(
@ -93,7 +91,7 @@ public function PlayerAPI_OnNewPlayer_Slot OnNewPlayer(
* the disconnected player.
*/
/* SIGNAL */
public function PlayerAPI_OnLostPlayer_Slot OnLostPlayerHandle(
public function PlayerAPI_OnLostPlayer_Slot OnLostPlayer(
AcediaObject receiver)
{
ConnectToConnectionService();
@ -185,10 +183,10 @@ private final function ConnectToConnectionService()
private final function AnnounceNewPlayer(
ConnectionService.Connection newConnection)
{
if (onNewPlayerSignal == none) {
return;
}
onNewPlayerSignal.Emit(FromController(newConnection.controllerReference));
local EPlayer newPlayer;
newPlayer = FromController(newConnection.controllerReference);
onNewPlayerSignal.Emit(newPlayer);
_.memory.Free(newPlayer);
}
private final function AnnounceLostPlayer(

Loading…
Cancel
Save