/**
 *
 * @global array $destroyed
 * @global <type> $pilots
 * @global array $pods
 * @param Kill $kill
 * @param <type> $side
 * @return <type>
 */
function handle_destroyed($kill, $side, &$destroyed, &$pilots, $sideAssignmentMap = array(), $completeInformation = FALSE)
{
    // -------------------------------------------------------------------------
    // FIX BATTLE REPORT a little by Evoke. Salvoxia
    // BEGIN
    // -------------------------------------------------------------------------
    // we don't want losses of our own corp/ally as losses on the enemy's side
    if ($side == 'e') {
        if (config::get('cfg_corpid')) {
            $corpId = config::get('cfg_corpid');
            $corpId = $corpId[0];
            if ($kill->getVictimCorpID() == $corpId) {
                return;
            }
        } elseif (config::get('cfg_allianceid')) {
            $allianceId = config::get('cfg_allianceid');
            $allianceId = $allianceId[0];
            if ($kill->getVictimAllianceID() == $allianceId) {
                return;
            }
        }
    }
    // -------------------------------------------------------------------------
    // FIX BATTLE REPORT a little by Evoke. Salvoxia
    // END
    // -------------------------------------------------------------------------
    if ($completeInformation && !is_null($destroyed) && is_array($destroyed)) {
        $destroyed[$kill->getID()] = $kill->getVictimID();
    }
    if (config::get('fleet_battles_mod_sideassign')) {
        // determine whether the pilot is member of an alliance
        if ($kill->getVictimAllianceName() == "None") {
            $entityType = "corp";
            $entityId = $kill->getVictimCorpID();
        } else {
            $entityType = "alliance";
            $entityId = $kill->getVictimAllianceID();
        }
        if (isset($sideAssignmentMap[$entityType][$entityId])) {
            $pilotSide = $sideAssignmentMap[$entityType][$entityId];
        } else {
            $pilotSide = $side;
        }
    } else {
        $pilotSide = $side;
    }
    $ship = Ship::lookup($kill->getVictimShipName());
    $shipc = $ship->getClass();
    $ts = strtotime($kill->getTimeStamp());
    // mark the pilot as podded
    if ($shipc->getID() == 18 || $shipc->getID() == 2) {
        // increase the timestamp of a podkill by 1 so its after the shipkill
        $ts++;
    }
    // search for ships with the same id
    if (isset($pilots[$pilotSide][$kill->getVictimId()]) && is_array($pilots[$pilotSide][$kill->getVictimId()])) {
        foreach ($pilots[$pilotSide][$kill->getVictimId()] as $id => $_ship) {
            if ($ship->getID() == $_ship['sid']) {
                $pilots[$pilotSide][$kill->getVictimId()][$id]['destroyed'] = true;
                if (!isset($pilots[$pilotSide][$kill->getVictimId()][$id]['kll_id'])) {
                    $pilots[$pilotSide][$kill->getVictimId()][$id]['kll_id'] = $kill->getID();
                    $pilots[$pilotSide][$kill->getVictimId()][$id]['kll_url'] = edkURI::page('kill_detail', $kill->getID(), "kll_id");
                }
                //$pilots[$side][$kill->getVictimId()][0]["times"] +=1;
                return;
            }
        }
    }
    if ($completeInformation) {
        $pilots[$pilotSide][$kill->getVictimId()][] = array('name' => $kill->getVictimName(), 'plt_url' => edkURI::page("pilot_detail", $kill->getVictimID(), "plt_id"), 'kll_id' => $kill->getID(), 'kll_url' => edkURI::page('kill_detail', $kill->getID(), "kll_id"), 'spic' => imageURL::getURL('Ship', $ship->getID(), 32), 'scl' => $shipc->getPoints(), 'destroyed' => true, 'corp' => $kill->getVictimCorpName(), 'alliance' => $kill->getVictimAllianceName(), 'aid' => $kill->getVictimAllianceID(), 'alliance_url' => edkURI::page("alliance_detail", $kill->getVictimAllianceID(), "all_id"), 'ship' => $kill->getVictimShipname(), 'shipClass' => $shipc->getName(), 'shipClassObject' => $shipc, 'sid' => $ship->getID(), 'cid' => $kill->getVictimCorpID(), 'crp_url' => edkURI::page("corp_detail", $kill->getVictimCorpID(), "crp_id"), 'ts' => $ts, 'times' => 0, 'color' => getColorClassByClass($shipc));
    } else {
        $pilots[$pilotSide][$kill->getVictimId()] = 1;
    }
}