- removed SDE database requirement from Pathfinder, #628
- improved "shattered" wormholes (e.g. UI updates on map, fixed broken statics,..), closed #647 - improved "route search" algorithm, WHs are no longer supposed to be "insecure"
This commit is contained in:
@@ -26,12 +26,6 @@ DB_UNIVERSE_NAME = eve_universe
|
||||
DB_UNIVERSE_USER = root
|
||||
DB_UNIVERSE_PASS =
|
||||
|
||||
; EVE-Online CCP database export
|
||||
DB_CCP_DNS = mysql:host=localhost;port=3306;dbname=
|
||||
DB_CCP_NAME = eve_lifeblood_min
|
||||
DB_CCP_USER = root
|
||||
DB_CCP_PASS =
|
||||
|
||||
; CCP SSO (OAuth2) - visit: https://developers.eveonline.com/applications
|
||||
CCP_SSO_URL = https://sisilogin.testeveonline.com
|
||||
CCP_SSO_CLIENT_ID =
|
||||
|
||||
@@ -223,11 +223,11 @@ class Cortex extends Cursor {
|
||||
protected function applyWhitelist() {
|
||||
if ($this->dbsType == 'sql') {
|
||||
// fetch full schema
|
||||
if (!$this->fluid && isset(self::$schema_cache[$this->table]))
|
||||
$schema = self::$schema_cache[$this->table];
|
||||
if (!$this->fluid && isset(self::$schema_cache[$this->table.$this->db->uuid()]))
|
||||
$schema = self::$schema_cache[$this->table.$this->db->uuid()];
|
||||
else {
|
||||
$schema = $this->mapper->schema();
|
||||
self::$schema_cache[$this->table] = $schema;
|
||||
self::$schema_cache[$this->table.$this->db->uuid()] = $schema;
|
||||
}
|
||||
// apply reduced fields schema
|
||||
if ($this->whitelist)
|
||||
|
||||
@@ -138,11 +138,10 @@ class Map extends Controller\AccessController {
|
||||
$return->connectionScopes = $connectionScopeData;
|
||||
|
||||
// get available wormhole types ---------------------------------------------------------------------------
|
||||
$wormholes = Model\BasicModel::getNew('WormholeModel');
|
||||
$rows = $wormholes->find('id > 0', null, $expireTimeSQL);
|
||||
$wormhole = Model\Universe\BasicUniverseModel::getNew('WormholeModel');
|
||||
$wormholesData = [];
|
||||
if($rows){
|
||||
foreach((array)$rows as $rowData){
|
||||
if($rows = $wormhole->find(null, ['order' => 'name asc'], $expireTimeSQL)){
|
||||
foreach($rows as $rowData){
|
||||
$wormholesData[$rowData->name] = $rowData->getData();
|
||||
}
|
||||
}
|
||||
@@ -741,12 +740,11 @@ class Map extends Controller\AccessController {
|
||||
// system belongs to the current map
|
||||
if(is_object($filteredMap->systems)){
|
||||
// update
|
||||
|
||||
/**
|
||||
* @var $system Model\SystemModel
|
||||
*/
|
||||
$system = $filteredMap->systems->current();
|
||||
$system->setData($systemData);
|
||||
$system->copyfrom($systemData, ['alias', 'status', 'position', 'locked', 'rallyUpdated', 'rallyPoke']);
|
||||
|
||||
if($system->save($activeCharacter)){
|
||||
$mapChanged = true;
|
||||
@@ -776,7 +774,6 @@ class Map extends Controller\AccessController {
|
||||
// connection belongs to the current map
|
||||
if(is_object($filteredMap->connections)){
|
||||
// update
|
||||
|
||||
/**
|
||||
* @var $connection Model\ConnectionModel
|
||||
*/
|
||||
|
||||
@@ -7,11 +7,12 @@
|
||||
*/
|
||||
|
||||
namespace Controller\Api;
|
||||
|
||||
use Controller;
|
||||
use Controller\Ccp\Universe;
|
||||
use lib\Config;
|
||||
use Model;
|
||||
|
||||
|
||||
/**
|
||||
* Routes controller
|
||||
* Class Route
|
||||
@@ -101,6 +102,7 @@ class Route extends Controller\AccessController {
|
||||
* -> (e.g. new system added, connection added/updated, ...)
|
||||
* @param array $mapIds
|
||||
* @param array $filterData
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function setDynamicJumpData($mapIds = [], $filterData = []){
|
||||
// make sure, mapIds are integers (protect against SQL injections)
|
||||
@@ -177,7 +179,7 @@ class Route extends Controller\AccessController {
|
||||
`system_src`.`systemId` systemId,
|
||||
(
|
||||
SELECT
|
||||
GROUP_CONCAT( NULLIF(`system_tar`.`name`, NULL) SEPARATOR ':')
|
||||
GROUP_CONCAT( NULLIF(`system_tar`.`systemId`, NULL) SEPARATOR ':')
|
||||
FROM
|
||||
`connection` INNER JOIN
|
||||
`system` system_tar ON
|
||||
@@ -211,6 +213,17 @@ class Route extends Controller\AccessController {
|
||||
$rows = $this->getDB()->exec($query, null, $this->dynamicJumpDataCacheTime);
|
||||
|
||||
if(count($rows) > 0){
|
||||
// enrich $row data with static system data (from universe DB)
|
||||
$universe = new Universe();
|
||||
for($i = 0; $i < count($rows); $i++){
|
||||
if($staticData = $universe->getSystemData($rows[$i]['systemId'])){
|
||||
$rows[$i]['systemName'] = $staticData->name;
|
||||
$rows[$i]['constellationId'] = $staticData->constellation->id;
|
||||
$rows[$i]['regionId'] = $staticData->constellation->region->id;
|
||||
$rows[$i]['trueSec'] = $staticData->trueSec;
|
||||
}
|
||||
}
|
||||
|
||||
// update jump data for this instance
|
||||
$this->updateJumpData($rows);
|
||||
}
|
||||
@@ -229,7 +242,7 @@ class Route extends Controller\AccessController {
|
||||
foreach($rows as &$row){
|
||||
$regionId = (int)$row['regionId'];
|
||||
$constId = (int)$row['constellationId'];
|
||||
$systemName = strtoupper($row['systemName']);
|
||||
$systemName = (string)($row['systemName']);
|
||||
$systemId = (int)$row['systemId'];
|
||||
$secStatus = (float)$row['trueSec'];
|
||||
|
||||
@@ -242,19 +255,19 @@ class Route extends Controller\AccessController {
|
||||
}
|
||||
|
||||
// fill "idArray" data ------------------------------------------------------------------------------------
|
||||
if( !isset($this->idArray[$systemName]) ){
|
||||
$this->idArray[$systemName] = $systemId;
|
||||
if( !isset($this->idArray[$systemId]) ){
|
||||
$this->idArray[$systemId] = $systemName;
|
||||
}
|
||||
|
||||
// fill "jumpArray" data ----------------------------------------------------------------------------------
|
||||
if( !is_array($this->jumpArray[$systemName]) ){
|
||||
$this->jumpArray[$systemName] = [];
|
||||
if( !is_array($this->jumpArray[$systemId]) ){
|
||||
$this->jumpArray[$systemId] = [];
|
||||
}
|
||||
$this->jumpArray[$systemName] = array_merge( explode(':', strtoupper($row['jumpNodes'])), $this->jumpArray[$systemName] );
|
||||
$this->jumpArray[$systemId] = array_merge(array_map('intval', explode(':', $row['jumpNodes'])), $this->jumpArray[$systemId]);
|
||||
|
||||
// add systemId to end (if not already there)
|
||||
if(end($this->jumpArray[$systemName]) != $systemId){
|
||||
array_push($this->jumpArray[$systemName],$systemId);
|
||||
// add systemName to end (if not already there)
|
||||
if(end($this->jumpArray[$systemId]) != $systemName){
|
||||
array_push($this->jumpArray[$systemId], $systemName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,24 +280,23 @@ class Route extends Controller\AccessController {
|
||||
private function filterJumpData($filterData = [], $keepSystems = []){
|
||||
if($filterData['flag'] == 'secure'){
|
||||
// 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);
|
||||
$this->jumpArray = array_filter($this->jumpArray, function($systemId) use($keepSystems) {
|
||||
$systemNameData = $this->nameArray[$systemId];
|
||||
$systemSec = $systemNameData[3];
|
||||
|
||||
if($systemSec < 0.45 && !in_array($systemId, $keepSystems)){
|
||||
// remove system from nameArray as well
|
||||
if(
|
||||
$systemSec < 0.45 &&
|
||||
!in_array($systemId, $keepSystems) &&
|
||||
!preg_match('/^j\d+$/i', $this->idArray[$systemId]) // WHs are supposed to be "secure"
|
||||
){
|
||||
// remove system from nameArray and idArray
|
||||
unset($this->nameArray[$systemId]);
|
||||
// remove system from idArray as well
|
||||
$systemName = $systemNameData[0];
|
||||
unset($this->idArray[$systemName]);
|
||||
unset($this->idArray[$systemId]);
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}, ARRAY_FILTER_USE_KEY );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,16 +310,16 @@ class Route extends Controller\AccessController {
|
||||
$info = null;
|
||||
switch($option){
|
||||
case 'systemName':
|
||||
$info = $this->nameArray[ $systemId ][0];
|
||||
$info = $this->nameArray[$systemId][0];
|
||||
break;
|
||||
case 'regionId':
|
||||
$info = $this->nameArray[ $systemId ][1];
|
||||
$info = $this->nameArray[$systemId][1];
|
||||
break;
|
||||
case 'constellationId':
|
||||
$info = $this->nameArray[ $systemId ][2];
|
||||
$info = $this->nameArray[$systemId][2];
|
||||
break;
|
||||
case 'trueSec':
|
||||
$info = $this->nameArray[ $systemId ][3];
|
||||
$info = $this->nameArray[$systemId][3];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -387,13 +399,13 @@ class Route extends Controller\AccessController {
|
||||
|
||||
/**
|
||||
* get formatted jump node data
|
||||
* @param $systemName
|
||||
* @param int $systemId
|
||||
* @return array
|
||||
*/
|
||||
protected function getJumpNodeData($systemName) : array {
|
||||
protected function getJumpNodeData(int $systemId) : array {
|
||||
return [
|
||||
'system' => $systemName,
|
||||
'security' => $this->getSystemInfoBySystemId($this->idArray[$systemName], 'trueSec')
|
||||
'system' => $this->getSystemInfoBySystemId($systemId, 'systemName'),
|
||||
'security' => $this->getSystemInfoBySystemId($systemId, 'trueSec')
|
||||
];
|
||||
}
|
||||
|
||||
@@ -430,6 +442,7 @@ class Route extends Controller\AccessController {
|
||||
* @param array $mapIds
|
||||
* @param array $filterData
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
private function searchRouteCustom(int $systemFromId, int $systemToId, $searchDepth = 0, array $mapIds = [], array $filterData = []) : array {
|
||||
@@ -454,19 +467,16 @@ class Route extends Controller\AccessController {
|
||||
// --> don´t filter some systems (e.g. systemFrom, systemTo) even if they are are WH,LS,0.0
|
||||
$this->filterJumpData($filterData, [$systemFromId, $systemToId]);
|
||||
|
||||
$systemFrom = $this->getSystemInfoBySystemId($systemFromId, 'systemName');
|
||||
$systemTo = $this->getSystemInfoBySystemId($systemToId, 'systemName');
|
||||
|
||||
// search route -------------------------------------------------------------------------------------------
|
||||
|
||||
// jump counter
|
||||
$jumpNum = 0;
|
||||
$depthSearched = 0;
|
||||
|
||||
if( isset($this->jumpArray[$systemFrom]) ){
|
||||
if( isset($this->jumpArray[$systemFromId]) ){
|
||||
// check if the system we are looking for is a direct neighbour
|
||||
foreach( $this->jumpArray[$systemFrom] as $n ) {
|
||||
if ($n == $systemTo) {
|
||||
foreach( $this->jumpArray[$systemFromId] as $n ) {
|
||||
if ($n == $systemToId) {
|
||||
$jumpNum = 2;
|
||||
$routeData['route'][] = $this->getJumpNodeData($n);
|
||||
break;
|
||||
@@ -475,11 +485,11 @@ class Route extends Controller\AccessController {
|
||||
|
||||
// system is not a direct neighbour -> search recursive its neighbours
|
||||
if ($jumpNum == 0) {
|
||||
$searchResult = $this->graph_find_path( $this->jumpArray, $systemFrom, $systemTo, $searchDepth );
|
||||
$searchResult = $this->graph_find_path( $this->jumpArray, $systemFromId, $systemToId, $searchDepth );
|
||||
$depthSearched = $searchResult['depth'];
|
||||
foreach( $searchResult['path'] as $systemName ) {
|
||||
foreach( $searchResult['path'] as $systemId ) {
|
||||
if ($jumpNum > 0) {
|
||||
$routeData['route'][] = $this->getJumpNodeData($systemName);
|
||||
$routeData['route'][] = $this->getJumpNodeData($systemId);
|
||||
}
|
||||
$jumpNum++;
|
||||
}
|
||||
@@ -489,7 +499,7 @@ class Route extends Controller\AccessController {
|
||||
// route found
|
||||
$routeData['routePossible'] = true;
|
||||
// insert "from" system on top
|
||||
array_unshift($routeData['route'], $this->getJumpNodeData($systemFrom));
|
||||
array_unshift($routeData['route'], $this->getJumpNodeData($systemFromId));
|
||||
} else {
|
||||
// route not found
|
||||
$routeData['routePossible'] = false;
|
||||
@@ -512,6 +522,7 @@ class Route extends Controller\AccessController {
|
||||
* @param array $mapIds
|
||||
* @param array $filterData
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
* @throws \Exception\PathfinderException
|
||||
*/
|
||||
private function searchRouteESI(int $systemFromId, int $systemToId, int $searchDepth = 0, array $mapIds = [], array $filterData = []) : array {
|
||||
@@ -540,18 +551,16 @@ class Route extends Controller\AccessController {
|
||||
$this->filterJumpData($filterData, [$systemFromId, $systemToId]);
|
||||
|
||||
$connections = [];
|
||||
foreach($this->jumpArray as $systemSourceName => $jumpData){
|
||||
foreach($this->jumpArray as $systemSourceId => $jumpData){
|
||||
$count = count($jumpData);
|
||||
if($count > 1){
|
||||
// ... should always > 1
|
||||
$systemSourceId = (int)$this->idArray[$systemSourceName];
|
||||
// loop all connections for current source system
|
||||
foreach($jumpData as $systemTargetName) {
|
||||
foreach($jumpData as $systemTargetId) {
|
||||
// skip last entry
|
||||
if(--$count <= 0){
|
||||
break;
|
||||
}
|
||||
$systemTargetId = (int)$this->idArray[$systemTargetName];
|
||||
|
||||
// systemIds exist and wer not removed before in filterJumpData()
|
||||
if($systemSourceId && $systemTargetId){
|
||||
@@ -599,8 +608,7 @@ class Route extends Controller\AccessController {
|
||||
$this->setStaticJumpData();
|
||||
|
||||
foreach($result['route'] as $systemId){
|
||||
$systemName = $this->getSystemInfoBySystemId($systemId, 'systemName');
|
||||
$routeData['route'][] = $this->getJumpNodeData($systemName);
|
||||
$routeData['route'][] = $this->getJumpNodeData($systemId);
|
||||
}
|
||||
}else{
|
||||
$depthSearched = $routeData['maxDepth'];
|
||||
|
||||
@@ -91,11 +91,11 @@ class Setup extends Controller\Controller {
|
||||
$return->countBuildAll = $categoryUniverseModel->getById($categoryId, 0)->getTypesCount(false);
|
||||
$return->progress = $percent($return->countAll, $return->countBuildAll);
|
||||
break;
|
||||
case 'SystemNeighbourModel':
|
||||
case 'SystemNeighbour':
|
||||
// Becomes deprecated with new Universe DB!!!
|
||||
$this->setupSystemJumpTable();
|
||||
|
||||
$return->countAll = 5214;
|
||||
$return->countAll = (int)$f3->get('REQUIREMENTS.DATA.NEIGHBOURS');
|
||||
$return->countBuild = Database::instance()->getRowCount('system_neighbour');
|
||||
$return->countBuildAll = $return->countBuild;
|
||||
$return->progress = $percent($return->countAll, $return->countBuildAll);
|
||||
@@ -144,67 +144,87 @@ class Setup extends Controller\Controller {
|
||||
* for system jump calculation. Call this function manually when CCP adds Systems/Stargates
|
||||
*/
|
||||
protected function setupSystemJumpTable(){
|
||||
$pfDB = $this->getDB('PF');
|
||||
$ccpDB = $this->getDB('CCP');
|
||||
$universeDB = $this->getDB('UNIVERSE');
|
||||
|
||||
$query = "SELECT
|
||||
map_sys.solarSystemID system_id,
|
||||
map_sys.regionID region_id,
|
||||
map_sys.constellationID constellation_id,
|
||||
map_sys.solarSystemName system_name,
|
||||
ROUND( map_sys.security, 4) system_security,
|
||||
(
|
||||
SELECT
|
||||
GROUP_CONCAT( NULLIF(map_sys_inner.solarSystemName, NULL) SEPARATOR ':')
|
||||
`system`.`id` `systemId`,
|
||||
`system`.`name` `systemName`,
|
||||
`system`.`constellationId` `constellationId`,
|
||||
ROUND( `system`.`securityStatus`, 4) `trueSec`,
|
||||
`constellation`.`regionId` `regionId`,
|
||||
(
|
||||
SELECT
|
||||
GROUP_CONCAT( NULLIF(`sys_inner`.`id`, NULL) SEPARATOR ':')
|
||||
FROM
|
||||
`stargate` INNER JOIN
|
||||
`system` `sys_inner` ON
|
||||
`sys_inner`.`id` = `stargate`.`destinationSystemId`
|
||||
WHERE
|
||||
`stargate`.`systemId` = `system`.`id`
|
||||
) `jumpNodes`
|
||||
FROM
|
||||
mapSolarSystemJumps map_jump INNER JOIN
|
||||
mapSolarSystems map_sys_inner ON
|
||||
map_sys_inner.solarSystemID = map_jump.toSolarSystemID
|
||||
`system` INNER JOIN
|
||||
`constellation` ON
|
||||
`constellation`.`id` = `system`.`constellationId`
|
||||
WHERE
|
||||
map_jump.fromSolarSystemID = map_sys.solarSystemID
|
||||
) system_neighbours
|
||||
FROM
|
||||
mapSolarSystems map_sys
|
||||
HAVING
|
||||
-- skip systems without neighbors (e.g. WHs)
|
||||
system_neighbours IS NOT NULL
|
||||
";
|
||||
`constellation`.`regionId` != :regionIdJove1 AND
|
||||
`constellation`.`regionId` != :regionIdJove2 AND
|
||||
`constellation`.`regionId` != :regionIdJove3 AND
|
||||
(
|
||||
`system`.`security` = :ns OR
|
||||
`system`.`security` = :ls OR
|
||||
`system`.`security` = :hs
|
||||
)
|
||||
";
|
||||
|
||||
$rows = $ccpDB->exec($query);
|
||||
$rows = $universeDB->exec($query, [
|
||||
':regionIdJove1' => 10000017,
|
||||
':regionIdJove2' => 10000019,
|
||||
':regionIdJove3' => 10000004,
|
||||
':ns' => '0.0',
|
||||
':ls' => 'L',
|
||||
':hs' => 'H'
|
||||
]);
|
||||
|
||||
if(count($rows) > 0){
|
||||
// switch DB back to pathfinder DB
|
||||
if(count($rows)){
|
||||
$pfDB = $this->getDB('PF');
|
||||
|
||||
// clear cache table
|
||||
$pfDB->exec("TRUNCATE system_neighbour");
|
||||
|
||||
foreach($rows as $row){
|
||||
if(!$row['jumpNodes']){
|
||||
// should never happen!
|
||||
continue;
|
||||
}
|
||||
|
||||
$pfDB->exec("
|
||||
INSERT INTO
|
||||
system_neighbour(
|
||||
regionId,
|
||||
constellationId,
|
||||
systemName,
|
||||
systemId,
|
||||
jumpNodes,
|
||||
trueSec
|
||||
)
|
||||
VALUES(
|
||||
:regionId,
|
||||
:constellationId,
|
||||
:systemName,
|
||||
:systemId,
|
||||
:jumpNodes,
|
||||
:trueSec
|
||||
)",
|
||||
[
|
||||
':regionId' => $row['region_id'],
|
||||
':constellationId' => $row['constellation_id'],
|
||||
':systemName' => $row['system_name'],
|
||||
':systemId' => $row['system_id'],
|
||||
':jumpNodes' => $row['system_neighbours'],
|
||||
':trueSec' => $row['system_security']
|
||||
]);
|
||||
INSERT INTO
|
||||
system_neighbour(
|
||||
regionId,
|
||||
constellationId,
|
||||
systemName,
|
||||
systemId,
|
||||
jumpNodes,
|
||||
trueSec
|
||||
)
|
||||
VALUES(
|
||||
:regionId,
|
||||
:constellationId,
|
||||
:systemName,
|
||||
:systemId,
|
||||
:jumpNodes,
|
||||
:trueSec
|
||||
)",
|
||||
[
|
||||
':regionId' => $row['regionId'],
|
||||
':constellationId' => $row['constellationId'],
|
||||
':systemName' => $row['systemName'],
|
||||
':systemId' => $row['systemId'],
|
||||
':jumpNodes' => $row['jumpNodes'],
|
||||
':trueSec' => $row['trueSec']
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,127 +9,10 @@
|
||||
namespace Controller\Api;
|
||||
|
||||
use Controller;
|
||||
use Data\Mapper as Mapper;
|
||||
use Model;
|
||||
|
||||
class System extends Controller\AccessController {
|
||||
|
||||
private $mainQuery = "SELECT
|
||||
map_sys.constellationID `connstallation_id`,
|
||||
map_sys.solarSystemID `system_id`,
|
||||
map_sys.solarSystemName `system_name`,
|
||||
map_sys.security `system_security`,
|
||||
map_con.constellationName `constallation_name`,
|
||||
map_reg.regionID `region_id`,
|
||||
map_reg.regionName `region_name`,
|
||||
'0' `trueSec`,
|
||||
'' `type`,
|
||||
IFNULL(
|
||||
(
|
||||
SELECT
|
||||
LOWER( system_effect.typeName )
|
||||
FROM
|
||||
invTypes system_effect INNER JOIN
|
||||
mapDenormalize map_norm ON
|
||||
map_norm.typeID = system_effect.typeID
|
||||
WHERE
|
||||
system_effect.groupID = 995 AND
|
||||
map_norm.solarSystemID = map_sys.solarSystemID
|
||||
LIMIT 1
|
||||
), '') `effect`,
|
||||
IFNULL(
|
||||
(
|
||||
SELECT
|
||||
map_worm_class.wormholeClassID system_class
|
||||
FROM
|
||||
mapLocationWormholeClasses map_worm_class
|
||||
WHERE
|
||||
map_worm_class.locationID = map_sys.regionID
|
||||
LIMIT 1
|
||||
), 7) `security`
|
||||
FROM
|
||||
mapSolarSystems map_sys INNER JOIN
|
||||
mapConstellations map_con ON
|
||||
map_sys.constellationID = map_con.constellationID INNER JOIN
|
||||
mapRegions map_reg ON
|
||||
map_con.regionID = map_reg.regionID";
|
||||
|
||||
private $whereQuery = "";
|
||||
|
||||
// exclude Jove Space
|
||||
private $havingQuery = "HAVING
|
||||
security IS NOT NULL";
|
||||
|
||||
private $orderByQuery = "ORDER BY
|
||||
system_name";
|
||||
|
||||
private $limitQuery = "";
|
||||
|
||||
|
||||
/**
|
||||
* build query
|
||||
* @return string
|
||||
*/
|
||||
private function _getQuery(){
|
||||
$query = $this->mainQuery;
|
||||
$query .= ' ' . $this->whereQuery;
|
||||
$query .= ' ' . $this->havingQuery;
|
||||
$query .= ' ' . $this->orderByQuery;
|
||||
$query .= ' ' . $this->limitQuery;
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* get system Data from CCPs [SDE]
|
||||
* search column for IDs can be (solarSystemID, regionID, constellationID)
|
||||
* @param array $columnIDs
|
||||
* @param string $column
|
||||
* @return Model\SystemModel[]
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getSystemModelByIds($columnIDs = [], $column = 'solarSystemID'){
|
||||
|
||||
$systemModels = [];
|
||||
|
||||
$ccpDB = $this->getDB('CCP');
|
||||
|
||||
$this->whereQuery = "WHERE
|
||||
map_sys." . $column . " IN (" . implode(',', $columnIDs) . ")";
|
||||
|
||||
$query = $this->_getQuery();
|
||||
|
||||
$rows = $ccpDB->exec($query, null, 60 * 60 * 24);
|
||||
|
||||
// format result
|
||||
$ccpSystemsData = (new Mapper\CcpSystemsMapper($rows))->getData();
|
||||
|
||||
foreach($ccpSystemsData as $ccpSystemData){
|
||||
/**
|
||||
* @var Model\SystemModel $system
|
||||
*/
|
||||
$system = Model\BasicModel::getNew('SystemModel');
|
||||
$system->setData($ccpSystemData);
|
||||
$systemModels[] = $system;
|
||||
}
|
||||
|
||||
return $systemModels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all static system Data from CCP DB (long cache timer)
|
||||
* @return array
|
||||
*/
|
||||
public function getSystems(){
|
||||
$ccpDB = $this->getDB('CCP');
|
||||
$query = $this->_getQuery();
|
||||
$rows = $ccpDB->exec($query, null, 60 * 60 * 24);
|
||||
// format result
|
||||
$mapper = new Mapper\CcpSystemsMapper($rows);
|
||||
|
||||
return $mapper->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* save a new system to a a map
|
||||
* @param \Base $f3
|
||||
@@ -160,59 +43,36 @@ class System extends Controller\AccessController {
|
||||
}
|
||||
|
||||
if( isset($systemData['id']) ){
|
||||
// update existing system (e.g. changed system description) -------------------------------------------
|
||||
|
||||
// update existing system (e.g. set description) ------------------------------------------------------
|
||||
/**
|
||||
* @var $system Model\SystemModel
|
||||
*/
|
||||
$system = Model\BasicModel::getNew('SystemModel');
|
||||
$system->getById($systemData['id']);
|
||||
if( !$system->dry() ){
|
||||
if( $system->hasAccess($activeCharacter) ){
|
||||
// system model found
|
||||
$systemModel = $system;
|
||||
}
|
||||
if(
|
||||
!$system->dry() &&
|
||||
$system->hasAccess($activeCharacter)
|
||||
){
|
||||
// system model found
|
||||
// activate system (e.g. was inactive))
|
||||
$system->setActive(true);
|
||||
$systemModel = $system;
|
||||
}
|
||||
}elseif( isset($mapData['id']) ){
|
||||
// save NEW system ------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @var $map Model\MapModel
|
||||
*/
|
||||
$map = Model\BasicModel::getNew('MapModel');
|
||||
$map->getById($mapData['id']);
|
||||
if( $map->hasAccess($activeCharacter) ){
|
||||
// make sure system is not already on map
|
||||
// --> (e.g. multiple simultaneously save() calls for the same system)
|
||||
$systemModel = $map->getSystemByCCPId($systemData['systemId']);
|
||||
if( is_null($systemModel) ){
|
||||
// system not found on map -> get static system data (CCP DB)
|
||||
$systemModel = $map->getNewSystem($systemData['systemId']);
|
||||
$defaultStatusId = 1;
|
||||
}else{
|
||||
// system already exists (e.g. was inactive)
|
||||
$defaultStatusId = $systemModel->statusId;
|
||||
}
|
||||
|
||||
if( !is_null($systemModel) ){
|
||||
$systemModel->statusId = isset($systemData['statusId']) ? $systemData['statusId'] : $defaultStatusId;
|
||||
}
|
||||
|
||||
// map is not changeable for a system! (security)
|
||||
$systemData['mapId'] = $map;
|
||||
if($map->hasAccess($activeCharacter)){
|
||||
$systemModel = $map->getNewSystem($systemData['systemId']);
|
||||
}
|
||||
}
|
||||
|
||||
if( !is_null($systemModel) ){
|
||||
// "statusId" was set above
|
||||
unset($systemData['statusId']);
|
||||
unset($systemData['mapId']);
|
||||
|
||||
// set/update system
|
||||
$systemModel->setData($systemData);
|
||||
// activate system (e.g. was inactive))
|
||||
$systemModel->setActive(true);
|
||||
|
||||
// set/update system custom data
|
||||
$systemModel->copyfrom($systemData, ['locked', 'rallyUpdated', 'position', 'description']);
|
||||
|
||||
if($systemModel->save($activeCharacter)){
|
||||
// get data from "fresh" model (e.g. some relational data has changed: "statusId")
|
||||
@@ -220,7 +80,7 @@ class System extends Controller\AccessController {
|
||||
* @var $newSystemModel Model\SystemModel
|
||||
*/
|
||||
$newSystemModel = Model\BasicModel::getNew('SystemModel');
|
||||
$newSystemModel->getById( $systemModel->id, 0);
|
||||
$newSystemModel->getById( $systemModel->_id, 0);
|
||||
$newSystemModel->clearCacheData();
|
||||
$return->systemData = $newSystemModel->getData();
|
||||
|
||||
|
||||
@@ -70,8 +70,8 @@ class Universe extends Controller\AccessController {
|
||||
|
||||
$filter = [
|
||||
'id LIKE :id OR name LIKE :name',
|
||||
':id' => $search . '%',
|
||||
':name' => '%' . $search . '%'
|
||||
':id' => $search . '%', // -> match first
|
||||
':name' => '%' . $search . '%' // -> match between
|
||||
];
|
||||
$options = [
|
||||
'order' => 'name',
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
namespace Controller\Ccp;
|
||||
|
||||
|
||||
use Controller\Controller;
|
||||
use lib\Util;
|
||||
use Model;
|
||||
@@ -137,6 +136,8 @@ class Universe extends Controller {
|
||||
return $return;
|
||||
}
|
||||
|
||||
// system search index methods ====================================================================================
|
||||
|
||||
/**
|
||||
* build search index from all systems data
|
||||
* @param int $offset
|
||||
@@ -144,7 +145,7 @@ class Universe extends Controller {
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function buildSystemsIndex(int $offset = 0, int $length = 10){
|
||||
public function buildSystemsIndex(int $offset = 0, int $length = 10) : array {
|
||||
/**
|
||||
* @var $system Model\Universe\SystemModel
|
||||
*/
|
||||
@@ -194,15 +195,26 @@ class Universe extends Controller {
|
||||
|
||||
/**
|
||||
* look for existing systemData in index
|
||||
* -> id is either a valid systemId OR systemName
|
||||
* @param int|string $id
|
||||
* -> if not exists -> try to build
|
||||
* @param int $systemId
|
||||
* @return null|\stdClass
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function getSystemData($id){
|
||||
public function getSystemData(int $systemId){
|
||||
$data = null;
|
||||
if($id){
|
||||
$cacheKeyRow = Model\Universe\BasicUniverseModel::generateHashKeyRow('system', $id);
|
||||
if($systemId){
|
||||
// ...check index for data
|
||||
$cacheKeyRow = Model\Universe\BasicUniverseModel::generateHashKeyRow('system', $systemId);
|
||||
$data = $this->get($cacheKeyRow);
|
||||
if(!$data){
|
||||
// .. try to build index
|
||||
/**
|
||||
* @var $system Model\Universe\SystemModel
|
||||
*/
|
||||
$system = Model\Universe\BasicUniverseModel::getNew('SystemModel');
|
||||
$system->getById($systemId);
|
||||
$data = $system->buildIndex();
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
@@ -212,7 +224,7 @@ class Universe extends Controller {
|
||||
* @param string $cacheKey
|
||||
* @return null|\stdClass
|
||||
*/
|
||||
protected function get(string $cacheKey){
|
||||
private function get(string $cacheKey){
|
||||
$data = null;
|
||||
if($this->getF3()->exists($cacheKey,$value)) {
|
||||
if(is_string($value) && strpos($value, Model\Universe\BasicUniverseModel::CACHE_KEY_PREFIX) === 0) {
|
||||
@@ -230,7 +242,7 @@ class Universe extends Controller {
|
||||
* clear cacheKey
|
||||
* @param string $cacheKey
|
||||
*/
|
||||
protected function clear(string $cacheKey){
|
||||
private function clear(string $cacheKey){
|
||||
if($this->getF3()->exists($cacheKey,$value)) {
|
||||
if(is_string($value) && strpos($value, Model\Universe\BasicUniverseModel::CACHE_KEY_PREFIX) === 0) {
|
||||
// value references another cacheKey -> clear that one as well
|
||||
|
||||
@@ -32,10 +32,10 @@ class Setup extends Controller {
|
||||
'DB_PF_NAME',
|
||||
'DB_PF_USER',
|
||||
'DB_PF_PASS',
|
||||
'DB_CCP_DNS',
|
||||
'DB_CCP_NAME',
|
||||
'DB_CCP_USER',
|
||||
'DB_CCP_PASS',
|
||||
'DB_UNIVERSE_DNS',
|
||||
'DB_UNIVERSE_NAME',
|
||||
'DB_UNIVERSE_USER',
|
||||
'DB_UNIVERSE_PASS',
|
||||
'CCP_SSO_URL',
|
||||
'CCP_SSO_CLIENT_ID',
|
||||
'CCP_SSO_SECRET_KEY',
|
||||
@@ -102,8 +102,7 @@ class Setup extends Controller {
|
||||
'Model\SystemPodKillModel',
|
||||
'Model\SystemFactionKillModel',
|
||||
'Model\SystemJumpModel'
|
||||
],
|
||||
'tables' => []
|
||||
]
|
||||
],
|
||||
'UNIVERSE' => [
|
||||
'info' => [],
|
||||
@@ -112,30 +111,15 @@ class Setup extends Controller {
|
||||
'Model\Universe\GroupModel',
|
||||
'Model\Universe\CategoryModel',
|
||||
'Model\Universe\StructureModel',
|
||||
// 'Model\Universe\WormholeModel',
|
||||
// 'Model\Universe\StargateModel',
|
||||
// 'Model\Universe\StarModel',
|
||||
// 'Model\Universe\PlanetModel',
|
||||
// 'Model\Universe\SystemModel',
|
||||
// 'Model\Universe\ConstellationModel',
|
||||
// 'Model\Universe\RegionModel',
|
||||
// 'Model\Universe\SystemStaticModel'
|
||||
],
|
||||
'tables' => []
|
||||
],
|
||||
'CCP' => [
|
||||
'info' => [],
|
||||
'models' => [],
|
||||
'tables' => [
|
||||
'invTypes',
|
||||
'mapConstellations',
|
||||
'mapDenormalize',
|
||||
'mapLocationWormholeClasses',
|
||||
'mapRegions',
|
||||
'mapSolarSystemJumps',
|
||||
'mapSolarSystems'
|
||||
'Model\Universe\WormholeModel',
|
||||
'Model\Universe\StargateModel',
|
||||
'Model\Universe\StarModel',
|
||||
'Model\Universe\PlanetModel',
|
||||
'Model\Universe\SystemModel',
|
||||
'Model\Universe\ConstellationModel',
|
||||
'Model\Universe\RegionModel',
|
||||
'Model\Universe\SystemStaticModel'
|
||||
]
|
||||
|
||||
]
|
||||
];
|
||||
|
||||
@@ -277,98 +261,6 @@ class Setup extends Controller {
|
||||
$f3->set('cacheSize', $this->getCacheData($f3));
|
||||
}
|
||||
|
||||
/**
|
||||
* IMPORTANT: This function is not required for setup. It just imports *.json -> DB
|
||||
*
|
||||
* imports wormhole static data for "shattered" systems
|
||||
* into table "system_wormhole"
|
||||
* -> a *.csv dump of this *.json file can e found under /export/csv
|
||||
* @param \Base $f3
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function importSystemWormholesFromJson(\Base $f3){
|
||||
$path = $f3->get('EXPORT') .'json/statics.json';
|
||||
$pfDB = $this->getDB('PF');
|
||||
$ccpDB = $this->getDB('CCP');
|
||||
|
||||
$content = file_get_contents($path);
|
||||
|
||||
$jsonIterator = new \RecursiveIteratorIterator(
|
||||
new \RecursiveArrayIterator(json_decode($content, TRUE)),
|
||||
\RecursiveIteratorIterator::SELF_FIRST);
|
||||
|
||||
$staticNames = [];
|
||||
|
||||
$data = [];
|
||||
$tmpVal = (object) [];
|
||||
foreach ($jsonIterator as $key => $val) {
|
||||
if(is_array($val)) {
|
||||
if(isset($tmpVal->name)){
|
||||
$data[] = $tmpVal;
|
||||
}
|
||||
$tmpVal = (object) [];
|
||||
$tmpVal->name = $key;
|
||||
} else {
|
||||
$tmpVal->wh = isset($tmpVal->wh) ? array_merge($tmpVal->wh, [$val]) : [$val];
|
||||
$staticNames[] = $val;
|
||||
}
|
||||
}
|
||||
$data[] = $tmpVal;
|
||||
|
||||
// get static IDs by name ------------------------------
|
||||
$staticNames = array_unique($staticNames);
|
||||
$staticNames = array_flip($staticNames);
|
||||
foreach($staticNames as $name => $index){
|
||||
$result = $pfDB->exec("
|
||||
SELECT
|
||||
id
|
||||
FROM " . $pfDB->quotekey(Model\BasicModel::getNew('WormholeModel')->getTable()) . "
|
||||
WHERE " . $pfDB->quotekey('name') . " = :name",
|
||||
[':name' => $name]
|
||||
);
|
||||
$id = (int)$result[0]['id'];
|
||||
if($id){
|
||||
$staticNames[$name] = (int)$result[0]['id'];
|
||||
}else{
|
||||
$f3->error(500, 'Wormhole data missing in table "wormhole" for "name" = "' . $name . '"');
|
||||
}
|
||||
}
|
||||
|
||||
// import data -----------------------------------------
|
||||
$systemWormhole = Model\BasicModel::getNew('SystemWormholeModel');
|
||||
foreach($data as $staticData){
|
||||
$result = $ccpDB->exec("
|
||||
SELECT
|
||||
solarSystemID
|
||||
FROM " . $ccpDB->quotekey('mapSolarSystems') . "
|
||||
WHERE
|
||||
" . $ccpDB->quotekey('solarSystemName') . " = :systemName",
|
||||
[':systemName' => $staticData->name]
|
||||
);
|
||||
|
||||
$solarSystemID = (int)$result[0]['solarSystemID'];
|
||||
if($solarSystemID){
|
||||
foreach($staticData->wh as $wh){
|
||||
$staticId = (int)$staticNames[$wh];
|
||||
if($staticId){
|
||||
// check if entry already exists
|
||||
$systemWormhole->load(['systemId=? AND wormholeId=?', $solarSystemID, $staticId]);
|
||||
if( $systemWormhole->dry() ){
|
||||
$systemWormhole->systemId = $solarSystemID;
|
||||
$systemWormhole->wormholeId = $staticId;
|
||||
$systemWormhole->save();
|
||||
$systemWormhole->reset();
|
||||
}
|
||||
}else{
|
||||
$f3->error(500, 'Wormhole data missing for "name" = "' . $wh . '"');
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$f3->error(500, 'System "' . $staticData->name . '" not found on CCP´s [SDE] database');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* set environment information
|
||||
* @param \Base $f3
|
||||
@@ -378,8 +270,8 @@ class Setup extends Controller {
|
||||
$environmentData = [];
|
||||
// exclude some sensitive data (e.g. database, passwords)
|
||||
$excludeVars = [
|
||||
'DB_PF_DNS', 'DB_PF_NAME', 'DB_PF_USER', 'DB_PF_PASS',
|
||||
'DB_CCP_DNS', 'DB_CCP_NAME', 'DB_CCP_USER', 'DB_CCP_PASS'
|
||||
'DB_PF_DNS', 'DB_PF_NAME', 'DB_PF_USER', 'DB_PF_PASS',
|
||||
'DB_UNIVERSE_DNS', 'DB_UNIVERSE_NAME', 'DB_UNIVERSE_USER', 'DB_UNIVERSE_PASS'
|
||||
];
|
||||
|
||||
// obscure some values
|
||||
@@ -885,7 +777,6 @@ class Setup extends Controller {
|
||||
switch($dbKey){
|
||||
case 'PF': $dbLabel = 'Pathfinder'; break;
|
||||
case 'UNIVERSE': $dbLabel = 'EVE-Online universe'; break;
|
||||
case 'CCP': $dbLabel = 'EVE-Online [SDE]'; break;
|
||||
}
|
||||
|
||||
$dbName = $dbConfigValues['NAME'];
|
||||
@@ -912,15 +803,6 @@ class Setup extends Controller {
|
||||
];
|
||||
}
|
||||
break;
|
||||
case 'CCP':
|
||||
// get table model from static table array
|
||||
foreach($dbData['tables'] as $tableName){
|
||||
$requiredTables[$tableName] = [
|
||||
'exists' => false,
|
||||
'empty' => true
|
||||
];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// db connect was successful
|
||||
@@ -1352,14 +1234,10 @@ class Setup extends Controller {
|
||||
// active DB and tables are required for obtain index data
|
||||
if(!$this->databaseHasError){
|
||||
$categoryUniverseModel = Model\Universe\BasicUniverseModel::getNew('CategoryModel');
|
||||
//$systemUniverseModel = Model\Universe\BasicUniverseModel::getNew('SystemModel');
|
||||
$systemUniverseModel = Model\Universe\BasicUniverseModel::getNew('SystemModel');
|
||||
$systemNeighbourModel = Model\BasicModel::getNew('SystemNeighbourModel');
|
||||
$wormholeModel = Model\BasicModel::getNew('WormholeModel');
|
||||
$systemWormholeModel = Model\BasicModel::getNew('SystemWormholeModel');
|
||||
$constellationWormholeModel = Model\BasicModel::getNew('ConstellationWormholeModel');
|
||||
|
||||
$indexInfo = [
|
||||
/*
|
||||
'Systems' => [
|
||||
'task' => [
|
||||
[
|
||||
@@ -1378,7 +1256,7 @@ class Setup extends Controller {
|
||||
'countBuild' => count((new Universe())->getSystemsIndex()),
|
||||
'countAll' => $this->dbLib->getRowCount($systemUniverseModel->getTable(), 'UNIVERSE'),
|
||||
'tooltip' => 'build up a static search index over all systems found on DB. Do not refresh page until import is complete (check progress)! Runtime: ~5min'
|
||||
], */
|
||||
],
|
||||
'Structures' => [
|
||||
'task' => [
|
||||
[
|
||||
@@ -1392,7 +1270,7 @@ class Setup extends Controller {
|
||||
'countBuild' => $categoryUniverseModel->getById(65, 0)->getTypesCount(false),
|
||||
'countAll' => (int)$f3->get('REQUIREMENTS.DATA.STRUCTURES'),
|
||||
'tooltip' => 'import all structure types (e.g. Citadels) from ESI. Runtime: ~15s'
|
||||
], /*
|
||||
],
|
||||
'Ships' => [
|
||||
'task' => [
|
||||
[
|
||||
@@ -1406,9 +1284,8 @@ class Setup extends Controller {
|
||||
'countBuild' => $categoryUniverseModel->getById(6, 0)->getTypesCount(false),
|
||||
'countAll' => (int)$f3->get('REQUIREMENTS.DATA.SHIPS'),
|
||||
'tooltip' => 'import all ships types from ESI. Runtime: ~2min'
|
||||
], */
|
||||
// All following rows become deprecated
|
||||
'SystemNeighbourModel' => [
|
||||
],
|
||||
'SystemNeighbour' => [
|
||||
'task' => [
|
||||
[
|
||||
'action' => 'buildIndex',
|
||||
@@ -1417,10 +1294,14 @@ class Setup extends Controller {
|
||||
'btn' => 'btn-primary'
|
||||
]
|
||||
],
|
||||
'label' => 'system_neighbour',
|
||||
'label' => 'build neighbour index',
|
||||
'countBuild' => $this->dbLib->getRowCount($systemNeighbourModel->getTable()),
|
||||
'countAll' => 5214
|
||||
'countAll' => (int)$f3->get('REQUIREMENTS.DATA.NEIGHBOURS'),
|
||||
'tooltip' => 'build up a static search index for route search. This is used as fallback in case ESI is down. Runtime: ~30s'
|
||||
|
||||
],
|
||||
// All following rows become deprecated
|
||||
/*
|
||||
'WormholeModel' => [
|
||||
'task' => [
|
||||
[
|
||||
@@ -1438,53 +1319,18 @@ class Setup extends Controller {
|
||||
'label' => 'wormhole',
|
||||
'countBuild' => $this->dbLib->getRowCount($wormholeModel->getTable()),
|
||||
'countAll' => 89
|
||||
],
|
||||
'SystemWormholeModel' => [
|
||||
'task' => [
|
||||
[
|
||||
'action' => 'exportTable',
|
||||
'label' => 'Export',
|
||||
'icon' => 'fa-download',
|
||||
'btn' => 'btn-default'
|
||||
],[
|
||||
'action' => 'importTable',
|
||||
'label' => 'Import',
|
||||
'icon' => 'fa-upload',
|
||||
'btn' => 'btn-primary'
|
||||
]
|
||||
],
|
||||
'label' => 'system_wormhole',
|
||||
'countBuild' => $this->dbLib->getRowCount($systemWormholeModel->getTable()),
|
||||
'countAll' => 234
|
||||
],
|
||||
'ConstellationWormholeModel' => [
|
||||
'task' => [
|
||||
[
|
||||
'action' => 'exportTable',
|
||||
'label' => 'Export',
|
||||
'icon' => 'fa-download',
|
||||
'btn' => 'btn-default'
|
||||
],[
|
||||
'action' => 'importTable',
|
||||
'label' => 'Import',
|
||||
'icon' => 'fa-upload',
|
||||
'btn' => 'btn-primary'
|
||||
]
|
||||
],
|
||||
'label' => 'constellation_wormhole',
|
||||
'countBuild' => $this->dbLib->getRowCount( $constellationWormholeModel->getTable() ),
|
||||
'countAll' => 461
|
||||
]
|
||||
*/
|
||||
];
|
||||
}else{
|
||||
$indexInfo = [
|
||||
'SystemNeighbourModel' => [
|
||||
'SystemNeighbour' => [
|
||||
'task' => [],
|
||||
'label' => 'Fix database errors first!'
|
||||
]
|
||||
];
|
||||
}
|
||||
//var_dump($indexInfo); die();
|
||||
|
||||
return $indexInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
namespace Cron;
|
||||
use Controller;
|
||||
use DB;
|
||||
|
||||
class CcpSystemsUpdate extends AbstractCron {
|
||||
@@ -24,42 +23,63 @@ class CcpSystemsUpdate extends AbstractCron {
|
||||
* @var array
|
||||
*/
|
||||
protected $logTables = [
|
||||
'jumps' => 'system_jumps',
|
||||
'ship_kills' => 'system_kills_ships',
|
||||
'pod_kills' => 'system_kills_pods',
|
||||
'npc_kills' => 'system_kills_factions'
|
||||
'jumps' => 'system_jumps',
|
||||
'ship_kills' => 'system_kills_ships',
|
||||
'pod_kills' => 'system_kills_pods',
|
||||
'npc_kills' => 'system_kills_factions'
|
||||
];
|
||||
|
||||
/**
|
||||
* checks if a table exists in DB or not
|
||||
* @param DB\SQL $db
|
||||
* @param string $table
|
||||
* @return bool
|
||||
*/
|
||||
protected function tableExists (DB\SQL $db, string $table) : bool {
|
||||
return !empty($db->exec('SHOW TABLES LIKE :table', [':table' => $table]));
|
||||
}
|
||||
|
||||
/**
|
||||
* check all system log tables for the correct number of system entries that will be locked
|
||||
* @return array
|
||||
*/
|
||||
private function prepareSystemLogTables(){
|
||||
// get information for all systems from CCP DB
|
||||
$systemController = new Controller\Api\System();
|
||||
$systemsData = $systemController->getSystems();
|
||||
private function prepareSystemLogTables() : array {
|
||||
$systemsData = [];
|
||||
|
||||
$pfDB = DB\Database::instance()->getDB('PF');
|
||||
// get all available systems from "universe" DB
|
||||
$universeDB = DB\Database::instance()->getDB('UNIVERSE');
|
||||
|
||||
// insert systems into each log table if not exist
|
||||
$pfDB->begin();
|
||||
foreach($this->logTables as $tableName){
|
||||
if($this->tableExists($universeDB, 'system')){
|
||||
$systemsData = $universeDB->exec('SELECT
|
||||
`id`
|
||||
FROM
|
||||
`system`
|
||||
WHERE
|
||||
`security` = :ns OR
|
||||
`security` = :ls OR
|
||||
`security` = :hs
|
||||
',
|
||||
[':ns' => '0.0', ':ls' => 'L', ':hs' => 'H']
|
||||
);
|
||||
|
||||
// insert systems into jump log table
|
||||
$sqlInsertSystem = "INSERT IGNORE INTO " . $tableName . " (systemId)
|
||||
$pfDB = DB\Database::instance()->getDB('PF');
|
||||
|
||||
// insert systems into each log table if not exist
|
||||
$pfDB->begin();
|
||||
foreach($this->logTables as $tableName){
|
||||
// insert systems into jump log table
|
||||
$sqlInsertSystem = "INSERT IGNORE INTO " . $tableName . " (systemId)
|
||||
VALUES(:systemId)";
|
||||
|
||||
foreach($systemsData as $systemData){
|
||||
// skip WH systems -> no jump data available
|
||||
if($systemData['type']['name'] == 'k-space'){
|
||||
foreach($systemsData as $systemData){
|
||||
$pfDB->exec($sqlInsertSystem, array(
|
||||
':systemId' => $systemData['systemId']
|
||||
':systemId' => $systemData['id']
|
||||
), 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$pfDB->commit();
|
||||
}
|
||||
$pfDB->commit();
|
||||
|
||||
return $systemsData;
|
||||
}
|
||||
@@ -70,7 +90,7 @@ class CcpSystemsUpdate extends AbstractCron {
|
||||
* >> php index.php "/cron/importSystemData"
|
||||
* @param \Base $f3
|
||||
*/
|
||||
function importSystemData($f3){
|
||||
function importSystemData(\Base $f3){
|
||||
$this->setMaxExecutionTime();
|
||||
|
||||
// prepare system jump log table ------------------------------------------------------------------------------
|
||||
@@ -135,7 +155,7 @@ class CcpSystemsUpdate extends AbstractCron {
|
||||
";
|
||||
|
||||
foreach($systemsData as $systemData){
|
||||
$systemId = $systemData['systemId'];
|
||||
$systemId = $systemData['id'];
|
||||
|
||||
// update data (if available)
|
||||
$currentData = 0;
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: exodus4d
|
||||
* Date: 14.02.15
|
||||
* Time: 21:28
|
||||
*/
|
||||
|
||||
namespace Data\Mapper;
|
||||
|
||||
class CcpSystemsMapper extends AbstractIterator {
|
||||
|
||||
protected static $map = [
|
||||
'system_id' => 'systemId',
|
||||
'system_name' => 'name',
|
||||
'connstallation_id' => ['constellation' => 'id'],
|
||||
'constallation_name' => ['constellation' => 'name'],
|
||||
'region_id' => ['region' => 'id'],
|
||||
'region_name' => ['region' => 'name']
|
||||
];
|
||||
|
||||
/**
|
||||
* map iterator
|
||||
* @return array
|
||||
*/
|
||||
public function getData(){
|
||||
|
||||
// "system trueSec" mapping -------------------------------------------
|
||||
self::$map['trueSec'] = function($iterator){
|
||||
$trueSec = self::formatTrueSec($iterator['system_security']);
|
||||
return $trueSec;
|
||||
};
|
||||
|
||||
// "system effect" mapping --------------------------------------------
|
||||
self::$map['effect'] = function($iterator){
|
||||
$effect = $iterator['effect'];
|
||||
|
||||
switch($iterator['effect']){
|
||||
case 'magnetar':
|
||||
$effect = 'magnetar';
|
||||
break;
|
||||
case 'red giant':
|
||||
$effect = 'redGiant';
|
||||
break;
|
||||
case 'pulsar':
|
||||
$effect = 'pulsar';
|
||||
break;
|
||||
case 'wolf-rayet star':
|
||||
$effect = 'wolfRayet';
|
||||
break;
|
||||
case 'cataclysmic variable':
|
||||
$effect = 'cataclysmic';
|
||||
break;
|
||||
case 'black hole':
|
||||
$effect = 'blackHole';
|
||||
break;
|
||||
}
|
||||
|
||||
return $effect;
|
||||
};
|
||||
|
||||
// "system security" mapping ------------------------------------------
|
||||
self::$map['security'] = function($iterator){
|
||||
$security = '';
|
||||
|
||||
if(
|
||||
$iterator['constellation']['id'] >= 22000001 &&
|
||||
$iterator['constellation']['id'] <= 22000025
|
||||
){
|
||||
// "Abyssal" system
|
||||
$security = 'A';
|
||||
}elseif(
|
||||
$iterator['security'] == 7 ||
|
||||
$iterator['security'] == 8 ||
|
||||
$iterator['security'] == 9
|
||||
){
|
||||
// k-space system
|
||||
$trueSec = self::formatTrueSec($iterator['system_security']);
|
||||
|
||||
if($trueSec <= 0){
|
||||
$security = '0.0';
|
||||
}elseif($trueSec < 0.5){
|
||||
$security = 'L';
|
||||
}else{
|
||||
$security = 'H';
|
||||
}
|
||||
}elseif(
|
||||
$iterator['security'] == 1 ||
|
||||
$iterator['security'] == 2 ||
|
||||
$iterator['security'] == 3 ||
|
||||
$iterator['security'] == 4 ||
|
||||
$iterator['security'] == 5 ||
|
||||
$iterator['security'] == 6
|
||||
){
|
||||
// standard wormhole system
|
||||
$security = 'C' . $iterator['security'];
|
||||
}elseif(
|
||||
$iterator['security'] == 13
|
||||
){
|
||||
// shattered wormhole system
|
||||
$security = 'SH';
|
||||
}
|
||||
|
||||
return $security;
|
||||
};
|
||||
|
||||
// "system type" mapping ----------------------------------------------
|
||||
self::$map['type'] = function($iterator){
|
||||
|
||||
// TODO refactor
|
||||
$type = 'w-space';
|
||||
$typeId = 1;
|
||||
if(
|
||||
$iterator['constellation']['id'] >= 22000001 &&
|
||||
$iterator['constellation']['id'] <= 22000025
|
||||
){
|
||||
// "Abyssal" system
|
||||
$type = 'a-space';
|
||||
$typeId = 3;
|
||||
}elseif(
|
||||
$iterator['security'] == 7 ||
|
||||
$iterator['security'] == 8 ||
|
||||
$iterator['security'] == 9
|
||||
){
|
||||
$type = 'k-space';
|
||||
$typeId = 2;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $typeId,
|
||||
'name' => $type
|
||||
];
|
||||
};
|
||||
|
||||
iterator_apply($this, 'self::recursiveIterator', [$this]);
|
||||
|
||||
return iterator_to_array($this, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* format trueSec
|
||||
* @param $trueSec
|
||||
* @return float
|
||||
*/
|
||||
static function formatTrueSec($trueSec){
|
||||
$positive = ($trueSec > 0);
|
||||
$trueSec = round((float)$trueSec, 1, PHP_ROUND_HALF_DOWN);
|
||||
|
||||
if($positive && $trueSec <= 0){
|
||||
$trueSec = 0.1;
|
||||
}
|
||||
return $trueSec;
|
||||
}
|
||||
|
||||
static function recursiveIterator($iterator){
|
||||
|
||||
while ( $iterator -> valid() ) {
|
||||
if ( $iterator->hasChildren() ) {
|
||||
$iterator->offsetSet($iterator->key(), self::recursiveIterator( $iterator->getChildren() )->getArrayCopy() );
|
||||
}else {
|
||||
|
||||
while( $iterator -> valid() ){
|
||||
|
||||
// check for mapping key
|
||||
if(array_key_exists($iterator->key(), self::$map)){
|
||||
|
||||
if(is_array(self::$map[$iterator->key()])){
|
||||
// a -> array mapping
|
||||
|
||||
$parentKey = array_keys( self::$map[$iterator->key()] )[0];
|
||||
$entryKey = array_values( self::$map[$iterator->key()] )[0];
|
||||
|
||||
// check if key already exists
|
||||
if($iterator->offsetExists($parentKey)){
|
||||
$currentValue = $iterator->offsetGet($parentKey);
|
||||
// add new array entry
|
||||
$currentValue[$entryKey] = $iterator->current();
|
||||
|
||||
$iterator->offsetSet( $parentKey, $currentValue );
|
||||
}else{
|
||||
$iterator->offsetSet( $parentKey, [$entryKey => $iterator->current() ] );
|
||||
}
|
||||
|
||||
$removeOldEntry = true;
|
||||
}elseif(is_object(self::$map[$iterator->key()])){
|
||||
// a -> a (format by function)
|
||||
|
||||
$formatFunction = self::$map[$iterator->key()];
|
||||
|
||||
$iterator->offsetSet( $iterator->key(), call_user_func($formatFunction, $iterator) );
|
||||
|
||||
// just value change no key change
|
||||
$removeOldEntry = false;
|
||||
$iterator->next();
|
||||
}else{
|
||||
// a -> b mapping
|
||||
$iterator->offsetSet( self::$map[$iterator->key()], $iterator->current() );
|
||||
|
||||
$removeOldEntry = true;
|
||||
}
|
||||
|
||||
// remove "old" entry
|
||||
if($removeOldEntry){
|
||||
$iterator->offsetUnset($iterator->key());
|
||||
}
|
||||
|
||||
}else{
|
||||
// continue with next entry
|
||||
$iterator -> next();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$iterator -> next();
|
||||
}
|
||||
|
||||
return $iterator;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -514,7 +514,7 @@ abstract class BasicModel extends \DB\Cortex {
|
||||
* -> this will not work (prevent abuse)
|
||||
* @param bool $active
|
||||
*/
|
||||
public function setActive($active){
|
||||
public function setActive(bool $active){
|
||||
// enables "active" change for this model
|
||||
$this->allowActiveChange = true;
|
||||
$this->active = $active;
|
||||
|
||||
@@ -470,25 +470,20 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
* @return SystemModel
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getNewSystem($systemId){
|
||||
public function getNewSystem(int $systemId) : SystemModel {
|
||||
// check for "inactive" system
|
||||
$system = $this->getSystemByCCPId($systemId);
|
||||
if(is_null($system)){
|
||||
// get blank system
|
||||
$systemController = new System();
|
||||
$systems = $systemController->getSystemModelByIds([$systemId]);
|
||||
if(count($systems)){
|
||||
$system = reset($systems);
|
||||
$system->mapId = $this->_id;
|
||||
}else{
|
||||
// should NEVER happen -> systemId does NOT exist in New Eden!!
|
||||
$this->getF3()->error(500, 'SystemId "' . $systemId . '"" does not exist in EVE!' );
|
||||
}
|
||||
/**
|
||||
* @var $system SystemModel
|
||||
*/
|
||||
$system = $this->rel('systems');
|
||||
$system->systemId = $systemId;
|
||||
$system->mapId = $this;
|
||||
$system->setType();
|
||||
}
|
||||
|
||||
if($system){
|
||||
$system->setActive(true);
|
||||
}
|
||||
$system->setActive(true);
|
||||
|
||||
return $system;
|
||||
}
|
||||
@@ -499,7 +494,7 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
* @param SystemModel $targetSystem
|
||||
* @return ConnectionModel
|
||||
*/
|
||||
public function getNewConnection(SystemModel $sourceSystem, SystemModel $targetSystem){
|
||||
public function getNewConnection(SystemModel $sourceSystem, SystemModel $targetSystem) : ConnectionModel {
|
||||
/**
|
||||
* @var $connection ConnectionModel
|
||||
*/
|
||||
@@ -562,7 +557,7 @@ class MapModel extends AbstractMapTrackingModel {
|
||||
* get either all system models in this map
|
||||
* @return SystemModel[]
|
||||
*/
|
||||
public function getSystems(){
|
||||
protected function getSystems(){
|
||||
$systems = [];
|
||||
|
||||
// orderBy x-Coordinate for smoother frontend animation (left to right)
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Model;
|
||||
|
||||
use DB\SQL\Schema;
|
||||
use lib\logging;
|
||||
use Controller\Ccp\Universe;
|
||||
|
||||
class SystemModel extends AbstractMapTrackingModel {
|
||||
|
||||
@@ -18,6 +19,8 @@ class SystemModel extends AbstractMapTrackingModel {
|
||||
|
||||
protected $table = 'system';
|
||||
|
||||
protected $staticSystemDataCache = [];
|
||||
|
||||
protected $fieldConf = [
|
||||
'active' => [
|
||||
'type' => Schema::DT_BOOL,
|
||||
@@ -40,6 +43,7 @@ class SystemModel extends AbstractMapTrackingModel {
|
||||
'systemId' => [
|
||||
'type' => Schema::DT_INT,
|
||||
'index' => true,
|
||||
'validate' => true
|
||||
],
|
||||
'name' => [
|
||||
'type' => Schema::DT_VARCHAR128,
|
||||
@@ -54,7 +58,7 @@ class SystemModel extends AbstractMapTrackingModel {
|
||||
],
|
||||
'regionId' => [
|
||||
'type' => Schema::DT_INT,
|
||||
'index' => true,
|
||||
'index' => true
|
||||
],
|
||||
'region' => [
|
||||
'type' => Schema::DT_VARCHAR128,
|
||||
@@ -63,7 +67,7 @@ class SystemModel extends AbstractMapTrackingModel {
|
||||
],
|
||||
'constellationId' => [
|
||||
'type' => Schema::DT_INT,
|
||||
'index' => true,
|
||||
'index' => true
|
||||
],
|
||||
'constellation' => [
|
||||
'type' => Schema::DT_VARCHAR128,
|
||||
@@ -202,56 +206,58 @@ class SystemModel extends AbstractMapTrackingModel {
|
||||
if(is_null($systemData)){
|
||||
// no cached system data found
|
||||
|
||||
$systemData = (object) [];
|
||||
$systemData->id = $this->_id;
|
||||
$systemData->mapId = is_object($this->mapId) ? $this->get('mapId', true) : 0;
|
||||
$systemData->systemId = $this->systemId;
|
||||
$systemData->name = $this->name;
|
||||
$systemData->alias = $this->alias;
|
||||
$systemData->effect = $this->effect;
|
||||
$systemData->security = $this->security;
|
||||
$systemData->trueSec = $this->trueSec;
|
||||
$systemData = (object) [];
|
||||
$systemData->id = $this->_id;
|
||||
$systemData->mapId = is_object($this->mapId) ? $this->get('mapId', true) : 0;
|
||||
$systemData->systemId = $this->systemId;
|
||||
$systemData->alias = $this->alias;
|
||||
|
||||
$systemData->region = (object) [];
|
||||
$systemData->region->id = $this->regionId;
|
||||
$systemData->region->name = $this->region;
|
||||
if(is_object($this->typeId)){
|
||||
$systemData->type = $this->typeId->getData();
|
||||
}
|
||||
|
||||
$systemData->constellation = (object) [];
|
||||
$systemData->constellation->id = $this->constellationId;
|
||||
$systemData->constellation->name = $this->constellation;
|
||||
$systemData->status = (object) [];
|
||||
$systemData->status->id = is_object($this->statusId) ? $this->statusId->id : 1;
|
||||
$systemData->status->name = is_object($this->statusId) ? $this->statusId->name : 'unknown';
|
||||
|
||||
$systemData->type = (object) [];
|
||||
$systemData->type->id = $this->typeId->id;
|
||||
$systemData->type->name = $this->typeId->name;
|
||||
$systemData->locked = $this->locked;
|
||||
$systemData->rallyUpdated = strtotime($this->rallyUpdated);
|
||||
$systemData->rallyPoke = $this->rallyPoke;
|
||||
$systemData->description = $this->description;
|
||||
|
||||
$systemData->status = (object) [];
|
||||
$systemData->status->id = is_object($this->statusId) ? $this->statusId->id : 1;
|
||||
$systemData->status->name = is_object($this->statusId) ? $this->statusId->name : 'unknown';
|
||||
$systemData->position = (object) [];
|
||||
$systemData->position->x = $this->posX;
|
||||
$systemData->position->y = $this->posY;
|
||||
|
||||
$systemData->locked = $this->locked;
|
||||
$systemData->rallyUpdated = strtotime($this->rallyUpdated);
|
||||
$systemData->rallyPoke = $this->rallyPoke;
|
||||
$systemData->description = $this->description;
|
||||
|
||||
$systemData->statics = $this->getStaticWormholeData();
|
||||
|
||||
$systemData->position = (object) [];
|
||||
$systemData->position->x = $this->posX;
|
||||
$systemData->position->y = $this->posY;
|
||||
|
||||
|
||||
$systemData->created = (object) [];
|
||||
$systemData->created->created = strtotime($this->created);
|
||||
$systemData->created = (object) [];
|
||||
$systemData->created->created = strtotime($this->created);
|
||||
if(is_object($this->createdCharacterId)){
|
||||
$systemData->created->character = $this->createdCharacterId->getData();
|
||||
}
|
||||
|
||||
$systemData->updated = (object) [];
|
||||
$systemData->updated->updated = strtotime($this->updated);
|
||||
$systemData->updated = (object) [];
|
||||
$systemData->updated->updated = strtotime($this->updated);
|
||||
if(is_object($this->updatedCharacterId)){
|
||||
$systemData->updated->character = $this->updatedCharacterId->getData();
|
||||
}
|
||||
|
||||
// static system data -------------------------------------------------------------------------------------
|
||||
$systemData->name = $this->name;
|
||||
$systemData->security = $this->security;
|
||||
$systemData->trueSec = $this->trueSec;
|
||||
$systemData->effect = $this->effect;
|
||||
$systemData->shattered = $this->shattered;
|
||||
|
||||
$systemData->constellation = (object) [];
|
||||
$systemData->constellation->id = $this->constellationId;
|
||||
$systemData->constellation->name = $this->constellation;
|
||||
|
||||
$systemData->region = (object) [];
|
||||
$systemData->region->id = $this->regionId;
|
||||
$systemData->region->name = $this->region;
|
||||
|
||||
$systemData->statics = $this->statics ? : [];
|
||||
|
||||
// max caching time for a system
|
||||
// the cached date has to be cleared manually on any change
|
||||
// this includes system, connection,... changes (all dependencies)
|
||||
@@ -262,7 +268,58 @@ class SystemModel extends AbstractMapTrackingModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* setter for system alias
|
||||
* get all static data
|
||||
* @return mixed|null|\stdClass
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function getStaticSystemData(){
|
||||
$staticData = null;
|
||||
if( !empty($this->staticSystemDataCache[$this->systemId]) ){
|
||||
$staticData = $this->staticSystemDataCache[$this->systemId];
|
||||
}else{
|
||||
$staticData = (new Universe())->getSystemData($this->systemId);
|
||||
if($staticData){
|
||||
$this->staticSystemDataCache = [$this->systemId => $staticData];
|
||||
}
|
||||
}
|
||||
return $staticData;
|
||||
}
|
||||
|
||||
/**
|
||||
* get static system data by key
|
||||
* @param string $key
|
||||
* @return null
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function getStaticSystemValue(string $key){
|
||||
$value = null;
|
||||
if( $staticData = $this->getStaticSystemData()){
|
||||
if(isset($staticData->$key)){
|
||||
$value = $staticData->$key;
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param int $val
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function validate_systemId(string $key, int $val): bool {
|
||||
$valid = true;
|
||||
// check if static system data exists for systemId = $val
|
||||
if( !(bool)(new Universe())->getSystemData($val) ){
|
||||
$valid = false;
|
||||
$this->throwValidationException($key, 'Validation failed: "' . $key . '" = "' . $val . '"');
|
||||
}
|
||||
|
||||
return $valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter for system alias
|
||||
* @param string $alias
|
||||
* @return string
|
||||
*/
|
||||
@@ -278,30 +335,35 @@ class SystemModel extends AbstractMapTrackingModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* setter for system security value
|
||||
* @param float $trueSec
|
||||
* @return float
|
||||
* setter for statusId
|
||||
* @param $status
|
||||
*/
|
||||
public function set_trueSec($trueSec){
|
||||
if(
|
||||
$trueSec > 0 &&
|
||||
$trueSec < 0.1
|
||||
){
|
||||
// 0.3 is still a LS -> no rounding
|
||||
$trueSec = 0.1;
|
||||
}else{
|
||||
$trueSec = round($trueSec, 1);
|
||||
public function set_status($status){
|
||||
if($statusId = (int)$status['id']){
|
||||
$this->statusId = $statusId;
|
||||
}
|
||||
|
||||
return $trueSec;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter validation for x coordinate
|
||||
* setter for position array
|
||||
* @param $position
|
||||
* @return null
|
||||
*/
|
||||
public function set_position($position){
|
||||
$position = (array)$position;
|
||||
if(count($position) === 2){
|
||||
$this->posX = $position['x'];
|
||||
$this->posY = $position['y'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter for x coordinate
|
||||
* @param int $posX
|
||||
* @return int
|
||||
*/
|
||||
public function set_posX($posX){
|
||||
public function set_posX(int $posX) : int {
|
||||
$posX = abs($posX);
|
||||
if($posX > self::MAX_POS_X){
|
||||
$posX = self::MAX_POS_X;
|
||||
@@ -311,11 +373,11 @@ class SystemModel extends AbstractMapTrackingModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* setter validation for y coordinate
|
||||
* setter for y coordinate
|
||||
* @param int $posY
|
||||
* @return int
|
||||
*/
|
||||
public function set_posY($posY){
|
||||
public function set_posY(int $posY) : int{
|
||||
$posY = abs($posY);
|
||||
if($posY > self::MAX_POS_Y){
|
||||
$posY = self::MAX_POS_Y;
|
||||
@@ -348,6 +410,50 @@ class SystemModel extends AbstractMapTrackingModel {
|
||||
return $rally;
|
||||
}
|
||||
|
||||
public function get_name(){
|
||||
return $this->getStaticSystemValue('name');
|
||||
}
|
||||
|
||||
public function get_constellationId(){
|
||||
$constellationData = $this->getStaticSystemValue('constellation');
|
||||
return $constellationData ? $constellationData->id : null;
|
||||
}
|
||||
|
||||
public function get_constellation(){
|
||||
$constellationData = $this->getStaticSystemValue('constellation');
|
||||
return $constellationData ? $constellationData->name : null;
|
||||
}
|
||||
|
||||
public function get_regionId(){
|
||||
$constellationData = $this->getStaticSystemValue('constellation');
|
||||
return ($constellationData && $constellationData->region) ? $constellationData->region->id : null;
|
||||
}
|
||||
|
||||
public function get_region(){
|
||||
$constellationData = $this->getStaticSystemValue('constellation');
|
||||
return ($constellationData && $constellationData->region) ? $constellationData->region->name : null;
|
||||
}
|
||||
|
||||
public function get_security(){
|
||||
return $this->getStaticSystemValue('security');
|
||||
}
|
||||
|
||||
public function get_trueSec(){
|
||||
return $this->getStaticSystemValue('trueSec');
|
||||
}
|
||||
|
||||
public function get_effect(){
|
||||
return $this->getStaticSystemValue('effect');
|
||||
}
|
||||
|
||||
public function get_shattered(){
|
||||
return $this->getStaticSystemValue('shattered');
|
||||
}
|
||||
|
||||
public function get_statics(){
|
||||
return $this->getStaticSystemValue('statics');
|
||||
}
|
||||
|
||||
/**
|
||||
* Event "Hook" function
|
||||
* @param self $self
|
||||
@@ -555,14 +661,6 @@ class SystemModel extends AbstractMapTrackingModel {
|
||||
return ($this->typeId->id === 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether this system is a shattered wormhole
|
||||
* @return bool
|
||||
*/
|
||||
public function isShatteredWormhole() : bool {
|
||||
return ($this->isWormhole() && $this->security === 'SH');
|
||||
}
|
||||
|
||||
/**
|
||||
* check whether this system is an Abyss system
|
||||
* @return bool
|
||||
@@ -631,44 +729,28 @@ class SystemModel extends AbstractMapTrackingModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* get static WH data for this system
|
||||
* -> any WH system has at least one static WH
|
||||
* @return \stdClass[]
|
||||
* @throws \Exception
|
||||
* set system type based on security
|
||||
*/
|
||||
protected function getStaticWormholeData(){
|
||||
$wormholeData = [];
|
||||
|
||||
// only wormholes have "static" connections
|
||||
if($this->isWormhole()){
|
||||
// get static systems by "constellationId" --------------------------------------------
|
||||
$constellationWormholeModel = self::getNew('ConstellationWormholeModel');
|
||||
$systemStatics = $constellationWormholeModel->find([
|
||||
'constellationId = :constellationId',
|
||||
':constellationId' => $this->constellationId
|
||||
]);
|
||||
|
||||
if( is_object($systemStatics) ){
|
||||
foreach($systemStatics as $systemStatic){
|
||||
$wormholeData[] = $systemStatic->getData();
|
||||
}
|
||||
}
|
||||
|
||||
// get static systems by "systemId" (shattered wormholes) -----------------------------
|
||||
$systemWormholeModel = self::getNew('SystemWormholeModel');
|
||||
$systemStatics = $systemWormholeModel->find([
|
||||
'systemId = :systemId',
|
||||
':systemId' => $this->systemId
|
||||
]);
|
||||
|
||||
if( is_object($systemStatics) ){
|
||||
foreach($systemStatics as $systemStatic){
|
||||
$wormholeData[] = $systemStatic->getData();
|
||||
}
|
||||
}
|
||||
public function setType(){
|
||||
switch($this->security){
|
||||
case 'H':
|
||||
case 'L':
|
||||
case '0.0':
|
||||
$typeId = 2; // k-space
|
||||
break;
|
||||
case 'A':
|
||||
$typeId = 3; // a-space
|
||||
break;
|
||||
default:
|
||||
$typeId = 1; // w-space
|
||||
}
|
||||
|
||||
return $wormholeData;
|
||||
/**
|
||||
* @var $type MapTypeModel
|
||||
*/
|
||||
$type = $this->rel('typeId');
|
||||
$type->getById($typeId);
|
||||
$this->typeId = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,4 +43,17 @@ class SystemTypeModel extends BasicModel {
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* get system type data
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function getData(){
|
||||
|
||||
$typeData = (object)[];
|
||||
$typeData->id = $this->_id;
|
||||
$typeData->name = $this->name;
|
||||
|
||||
return $typeData;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -110,10 +110,10 @@ class SystemModel extends BasicUniverseModel {
|
||||
$systemData->security = $this->security;
|
||||
$systemData->trueSec = (float)$this->trueSec;
|
||||
$systemData->effect = $this->effect;
|
||||
$systemData->shattered = $this->shattered;
|
||||
$systemData->shattered = (bool)$this->shattered;
|
||||
|
||||
if($this->starId){
|
||||
$systemData->star = $this->starId->getData();
|
||||
$systemData->star = $this->starId->getData();
|
||||
}
|
||||
|
||||
if( !empty($planetsData = $this->getPlanetsData()) ){
|
||||
@@ -125,7 +125,7 @@ class SystemModel extends BasicUniverseModel {
|
||||
}
|
||||
|
||||
if( !empty($stargatesData = $this->getStargatesData()) ){
|
||||
$systemData->stargates = $stargatesData;
|
||||
$systemData->stargates = $stargatesData;
|
||||
}
|
||||
|
||||
return $systemData;
|
||||
|
||||
@@ -77,6 +77,33 @@ class WormholeModel extends BasicUniverseModel {
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* get wormhole data
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function getData(){
|
||||
|
||||
$wormholeData = (object) [];
|
||||
$wormholeData->name = $this->name;
|
||||
$wormholeData->static = $this->static;
|
||||
$wormholeData->security = $this->security;
|
||||
$wormholeData->massTotal = $this->massTotal;
|
||||
$wormholeData->massIndividual = $this->massIndividual;
|
||||
|
||||
if($this->massRegeneration){
|
||||
$wormholeData->massRegeneration = $this->massRegeneration;
|
||||
}
|
||||
|
||||
$wormholeData->maxStableTime = $this->maxStableTime;
|
||||
|
||||
// signature strength as defined by http://wiki.eve-inspiracy.com/index.php?title=Wormhole_Signature_Strength_List
|
||||
if($this->signatureStrength){
|
||||
$wormholeData->signatureStrength = $this->signatureStrength;
|
||||
}
|
||||
|
||||
return $wormholeData;
|
||||
}
|
||||
|
||||
/**
|
||||
* setter for typeId
|
||||
* @param string $typeId
|
||||
|
||||
@@ -75,3 +75,4 @@ NPM = 3.10.0
|
||||
[REQUIREMENTS.DATA]
|
||||
STRUCTURES = 33
|
||||
SHIPS = 490
|
||||
NEIGHBOURS = 5201
|
||||
|
||||
@@ -482,6 +482,7 @@ define([
|
||||
system.data('region', data.region.name);
|
||||
system.data('constellationId', parseInt(data.constellation.id));
|
||||
system.data('constellation', data.constellation.name);
|
||||
system.data('shattered', data.shattered);
|
||||
system.data('statics', data.statics);
|
||||
system.data('updated', parseInt(data.updated.updated));
|
||||
system.data('changed', false);
|
||||
@@ -2189,17 +2190,14 @@ define([
|
||||
}
|
||||
|
||||
// init system tooltips =======================================================================================
|
||||
// TODO check this code:
|
||||
/*
|
||||
let systemTooltipOptions = {
|
||||
toggle: 'tooltip',
|
||||
placement: 'right',
|
||||
container: 'body',
|
||||
viewport: system.id
|
||||
};
|
||||
|
||||
system.find('.fas').tooltip(systemTooltipOptions);
|
||||
*/
|
||||
|
||||
// context menu ===============================================================================================
|
||||
|
||||
// trigger context menu
|
||||
@@ -3287,6 +3285,7 @@ define([
|
||||
systemData.rallyUpdated = system.data('rallyUpdated') || 0;
|
||||
systemData.rallyPoke = system.data('rallyPoke') ? 1 : 0;
|
||||
systemData.currentUser = system.data('currentUser'); // if user is currently in this system
|
||||
systemData.shattered = system.data('shattered') ? 1 : 0;
|
||||
systemData.statics = system.data('statics');
|
||||
systemData.updated = {
|
||||
updated: parseInt( system.data('updated') )
|
||||
|
||||
@@ -24,6 +24,9 @@ define([
|
||||
popoverTriggerClass: 'pf-popover-trigger', // class for "popover" trigger elements
|
||||
|
||||
systemHeadInfoClass: 'pf-system-head-info', // class for system info
|
||||
systemHeadInfoLeftClass: 'pf-system-head-info-left', // class for left system info
|
||||
systemHeadInfoRightClass: 'pf-system-head-info-right', // class for right system info
|
||||
|
||||
systemActiveClass: 'pf-system-active', // class for an active system on a map
|
||||
systemTooltipInnerIdPrefix: 'pf-system-tooltip-inner-', // id prefix for system tooltip content
|
||||
systemTooltipInnerClass: 'pf-system-tooltip-inner', // class for system tooltip content
|
||||
@@ -406,7 +409,7 @@ define([
|
||||
* @param systems
|
||||
*/
|
||||
let removeSystems = (map, systems) => {
|
||||
let removeSystemCallbak = function(deleteSystem){
|
||||
let removeSystemCallbak = deleteSystem => {
|
||||
map.remove(deleteSystem);
|
||||
};
|
||||
|
||||
@@ -441,7 +444,7 @@ define([
|
||||
* @param sourceSystem
|
||||
* @returns {{x: *, y: *}}
|
||||
*/
|
||||
let calculateNewSystemPosition = function(sourceSystem){
|
||||
let calculateNewSystemPosition = sourceSystem => {
|
||||
let mapContainer = sourceSystem.parent();
|
||||
let grid = [MapUtil.config.mapSnapToGridDimension, MapUtil.config.mapSnapToGridDimension];
|
||||
|
||||
@@ -490,24 +493,39 @@ define([
|
||||
*/
|
||||
let getHeadInfoElement = (data) => {
|
||||
let headInfo = null;
|
||||
let headInfoLeft = [];
|
||||
let headInfoRight = [];
|
||||
|
||||
if(data.shattered){
|
||||
headInfoLeft.push('<i class="fas fa-fw fa-skull ' + Util.getSecurityClassForSystem('SH') + '" title="shattered"></i>');
|
||||
}
|
||||
|
||||
// check systemData if headInfo element is needed
|
||||
if(data.statics && data.statics.length){
|
||||
// format wh statics
|
||||
let statics = [];
|
||||
for(let staticData of data.statics){
|
||||
statics.push(
|
||||
for(let wormholeName of data.statics){
|
||||
let staticData = Object.assign({}, Init.wormholes[wormholeName]);
|
||||
headInfoRight.push(
|
||||
'<span class="' +
|
||||
Util.getSecurityClassForSystem(staticData.security) + ' ' +
|
||||
config.popoverTriggerClass + '" data-name="' + staticData.name +
|
||||
'">' + staticData.security + '</span>'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
headInfo = $('<div>', {
|
||||
if(headInfoLeft.length || headInfoRight.length){
|
||||
headInfo = $('<div>', {
|
||||
class: config.systemHeadInfoClass
|
||||
}).append(
|
||||
statics.join(' ')
|
||||
$('<div>', {
|
||||
class: config.systemHeadInfoLeftClass,
|
||||
html: headInfoLeft.join(' ')
|
||||
}),
|
||||
$('<div>', {
|
||||
class: config.systemHeadInfoRightClass,
|
||||
html: headInfoRight.join(' ')
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ define([
|
||||
// current position
|
||||
if(tempSystemData.currentUser === true){
|
||||
tempData.position = {
|
||||
position: '<i class="fas fa-map-marker-alt fa-lg fa-fw"></i>',
|
||||
position: '<i class="fas fa-map-marker-alt fa-fw"></i>',
|
||||
position_sort: 1
|
||||
};
|
||||
}else{
|
||||
@@ -379,8 +379,9 @@ define([
|
||||
|
||||
// static
|
||||
let statics = [];
|
||||
for(let j = 0; j < tempSystemData.statics.length; j++){
|
||||
let security = tempSystemData.statics[j].security;
|
||||
for(let wormholeName of tempSystemData.statics){
|
||||
let wormholeData = Object.assign({}, Init.wormholes[wormholeName]);
|
||||
let security = wormholeData.security;
|
||||
let secClass = Util.getSecurityClassForSystem(security);
|
||||
statics.push('<span class="' + secClass + '">' + security + '</span>');
|
||||
}
|
||||
@@ -390,7 +391,7 @@ define([
|
||||
let systemStatusClass = Util.getStatusInfoForSystem(tempSystemData.status.id, 'class');
|
||||
if(systemStatusClass !== ''){
|
||||
tempData.status = {
|
||||
status: '<i class="far fa-square fa-lg fa-fw ' + systemStatusClass + '"></i>',
|
||||
status: '<i class="far fa-square fa-fw ' + systemStatusClass + '"></i>',
|
||||
status_sort: tempSystemData.status.id
|
||||
};
|
||||
}else{
|
||||
@@ -404,7 +405,7 @@ define([
|
||||
let systemEffectClass = MapUtil.getEffectInfoForSystem(tempSystemData.effect, 'class');
|
||||
if(systemEffectClass !== ''){
|
||||
tempData.effect = {
|
||||
effect: '<i class="fas fa-square fa-lg fa-fw ' + systemEffectClass + '"></i>',
|
||||
effect: '<i class="fas fa-square fa-fw ' + systemEffectClass + '"></i>',
|
||||
effect_sort: tempSystemData.effect
|
||||
};
|
||||
}else{
|
||||
@@ -428,10 +429,23 @@ define([
|
||||
};
|
||||
}
|
||||
|
||||
// shattered
|
||||
if(tempSystemData.shattered){
|
||||
tempData.shattered = {
|
||||
shattered: '<i class="fas fa-skull fa-fw ' + Util.getSecurityClassForSystem('SH') + '"></i>',
|
||||
shattered_sort: tempSystemData.shattered
|
||||
};
|
||||
}else{
|
||||
tempData.shattered = {
|
||||
shattered: '',
|
||||
shattered_sort: 0
|
||||
};
|
||||
}
|
||||
|
||||
// locked
|
||||
if(tempSystemData.locked === 1){
|
||||
tempData.locked = {
|
||||
locked: '<i class="fas fa-lock fa-lg fa-fw"></i>',
|
||||
locked: '<i class="fas fa-lock fa-fw"></i>',
|
||||
locked_sort: tempSystemData.locked
|
||||
};
|
||||
}else{
|
||||
@@ -499,6 +513,16 @@ define([
|
||||
_: 'trueSec',
|
||||
sort: 'trueSec_sort'
|
||||
}
|
||||
},{
|
||||
title: '<i class="fas fa-skull" title="shattered" data-toggle="tooltip"></i>',
|
||||
width: '10px',
|
||||
className: ['text-center', 'min-desktop'].join(' '),
|
||||
searchable: false,
|
||||
data: 'shattered',
|
||||
render: {
|
||||
_: 'shattered',
|
||||
sort: 'shattered_sort'
|
||||
}
|
||||
},{
|
||||
title: 'system',
|
||||
data: 'name',
|
||||
@@ -517,7 +541,8 @@ define([
|
||||
data: 'region'
|
||||
},{
|
||||
title: '<i class="far fa-square" title="system status" data-toggle="tooltip"></i>',
|
||||
width: '12px',
|
||||
width: '10px',
|
||||
className: 'text-center',
|
||||
searchable: false,
|
||||
data: 'status',
|
||||
render: {
|
||||
@@ -526,7 +551,7 @@ define([
|
||||
}
|
||||
},{
|
||||
title: '<i class="fas fa-square" title="system effect" data-toggle="tooltip"></i>',
|
||||
width: '12px',
|
||||
width: '10px',
|
||||
className: 'text-center',
|
||||
searchable: false,
|
||||
data: 'effect',
|
||||
@@ -541,6 +566,7 @@ define([
|
||||
},{
|
||||
title: '<i class="fas fa-map-marker-alt" title="your position" data-toggle="tooltip"></i>',
|
||||
width: '8px',
|
||||
className: 'text-center',
|
||||
searchable: false,
|
||||
data: 'position',
|
||||
render: {
|
||||
@@ -556,6 +582,7 @@ define([
|
||||
},{
|
||||
title: '<i class="fas fa-lock" title="system locked" data-toggle="tooltip"></i>',
|
||||
width: '10px',
|
||||
className: 'text-center',
|
||||
searchable: false,
|
||||
data: 'locked',
|
||||
render: {
|
||||
|
||||
@@ -186,20 +186,17 @@ define([
|
||||
// store systemId -> module can be updated with the correct data
|
||||
moduleElement.data('id', systemData.id);
|
||||
|
||||
// shattered wormhole info data
|
||||
let shatteredWormholeInfo = false;
|
||||
|
||||
// add security class for statics
|
||||
// system "static" wh data
|
||||
let staticsData = [];
|
||||
if(
|
||||
systemData.statics &&
|
||||
systemData.statics.length > 0
|
||||
){
|
||||
for(let i = 0; i < systemData.statics.length; i++){
|
||||
systemData.statics[i].class = Util.getSecurityClassForSystem( systemData.statics[i].security );
|
||||
for(let wormholeName of systemData.statics){
|
||||
let wormholeData = Object.assign({}, Init.wormholes[wormholeName]);
|
||||
wormholeData.class = Util.getSecurityClassForSystem(wormholeData.security);
|
||||
staticsData.push(wormholeData);
|
||||
}
|
||||
}else if(systemData.type.id === 1){
|
||||
// system type "wormhole" but no statics => "shattered wormhole"
|
||||
shatteredWormholeInfo = true;
|
||||
}
|
||||
|
||||
let effectName = MapUtil.getEffectInfoForSystem(systemData.effect, 'name');
|
||||
@@ -336,12 +333,9 @@ define([
|
||||
$(moduleElement).find('.' + config.systemInfoEffectInfoClass).addSystemEffectTooltip(systemData.security, systemData.effect);
|
||||
|
||||
// init static wormhole information ----------------------------------------------------------
|
||||
if(systemData.statics){
|
||||
for(let i = 0; i < systemData.statics.length; i++){
|
||||
let staticData = systemData.statics[i];
|
||||
let staticRowElement = tempModuleElement.find('.' + config.systemInfoWormholeClass + staticData.name);
|
||||
staticRowElement.addWormholeInfoTooltip(staticData);
|
||||
}
|
||||
for(let staticData of staticsData){
|
||||
let staticRowElement = tempModuleElement.find('.' + config.systemInfoWormholeClass + staticData.name);
|
||||
staticRowElement.addWormholeInfoTooltip(staticData);
|
||||
}
|
||||
|
||||
// constellation popover ---------------------------------------------------------------------
|
||||
@@ -378,6 +372,7 @@ define([
|
||||
|
||||
let moduleData = {
|
||||
system: systemData,
|
||||
static: staticsData,
|
||||
tableClass: config.systemInfoTableClass,
|
||||
nameInfoClass: config.systemInfoNameInfoClass,
|
||||
effectInfoClass: config.systemInfoEffectInfoClass,
|
||||
@@ -407,7 +402,7 @@ define([
|
||||
return (val, render) => render(val).replace(/ /g, '_');
|
||||
},
|
||||
|
||||
shatteredWormholeInfo: shatteredWormholeInfo,
|
||||
shatteredClass: Util.getSecurityClassForSystem('SH'),
|
||||
|
||||
ajaxConstellationInfoUrl: Init.path.getConstellationData,
|
||||
|
||||
|
||||
@@ -1666,8 +1666,9 @@ define([
|
||||
// add static WH(s) for this system
|
||||
if(systemData.statics){
|
||||
let staticWHData = [];
|
||||
for(let i = 0; i < systemData.statics.length; i++){
|
||||
let staticWHName = systemData.statics[i].name + ' - ' + systemData.statics[i].security;
|
||||
for(let wormholeName of systemData.statics) {
|
||||
let wormholeData = Object.assign({}, Init.wormholes[wormholeName]);
|
||||
let staticWHName = wormholeData.name + ' - ' + wormholeData.security;
|
||||
|
||||
newSelectOptionsCount++;
|
||||
staticWHData.push( {value: newSelectOptionsCount, text: staticWHName} );
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -482,6 +482,7 @@ define([
|
||||
system.data('region', data.region.name);
|
||||
system.data('constellationId', parseInt(data.constellation.id));
|
||||
system.data('constellation', data.constellation.name);
|
||||
system.data('shattered', data.shattered);
|
||||
system.data('statics', data.statics);
|
||||
system.data('updated', parseInt(data.updated.updated));
|
||||
system.data('changed', false);
|
||||
@@ -2189,17 +2190,14 @@ define([
|
||||
}
|
||||
|
||||
// init system tooltips =======================================================================================
|
||||
// TODO check this code:
|
||||
/*
|
||||
let systemTooltipOptions = {
|
||||
toggle: 'tooltip',
|
||||
placement: 'right',
|
||||
container: 'body',
|
||||
viewport: system.id
|
||||
};
|
||||
|
||||
system.find('.fas').tooltip(systemTooltipOptions);
|
||||
*/
|
||||
|
||||
// context menu ===============================================================================================
|
||||
|
||||
// trigger context menu
|
||||
@@ -3287,6 +3285,7 @@ define([
|
||||
systemData.rallyUpdated = system.data('rallyUpdated') || 0;
|
||||
systemData.rallyPoke = system.data('rallyPoke') ? 1 : 0;
|
||||
systemData.currentUser = system.data('currentUser'); // if user is currently in this system
|
||||
systemData.shattered = system.data('shattered') ? 1 : 0;
|
||||
systemData.statics = system.data('statics');
|
||||
systemData.updated = {
|
||||
updated: parseInt( system.data('updated') )
|
||||
|
||||
@@ -24,6 +24,9 @@ define([
|
||||
popoverTriggerClass: 'pf-popover-trigger', // class for "popover" trigger elements
|
||||
|
||||
systemHeadInfoClass: 'pf-system-head-info', // class for system info
|
||||
systemHeadInfoLeftClass: 'pf-system-head-info-left', // class for left system info
|
||||
systemHeadInfoRightClass: 'pf-system-head-info-right', // class for right system info
|
||||
|
||||
systemActiveClass: 'pf-system-active', // class for an active system on a map
|
||||
systemTooltipInnerIdPrefix: 'pf-system-tooltip-inner-', // id prefix for system tooltip content
|
||||
systemTooltipInnerClass: 'pf-system-tooltip-inner', // class for system tooltip content
|
||||
@@ -406,7 +409,7 @@ define([
|
||||
* @param systems
|
||||
*/
|
||||
let removeSystems = (map, systems) => {
|
||||
let removeSystemCallbak = function(deleteSystem){
|
||||
let removeSystemCallbak = deleteSystem => {
|
||||
map.remove(deleteSystem);
|
||||
};
|
||||
|
||||
@@ -441,7 +444,7 @@ define([
|
||||
* @param sourceSystem
|
||||
* @returns {{x: *, y: *}}
|
||||
*/
|
||||
let calculateNewSystemPosition = function(sourceSystem){
|
||||
let calculateNewSystemPosition = sourceSystem => {
|
||||
let mapContainer = sourceSystem.parent();
|
||||
let grid = [MapUtil.config.mapSnapToGridDimension, MapUtil.config.mapSnapToGridDimension];
|
||||
|
||||
@@ -490,24 +493,39 @@ define([
|
||||
*/
|
||||
let getHeadInfoElement = (data) => {
|
||||
let headInfo = null;
|
||||
let headInfoLeft = [];
|
||||
let headInfoRight = [];
|
||||
|
||||
if(data.shattered){
|
||||
headInfoLeft.push('<i class="fas fa-fw fa-skull ' + Util.getSecurityClassForSystem('SH') + '" title="shattered"></i>');
|
||||
}
|
||||
|
||||
// check systemData if headInfo element is needed
|
||||
if(data.statics && data.statics.length){
|
||||
// format wh statics
|
||||
let statics = [];
|
||||
for(let staticData of data.statics){
|
||||
statics.push(
|
||||
for(let wormholeName of data.statics){
|
||||
let staticData = Object.assign({}, Init.wormholes[wormholeName]);
|
||||
headInfoRight.push(
|
||||
'<span class="' +
|
||||
Util.getSecurityClassForSystem(staticData.security) + ' ' +
|
||||
config.popoverTriggerClass + '" data-name="' + staticData.name +
|
||||
'">' + staticData.security + '</span>'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
headInfo = $('<div>', {
|
||||
if(headInfoLeft.length || headInfoRight.length){
|
||||
headInfo = $('<div>', {
|
||||
class: config.systemHeadInfoClass
|
||||
}).append(
|
||||
statics.join(' ')
|
||||
$('<div>', {
|
||||
class: config.systemHeadInfoLeftClass,
|
||||
html: headInfoLeft.join(' ')
|
||||
}),
|
||||
$('<div>', {
|
||||
class: config.systemHeadInfoRightClass,
|
||||
html: headInfoRight.join(' ')
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ define([
|
||||
// current position
|
||||
if(tempSystemData.currentUser === true){
|
||||
tempData.position = {
|
||||
position: '<i class="fas fa-map-marker-alt fa-lg fa-fw"></i>',
|
||||
position: '<i class="fas fa-map-marker-alt fa-fw"></i>',
|
||||
position_sort: 1
|
||||
};
|
||||
}else{
|
||||
@@ -379,8 +379,9 @@ define([
|
||||
|
||||
// static
|
||||
let statics = [];
|
||||
for(let j = 0; j < tempSystemData.statics.length; j++){
|
||||
let security = tempSystemData.statics[j].security;
|
||||
for(let wormholeName of tempSystemData.statics){
|
||||
let wormholeData = Object.assign({}, Init.wormholes[wormholeName]);
|
||||
let security = wormholeData.security;
|
||||
let secClass = Util.getSecurityClassForSystem(security);
|
||||
statics.push('<span class="' + secClass + '">' + security + '</span>');
|
||||
}
|
||||
@@ -390,7 +391,7 @@ define([
|
||||
let systemStatusClass = Util.getStatusInfoForSystem(tempSystemData.status.id, 'class');
|
||||
if(systemStatusClass !== ''){
|
||||
tempData.status = {
|
||||
status: '<i class="far fa-square fa-lg fa-fw ' + systemStatusClass + '"></i>',
|
||||
status: '<i class="far fa-square fa-fw ' + systemStatusClass + '"></i>',
|
||||
status_sort: tempSystemData.status.id
|
||||
};
|
||||
}else{
|
||||
@@ -404,7 +405,7 @@ define([
|
||||
let systemEffectClass = MapUtil.getEffectInfoForSystem(tempSystemData.effect, 'class');
|
||||
if(systemEffectClass !== ''){
|
||||
tempData.effect = {
|
||||
effect: '<i class="fas fa-square fa-lg fa-fw ' + systemEffectClass + '"></i>',
|
||||
effect: '<i class="fas fa-square fa-fw ' + systemEffectClass + '"></i>',
|
||||
effect_sort: tempSystemData.effect
|
||||
};
|
||||
}else{
|
||||
@@ -428,10 +429,23 @@ define([
|
||||
};
|
||||
}
|
||||
|
||||
// shattered
|
||||
if(tempSystemData.shattered){
|
||||
tempData.shattered = {
|
||||
shattered: '<i class="fas fa-skull fa-fw ' + Util.getSecurityClassForSystem('SH') + '"></i>',
|
||||
shattered_sort: tempSystemData.shattered
|
||||
};
|
||||
}else{
|
||||
tempData.shattered = {
|
||||
shattered: '',
|
||||
shattered_sort: 0
|
||||
};
|
||||
}
|
||||
|
||||
// locked
|
||||
if(tempSystemData.locked === 1){
|
||||
tempData.locked = {
|
||||
locked: '<i class="fas fa-lock fa-lg fa-fw"></i>',
|
||||
locked: '<i class="fas fa-lock fa-fw"></i>',
|
||||
locked_sort: tempSystemData.locked
|
||||
};
|
||||
}else{
|
||||
@@ -499,6 +513,16 @@ define([
|
||||
_: 'trueSec',
|
||||
sort: 'trueSec_sort'
|
||||
}
|
||||
},{
|
||||
title: '<i class="fas fa-skull" title="shattered" data-toggle="tooltip"></i>',
|
||||
width: '10px',
|
||||
className: ['text-center', 'min-desktop'].join(' '),
|
||||
searchable: false,
|
||||
data: 'shattered',
|
||||
render: {
|
||||
_: 'shattered',
|
||||
sort: 'shattered_sort'
|
||||
}
|
||||
},{
|
||||
title: 'system',
|
||||
data: 'name',
|
||||
@@ -517,7 +541,8 @@ define([
|
||||
data: 'region'
|
||||
},{
|
||||
title: '<i class="far fa-square" title="system status" data-toggle="tooltip"></i>',
|
||||
width: '12px',
|
||||
width: '10px',
|
||||
className: 'text-center',
|
||||
searchable: false,
|
||||
data: 'status',
|
||||
render: {
|
||||
@@ -526,7 +551,7 @@ define([
|
||||
}
|
||||
},{
|
||||
title: '<i class="fas fa-square" title="system effect" data-toggle="tooltip"></i>',
|
||||
width: '12px',
|
||||
width: '10px',
|
||||
className: 'text-center',
|
||||
searchable: false,
|
||||
data: 'effect',
|
||||
@@ -541,6 +566,7 @@ define([
|
||||
},{
|
||||
title: '<i class="fas fa-map-marker-alt" title="your position" data-toggle="tooltip"></i>',
|
||||
width: '8px',
|
||||
className: 'text-center',
|
||||
searchable: false,
|
||||
data: 'position',
|
||||
render: {
|
||||
@@ -556,6 +582,7 @@ define([
|
||||
},{
|
||||
title: '<i class="fas fa-lock" title="system locked" data-toggle="tooltip"></i>',
|
||||
width: '10px',
|
||||
className: 'text-center',
|
||||
searchable: false,
|
||||
data: 'locked',
|
||||
render: {
|
||||
|
||||
@@ -186,20 +186,17 @@ define([
|
||||
// store systemId -> module can be updated with the correct data
|
||||
moduleElement.data('id', systemData.id);
|
||||
|
||||
// shattered wormhole info data
|
||||
let shatteredWormholeInfo = false;
|
||||
|
||||
// add security class for statics
|
||||
// system "static" wh data
|
||||
let staticsData = [];
|
||||
if(
|
||||
systemData.statics &&
|
||||
systemData.statics.length > 0
|
||||
){
|
||||
for(let i = 0; i < systemData.statics.length; i++){
|
||||
systemData.statics[i].class = Util.getSecurityClassForSystem( systemData.statics[i].security );
|
||||
for(let wormholeName of systemData.statics){
|
||||
let wormholeData = Object.assign({}, Init.wormholes[wormholeName]);
|
||||
wormholeData.class = Util.getSecurityClassForSystem(wormholeData.security);
|
||||
staticsData.push(wormholeData);
|
||||
}
|
||||
}else if(systemData.type.id === 1){
|
||||
// system type "wormhole" but no statics => "shattered wormhole"
|
||||
shatteredWormholeInfo = true;
|
||||
}
|
||||
|
||||
let effectName = MapUtil.getEffectInfoForSystem(systemData.effect, 'name');
|
||||
@@ -336,12 +333,9 @@ define([
|
||||
$(moduleElement).find('.' + config.systemInfoEffectInfoClass).addSystemEffectTooltip(systemData.security, systemData.effect);
|
||||
|
||||
// init static wormhole information ----------------------------------------------------------
|
||||
if(systemData.statics){
|
||||
for(let i = 0; i < systemData.statics.length; i++){
|
||||
let staticData = systemData.statics[i];
|
||||
let staticRowElement = tempModuleElement.find('.' + config.systemInfoWormholeClass + staticData.name);
|
||||
staticRowElement.addWormholeInfoTooltip(staticData);
|
||||
}
|
||||
for(let staticData of staticsData){
|
||||
let staticRowElement = tempModuleElement.find('.' + config.systemInfoWormholeClass + staticData.name);
|
||||
staticRowElement.addWormholeInfoTooltip(staticData);
|
||||
}
|
||||
|
||||
// constellation popover ---------------------------------------------------------------------
|
||||
@@ -378,6 +372,7 @@ define([
|
||||
|
||||
let moduleData = {
|
||||
system: systemData,
|
||||
static: staticsData,
|
||||
tableClass: config.systemInfoTableClass,
|
||||
nameInfoClass: config.systemInfoNameInfoClass,
|
||||
effectInfoClass: config.systemInfoEffectInfoClass,
|
||||
@@ -407,7 +402,7 @@ define([
|
||||
return (val, render) => render(val).replace(/ /g, '_');
|
||||
},
|
||||
|
||||
shatteredWormholeInfo: shatteredWormholeInfo,
|
||||
shatteredClass: Util.getSecurityClassForSystem('SH'),
|
||||
|
||||
ajaxConstellationInfoUrl: Init.path.getConstellationData,
|
||||
|
||||
|
||||
@@ -1666,8 +1666,9 @@ define([
|
||||
// add static WH(s) for this system
|
||||
if(systemData.statics){
|
||||
let staticWHData = [];
|
||||
for(let i = 0; i < systemData.statics.length; i++){
|
||||
let staticWHName = systemData.statics[i].name + ' - ' + systemData.statics[i].security;
|
||||
for(let wormholeName of systemData.statics) {
|
||||
let wormholeData = Object.assign({}, Init.wormholes[wormholeName]);
|
||||
let staticWHName = wormholeData.name + ' - ' + wormholeData.security;
|
||||
|
||||
newSelectOptionsCount++;
|
||||
staticWHData.push( {value: newSelectOptionsCount, text: staticWHName} );
|
||||
|
||||
@@ -61,7 +61,12 @@
|
||||
<i class="fas fa-fw fa-question-circle"></i>
|
||||
</th>
|
||||
<th>Name</th>
|
||||
<th class="text-right {{#systemNameClass}}{{system.security}}{{/systemNameClass}}">{{system.name}}</th>
|
||||
<th class="text-right">
|
||||
{{#system.shattered}}
|
||||
<i class="fas fa-fw fa-skull {{shatteredClass}}" data-toggle="tooltip" data-container="body" title="shattered"></i>
|
||||
{{/system.shattered}}
|
||||
<span class="{{#systemNameClass}}{{system.security}}{{/systemNameClass}}">{{system.name}}</span>
|
||||
</th>
|
||||
<th class="pf-table-cell-20 text-right {{securityClass}}">{{system.security}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -82,7 +87,7 @@
|
||||
<td class="text-right"><i class="fas fa-fw fa-square pf-system-effect {{effectClass}}"></i></td>
|
||||
</tr>
|
||||
{{/effectName}}
|
||||
{{#system.statics}}
|
||||
{{#static}}
|
||||
<tr>
|
||||
<td class="text-right pf-help {{wormholePrefixClass}}{{name}}">
|
||||
<i class="fas fa-fw fa-question-circle"></i>
|
||||
@@ -91,15 +96,7 @@
|
||||
<td class="text-right">{{name}}</td>
|
||||
<td class="text-right {{class}}">{{security}}</td>
|
||||
</tr>
|
||||
{{/system.statics}}
|
||||
{{#shatteredWormholeInfo}}
|
||||
<tr>
|
||||
<td class="text-right pf-help"></td>
|
||||
<td>Shattered System</td>
|
||||
<td class="text-right pf-font-capitalize {{securityClass}}">Unknown statics</td>
|
||||
<td class="text-right"></td>
|
||||
</tr>
|
||||
{{/shatteredWormholeInfo}}
|
||||
{{/static}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -350,7 +350,7 @@ $mapWrapperMaxWidth: $mapWidth + 35px;
|
||||
|
||||
// ================================================================================================================
|
||||
.pf-system-head-info{
|
||||
text-align: right;
|
||||
display: flex;
|
||||
color: lighten($gray-light, 10%);
|
||||
font-size: 10px;
|
||||
line-height: 10px;
|
||||
@@ -362,6 +362,15 @@ $mapWrapperMaxWidth: $mapWidth + 35px;
|
||||
}
|
||||
}
|
||||
|
||||
.pf-system-head-info-left{
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.pf-system-head-info-right{
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
// ================================================================================================================
|
||||
|
||||
.pf-system-body{
|
||||
|
||||
Reference in New Issue
Block a user