$num_findpships = @mysql_num_rows($res_findpships);
			if ($num_findpships > 0) {
				while ($rec_findpships = mysql_fetch_assoc($res_findpships)) {
					$defendfleet->addShips($rec_findpships['unique_id'], $id, $fleet_id, $rec_findpships['ship_id'], $rec_findpships['amount'], $rec_findpships['armor'], $rec_findpships['firepower'], $rec_findpships['primary'], $rec_findpships['secondary']);
				}
			}
		}
	}

	for ($y = 0; $y < count($shipdata); $y++) {
		$single_shipdata = $shipdata[$y];
		$ship_id = $single_shipdata['id'];;
		unset($defend_shipcollection, $attack_shipcollection);

		if ($defendfleet) {
			$defend_shipcollection = $defendfleet->getShipCollection($ship_id);
			for ($i = 0; $i < count($defend_shipcollection); $i++) {
				if (($defend_shipcollection[$i]->getPrim() > 0) || ($defend_shipcollection[$i]->getSec() > 0)) {
					$ship_amount = $defend_shipcollection[$i]->getAmount();
					$hitted_armor = ($ship_amount * $single_shipdata['firepower']) * $single_shipdata['accurate'];

					$attackfleet->newRemoveShips($defend_shipcollection[$i]->getPrim(), $defend_shipcollection[$i]->getSec(), $hitted_armor);
					appendPlayerLog($defend_shipcollection[$i]->getPlayerId(), 'Removing ships for attacker. Prim target: '.$defend_shipcollection[$i]->getPrim().'. Sec target: '.$defend_shipcollection[$i]->getSec().'. Hitted armor: '.$hitted_armor, '');
				}
			}

			$attack_shipcollection = $attackfleet->getShipCollection($ship_id);

			for ($i = 0; $i < count($attack_shipcollection); $i++) {
				if (($attack_shipcollection[$i]->getPrim() > 0) || ($attack_shipcollection[$i]->getSec() > 0)) {
					$ship_amount = $attack_shipcollection[$i]->getAmount();