- part 1/2 WIP added WebSocket extension, #420

- part 1/2 added "secure routes" to route finder module, #311
This commit is contained in:
Exodus4D
2017-01-05 22:15:12 +01:00
parent f927395484
commit 4e0533c7fe
12 changed files with 556 additions and 83 deletions

View File

@@ -53,13 +53,17 @@ class Route extends Controller\AccessController {
* -> this function is required for route search! (Don´t forget)
* @param array $mapIds
* @param array $filterData
* @param array $keepSystems
*/
public function initJumpData($mapIds = [], $filterData = []){
public function initJumpData($mapIds = [], $filterData = [], $keepSystems = []){
// add static data (e.g. K-Space stargates,..)
$this->setStaticJumpData();
// add map specific data
$this->setDynamicJumpData($mapIds, $filterData);
// filter jump data (e.g. remove some systems (0.0, LS)
$this->filterJumpData($filterData, $keepSystems);
}
/**
@@ -256,6 +260,35 @@ class Route extends Controller\AccessController {
}
}
/**
* filter systems (remove some systems) e.g. WH,LS,0.0 for "safer search"
* @param array $filterData
* @param array $keepSystems
*/
private function filterJumpData($filterData = [], $keepSystems = []){
if($filterData['safer']){
// remove all systems (TrueSec < 0.5) from search arrays
$this->jumpArray = array_filter($this->jumpArray, function($jumpData) use($keepSystems) {
// systemId is always last entry
$systemId = end($jumpData);
$systemNameData = $this->nameArray[$systemId];
$systemSec = $systemNameData[3];
if($systemSec < 0.45 && !in_array($systemId, $keepSystems)){
// remove system from nameArray as well
unset($this->nameArray[$systemId]);
// remove system from idArray as well
$systemName = $systemNameData[0];
unset($this->idArray[$systemName]);
return false;
}else{
return true;
}
});
}
}
/**
* get system data by systemId and dataName
* @param $systemId
@@ -504,7 +537,7 @@ class Route extends Controller\AccessController {
array_walk($mapData, function(&$item, &$key, $data){
if( isset($data[1][$key]) ){
// character has mas access -> do not check again
// character has map access -> do not check again
$item = $data[1][$key];
}else{
// check map access for current character
@@ -534,7 +567,8 @@ class Route extends Controller\AccessController {
'wormholes' => (bool) $routeData['wormholes'],
'wormholesReduced' => (bool) $routeData['wormholesReduced'],
'wormholesCritical' => (bool) $routeData['wormholesCritical'],
'wormholesEOL' => (bool) $routeData['wormholesEOL']
'wormholesEOL' => (bool) $routeData['wormholesEOL'],
'safer' => (bool) $routeData['safer']
];
$returnRoutData = [
@@ -553,8 +587,9 @@ class Route extends Controller\AccessController {
count($mapIds) > 0
){
$systemFrom = $routeData['systemFromData']['name'];
$systemFromId = (int)$routeData['systemFromData']['systemId'];
$systemTo = $routeData['systemToData']['name'];
$systemToId = (int)$routeData['systemToData']['systemId'];
$cacheKey = $this->getRouteCacheKey(
$mapIds,
@@ -571,7 +606,9 @@ class Route extends Controller\AccessController {
$searchDepth = $f3->get('PATHFINDER.ROUTE.SEARCH_DEPTH');
// set jump data for following route search
$this->initJumpData($mapIds, $filterData);
// --> don´t filter some systems (e.g. systemFrom, systemTo) even if they are are WH,LS,0.0
$keepSystems = [$systemFromId, $systemToId];
$this->initJumpData($mapIds, $filterData, $keepSystems);
// no cached route data found
$foundRoutData = $this->findRoute($systemFrom, $systemTo, $searchDepth);