mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 12:27:51 +00:00
Fixed a mini memory leak
This commit is contained in:
parent
7e4692aaf1
commit
07ac028558
@ -49,6 +49,11 @@ class ConsoleAPI{
|
|||||||
|
|
||||||
public function defaultCommands($cmd, $params){
|
public function defaultCommands($cmd, $params){
|
||||||
switch($cmd){
|
switch($cmd){
|
||||||
|
case "crash": //Crashes the server to generate an report
|
||||||
|
$this->callNotDefinedMethodCrash();
|
||||||
|
$this->server->api->server; //Access a private property
|
||||||
|
callNotExistingFunction();
|
||||||
|
break;
|
||||||
case "invisible":
|
case "invisible":
|
||||||
$p = strtolower(array_shift($params));
|
$p = strtolower(array_shift($params));
|
||||||
switch($p){
|
switch($p){
|
||||||
|
@ -27,7 +27,7 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
|
|
||||||
|
|
||||||
class Player{
|
class Player{
|
||||||
private $server, $timeout, $connected, $queue, $buffer;
|
private $server, $timeout, $connected, $queue, $buffer, $evid = array();
|
||||||
var $clientID, $ip, $port, $counter, $username, $eid, $data, $entity, $auth, $CID, $MTU, $spawned, $equipment;
|
var $clientID, $ip, $port, $counter, $username, $eid, $data, $entity, $auth, $CID, $MTU, $spawned, $equipment;
|
||||||
function __construct($server, $clientID, $ip, $port, $MTU){
|
function __construct($server, $clientID, $ip, $port, $MTU){
|
||||||
$this->queue = array();
|
$this->queue = array();
|
||||||
@ -44,8 +44,8 @@ class Player{
|
|||||||
$this->timeout = microtime(true) + 25;
|
$this->timeout = microtime(true) + 25;
|
||||||
$this->equipment = array(1, 0);
|
$this->equipment = array(1, 0);
|
||||||
$this->spawned = false;
|
$this->spawned = false;
|
||||||
$this->server->event("server.tick", array($this, "onTick"));
|
$this->evid[] = $this->server->event("server.tick", array($this, "onTick"));
|
||||||
$this->server->event("server.close", array($this, "close"));
|
$this->evid[] = $this->server->event("server.close", array($this, "close"));
|
||||||
console("[DEBUG] New Session started with ".$ip.":".$port.". MTU ".$this->MTU.", Client ID ".$this->clientID, true, true, 2);
|
console("[DEBUG] New Session started with ".$ip.":".$port.". MTU ".$this->MTU.", Client ID ".$this->clientID, true, true, 2);
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
$this->auth = false;
|
$this->auth = false;
|
||||||
@ -92,6 +92,9 @@ class Player{
|
|||||||
|
|
||||||
public function close($reason = "", $msg = true){
|
public function close($reason = "", $msg = true){
|
||||||
if($this->connected === true){
|
if($this->connected === true){
|
||||||
|
foreach($this->evid as $ev){
|
||||||
|
$this->server->deleteEvent($ev);
|
||||||
|
}
|
||||||
$this->server->api->dhandle("player.quit", $this);
|
$this->server->api->dhandle("player.quit", $this);
|
||||||
$reason = $reason == "" ? "server stop":$reason;
|
$reason = $reason == "" ? "server stop":$reason;
|
||||||
$this->save();
|
$this->save();
|
||||||
@ -323,14 +326,14 @@ class Player{
|
|||||||
$this->entity->data["clientID"] = $this->clientID;
|
$this->entity->data["clientID"] = $this->clientID;
|
||||||
$this->server->api->entity->spawnAll($this);
|
$this->server->api->entity->spawnAll($this);
|
||||||
$this->server->api->entity->spawnToAll($this->eid);
|
$this->server->api->entity->spawnToAll($this->eid);
|
||||||
$this->server->event("server.timee", array($this, "eventHandler"));
|
$this->evid[] = $this->server->event("server.timee", array($this, "eventHandler"));
|
||||||
$this->server->event("server.chat", array($this, "eventHandler"));
|
$this->evid[] = $this->server->event("server.chat", array($this, "eventHandler"));
|
||||||
$this->server->event("entity.remove", array($this, "eventHandler"));
|
$this->evid[] = $this->server->event("entity.remove", array($this, "eventHandler"));
|
||||||
$this->server->event("entity.move", array($this, "eventHandler"));
|
$this->evid[] = $this->server->event("entity.move", array($this, "eventHandler"));
|
||||||
$this->server->event("entity.animate", array($this, "eventHandler"));
|
$this->evid[] = $this->server->event("entity.animate", array($this, "eventHandler"));
|
||||||
$this->server->event("player.equipment.change", array($this, "eventHandler"));
|
$this->evid[] = $this->server->event("player.equipment.change", array($this, "eventHandler"));
|
||||||
$this->server->event("player.pickup", array($this, "eventHandler"));
|
$this->evid[] = $this->server->event("player.pickup", array($this, "eventHandler"));
|
||||||
$this->server->event("block.change", array($this, "eventHandler"));
|
$this->evid[] = $this->server->event("block.change", array($this, "eventHandler"));
|
||||||
console("[DEBUG] Player with EID ".$this->eid." \"".$this->username."\" spawned!", true, true, 2);
|
console("[DEBUG] Player with EID ".$this->eid." \"".$this->username."\" spawned!", true, true, 2);
|
||||||
|
|
||||||
$this->eventHandler(new Container($this->server->motd), "server.chat");
|
$this->eventHandler(new Container($this->server->motd), "server.chat");
|
||||||
|
@ -541,7 +541,7 @@ class PocketMinecraftServer{
|
|||||||
$add = ' unset($this->schedule['.$this->scheduleCnt.']);';
|
$add = ' unset($this->schedule['.$this->scheduleCnt.']);';
|
||||||
}
|
}
|
||||||
$this->schedule[$this->scheduleCnt] = array($callback, $data, $eventName);
|
$this->schedule[$this->scheduleCnt] = array($callback, $data, $eventName);
|
||||||
$this->action(50000 * $ticks, '$schedule = $this->schedule['.$this->scheduleCnt.'];'.$add.'if(!is_callable($schedule[0])){unset($this->schedule['.$this->scheduleCnt.']);return;} call_user_func($schedule[0], $schedule[1], $schedule[2]);', (bool) $repeat);
|
$this->action(50000 * $ticks, '$schedule = $this->schedule['.$this->scheduleCnt.'];'.$add.'if(!is_callable($schedule[0])){unset($this->schedule['.$this->scheduleCnt.']);return false;} call_user_func($schedule[0], $schedule[1], $schedule[2]);', (bool) $repeat);
|
||||||
return $this->scheduleCnt++;
|
return $this->scheduleCnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,8 +561,8 @@ class PocketMinecraftServer{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while(false !== ($action = $actions->fetchArray(SQLITE3_ASSOC))){
|
while(false !== ($action = $actions->fetchArray(SQLITE3_ASSOC))){
|
||||||
eval(base64_decode($action["code"]));
|
$return = eval(base64_decode($action["code"]));
|
||||||
if($action["repeat"] === 0){
|
if($action["repeat"] === 0 or $return === false){
|
||||||
$this->query("DELETE FROM actions WHERE ID = ".$action["ID"].";");
|
$this->query("DELETE FROM actions WHERE ID = ".$action["ID"].";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user