Location: PHPKode > projects > PhpBlock > A9.8/modules/dungeon/tick/DungeonRemoveOldImageTick.php
<?php
include_once $PATH_TO_CODE."/modules/dungeon/tick/allincludefortick.php";

class DungeonRemoveOldImageTick extends Tick {
    public function getName() {
        return "image rock creation";
    }
    public function run() {

        global $gloObjectManager;

        $locBlockImageToGenerate = 50;

        $resBlock = executer("SELECT blockId FROM blockInfo WHERE value=1
            AND type1=".DungeonConstante::$BLOCK_INFO_TYPE1_ROCK_IMAGE.
            " AND type2=".DungeonConstante::$BLOCK_INFO_TYPE2_ROCK_HAS_BEEN_MODIFIED.
            " ORDER BY blockId LIMIT  $locBlockImageToGenerate");
        if(mysql_affected_rows() > 0) {
	        executer("UPDATE blockInfo SET value=0 WHERE value=1
	            AND type1=".DungeonConstante::$BLOCK_INFO_TYPE1_ROCK_IMAGE.
	            " AND type2=".DungeonConstante::$BLOCK_INFO_TYPE2_ROCK_HAS_BEEN_MODIFIED.
	            " ORDER BY blockId LIMIT $locBlockImageToGenerate");

			$locListBlockId = array();
	        
	        while($row = mysql_fetch_array($resBlock)) {
	            $locBlockId = $row[0];
	            if(!in_array($locBlockId, $locListBlockId)) {
	                array_push($locListBlockId, $locBlockId);
	            }
	        }
	        
	        foreach($locListBlockId as $locBlockId) {
	            $locBlock = $gloObjectManager->getBlock($locBlockId);
	            $locBlock->createRockImage(Constante::$BLOCK_IMAGE_SIZE);
	        }
	
	        if(count($locListBlockId) > 0) {
	            $locListBlockIdWhereClause = implode(",", $locListBlockId);
	            executer("UPDATE blockInfo SET value=value+1
	                WHERE blockId IN ($locListBlockIdWhereClause)
	                  AND type1=".DungeonConstante::$BLOCK_INFO_TYPE1_ROCK_IMAGE.
	                " AND type2=".DungeonConstante::$BLOCK_INFO_TYPE2_ROCK_IMAGE_MODIFIER_COUNT);
	            executer("UPDATE blockInfo SET value=".time().
	              " WHERE blockId IN ($locListBlockIdWhereClause)
	                  AND type1=".DungeonConstante::$BLOCK_INFO_TYPE1_ROCK_IMAGE.
	                " AND type2=".DungeonConstante::$BLOCK_INFO_TYPE2_ROCK_IMAGE_TIMESTAMP);
	        }
        }
	}
}
?>
Return current item: PhpBlock