if (count($killed_ids)) { // These will get used for each alliances' kill/death results $fleets[0] = $fleets[1] = array(0, 0); foreach ($killed_ids as $account_id) { $ships[] = $players[$account_id][SHIP_ID]; $hqs[] = $players[$account_id][RACE_ID]; if ($players[$account_id][ALLIANCE_ID] == $player->alliance_id) { ++$fleets[0][1]; ++$fleets[1][0]; } else { ++$fleets[1][1]; ++$fleets[0][0]; } } $ships = build_ships(array_unique($ships)); $hqs = build_hqs(array_unique($hqs)); $required_ids = array_merge($killed_ids, $killer_ids); foreach ($required_ids as $account_id) { $relations[] = $players[$account_id][RACE_ID]; } $relations = build_relations(array_unique($relations)); $ship_names = build_ship_names($required_ids); $bounties = build_bounties($required_ids); $messages = ''; $unread_messages = ''; $news_messages = ''; foreach ($killed_ids as $killed_id) { if (!empty($news)) { $news .= ','; } $news .= process_news($players, $killed_id, $ship_names);
function podPlayers($IDArray, $ships, $hqs, $port, $players) { if (DEBUG) { print "Podding Players<br>"; } global $db, $session, $player; if (!sizeof($IDArray)) { return; } $hqs = build_hqs(array_unique($hqs)); $ships = build_ships(array_unique($ships)); foreach ($IDArray as $accId) { // Escape pod speed is 7 $turns = ceil($players[$accId][TURNS] * (7 / $ships[$players[$accId][SHIP_ID]][1])); if ($turns > MAX_TURNS) { $turns = MAX_TURNS; } $newExp = $players[$accId][EXPERIENCE] * 0.67; $sectorId = $hqs[$players[$accId][RACE_ID]]; $insurance = ceil($ships[$players[$accId][SHIP_ID]][0] * 0.25); if ($insurance < 5000) { $insurance = 5000; } $db->query("UPDATE player SET ship_type_id = 69, turns = {$turns}, newbie_turns = 100, " . "deaths = deaths + 1, dead = 'TRUE', sector_id = {$sectorId}, credits = {$insurance}, experience = {$newExp} " . "WHERE game_id = {$player->game_id} AND account_id = {$accId}"); $db->query('UPDATE player_has_stats SET deaths=deaths+1 WHERE game_id=' . $player->game_id . ' AND account_id=' . $accId . ' LIMIT 1'); $db->query('UPDATE account_has_stats SET deaths=deaths+1 WHERE account_id=' . $accId . ' LIMIT 1'); $db->query('UPDATE ship_has_hardware SET amount=50 WHERE (hardware_type_id=1 OR hardware_type_id=2) AND account_id=' . $accId . ' AND game_id=' . $player->game_id . ' LIMIT 2'); $db->query('DELETE FROM ship_has_hardware WHERE hardware_type_id=4 AND account_id=' . $accId . ' AND game_id=' . $player->game_id . ' LIMIT 1'); $msg = $players[$accId][PLAYER_NAME]; $db->query("SELECT * FROM ship_has_name WHERE account_id = {$accId} AND game_id = {$player->game_id}"); if ($db->next_record()) { $ship_names[$accId] = $db->f("ship_name"); } if (isset($ship_names[$accId])) { $msg .= ' flying '; if (!stristr($ship_names[$accId], '<img')) { if (stristr($ship_names[$accId], '<mar')) { $msg .= "<span class=\"yellow\">" . strip_tags($ship_names[$accId]) . "</span>"; } else { $msg .= $ship_names[$accId]; } } else { $msg .= strip_tags($ship_names[$accId], '<img>'); } } $msg .= ' was destroyed while invading '; $msg .= "<span style=\"color:yellow;font-variant:small-caps\">Port " . $player->sector_id . "</span>."; $msg = mysql_real_escape_string($msg); $db->query("INSERT INTO news (game_id, time, news_message) VALUES ({$player->game_id}, " . TIME . ", '{$msg}')"); $killer_id = 0; $temp = mysql_real_escape_string('You were <span class="red">DESTROYED</span> by <span style="color:yellow;font-variant:small-caps">Port ' . $player->sector_id . '</span>\'s defenses.'); $msg = '(' . SmrSession::$game_id . ',' . $accId . ',2,"' . $temp . '",' . $killer_id . ',' . TIME . ',"FALSE",' . MESSAGE_EXPIRES . ')'; $db->query("INSERT INTO message (game_id, account_id, message_type_id, message_text, sender_id, send_time, msg_read, expire_time) VALUES {$msg}"); $db->query("INSERT INTO player_has_unread_messages (account_id, game_id, message_type_id) VALUES ({$accId}, " . SmrSession::$game_id . ", 2)"); unset($temp); } //Deal with hardware, cloaks etc for podded players $num_podded = count($IDArray); if ($num_podded) { $podded_in = implode(',', $IDArray); $db->query('DELETE FROM ship_has_weapon WHERE account_id IN (' . $podded_in . ') AND game_id=' . SmrSession::$game_id); $db->query('DELETE FROM ship_has_cargo WHERE account_id IN (' . $podded_in . ') AND game_id=' . SmrSession::$game_id); $db->query('DELETE FROM ship_has_illusion WHERE account_id IN (' . $podded_in . ') AND game_id=' . SmrSession::$game_id); $db->query('DELETE FROM player_plotted_course WHERE account_id IN (' . $podded_in . ') AND game_id=' . SmrSession::$game_id . ' LIMIT ' . $num_podded); $db->query('DELETE FROM ship_has_hardware WHERE account_id IN (' . $podded_in . ') AND hardware_type_id>4 AND game_id=' . SmrSession::$game_id); $db->query('UPDATE ship_has_hardware SET amount=5 WHERE account_id IN (' . $podded_in . ') AND hardware_type_id=3 AND game_id=' . SmrSession::$game_id . ' LIMIT ' . $num_podded); $db->query('UPDATE ship_has_hardware SET old_amount=amount WHERE account_id IN (' . $podded_in . ') AND game_id=' . SmrSession::$game_id); } }
function podPlayers($IDArray, $ships, $hqs, $port, $players) { if (DEBUG) { $PHP_OUTPUT .= 'Podding Players<br>'; } global $db, $session, $player; if (!sizeof($IDArray)) { return; } $hqs = build_hqs(array_unique($hqs)); $ships = build_ships(array_unique($ships)); foreach ($IDArray as $accId) { // Escape pod speed is 7 $turns = ceil($players[$accId][TURNS] * (7 / $ships[$players[$accId][SHIP_ID]][1])); if ($turns > MAX_TURNS) { $turns = MAX_TURNS; } $newExp = $players[$accId][EXPERIENCE] * 0.67; $sectorId = $hqs[$players[$accId][RACE_ID]]; $insurance = ceil($ships[$players[$accId][SHIP_ID]][0] * 0.25); if ($insurance < 5000) { $insurance = 5000; } $db->query('UPDATE player SET ship_type_id = 69, turns = ' . $turns . ', newbie_turns = 100, ' . 'deaths = deaths + 1, dead = \'TRUE\', sector_id = ' . $sectorId . ', credits = ' . $insurance . ', experience = ' . $newExp . ' ' . 'WHERE game_id = ' . $player->getGameID() . ' AND account_id = ' . $accId); $currPlayer =& SmrPlayer::getPlayer($accId, SmrSession::$game_id, true); $currPlayer->increaseHOF(1, array('Dying', 'Deaths')); $currPlayer->update(); $db->query('UPDATE ship_has_hardware SET amount=50 WHERE (hardware_type_id=1 OR hardware_type_id=2) AND account_id=' . $accId . ' AND game_id=' . $player->getGameID() . ' LIMIT 2'); $db->query('DELETE FROM ship_has_hardware WHERE hardware_type_id=4 AND account_id=' . $accId . ' AND game_id=' . $player->getGameID() . ' LIMIT 1'); $msg = $players[$accId][PLAYER_NAME]; $db->query('SELECT * FROM ship_has_name WHERE account_id = ' . $accId . ' AND game_id = ' . $player->getGameID()); if ($db->next_record()) { $ship_names[$accId] = $db->f('ship_name'); } if (isset($ship_names[$accId])) { $msg .= ' flying '; if (!stristr($ship_names[$accId], '<img')) { if (stristr($ship_names[$accId], '<mar')) { $msg .= '<span class="yellow">' . strip_tags($ship_names[$accId]) . '</span>'; } else { $msg .= $ship_names[$accId]; } } else { $msg .= strip_tags($ship_names[$accId], '<img>'); } } $msg .= ' was destroyed while invading '; $msg .= '<span style="color:yellow;font-variant:small-caps">Port ' . $player->getSectorID() . '</span>.'; $msg = mysql_real_escape_string($msg); $db->query('INSERT INTO news (game_id, time, news_message,killer_id,dead_id,dead_alliance) VALUES (' . $player->getGameID() . ', ' . TIME . ', ' . $db->escapeString($msg) . ',' . ACCOUNT_ID_PORT . ',' . $currPlayer->getAccountID() . ',' . $currPlayer->getAllianceID() . ')'); $killer_id = 0; $temp = 'You were <span class="red">DESTROYED</span> by <span style="color:yellow;font-variant:small-caps">Port ' . $player->getSectorID() . '</span>\'s defenses.'; $msg = '(' . SmrSession::$game_id . ',' . $accId . ',2,' . $db->escape_string($temp) . ',' . $killer_id . ',' . TIME . ',\'FALSE\',' . MESSAGE_EXPIRES . ')'; $db->query('INSERT INTO message (game_id, account_id, message_type_id, message_text, sender_id, send_time, msg_read, expire_time) VALUES ' . $msg); $db->query('INSERT INTO player_has_unread_messages (account_id, game_id, message_type_id) VALUES (' . $accId . ', ' . SmrSession::$game_id . ', 2)'); unset($temp); } //Deal with hardware, cloaks etc for podded players $num_podded = count($IDArray); if ($num_podded) { $podded_in = implode(',', $IDArray); $db->query('DELETE FROM ship_has_weapon WHERE account_id IN (' . $podded_in . ') AND game_id=' . SmrSession::$game_id); $db->query('DELETE FROM ship_has_cargo WHERE account_id IN (' . $podded_in . ') AND game_id=' . SmrSession::$game_id); $db->query('DELETE FROM ship_has_illusion WHERE account_id IN (' . $podded_in . ') AND game_id=' . SmrSession::$game_id); $db->query('DELETE FROM player_plotted_course WHERE account_id IN (' . $podded_in . ') AND game_id=' . SmrSession::$game_id . ' LIMIT ' . $num_podded); $db->query('DELETE FROM ship_has_hardware WHERE account_id IN (' . $podded_in . ') AND hardware_type_id>4 AND game_id=' . SmrSession::$game_id); $db->query('UPDATE ship_has_hardware SET amount=5 WHERE account_id IN (' . $podded_in . ') AND hardware_type_id=3 AND game_id=' . SmrSession::$game_id . ' LIMIT ' . $num_podded); $db->query('UPDATE ship_has_hardware SET old_amount=amount WHERE account_id IN (' . $podded_in . ') AND game_id=' . SmrSession::$game_id); } }