mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Fixed random entity memory leak + loops
This commit is contained in:
parent
6660a0a771
commit
237ad4eee4
@ -585,7 +585,7 @@ class PocketMinecraftServer{
|
||||
$add = ' unset($this->schedule['.$chcnt.']);';
|
||||
}
|
||||
$this->schedule[$chcnt] = array($callback, $data, $eventName);
|
||||
$this->action(50000 * $ticks, '$schedule = $this->schedule['.$chcnt.'];'.$add.'if(!is_callable($schedule[0])){unset($this->schedule['.$chcnt.']);return false;} call_user_func($schedule[0], $schedule[1], $schedule[2]);', (bool) $repeat);
|
||||
$this->action(50000 * $ticks, '$schedule = $this->schedule['.$chcnt.'];'.$add.'if(!is_callable($schedule[0])){unset($this->schedule['.$chcnt.']);return false;} return call_user_func($schedule[0], $schedule[1], $schedule[2]);', (bool) $repeat);
|
||||
return $chcnt;
|
||||
}
|
||||
|
||||
|
@ -80,9 +80,12 @@ class Entity extends stdClass{
|
||||
}
|
||||
|
||||
public function update(){
|
||||
if($this->closed === true){
|
||||
return false;
|
||||
}
|
||||
$this->calculateVelocity();
|
||||
$this->server->api->dhandle("entity.move", $this);
|
||||
if($this->class === ENTITY_ITEM and $this->closed === false and $this->server->gamemode === 0){
|
||||
if($this->class === ENTITY_ITEM and $this->server->gamemode === 0){
|
||||
$player = $this->server->query("SELECT EID FROM entities WHERE class == ".ENTITY_PLAYER." AND abs(x - {$this->x}) <= 1.5 AND abs(y - {$this->y}) <= 1.5 AND abs(z - {$this->z}) <= 1.5 LIMIT 1;", true);
|
||||
if($player !== true and $player !== false){
|
||||
if($this->server->api->dhandle("player.pickup", array(
|
||||
@ -93,6 +96,7 @@ class Entity extends stdClass{
|
||||
"target" => $this->eid
|
||||
)) !== false){
|
||||
$this->close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user