function combat_store($pid, $commit) { global $combat; if (COMBAT_VERBOSE) { echo "Werte Ergebnisse aus..." . COMBAT_NEWLINE; start_timer(1); } $query = $GLOBALS["db"]->query("SELECT uid, fid, prod_id, special, category, killed_special, SUM(count_max-count) \nAS destroyed FROM combat GROUP BY uid, fid, prod_id, special, category, killed_special HAVING destroyed>0") or die("DEST1: " . $GLOBALS["db"]->error); if (!$query) { return false; } while ($result = $query->fetch_assoc()) { switch ($result["category"]) { // Schiffchens case 1: if ($result["killed_special"] != "E") { $sql = "UPDATE fleet SET count=count-" . $result["destroyed"] . " WHERE fid=" . $result["fid"] . " AND prod_id=" . $result["prod_id"]; combat_store_commit($sql, $commit); } break; // Trüppchens (Planet) // Trüppchens (Planet) case 2: $sql = "UPDATE infantery SET count=count-" . $result["destroyed"] . " WHERE pid=" . $pid . " AND uid=" . $result["uid"] . " AND prod_id=" . $result["prod_id"]; combat_store_commit($sql, $commit); break; // Gebäude // Gebäude case 3: switch ($result["killed_special"][0]) { case "H": // Planetare Schilde entfernen $sql = "DELETE FROM planetary_shields WHERE pid=" . $pid . " AND prod_id = " . $result["prod_id"]; combat_store_commit($sql, $commit); break; case "T": // rune: Tradestation entfernen $sql = "DELETE FROM tradestations WHERE uid = " . $result["uid"]; combat_store_commit($sql, $commit); $sql = "DELETE FROM stockmarket_orders WHERE uid = " . $result["uid"]; combat_store_commit($sql, $commit); break; } $sql = "DELETE FROM constructions WHERE pid=" . $pid . " AND prod_id=" . $result["prod_id"]; combat_store_commit($sql, $commit); break; // Truppen auf Transportern // Truppen auf Transportern case 4: $sql = "UPDATE inf_transports SET count=count-" . $result["destroyed"] . " WHERE fid=" . $result["fid"] . " AND prod_id=" . $result["prod_id"]; combat_store_commit($sql, $commit); break; } } // Schiffe klauen $query = $GLOBALS["db"]->query("SELECT prod_id, killed_by, warpreload, SUM(count_max) AS CountSum FROM combat \nWHERE killed_special='R' GROUP BY prod_id, killed_by, warpreload") or die($GLOBALS["db"]->error); while ($result = $query->fetch_assoc()) { if ($commit) { if (!fleet_add($combat[$result["killed_by"]]["fid"], $result["prod_id"], $result["CountSum"], $result["warpreload"])) { die("FLEET ADD:" . $GLOBALS["db"]->error); } } } // Truppen entladen $query = $GLOBALS["db"]->query("SELECT prod_id, SUM(count) AS SumCount, uid, fid FROM\ncombat WHERE position='U' GROUP BY uid, prod_id, fid") or die($GLOBALS["db"]->error); while ($result = $query->fetch_assoc()) { $sql = "UPDATE inf_transports SET count=count-" . $result["SumCount"] . " WHERE \nfid=" . $result["fid"] . " AND prod_id=" . $result["prod_id"]; combat_store_commit($sql, $commit); if (dcount("prod_id", "infantery", "prod_id=" . $result["prod_id"] . " AND pid={$pid} AND uid=" . $result["uid"]) > 0) { $sql = "UPDATE infantery SET count=count+" . $result["SumCount"] . " WHERE \nprod_id=" . $result["prod_id"] . " AND pid={$pid} AND uid=" . $result["uid"]; } else { $sql = "INSERT INTO infantery (prod_id, count, pid, uid) VALUES \n(" . $result["prod_id"] . ", " . $result["SumCount"] . ", {$pid}, " . $result["uid"] . ")"; } combat_store_commit($sql, $commit); } // Schildgeneratoren speichern $query = $GLOBALS["db"]->query("SELECT * FROM combat WHERE special LIKE 'H%' AND count>0") or die($GLOBALS["db"]->error); while ($result = $query->fetch_assoc()) { $sql = "UPDATE planetary_shields SET value={$result['shield']} WHERE prod_id=\n{$result['prod_id']} AND pid={$pid}"; combat_store_commit($sql, $commit); } // Planet erobert? if ($pid != 0) { $winner = combat_get_conqueror($pid); if ($winner) { $combat["shots_fired"]++; if ($winner == -100) { $sql = "UPDATE planets SET last_combat=" . dlookup("week", "timeinfo"); combat_store_commit($sql, $commit); } else { $sql = "UPDATE planets SET uid={$winner},production_factor=0.01 WHERE id={$pid}"; combat_store_commit($sql, $commit); // rune: wenn tradestation vorhanden, löschen, res dem eroberer gutschreiben $sql = "UPDATE ressources r, tradestations t SET r.metal = r.metal + t.metal, r.energy = r.energy + t.energy, r.mopgas = r.mopgas + t.mopgas, r.erkunum = r.erkunum + t.erkunum, r.gortium = r.gortium + t.gortium, r.susebloom = r.susebloom + t.susebloom WHERE r.uid = {$winner} AND t.pid = " . $pid; combat_store_commit($sql, $commit); $sql = "DELETE t.*, c.*, s.* FROM tradestations t, constructions c, stockmarket_orders s, shipvalues sv WHERE t.pid = {$pid} and t.uid = s.uid and c.pid = t.pid and sv.special = 'T' and c.prod_id = sv.prod_id"; combat_store_commit($sql, $commit); } } } // Erfahrungspunkte fuer Admiraele $query = $GLOBALS["db"]->query("SELECT SUM(c1.challenge*c1.count_max) AS xp_earned, c2.admiral_id AS admiral_id FROM \ncombat c1 INNER JOIN combat c2 ON (c1.killed_by=c2.id) WHERE c2.admiral_id <> 0 \nGROUP BY c2.admiral_id") or die($GLOBALS["db"]->error); while ($result = $query->fetch_assoc()) { $sql = "UPDATE admirals SET value=value+" . $result["xp_earned"] . " WHERE id=" . $result["admiral_id"]; combat_store_commit($sql, $commit); } // Töten der armen Admiräller $query = $GLOBALS["db"]->query("SELECT admiral_carried FROM combat WHERE killed_by IS NOT NULL AND \nadmiral_carried IS NOT NULL"); while ($result = $query->fetch_assoc()) { $sql = "DELETE FROM admirals WHERE id=" . $result["admiral_carried"]; combat_store_commit($sql, $commit); } if (COMBAT_VERBOSE) { echo "...fertig! (" . round(read_timer(1), 4) . "s)" . COMBAT_NEWLINE; } echo COMBAT_NEWLINE; }
function fleetstatus_update_fleet($fsid, $fleetdata, $svs = 0, $prec = 0) { if (!$fsid || !is_numeric($fsid)) { return false; } if (!($status = fleetstatus_get($fsid))) { return false; } if ($status['fid']) { $fid = $status['fid']; fleet_update($fid, $fleetdata); } else { if ($status['uid']) { // intern neu, geht normalerweise gar net } else { // extern neu $fid = fleet_add($fleetdata); } } if (!strlen($svs)) { $svs = "NULL"; } if (!strlen($prec)) { $prec = "NULL"; } return query("update fleet_status set \n fid = {$fid},\n prec = {$prec},\n svs = {$svs},\n lastupdate = unix_timestamp()\n where fsid = {$fsid}\n "); }
/** * @return unknown * @param $nick unknown * @param $password unknown * @param $email unknown * @param $phone unknown * @param $koords unknown * @desc Enter description here... */ function addUser($nick, $login, $password, $gid, $gala, $pos, $ircauth) { Assert::isNumeric($gid); Assert::isId($gala); Assert::isId($pos); $nick = mysql_real_escape_string($nick); $login = mysql_real_escape_string($login); $ircauth = mysql_real_escape_string($ircauth); $user = insertsql("insert into user (nick,login,password,gid,gala,pos,changepw,ircauth) values ('{$nick}','{$login}','" . md5($password) . "',{$gid},{$gala},{$pos},1,'{$ircauth}')"); for ($i = 0; $i < 3; $i++) { if ($i > 0) { $status = fleetstatus_get_bykoords($gala, $pos, $i); } if ($status['fid']) { $fid = $status['fid']; } else { $fid = fleet_add(); } insertsql("insert into user_fleet (gala,pos,fid,fleetnum) values ({$gala},{$pos},{$fid},{$i})"); } $position = getScan(array("gala" => $gala, "pos" => $pos)); if ($position) { scan_update_nick($gala, $pos, $nick); } else { scan_add($gala, $pos, array("nick" => $nick)); } return $user; }
function miliscan_fleet_add($sid, $fleetnum, $fleet) { $logger =& LoggerManager::getLogger("db.scans"); $logger->debug(array("sid" => $sid, "fleetnum" => $fleetnum, "fleet" => $fleet)); Assert::isId($sid); Assert::isNumeric($fleetnum); $fid = fleet_add($fleet); $insert = array("sid" => $sid, "fid" => $fid, "num" => $fleetnum); if (strlen($fleet['type'])) { $insert['type'] = "'" . addslashes($fleet['type']) . "'"; } if (strlen($fleet['dir'])) { $insert['dir'] = "'" . addslashes($fleet['dir']) . "'"; } if (strlen($fleet['status'])) { $insert['status'] = $fleet['status']; } if (strlen($fleet['return_flight'])) { $insert['return_flight'] = $fleet['return_flight']; } insertSQL("\n insert into scanmili_fleet (" . join(",", array_keys($insert)) . ")\n values (" . join(",", $insert) . ")\n "); return $fid; }