예제 #1
0
function research()
{
    $sth = mysql_query("update researching set time=time-'1'");
    if (!$sth) {
        echo "Database failure!";
        return 0;
    }
    $sth = mysql_query("select r.*,t.* from researching r, tech t where r.t_id=t.t_id and r.time=0");
    if (!$sth) {
        echo "Database failure!";
        return 0;
    }
    while ($research = mysql_fetch_array($sth)) {
        ticker($research["uid"], "*lresearch.php*Your research has been finished!", "r");
        $sth1 = mysql_query("insert into research (uid,t_id) values ('" . $research["uid"] . "','" . $research["t_id"] . "')");
        if (!$sth1) {
            var_dump($research);
            echo "Database failure!";
        }
        $sth1 = mysql_query("delete from researching where uid='" . $research["uid"] . "'");
        if (!$sth1) {
            var_dump($research);
            echo "Database failure2!";
        }
        if ($research["special"] & COLONIST_BOOST) {
            ticker($research["uid"], "*lresearch.php*Your research has triggered a colonist boost!", "r");
            $sth1 = mysql_query("update ressources set colonists=colonists+5 where uid=" . $research["uid"]);
            if (!$sth1) {
                var_dump($research);
                echo "ERR::RESEARCH\n";
            }
        }
        $queue = get_research_queue($research["uid"]);
        if (sizeof($queue) > 0) {
            $next_tech = array_shift($queue);
            $sth1 = mysql_query("insert into researching (t_id,uid,time) select " . $next_tech . "," . $research["uid"] . ",t.com_time from tech t where t_id=" . $next_tech);
            if (!$sth1) {
                echo "ERR::INSERT QUEUE";
            }
            save_research_queue($research["uid"], array_values($queue));
        }
    }
}
예제 #2
0
function qmove()
{
    global $uid;
    $queue = get_research_queue($uid);
    if (sizeof($queue) <= 1) {
        return;
    }
    $done = false;
    for ($i = 0; $i < sizeof($queue) && !$done; $i++) {
        if ($queue[$i] == $_GET["tid"]) {
            if ($_GET["direction"] == "l" && $i != 0) {
                $tmp = $queue[$i];
                $queue[$i] = $queue[$i - 1];
                $queue[$i - 1] = $tmp;
                $done = true;
            } elseif ($_GET["direction"] == "r" && $i + 1 < sizeof($queue)) {
                $tmp = $queue[$i];
                $queue[$i] = $queue[$i + 1];
                $queue[$i + 1] = $tmp;
                $done = true;
            }
        }
    }
    save_research_queue($uid, array_values($queue));
}