Server: Removed identifiers array

This is completely unnecessary and adds extra complexity for no good reason. Maybe it was used historically, but nowadays it is only used to identify players to send async-prepared batch packets to.

There are two alternative ways to do that:
1. use spl_object_hash() as the targets array in CompressBatchedTask
2. use ServerScheduler's object storage to retain references to the Player[] array.

I've opted for the second method.

Removing these identifiers allows great code simplification in removePlayer() and removes the need for those old stupid hacks.

This also includes a backwards-compatibility break by removing the $identifier parameter of Server->addPlayer().
This commit is contained in:
Dylan K. Taylor
2018-02-27 11:43:02 +00:00
parent e0d5c79848
commit f903dbfe00
3 changed files with 21 additions and 37 deletions

View File

@ -134,7 +134,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
$this->players[$identifier] = $player;
$this->identifiersACK[$identifier] = 0;
$this->identifiers[spl_object_hash($player)] = $identifier;
$this->server->addPlayer($identifier, $player);
$this->server->addPlayer($player);
}
public function handleEncapsulated(string $identifier, EncapsulatedPacket $packet, int $flags) : void{