Fixed no events

This commit is contained in:
Shoghi Cervantes Pueyo 2012-12-17 20:20:07 +01:00
parent f42f2d5e82
commit 6eb37ac72f
3 changed files with 8 additions and 3 deletions

1
TODO
View File

@ -3,3 +3,4 @@
- Mob spawning, item pick up - Mob spawning, item pick up
- Fix metadata orientation - Fix metadata orientation
- Proper session checks - Proper session checks
- Fix incorrect timeout

View File

@ -159,7 +159,6 @@ class ChunkParser{
$this->map[$x] = array(); $this->map[$x] = array();
for($z = 0; $z < 16; ++$z){ for($z = 0; $z < 16; ++$z){
$this->map[$x][$z] = $this->parseChunk($x, $z); $this->map[$x][$z] = $this->parseChunk($x, $z);
console("[INTERNAL] Chunk X ".$x." Z ".$z." loaded", true, true, 3);
} }
} }
console("[DEBUG] Chunks loaded!", true, true, 2); console("[DEBUG] Chunks loaded!", true, true, 2);

View File

@ -189,11 +189,12 @@ class PocketMinecraftServer extends stdClass{
$priority = (int) $priority; $priority = (int) $priority;
$this->handlers[$this->handCnt] = $callable; $this->handlers[$this->handCnt] = $callable;
$this->query("INSERT INTO handlers (ID, name, priority) VALUES (".$this->handCnt.", '".str_replace("'", "\\'", $event)."', ".$priority.");"); $this->query("INSERT INTO handlers (ID, name, priority) VALUES (".$this->handCnt.", '".str_replace("'", "\\'", $event)."', ".$priority.");");
console("[INTERNAL] New handler ".(is_array($func) ? get_class($func[0])."::".$func[1]:$func)." to special event ".$event." (ID ".$this->handCnt.")", true, true, 3); console("[INTERNAL] New handler ".(is_array($callable) ? get_class($callable[0])."::".$callable[1]:$callable)." to special event ".$event." (ID ".$this->handCnt.")", true, true, 3);
return $this->handCnt++; return $this->handCnt++;
} }
public function handle($event, &$data){ public function handle($event, &$data){
$this->preparedSQL->selectHandlers->clear();
$this->preparedSQL->selectHandlers->bindValue(1, $event, SQLITE3_TEXT); $this->preparedSQL->selectHandlers->bindValue(1, $event, SQLITE3_TEXT);
$handlers = $this->preparedSQL->selectHandlers->execute(); $handlers = $this->preparedSQL->selectHandlers->execute();
if($handlers === false or $handlers === true){ if($handlers === false or $handlers === true){
@ -416,6 +417,7 @@ class PocketMinecraftServer extends stdClass{
} }
public function trigger($event, $data = ""){ public function trigger($event, $data = ""){
$this->preparedSQL->selectEvents->clear();
$this->preparedSQL->selectEvents->bindValue(1, $event, SQLITE3_TEXT); $this->preparedSQL->selectEvents->bindValue(1, $event, SQLITE3_TEXT);
$events = $this->preparedSQL->selectEvents->execute(); $events = $this->preparedSQL->selectEvents->execute();
if($events === false or $events === true){ if($events === false or $events === true){
@ -445,8 +447,10 @@ class PocketMinecraftServer extends stdClass{
public function tickerFunction($time){ public function tickerFunction($time){
//actions that repeat every x time will go here //actions that repeat every x time will go here
$this->preparedSQL->selectActions->clear();
$this->preparedSQL->selectActions->bindValue(1, $time, SQLITE3_FLOAT); $this->preparedSQL->selectActions->bindValue(1, $time, SQLITE3_FLOAT);
$actions = $this->preparedSQL->selectActions->execute(); $actions = $this->preparedSQL->selectActions->execute();
if($actions === false or $actions === true){ if($actions === false or $actions === true){
return; return;
} }
@ -456,6 +460,7 @@ class PocketMinecraftServer extends stdClass{
$this->query("DELETE FROM actions WHERE ID = ".$action["ID"].";"); $this->query("DELETE FROM actions WHERE ID = ".$action["ID"].";");
} }
} }
$this->preparedSQL->updateActions->clear();
$this->preparedSQL->updateActions->bindValue(":time", $time, SQLITE3_FLOAT); $this->preparedSQL->updateActions->bindValue(":time", $time, SQLITE3_FLOAT);
$this->preparedSQL->updateActions->execute(); $this->preparedSQL->updateActions->execute();
} }