Пример #1
0
function proc_leave()
{
    global $uid;
    if (has_alliance_lock($uid)) {
        show_message("You can't use any alliance options due to an alliance lock!");
        return false;
    }
    $sth = mysql_query("select u.alliance from users u, alliance a where a.id = u.alliance and u.id not in (a.milminister, a.leader, a.forminister, a.devminister) and u.id=" . $uid);
    if (!$sth) {
        show_message("Database Failure C1");
        return 0;
    }
    if (mysql_num_rows($sth) == 0) {
        show_message("AgaFu Bloeck");
        return 0;
    }
    if (!remove_from_alliance($uid)) {
        show_error("ERR::REMOVE FROM ALLIANCE");
        return false;
    }
    $homeworld = get_homeworld($uid);
    // mop: eigentlich suboptimal. dann kommt die ganze flotte zum heimatplaneten (also auch kriegsschiffe)
    $sth = mysql_query("update fleet_info set sid=" . get_sid_by_pid($homeworld) . ",pid={$homeworld} where uid={$uid}");
    if (!$sth) {
        show_error("Database failure!");
    }
    show_message("Your fleets have been moved to your homeplanet!");
    show_message("You have left the alliance");
}
 function get_battles()
 {
     if (SIMULATION_MODE) {
         $sth = mysql_query("select distinct side from battle_" . $GLOBALS["sim_uid"]);
         if (!$sth || mysql_num_rows($sth) != 2) {
             return false;
         } else {
             return array("0" => "0");
         }
     } else {
         $battles = array();
         $sth = mysql_query("select distinct f1.sid,f1.pid from fleet_info f1,fleet_info f2, users u1, users u2,diplomacy d where f1.pid=f2.pid and f1.sid=f2.sid and f1.fid!=f2.fid and f1.uid!=f2.uid and u1.id=f1.uid and u2.id=f2.uid and d.alliance1=u1.alliance and d.alliance2=u2.alliance and d.status=0");
         if (!$sth) {
             return false;
         }
         while (list($sid, $pid) = mysql_fetch_row($sth)) {
             $battles[] = array($sid, $pid);
         }
         $sth = mysql_query("select distinct p.id,p.sid from planets p, fleet_info f,users u1, users u2,diplomacy d where f.sid=p.sid and f.pid=p.id and u1.id=p.uid and u2.id=f.uid and d.alliance1=u1.alliance and d.alliance2=u2.alliance and d.status=0 and f.mission in (1,2)");
         if (!$sth) {
             return false;
         }
         while (list($pid, $sid) = mysql_fetch_row($sth)) {
             if (!in_array(array($sid, $pid), $battles)) {
                 $battles[] = array($sid, $pid);
             }
         }
         $sth = mysql_query("select distinct i1.pid from infantery i1, infantery i2, users u1, users u2,diplomacy d where i1.pid=i2.pid and u1.id=i1.uid and u2.id=i2.uid and d.alliance1=u1.alliance and d.alliance2=u2.alliance and d.status=0");
         if (!$sth) {
             return false;
         }
         while (list($pid) = mysql_fetch_row($sth)) {
             if (!in_array(array($sid, $pid), $battles)) {
                 $battles[] = array(get_sid_by_pid($pid), $pid);
             }
         }
         return $battles;
     }
 }
