Fixed entities being updated when they shouldn't

This commit is contained in:
Shoghi Cervantes 2013-06-05 12:11:04 +02:00
parent 2dd188a0bd
commit a5bc95e733
2 changed files with 4 additions and 7 deletions

View File

@ -48,6 +48,7 @@ class EntityAPI{
public function updateEntities(){ public function updateEntities(){
$l = $this->server->query("SELECT EID FROM entities WHERE hasUpdate = 1;"); $l = $this->server->query("SELECT EID FROM entities WHERE hasUpdate = 1;");
$this->server->query("UPDATE entities SET hasUpdate = 0;");
if($l !== false and $l !== true){ if($l !== false and $l !== true){
while(($e = $l->fetchArray(SQLITE3_ASSOC)) !== false){ while(($e = $l->fetchArray(SQLITE3_ASSOC)) !== false){
$e = $this->get($e["EID"]); $e = $this->get($e["EID"]);
@ -128,9 +129,9 @@ class EntityAPI{
"x" => $pos->x, "x" => $pos->x,
"y" => $pos->y + 0.19, "y" => $pos->y + 0.19,
"z" => $pos->z, "z" => $pos->z,
"speedX" => mt_rand(-3, 3) / 8, //"speedX" => mt_rand(-3, 3) / 8,
"speedY" => mt_rand(5, 8) / 1.5, "speedY" => mt_rand(5, 8) / 2,
"speedZ" => mt_rand(-3, 3) / 8, //"speedZ" => mt_rand(-3, 3) / 8,
"item" => $item, "item" => $item,
); );
if($this->server->api->handle("item.drop", $data) !== false){ if($this->server->api->handle("item.drop", $data) !== false){

View File

@ -498,11 +498,7 @@ class PocketMinecraftServer{
if(!is_callable($callback)){ if(!is_callable($callback)){
return false; return false;
} }
$add = "";
$chcnt = $this->scheduleCnt++; $chcnt = $this->scheduleCnt++;
if($repeat === false){
$add = '$this->schedule['.$chcnt.']=null;unset($this->schedule['.$chcnt.']);';
}
$this->schedule[$chcnt] = array($callback, $data, $eventName); $this->schedule[$chcnt] = array($callback, $data, $eventName);
$this->query("INSERT INTO actions (ID, interval, last, repeat) VALUES(".$chcnt.", ".($ticks / 20).", ".microtime(true).", ".(((bool) $repeat) === true ? 1:0).");"); $this->query("INSERT INTO actions (ID, interval, last, repeat) VALUES(".$chcnt.", ".($ticks / 20).", ".microtime(true).", ".(((bool) $repeat) === true ? 1:0).");");
return $chcnt; return $chcnt;