Пример #3
0
function can_scan_planet_surface($pid)
{
    global $map_info;
    global $uid;
    $can_scan = false;
    $sid = get_sid_by_pid($pid);
    // planetary shield und defence masquerader (15 & 38) können planeten scan verhindern)
    $sth = mysql_query("select distinct 1 from constructions where pid='" . $pid . "' and (prod_id=15 or prod_id=38)");
    if (!$sth) {
        return false;
    }
    if (mysql_num_rows($sth) == 0) {
        $allies = $map_info->get_allies();
        $allies[] = $uid;
        // probe sowie dreamcatcher können die planetenoberfläche scannen
        $sth = mysql_query("select distinct 1 from fleet_info fi join fleet f using(fid) where fi.uid in (" . implode(",", $allies) . ") and fi.pid = '" . $pid . "' and (f.prod_id = 3 or f.prod_id = 35)");
        if (!$sth) {
            return false;
        }
        if (mysql_num_rows($sth) > 0) {
            $can_scan = true;
        }
    }
    return $can_scan;
}
Пример #4
0
function oproduction()
{
    global $uid;
    global $pid;
    global $prod_id;
    global $skin;
    $sth = mysql_query("######################## oproduction ###########################");
    $sth = mysql_query("select * from constructions where prod_id={$prod_id} and pid={$pid} and type=1");
    if (mysql_num_rows($sth) > 0) {
        show_error("You've already build this building on this planet!");
        return 0;
    }
    $sth = mysql_query("select uid from planets where id={$pid}");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    $user_id = mysql_fetch_array($sth);
    if ($user_id["uid"] != $uid) {
        show_error("I'm not stupid man!");
        return 0;
    }
    $sth = mysql_query("select p.* from production as p,research as r left join constructions as b on p.prod_id=b.prod_id and b.pid={$pid} and b.type=1 where (p.typ='O' or p.typ='R') and p.tech=r.t_id and r.uid={$uid} and p.prod_id={$prod_id} and b.prod_id is NULL");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    if (mysql_num_rows($sth) == 0) {
        show_error("If you try to hack the links i can tell you that you'll always fail:)");
        return 0;
    }
    $prod = mysql_fetch_array($sth);
    if ($prod["p_depend"] != NULL) {
        if (!construction_exists($prod["p_depend"], $pid)) {
            show_error("Damn Hacker:)");
            return 0;
        }
    }
    $sth = mysql_query("select special from production where prod_id={$prod_id} and special!=''");
    if (mysql_num_rows($sth) > 0) {
        $special = mysql_fetch_array($sth);
        switch ($special["special"]) {
            case "U":
                $sth = mysql_query("select * from constructions as o,planets as p where o.prod_id=" . $prod_id . " and o.pid=p.id and o.type=1 and p.uid=" . $uid);
                if (mysql_num_rows($sth) != 0) {
                    show_error("You can only build this orbital on ONE planet!");
                    return 0;
                }
                $sth = mysql_query("select * from o_production o, planets p where o.prod_id=" . $prod_id . " and o.planet_id=p.id and p.uid=" . $uid);
                if (mysql_num_rows($sth) != 0) {
                    show_error("You can only build this orbital on ONE planet!");
                    return 0;
                }
                break;
            case "S":
                $sid = get_sid_by_pid($pid);
                $sth = mysql_query("select * from constructions as o,planets as p where p.sid=" . $sid . " and o.pid=p.id and o.type=1 and o.prod_id=" . $prod_id);
                if (!$sth) {
                    show_error("Database failure!");
                    return 0;
                }
                if (mysql_num_rows($sth) > 0) {
                    show_message("You can only build this orbital one time per system");
                    return 0;
                }
        }
    }
    $sth = mysql_query("select * from ressources where uid='{$uid}' and if(metal<0,0,metal)>=" . $prod["metal"] . " and if(energy<0,0,energy)>=" . $prod["energy"] . " and if(mopgas<0,0,mopgas)>=" . $prod["mopgas"] . " and if(erkunum<0,0,erkunum)>=" . $prod["erkunum"] . " and if(gortium<0,0,gortium)>=" . $prod["gortium"] . " and if(susebloom<0,0,susebloom)>=" . $prod["susebloom"]);
    if (mysql_num_rows($sth) == 0) {
        show_error("You don't have enough ressources to build this structure!");
        return 0;
    }
    $sth = mysql_query("select com_time from production where prod_id={$prod_id}");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    $time = mysql_fetch_array($sth);
    $sth = mysql_query("select prod_id from o_production where planet_id={$pid} and prod_id={$prod_id}");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    if (mysql_num_rows($sth) > 0) {
        show_error("You are already building this building here!");
        return 0;
    }
    $sth = mysql_query("select max(pos) from o_production where planet_id={$pid}");
    if (!$sth) {
        show_error("Database failure!");
        return 0;
    }
    $max_pos = mysql_fetch_row($sth);
    if ($max_pos[0] == NULL) {
        $max_pos[0] = 0;
    }
    $sth = mysql_query("insert into o_production (prod_id,planet_id,time,pos) values ('{$prod_id}','{$pid}','" . $time["com_time"] . "','" . ($max_pos[0] + 1) . "')");
    if ($max_pos[0] == 0) {
        $sth = mysql_query("update ressources set metal=metal-" . $prod["metal"] . ",energy=energy-" . $prod["energy"] . ",mopgas=mopgas-" . $prod["mopgas"] . ",erkunum=erkunum-" . $prod["erkunum"] . ",gortium=gortium-" . $prod["gortium"] . ",susebloom=susebloom-" . $prod["susebloom"] . " where uid={$uid}");
    }
    $sth = mysql_query("######################## oproduction ENDE ###########################");
}
Пример #5
0
function startup()
{
    global $uid;
    global $ses;
    global $globalTranslate;
    $availHeight = $_GET["availHeight"];
    $availWidth = $_GET["availWidth"];
    $globalTranslate = get_global_SVGTransform($uid, 0, 0, $availHeight, $availWidth);
    $ses->reg("globalTranslate");
    $universe = new universe();
    $cids = $universe->get_surrounding_constellations(get_cid_by_sid(get_sid_by_pid(get_homeworld($uid))));
    $GLOBALS["map_info"] = new map_info($uid, $cids);
    get_svg_stars_of_cids($cids, $fleet_symbols, $fleet_routes, $scans, $systems);
    echo "<g id=\"startranslate\" transform=\"translate(" . $globalTranslate . ")\">";
    // runelord: zuerst die scans, damit die nix verdecken
    echo "<g id=\"fleet_scans\">\n";
    echo $scans;
    echo "</g>\n";
    // mop: dann die constellationen malen, damit die sterne drüberliegen können
    echo "<g id=\"constellationgrid\">";
    constellation_grid();
    echo "</g>";
    echo "<g id=\"stars\">";
    echo $systems;
    echo "</g>";
    echo "<g id=\"flottenpfade\">\n";
    echo $fleet_routes;
    echo "</g>\n";
    echo "<g id=\"fleet_symbols\">\n";
    echo $fleet_symbols;
    echo "</g>\n";
    echo "</g>";
    $coords = $universe->get_coords_by_cids($cids);
    $translate = explode(" ", $globalTranslate);
    echo "\n<!-- " . ($coords[0] + $translate[0]) . " " . ($coords[1] + $translate[0]) . " " . ($coords[2] + $translate[1]) . " " . ($coords[3] + $translate[1]) . " -->";
}