@@ -819,6 +819,9 @@ discard block  | 
                                                    ||
| 819 | 819 | return max(0, $this->shipsGetCapacity() - $this->resourcesGetTotal());  | 
                                                        
| 820 | 820 | }  | 
                                                        
| 821 | 821 | |
| 822 | + /**  | 
                                                        |
| 823 | + * @param integer $ship_id  | 
                                                        |
| 824 | + */  | 
                                                        |
| 822 | 825 |    public function shipsGetTotalById($ship_id) { | 
                                                        
| 823 | 826 | return $this->unitList->unitsCountById($ship_id);  | 
                                                        
| 824 | 827 | }  | 
                                                        
@@ -933,7 +936,7 @@ discard block  | 
                                                    ||
| 933 | 936 | /**  | 
                                                        
| 934 | 937 | * Set current resource list from array of units  | 
                                                        
| 935 | 938 | *  | 
                                                        
| 936 | - * @param array $resource_list  | 
                                                        |
| 939 | + * @param integer[] $resource_list  | 
                                                        |
| 937 | 940 | */  | 
                                                        
| 938 | 941 |    public function resourcesSet($resource_list) { | 
                                                        
| 939 | 942 |      if(!empty($this->propertiesAdjusted['resource_list'])) { | 
                                                        
@@ -978,7 +981,7 @@ discard block  | 
                                                    ||
| 978 | 981 | }  | 
                                                        
| 979 | 982 | |
| 980 | 983 | /**  | 
                                                        
| 981 | - * @param array $rate  | 
                                                        |
| 984 | + * @param integer[] $rate  | 
                                                        |
| 982 | 985 | *  | 
                                                        
| 983 | 986 | * @return float  | 
                                                        
| 984 | 987 | */  | 
                                                        
@@ -1009,7 +1012,6 @@ discard block  | 
                                                    ||
| 1009 | 1012 | * Restores fleet or resources to planet  | 
                                                        
| 1010 | 1013 | *  | 
                                                        
| 1011 | 1014 | * @param bool $start  | 
                                                        
| 1012 | - * @param bool $only_resources  | 
                                                        |
| 1013 | 1015 | * @param int $result  | 
                                                        
| 1014 | 1016 | *  | 
                                                        
| 1015 | 1017 | * @return int  | 
                                                        
@@ -1060,7 +1062,7 @@ discard block  | 
                                                    ||
| 1060 | 1062 | /**  | 
                                                        
| 1061 | 1063 | * @param int $speed_percent  | 
                                                        
| 1062 | 1064 | *  | 
                                                        
| 1063 | - * @return array  | 
                                                        |
| 1065 | + * @return integer  | 
                                                        |
| 1064 | 1066 | */  | 
                                                        
| 1065 | 1067 |    protected function flt_travel_data($speed_percent = 10) { | 
                                                        
| 1066 | 1068 | $distance = $this->targetVector->distanceFromCoordinates($this->dbSourcePlanetRow);  | 
                                                        
@@ -1161,6 +1163,9 @@ discard block  | 
                                                    ||
| 1161 | 1163 | }  | 
                                                        
| 1162 | 1164 | }  | 
                                                        
| 1163 | 1165 | |
| 1166 | + /**  | 
                                                        |
| 1167 | + * @param integer $errorCode  | 
                                                        |
| 1168 | + */  | 
                                                        |
| 1164 | 1169 |    public function restrictToTypePlanet($errorCode) { | 
                                                        
| 1165 | 1170 |      if($this->targetVector->type != PT_PLANET) { | 
                                                        
| 1166 | 1171 | throw new Exception($errorCode, $errorCode);  | 
                                                        
@@ -314,9 +314,9 @@ discard block  | 
                                                    ||
| 314 | 314 |    public function renderAvailableShips(&$template_result, $playerRow, $planetRow) { | 
                                                        
| 315 | 315 | $record_index = 0;  | 
                                                        
| 316 | 316 | $ship_list = array();  | 
                                                        
| 317 | -    foreach(sn_get_groups('fleet') as $n => $unit_id) { | 
                                                        |
| 317 | +    foreach (sn_get_groups('fleet') as $n => $unit_id) { | 
                                                        |
| 318 | 318 | $unit_level = mrc_get_level($playerRow, $planetRow, $unit_id, false, true);  | 
                                                        
| 319 | -      if($unit_level <= 0) { | 
                                                        |
| 319 | +      if ($unit_level <= 0) { | 
                                                        |
| 320 | 320 | continue;  | 
                                                        
| 321 | 321 | }  | 
                                                        
| 322 | 322 | $ship_data = get_ship_data($unit_id, $playerRow);  | 
                                                        
@@ -337,7 +337,7 @@ discard block  | 
                                                    ||
| 337 | 337 | |
| 338 | 338 | sortUnitRenderedList($ship_list, classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT], classSupernova::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE]);  | 
                                                        
| 339 | 339 | |
| 340 | -    foreach($ship_list as $ship_data) { | 
                                                        |
| 340 | +    foreach ($ship_list as $ship_data) { | 
                                                        |
| 341 | 341 | $template_result['.']['ships'][] = $ship_data;  | 
                                                        
| 342 | 342 | }  | 
                                                        
| 343 | 343 | }  | 
                                                        
@@ -356,7 +356,7 @@ discard block  | 
                                                    ||
| 356 | 356 |    public function dbInsert() { | 
                                                        
| 357 | 357 | // WARNING! MISSION TIMES MUST BE SET WITH set_times() method!  | 
                                                        
| 358 | 358 | // TODO - more checks!  | 
                                                        
| 359 | -    if(empty($this->_time_launch)) { | 
                                                        |
| 359 | +    if (empty($this->_time_launch)) { | 
                                                        |
| 360 | 360 |        die('Fleet time not set!'); | 
                                                        
| 361 | 361 | }  | 
                                                        
| 362 | 362 | |
@@ -565,7 +565,7 @@ discard block  | 
                                                    ||
| 565 | 565 | // Записываем изменения в БД  | 
                                                        
| 566 | 566 | $this->dbSave();  | 
                                                        
| 567 | 567 | |
| 568 | -    if($this->_group_id) { | 
                                                        |
| 568 | +    if ($this->_group_id) { | 
                                                        |
| 569 | 569 | // TODO: Make here to delete only one AKS - by adding aks_fleet_count to AKS table  | 
                                                        
| 570 | 570 | db_fleet_aks_purge();  | 
                                                        
| 571 | 571 | }  | 
                                                        
@@ -632,18 +632,18 @@ discard block  | 
                                                    ||
| 632 | 632 | */  | 
                                                        
| 633 | 633 | // TODO - separate shipList and unitList  | 
                                                        
| 634 | 634 |    public function unitsSetFromArray($unit_array) { | 
                                                        
| 635 | -    if(empty($unit_array) || !is_array($unit_array)) { | 
                                                        |
| 635 | +    if (empty($unit_array) || !is_array($unit_array)) { | 
                                                        |
| 636 | 636 | return;  | 
                                                        
| 637 | 637 | }  | 
                                                        
| 638 | -    foreach($unit_array as $unit_id => $unit_count) { | 
                                                        |
| 638 | +    foreach ($unit_array as $unit_id => $unit_count) { | 
                                                        |
| 639 | 639 | $unit_count = floatval($unit_count);  | 
                                                        
| 640 | -      if(!$unit_count) { | 
                                                        |
| 640 | +      if (!$unit_count) { | 
                                                        |
| 641 | 641 | continue;  | 
                                                        
| 642 | 642 | }  | 
                                                        
| 643 | 643 | |
| 644 | -      if($this->isShip($unit_id)) { | 
                                                        |
| 644 | +      if ($this->isShip($unit_id)) { | 
                                                        |
| 645 | 645 | $this->unitList->unitSetCount($unit_id, $unit_count);  | 
                                                        
| 646 | -      } elseif($this->isResource($unit_id)) { | 
                                                        |
| 646 | +      } elseif ($this->isResource($unit_id)) { | 
                                                        |
| 647 | 647 | $this->resource_list[$unit_id] = $unit_count;  | 
                                                        
| 648 | 648 |        } else { | 
                                                        
| 649 | 649 |          throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR); | 
                                                        
@@ -672,7 +672,7 @@ discard block  | 
                                                    ||
| 672 | 672 |    public function parse_missile_db_row($missile_db_row) { | 
                                                        
| 673 | 673 | // $this->_reset();  | 
                                                        
| 674 | 674 | |
| 675 | -    if(empty($missile_db_row) || !is_array($missile_db_row)) { | 
                                                        |
| 675 | +    if (empty($missile_db_row) || !is_array($missile_db_row)) { | 
                                                        |
| 676 | 676 | return;  | 
                                                        
| 677 | 677 | }  | 
                                                        
| 678 | 678 | |
@@ -835,7 +835,7 @@ discard block  | 
                                                    ||
| 835 | 835 |    public function shipsGetCapacityRecyclers(array $recycler_info) { | 
                                                        
| 836 | 836 | $recyclers_incoming_capacity = 0;  | 
                                                        
| 837 | 837 | $fleet_data = $this->shipsGetArray();  | 
                                                        
| 838 | -    foreach($recycler_info as $recycler_id => $recycler_data) { | 
                                                        |
| 838 | +    foreach ($recycler_info as $recycler_id => $recycler_data) { | 
                                                        |
| 839 | 839 | $recyclers_incoming_capacity += $fleet_data[$recycler_id] * $recycler_data['capacity'];  | 
                                                        
| 840 | 840 | }  | 
                                                        
| 841 | 841 | |
@@ -855,7 +855,7 @@ discard block  | 
                                                    ||
| 855 | 855 | sn_db_transaction_check(true);  | 
                                                        
| 856 | 856 | |
| 857 | 857 | // Если флот уже обработан - не существует или возращается - тогда ничего не делаем  | 
                                                        
| 858 | -    if($this->isEmpty()) { | 
                                                        |
| 858 | +    if ($this->isEmpty()) { | 
                                                        |
| 859 | 859 | return $result;  | 
                                                        
| 860 | 860 | }  | 
                                                        
| 861 | 861 | |
@@ -877,18 +877,18 @@ discard block  | 
                                                    ||
| 877 | 877 | // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом  | 
                                                        
| 878 | 878 | // Флот, который возвращается на захваченную планету, пропадает  | 
                                                        
| 879 | 879 | // Ship landing is possible only to fleet owner's planet  | 
                                                        
| 880 | -    if($this->getPlayerOwnerId() == $planet_arrival['id_owner']) { | 
                                                        |
| 880 | +    if ($this->getPlayerOwnerId() == $planet_arrival['id_owner']) { | 
                                                        |
| 881 | 881 | $db_changeset = array();  | 
                                                        
| 882 | 882 | |
| 883 | 883 | $fleet_array = $this->shipsGetArray();  | 
                                                        
| 884 | -      foreach($fleet_array as $ship_id => $ship_count) { | 
                                                        |
| 885 | -        if($ship_count) { | 
                                                        |
| 884 | +      foreach ($fleet_array as $ship_id => $ship_count) { | 
                                                        |
| 885 | +        if ($ship_count) { | 
                                                        |
| 886 | 886 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($ship_id, $ship_count, $user, $planet_arrival['id']);  | 
                                                        
| 887 | 887 | }  | 
                                                        
| 888 | 888 | }  | 
                                                        
| 889 | 889 | |
| 890 | 890 | // Adjusting ship amount on planet  | 
                                                        
| 891 | -      if(!empty($db_changeset)) { | 
                                                        |
| 891 | +      if (!empty($db_changeset)) { | 
                                                        |
| 892 | 892 | db_changeset_apply($db_changeset);  | 
                                                        
| 893 | 893 | }  | 
                                                        
| 894 | 894 | |
@@ -936,7 +936,7 @@ discard block  | 
                                                    ||
| 936 | 936 | * @param array $resource_list  | 
                                                        
| 937 | 937 | */  | 
                                                        
| 938 | 938 |    public function resourcesSet($resource_list) { | 
                                                        
| 939 | -    if(!empty($this->propertiesAdjusted['resource_list'])) { | 
                                                        |
| 939 | +    if (!empty($this->propertiesAdjusted['resource_list'])) { | 
                                                        |
| 940 | 940 |        throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR); | 
                                                        
| 941 | 941 | }  | 
                                                        
| 942 | 942 | $this->resourcesAdjust($resource_list, true);  | 
                                                        
@@ -950,13 +950,13 @@ discard block  | 
                                                    ||
| 950 | 950 |    public function resourcesAdjust($resource_delta_list, $replace_value = false) { | 
                                                        
| 951 | 951 | !is_array($resource_delta_list) ? $resource_delta_list = array() : false;  | 
                                                        
| 952 | 952 | |
| 953 | -    foreach($resource_delta_list as $resource_id => $unit_delta) { | 
                                                        |
| 954 | -      if(!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) { | 
                                                        |
| 953 | +    foreach ($resource_delta_list as $resource_id => $unit_delta) { | 
                                                        |
| 954 | +      if (!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) { | 
                                                        |
| 955 | 955 | // Not a resource or no resources - continuing  | 
                                                        
| 956 | 956 | continue;  | 
                                                        
| 957 | 957 | }  | 
                                                        
| 958 | 958 | |
| 959 | -      if($replace_value) { | 
                                                        |
| 959 | +      if ($replace_value) { | 
                                                        |
| 960 | 960 | $this->resource_list[$resource_id] = $unit_delta;  | 
                                                        
| 961 | 961 |        } else { | 
                                                        
| 962 | 962 | $this->resource_list[$resource_id] += $unit_delta;  | 
                                                        
@@ -966,7 +966,7 @@ discard block  | 
                                                    ||
| 966 | 966 | }  | 
                                                        
| 967 | 967 | |
| 968 | 968 | // Check for negative unit value  | 
                                                        
| 969 | -      if($this->resource_list[$resource_id] < 0) { | 
                                                        |
| 969 | +      if ($this->resource_list[$resource_id] < 0) { | 
                                                        |
| 970 | 970 | // TODO  | 
                                                        
| 971 | 971 |          throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR); | 
                                                        
| 972 | 972 | }  | 
                                                        
@@ -1018,7 +1018,7 @@ discard block  | 
                                                    ||
| 1018 | 1018 | sn_db_transaction_check(true);  | 
                                                        
| 1019 | 1019 | |
| 1020 | 1020 | // Если флот уже обработан - не существует или возращается - тогда ничего не делаем  | 
                                                        
| 1021 | -    if(!$this->resourcesGetTotal()) { | 
                                                        |
| 1021 | +    if (!$this->resourcesGetTotal()) { | 
                                                        |
| 1022 | 1022 | return $result;  | 
                                                        
| 1023 | 1023 | }  | 
                                                        
| 1024 | 1024 | |
@@ -1038,7 +1038,7 @@ discard block  | 
                                                    ||
| 1038 | 1038 | // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом  | 
                                                        
| 1039 | 1039 | |
| 1040 | 1040 | // Restoring resources to planet  | 
                                                        
| 1041 | -    if($this->resourcesGetTotal()) { | 
                                                        |
| 1041 | +    if ($this->resourcesGetTotal()) { | 
                                                        |
| 1042 | 1042 | $fleet_resources = $this->resourcesGetList();  | 
                                                        
| 1043 | 1043 | db_planet_set_by_id($planet_arrival['id'],  | 
                                                        
| 1044 | 1044 |          "`metal` = `metal` + '{$fleet_resources[RES_METAL]}', `crystal` = `crystal` + '{$fleet_resources[RES_CRYSTAL]}', `deuterium` = `deuterium` + '{$fleet_resources[RES_DEUTERIUM]}'"); | 
                                                        
@@ -1103,12 +1103,12 @@ discard block  | 
                                                    ||
| 1103 | 1103 | |
| 1104 | 1104 |    protected function populateTargetPlanet() { | 
                                                        
| 1105 | 1105 | $targetPlanetCoords = $this->targetVector;  | 
                                                        
| 1106 | -    if($this->mission_type != MT_NONE) { | 
                                                        |
| 1106 | +    if ($this->mission_type != MT_NONE) { | 
                                                        |
| 1107 | 1107 | $this->restrictTargetTypeByMission();  | 
                                                        
| 1108 | 1108 | |
| 1109 | 1109 | // TODO - Нельзя тут просто менять тип планеты или координат!  | 
                                                        
| 1110 | 1110 | // If current planet type is not allowed on mission - switch planet type  | 
                                                        
| 1111 | -      if(empty($this->allowed_planet_types[$this->targetVector->type])) { | 
                                                        |
| 1111 | +      if (empty($this->allowed_planet_types[$this->targetVector->type])) { | 
                                                        |
| 1112 | 1112 | $targetPlanetCoords->type = reset($this->allowed_planet_types);  | 
                                                        
| 1113 | 1113 | }  | 
                                                        
| 1114 | 1114 | }  | 
                                                        
@@ -1117,14 +1117,14 @@ discard block  | 
                                                    ||
| 1117 | 1117 | }  | 
                                                        
| 1118 | 1118 | |
| 1119 | 1119 |    protected function restrictTargetTypeByMission() { | 
                                                        
| 1120 | -    if($this->_mission_type == MT_MISSILE) { | 
                                                        |
| 1120 | +    if ($this->_mission_type == MT_MISSILE) { | 
                                                        |
| 1121 | 1121 | $this->allowed_planet_types = array(PT_PLANET => PT_PLANET);  | 
                                                        
| 1122 | -    } elseif($this->_mission_type == MT_COLONIZE || $this->_mission_type == MT_EXPLORE) { | 
                                                        |
| 1122 | +    } elseif ($this->_mission_type == MT_COLONIZE || $this->_mission_type == MT_EXPLORE) { | 
                                                        |
| 1123 | 1123 | // TODO - PT_NONE  | 
                                                        
| 1124 | 1124 | $this->allowed_planet_types = array(PT_PLANET => PT_PLANET);  | 
                                                        
| 1125 | -    } elseif($this->_mission_type == MT_RECYCLE) { | 
                                                        |
| 1125 | +    } elseif ($this->_mission_type == MT_RECYCLE) { | 
                                                        |
| 1126 | 1126 | $this->allowed_planet_types = array(PT_DEBRIS => PT_DEBRIS);  | 
                                                        
| 1127 | -    } elseif($this->_mission_type == MT_DESTROY) { | 
                                                        |
| 1127 | +    } elseif ($this->_mission_type == MT_DESTROY) { | 
                                                        |
| 1128 | 1128 | $this->allowed_planet_types = array(PT_MOON => PT_MOON);  | 
                                                        
| 1129 | 1129 |      } else { | 
                                                        
| 1130 | 1130 | $this->allowed_planet_types = array(PT_PLANET => PT_PLANET, PT_MOON => PT_MOON);  | 
                                                        
@@ -1156,13 +1156,13 @@ discard block  | 
                                                    ||
| 1156 | 1156 | |
| 1157 | 1157 | |
| 1158 | 1158 |    public function restrictToKnownSpace() { | 
                                                        
| 1159 | -    if(!$this->targetVector->isInKnownSpace()) { | 
                                                        |
| 1159 | +    if (!$this->targetVector->isInKnownSpace()) { | 
                                                        |
| 1160 | 1160 |        throw new Exception('FLIGHT_VECTOR_BEYOND_SYSTEM', FLIGHT_VECTOR_BEYOND_SYSTEM); | 
                                                        
| 1161 | 1161 | }  | 
                                                        
| 1162 | 1162 | }  | 
                                                        
| 1163 | 1163 | |
| 1164 | 1164 |    public function restrictToTypePlanet($errorCode) { | 
                                                        
| 1165 | -    if($this->targetVector->type != PT_PLANET) { | 
                                                        |
| 1165 | +    if ($this->targetVector->type != PT_PLANET) { | 
                                                        |
| 1166 | 1166 | throw new Exception($errorCode, $errorCode);  | 
                                                        
| 1167 | 1167 | }  | 
                                                        
| 1168 | 1168 | }  | 
                                                        
@@ -1170,25 +1170,25 @@ discard block  | 
                                                    ||
| 1170 | 1170 |    public function restrictToNoMissiles() { | 
                                                        
| 1171 | 1171 | $missilesAttack = $this->unitList->unitsCountById(UNIT_DEF_MISSILE_INTERPLANET);  | 
                                                        
| 1172 | 1172 | $missilesDefense = $this->unitList->unitsCountById(UNIT_DEF_MISSILE_INTERCEPTOR);  | 
                                                        
| 1173 | -    if($missilesAttack > 0 || $missilesDefense > 0) { | 
                                                        |
| 1173 | +    if ($missilesAttack > 0 || $missilesDefense > 0) { | 
                                                        |
| 1174 | 1174 |        throw new Exception('FLIGHT_SHIPS_NO_MISSILES', FLIGHT_SHIPS_NO_MISSILES); | 
                                                        
| 1175 | 1175 | }  | 
                                                        
| 1176 | 1176 | }  | 
                                                        
| 1177 | 1177 | |
| 1178 | 1178 |    public function restrictToTargetOwn() { | 
                                                        
| 1179 | -    if($this->dbTargetRow['id'] != $this->getPlayerOwnerId()) { | 
                                                        |
| 1179 | +    if ($this->dbTargetRow['id'] != $this->getPlayerOwnerId()) { | 
                                                        |
| 1180 | 1180 |        throw new Exception('FLIGHT_VECTOR_ONLY_OWN', FLIGHT_VECTOR_ONLY_OWN); | 
                                                        
| 1181 | 1181 | }  | 
                                                        
| 1182 | 1182 | }  | 
                                                        
| 1183 | 1183 | |
| 1184 | 1184 |    public function restrictToTargetOther() { | 
                                                        
| 1185 | -    if($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) { | 
                                                        |
| 1185 | +    if ($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) { | 
                                                        |
| 1186 | 1186 |        throw new Exception('FLIGHT_VECTOR_ONLY_OTHER', FLIGHT_VECTOR_ONLY_OTHER); | 
                                                        
| 1187 | 1187 | }  | 
                                                        
| 1188 | 1188 | }  | 
                                                        
| 1189 | 1189 | |
| 1190 | 1190 |    public function restrictToNotOnlySpies() { | 
                                                        
| 1191 | -    if($this->unitList->unitsCountById(SHIP_SPY) == $this->shipsGetTotal()) { | 
                                                        |
| 1191 | +    if ($this->unitList->unitsCountById(SHIP_SPY) == $this->shipsGetTotal()) { | 
                                                        |
| 1192 | 1192 |        throw new Exception('FLIGHT_SHIPS_NOT_ONLY_SPIES', FLIGHT_SHIPS_NOT_ONLY_SPIES); | 
                                                        
| 1193 | 1193 | }  | 
                                                        
| 1194 | 1194 | }  | 
                                                        
@@ -1198,26 +1198,26 @@ discard block  | 
                                                    ||
| 1198 | 1198 | }  | 
                                                        
| 1199 | 1199 | |
| 1200 | 1200 |    protected function restrictToMovable() { | 
                                                        
| 1201 | -    if(!$this->unitList->unitsIsAllMovable($this->dbOwnerRow)) { | 
                                                        |
| 1201 | +    if (!$this->unitList->unitsIsAllMovable($this->dbOwnerRow)) { | 
                                                        |
| 1202 | 1202 |        throw new Exception('FLIGHT_SHIPS_UNMOVABLE', FLIGHT_SHIPS_UNMOVABLE); | 
                                                        
| 1203 | 1203 | }  | 
                                                        
| 1204 | 1204 | }  | 
                                                        
| 1205 | 1205 | |
| 1206 | 1206 |    protected function restrictToFleetUnits() { | 
                                                        
| 1207 | -    if(!$this->unitList->unitsInGroup(sn_get_groups(array('fleet', 'missile')))) { | 
                                                        |
| 1207 | +    if (!$this->unitList->unitsInGroup(sn_get_groups(array('fleet', 'missile')))) { | 
                                                        |
| 1208 | 1208 |        throw new Exception('FLIGHT_SHIPS_UNIT_WRONG', FLIGHT_SHIPS_UNIT_WRONG); | 
                                                        
| 1209 | 1209 | }  | 
                                                        
| 1210 | 1210 | }  | 
                                                        
| 1211 | 1211 | |
| 1212 | 1212 |    protected function restrictToColonizer() { | 
                                                        
| 1213 | 1213 | // Colonization fleet should have at least one colonizer  | 
                                                        
| 1214 | -    if(!$this->unitList->unitsCountById(SHIP_COLONIZER) <= 0) { | 
                                                        |
| 1214 | +    if (!$this->unitList->unitsCountById(SHIP_COLONIZER) <= 0) { | 
                                                        |
| 1215 | 1215 |        throw new Exception('FLIGHT_SHIPS_NO_COLONIZER', FLIGHT_SHIPS_NO_COLONIZER); | 
                                                        
| 1216 | 1216 | }  | 
                                                        
| 1217 | 1217 | }  | 
                                                        
| 1218 | 1218 | |
| 1219 | 1219 |    protected function restrictToTargetExists() { | 
                                                        
| 1220 | -    if(empty($this->dbTargetRow) || empty($this->dbTargetRow['id'])) { | 
                                                        |
| 1220 | +    if (empty($this->dbTargetRow) || empty($this->dbTargetRow['id'])) { | 
                                                        |
| 1221 | 1221 |        throw new Exception('FLIGHT_VECTOR_NO_TARGET', FLIGHT_VECTOR_NO_TARGET); | 
                                                        
| 1222 | 1222 | }  | 
                                                        
| 1223 | 1223 | }  | 
                                                        
@@ -1225,7 +1225,7 @@ discard block  | 
                                                    ||
| 1225 | 1225 | |
| 1226 | 1226 |    protected function restrictKnownSpaceOrMissionExplore() { | 
                                                        
| 1227 | 1227 | // Is it exploration - fleet sent beyond of system?  | 
                                                        
| 1228 | -    if($this->targetVector->isInKnownSpace()) { | 
                                                        |
| 1228 | +    if ($this->targetVector->isInKnownSpace()) { | 
                                                        |
| 1229 | 1229 | // No exploration beyond this point  | 
                                                        
| 1230 | 1230 | unset($this->allowed_missions[MT_EXPLORE]);  | 
                                                        
| 1231 | 1231 | |
@@ -1243,7 +1243,7 @@ discard block  | 
                                                    ||
| 1243 | 1243 | |
| 1244 | 1244 |    protected function restrictTargetExistsOrMissionColonize() { | 
                                                        
| 1245 | 1245 | // Is it colonization - fleet sent to empty place?  | 
                                                        
| 1246 | -    if(!empty($this->dbTargetRow)) { | 
                                                        |
| 1246 | +    if (!empty($this->dbTargetRow)) { | 
                                                        |
| 1247 | 1247 | // No colonization beyond this point  | 
                                                        
| 1248 | 1248 | unset($this->allowed_missions[MT_COLONIZE]);  | 
                                                        
| 1249 | 1249 | |
@@ -1262,7 +1262,7 @@ discard block  | 
                                                    ||
| 1262 | 1262 | }  | 
                                                        
| 1263 | 1263 | |
| 1264 | 1264 |    protected function restrictNotDebrisOrMissionRecycle() { | 
                                                        
| 1265 | -    if($this->targetVector->type != PT_DEBRIS) { | 
                                                        |
| 1265 | +    if ($this->targetVector->type != PT_DEBRIS) { | 
                                                        |
| 1266 | 1266 | // No recycling beyond this point  | 
                                                        
| 1267 | 1267 | unset($this->allowed_missions[MT_RECYCLE]);  | 
                                                        
| 1268 | 1268 | |
@@ -1273,11 +1273,11 @@ discard block  | 
                                                    ||
| 1273 | 1273 | |
| 1274 | 1274 | // restrict to recyclers  | 
                                                        
| 1275 | 1275 | $recyclers = 0;  | 
                                                        
| 1276 | -    foreach(sn_get_groups('flt_recyclers') as $recycler_id) { | 
                                                        |
| 1276 | +    foreach (sn_get_groups('flt_recyclers') as $recycler_id) { | 
                                                        |
| 1277 | 1277 | $recyclers += $this->unitList->unitsCountById($recycler_id);  | 
                                                        
| 1278 | 1278 | }  | 
                                                        
| 1279 | 1279 | |
| 1280 | -    if($recyclers <= 0) { | 
                                                        |
| 1280 | +    if ($recyclers <= 0) { | 
                                                        |
| 1281 | 1281 |        throw new Exception('FLIGHT_SHIPS_NO_RECYCLERS', FLIGHT_SHIPS_NO_RECYCLERS); | 
                                                        
| 1282 | 1282 | }  | 
                                                        
| 1283 | 1283 | |
@@ -1288,14 +1288,14 @@ discard block  | 
                                                    ||
| 1288 | 1288 | |
| 1289 | 1289 |    protected function restrictMissionMissile() { | 
                                                        
| 1290 | 1290 | $missilesAttack = $this->unitList->unitsCountById(UNIT_DEF_MISSILE_INTERPLANET);  | 
                                                        
| 1291 | -    if($missilesAttack <= 0) { | 
                                                        |
| 1291 | +    if ($missilesAttack <= 0) { | 
                                                        |
| 1292 | 1292 | // No missile attack beyond this point  | 
                                                        
| 1293 | 1293 | unset($this->allowed_missions[MT_MISSILE]);  | 
                                                        
| 1294 | 1294 | |
| 1295 | 1295 | return;  | 
                                                        
| 1296 | 1296 | }  | 
                                                        
| 1297 | 1297 | |
| 1298 | -    if($missilesAttack != $this->shipsGetTotal()) { | 
                                                        |
| 1298 | +    if ($missilesAttack != $this->shipsGetTotal()) { | 
                                                        |
| 1299 | 1299 |        throw new Exception('FLIGHT_SHIPS_ONLY_MISSILES', FLIGHT_SHIPS_ONLY_MISSILES); | 
                                                        
| 1300 | 1300 | }  | 
                                                        
| 1301 | 1301 | |
@@ -1307,7 +1307,7 @@ discard block  | 
                                                    ||
| 1307 | 1307 | }  | 
                                                        
| 1308 | 1308 | |
| 1309 | 1309 |    protected function restrictToNotOnlySpiesOrMissionSpy() { | 
                                                        
| 1310 | -    if($this->unitList->unitsCountById(SHIP_SPY) != $this->shipsGetTotal()) { | 
                                                        |
| 1310 | +    if ($this->unitList->unitsCountById(SHIP_SPY) != $this->shipsGetTotal()) { | 
                                                        |
| 1311 | 1311 |  //      throw new Exception('FLIGHT_SHIPS_ONLY_SPIES', FLIGHT_SHIPS_ONLY_SPIES); | 
                                                        
| 1312 | 1312 | unset($this->allowed_missions[MT_SPY]);  | 
                                                        
| 1313 | 1313 | |
@@ -1323,14 +1323,14 @@ discard block  | 
                                                    ||
| 1323 | 1323 |    protected function restrictMissionDestroy() { | 
                                                        
| 1324 | 1324 | // If target vector is not Moon - then it can't be Destroy mission  | 
                                                        
| 1325 | 1325 | // If no Reapers (i.e. Death Star) in fleet - then mission Moon Destroy is unaccessible  | 
                                                        
| 1326 | -    if($this->targetVector->type != PT_MOON || $this->unitList->unitsCountById(SHIP_HUGE_DEATH_STAR) <= 0) { | 
                                                        |
| 1326 | +    if ($this->targetVector->type != PT_MOON || $this->unitList->unitsCountById(SHIP_HUGE_DEATH_STAR) <= 0) { | 
                                                        |
| 1327 | 1327 | unset($this->allowed_missions[MT_DESTROY]);  | 
                                                        
| 1328 | 1328 | }  | 
                                                        
| 1329 | 1329 | }  | 
                                                        
| 1330 | 1330 | |
| 1331 | 1331 |    protected function restrictMissionACS() { | 
                                                        
| 1332 | 1332 | // If no ACS group is shown - then it can't be an ACS attack  | 
                                                        
| 1333 | -    if(empty($this->_group_id)) { | 
                                                        |
| 1333 | +    if (empty($this->_group_id)) { | 
                                                        |
| 1334 | 1334 | unset($this->allowed_missions[MT_ACS]);  | 
                                                        
| 1335 | 1335 | }  | 
                                                        
| 1336 | 1336 | }  | 
                                                        
@@ -1338,7 +1338,7 @@ discard block  | 
                                                    ||
| 1338 | 1338 | /** @throws Exception */  | 
                                                        
| 1339 | 1339 |    protected function restrictFriendOrFoe() { | 
                                                        
| 1340 | 1340 | // Checking target owner  | 
                                                        
| 1341 | -    if($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) { | 
                                                        |
| 1341 | +    if ($this->dbTargetRow['id'] == $this->getPlayerOwnerId()) { | 
                                                        |
| 1342 | 1342 | // Spying can't be done on owner's planet/moon  | 
                                                        
| 1343 | 1343 | unset($this->allowed_missions[MT_SPY]);  | 
                                                        
| 1344 | 1344 | // Attack can't be done on owner's planet/moon  | 
                                                        
@@ -1399,7 +1399,7 @@ discard block  | 
                                                    ||
| 1399 | 1399 | * @throws Exception  | 
                                                        
| 1400 | 1400 | */  | 
                                                        
| 1401 | 1401 |    public function restrictMission() { | 
                                                        
| 1402 | -    if($this->targetVector->isEqualToPlanet($this->dbSourcePlanetRow)) { | 
                                                        |
| 1402 | +    if ($this->targetVector->isEqualToPlanet($this->dbSourcePlanetRow)) { | 
                                                        |
| 1403 | 1403 |        throw new Exception('FLIGHT_VECTOR_SAME_SOURCE', FLIGHT_VECTOR_SAME_SOURCE); | 
                                                        
| 1404 | 1404 | }  | 
                                                        
| 1405 | 1405 | |
@@ -1430,7 +1430,7 @@ discard block  | 
                                                    ||
| 1430 | 1430 | |
| 1431 | 1431 | |
| 1432 | 1432 |    protected function printErrorIfNoShips() { | 
                                                        
| 1433 | -    if($this->unitList->unitsCount() <= 0) { | 
                                                        |
| 1433 | +    if ($this->unitList->unitsCount() <= 0) { | 
                                                        |
| 1434 | 1434 | message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5);  | 
                                                        
| 1435 | 1435 | }  | 
                                                        
| 1436 | 1436 | }  | 
                                                        
@@ -1467,7 +1467,7 @@ discard block  | 
                                                    ||
| 1467 | 1467 | |
| 1468 | 1468 |      lng_include('overview'); | 
                                                        
| 1469 | 1469 | |
| 1470 | -    if(empty($this->dbSourcePlanetRow)) { | 
                                                        |
| 1470 | +    if (empty($this->dbSourcePlanetRow)) { | 
                                                        |
| 1471 | 1471 | message(classLocale::$lang['fl_noplanetrow'], classLocale::$lang['fl_error']);  | 
                                                        
| 1472 | 1472 | }  | 
                                                        
| 1473 | 1473 | |
@@ -1543,9 +1543,9 @@ discard block  | 
                                                    ||
| 1543 | 1543 | |
| 1544 | 1544 |      try { | 
                                                        
| 1545 | 1545 | $this->restrictMission();  | 
                                                        
| 1546 | -    } catch(Exception $e) { | 
                                                        |
| 1546 | +    } catch (Exception $e) { | 
                                                        |
| 1547 | 1547 | // TODO - MESSAGE BOX  | 
                                                        
| 1548 | -      if($e->getCode() != FLIGHT_ALLOWED) { | 
                                                        |
| 1548 | +      if ($e->getCode() != FLIGHT_ALLOWED) { | 
                                                        |
| 1549 | 1549 | pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]);  | 
                                                        
| 1550 | 1550 |        } else { | 
                                                        
| 1551 | 1551 |          pdump('FLIGHT_ALLOWED', FLIGHT_ALLOWED); | 
                                                        
@@ -1555,20 +1555,19 @@ discard block  | 
                                                    ||
| 1555 | 1555 | $this->renderAllowedMissions($template_result);  | 
                                                        
| 1556 | 1556 | $this->renderFleet($template_result);  | 
                                                        
| 1557 | 1557 | |
| 1558 | - $max_duration = $this->_mission_type == MT_EXPLORE ? get_player_max_expedition_duration($this->dbOwnerRow) :  | 
                                                        |
| 1559 | - (isset($this->allowed_missions[MT_HOLD]) ? 12 : 0);  | 
                                                        |
| 1558 | + $max_duration = $this->_mission_type == MT_EXPLORE ? get_player_max_expedition_duration($this->dbOwnerRow) : (isset($this->allowed_missions[MT_HOLD]) ? 12 : 0);  | 
                                                        |
| 1560 | 1559 | $this->renderDuration($template_result, $max_duration);  | 
                                                        
| 1561 | 1560 | |
| 1562 | 1561 | $travel_data = $this->flt_travel_data($this->oldSpeedInTens);  | 
                                                        
| 1563 | 1562 | |
| 1564 | 1563 |      $sn_group_resources = sn_get_groups('resources_loot'); | 
                                                        
| 1565 | 1564 | $planetResources = array();  | 
                                                        
| 1566 | -    foreach($sn_group_resources as $resource_id) { | 
                                                        |
| 1565 | +    foreach ($sn_group_resources as $resource_id) { | 
                                                        |
| 1567 | 1566 | $planetResources[$resource_id] = floor(mrc_get_level($this->dbOwnerRow, $this->dbSourcePlanetRow, $resource_id) - ($resource_id == RES_DEUTERIUM ? $travel_data['consumption'] : 0));  | 
                                                        
| 1568 | 1567 | }  | 
                                                        
| 1569 | 1568 | $this->renderPlanetResources($planetResources, $template_result);  | 
                                                        
| 1570 | 1569 | |
| 1571 | -    if(sn_module::$sn_module['unit_captain']->manifest['active'] && ($captain = sn_module::$sn_module['unit_captain']->unit_captain_get($this->dbSourcePlanetRow['id'])) && $captain['unit_location_type'] == LOC_PLANET) { | 
                                                        |
| 1570 | +    if (sn_module::$sn_module['unit_captain']->manifest['active'] && ($captain = sn_module::$sn_module['unit_captain']->unit_captain_get($this->dbSourcePlanetRow['id'])) && $captain['unit_location_type'] == LOC_PLANET) { | 
                                                        |
| 1572 | 1571 | $template_result += array(  | 
                                                        
| 1573 | 1572 | 'CAPTAIN_ID' => $captain['unit_id'],  | 
                                                        
| 1574 | 1573 | 'CAPTAIN_LEVEL' => $captain['captain_level'],  | 
                                                        
@@ -1610,10 +1609,10 @@ discard block  | 
                                                    ||
| 1610 | 1609 |    protected function renderAllowedMissions(&$template_result) { | 
                                                        
| 1611 | 1610 | ksort($this->allowed_missions);  | 
                                                        
| 1612 | 1611 | // If mission is not set - setting first mission from allowed  | 
                                                        
| 1613 | -    if(empty($this->_mission_type) && is_array($this->allowed_missions)) { | 
                                                        |
| 1612 | +    if (empty($this->_mission_type) && is_array($this->allowed_missions)) { | 
                                                        |
| 1614 | 1613 | $this->_mission_type = reset($this->allowed_missions);  | 
                                                        
| 1615 | 1614 | }  | 
                                                        
| 1616 | -    foreach($this->allowed_missions as $key => $value) { | 
                                                        |
| 1615 | +    foreach ($this->allowed_missions as $key => $value) { | 
                                                        |
| 1617 | 1616 | $template_result['.']['missions'][] = array(  | 
                                                        
| 1618 | 1617 | 'ID' => $key,  | 
                                                        
| 1619 | 1618 | 'NAME' => classLocale::$lang['type_mission'][$key],  | 
                                                        
@@ -1625,9 +1624,9 @@ discard block  | 
                                                    ||
| 1625 | 1624 | * @param $template_result  | 
                                                        
| 1626 | 1625 | */  | 
                                                        
| 1627 | 1626 |    protected function renderDuration(&$template_result, $max_duration) { | 
                                                        
| 1628 | -    if($max_duration) { | 
                                                        |
| 1627 | +    if ($max_duration) { | 
                                                        |
| 1629 | 1628 | $config_game_speed_expedition = ($this->_mission_type == MT_EXPLORE && classSupernova::$config->game_speed_expedition ? classSupernova::$config->game_speed_expedition : 1);  | 
                                                        
| 1630 | -      for($i = 1; $i <= $max_duration; $i++) { | 
                                                        |
| 1629 | +      for ($i = 1; $i <= $max_duration; $i++) { | 
                                                        |
| 1631 | 1630 | $template_result['.']['duration'][] = array(  | 
                                                        
| 1632 | 1631 | 'ID' => $i,  | 
                                                        
| 1633 | 1632 | 'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)),  | 
                                                        
@@ -1643,7 +1642,7 @@ discard block  | 
                                                    ||
| 1643 | 1642 |    protected function renderPlanetResources(&$planetResources, &$template_result) { | 
                                                        
| 1644 | 1643 | // TODO - REDO to resource_id  | 
                                                        
| 1645 | 1644 | $i = 0;  | 
                                                        
| 1646 | -    foreach($planetResources as $resource_id => $resource_amount) { | 
                                                        |
| 1645 | +    foreach ($planetResources as $resource_id => $resource_amount) { | 
                                                        |
| 1647 | 1646 | $template_result['.']['resources'][] = array(  | 
                                                        
| 1648 | 1647 | 'ID' => $i++, // $resource_id,  | 
                                                        
| 1649 | 1648 | 'ON_PLANET' => $resource_amount,  | 
                                                        
@@ -1657,7 +1656,7 @@ discard block  | 
                                                    ||
| 1657 | 1656 | * @param $template_result  | 
                                                        
| 1658 | 1657 | */  | 
                                                        
| 1659 | 1658 |    protected function renderAllowedPlanetTypes(&$template_result) { | 
                                                        
| 1660 | -    foreach($this->allowed_planet_types as $possible_planet_type_id) { | 
                                                        |
| 1659 | +    foreach ($this->allowed_planet_types as $possible_planet_type_id) { | 
                                                        |
| 1661 | 1660 | $template_result['.']['possible_planet_type_id'][] = array(  | 
                                                        
| 1662 | 1661 | 'ID' => $possible_planet_type_id,  | 
                                                        
| 1663 | 1662 | 'NAME' => classLocale::$lang['sys_planet_type'][$possible_planet_type_id],  | 
                                                        
@@ -1680,14 +1679,14 @@ discard block  | 
                                                    ||
| 1680 | 1679 | 'TYPE_PRINT' => classLocale::$lang['fl_shrtcup'][$shortcut['planet_type']],  | 
                                                        
| 1681 | 1680 | );  | 
                                                        
| 1682 | 1681 | |
| 1683 | -    if(isset($shortcut['priority'])) { | 
                                                        |
| 1682 | +    if (isset($shortcut['priority'])) { | 
                                                        |
| 1684 | 1683 | $result += array(  | 
                                                        
| 1685 | 1684 | 'PRIORITY' => $shortcut['priority'],  | 
                                                        
| 1686 | 1685 | 'PRIORITY_CLASS' => $note_priority_classes[$shortcut['priority']],  | 
                                                        
| 1687 | 1686 | );  | 
                                                        
| 1688 | 1687 | }  | 
                                                        
| 1689 | 1688 | |
| 1690 | -    if(isset($shortcut['id'])) { | 
                                                        |
| 1689 | +    if (isset($shortcut['id'])) { | 
                                                        |
| 1691 | 1690 | $result += array(  | 
                                                        
| 1692 | 1691 | 'ID' => $shortcut['id'],  | 
                                                        
| 1693 | 1692 | );  | 
                                                        
@@ -1702,7 +1701,7 @@ discard block  | 
                                                    ||
| 1702 | 1701 |    protected function renderFleetShortcuts(&$template_result) { | 
                                                        
| 1703 | 1702 | // Building list of shortcuts  | 
                                                        
| 1704 | 1703 | $query = db_note_list_select_by_owner_and_planet($this->dbOwnerRow);  | 
                                                        
| 1705 | -    while($row = db_fetch($query)) { | 
                                                        |
| 1704 | +    while ($row = db_fetch($query)) { | 
                                                        |
| 1706 | 1705 | $template_result['.']['shortcut'][] = $this->renderFleet1TargetSelect($row);  | 
                                                        
| 1707 | 1706 | }  | 
                                                        
| 1708 | 1707 | }  | 
                                                        
@@ -1714,12 +1713,12 @@ discard block  | 
                                                    ||
| 1714 | 1713 | */  | 
                                                        
| 1715 | 1714 |    protected function renderOwnPlanets(&$template_result) { | 
                                                        
| 1716 | 1715 | $colonies = db_planet_list_sorted($this->dbOwnerRow);  | 
                                                        
| 1717 | -    if(count($colonies) <= 1) { | 
                                                        |
| 1716 | +    if (count($colonies) <= 1) { | 
                                                        |
| 1718 | 1717 | return;  | 
                                                        
| 1719 | 1718 | }  | 
                                                        
| 1720 | 1719 | |
| 1721 | -    foreach($colonies as $row) { | 
                                                        |
| 1722 | -      if($row['id'] == $this->dbSourcePlanetRow['id']) { | 
                                                        |
| 1720 | +    foreach ($colonies as $row) { | 
                                                        |
| 1721 | +      if ($row['id'] == $this->dbSourcePlanetRow['id']) { | 
                                                        |
| 1723 | 1722 | continue;  | 
                                                        
| 1724 | 1723 | }  | 
                                                        
| 1725 | 1724 | |
@@ -1732,10 +1731,10 @@ discard block  | 
                                                    ||
| 1732 | 1731 | */  | 
                                                        
| 1733 | 1732 |    protected function renderACSList(&$template_result) { | 
                                                        
| 1734 | 1733 | $query = db_acs_get_list();  | 
                                                        
| 1735 | -    while($row = db_fetch($query)) { | 
                                                        |
| 1734 | +    while ($row = db_fetch($query)) { | 
                                                        |
| 1736 | 1735 |        $members = explode(',', $row['eingeladen']); | 
                                                        
| 1737 | -      foreach($members as $a => $b) { | 
                                                        |
| 1738 | -        if($b == $this->dbOwnerRow['id']) { | 
                                                        |
| 1736 | +      foreach ($members as $a => $b) { | 
                                                        |
| 1737 | +        if ($b == $this->dbOwnerRow['id']) { | 
                                                        |
| 1739 | 1738 | $template_result['.']['acss'][] = $this->renderFleet1TargetSelect($row);  | 
                                                        
| 1740 | 1739 | }  | 
                                                        
| 1741 | 1740 | }  | 
                                                        
@@ -1746,7 +1745,7 @@ discard block  | 
                                                    ||
| 1746 | 1745 | * @param $template_result  | 
                                                        
| 1747 | 1746 | */  | 
                                                        
| 1748 | 1747 |    protected function renderShipSortOptions(&$template_result) { | 
                                                        
| 1749 | -    foreach(classLocale::$lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) { | 
                                                        |
| 1748 | +    foreach (classLocale::$lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) { | 
                                                        |
| 1750 | 1749 | $template_result['.']['ship_sort_list'][] = array(  | 
                                                        
| 1751 | 1750 | 'VALUE' => $sort_id,  | 
                                                        
| 1752 | 1751 | 'TEXT' => $sort_text,  | 
                                                        
@@ -324,6 +324,10 @@  | 
                                                    ||
| 324 | 324 | * @return int|mixed  | 
                                                        
| 325 | 325 | */  | 
                                                        
| 326 | 326 | // TODO - REDO!!!!  | 
                                                        
| 327 | +  | 
                                                        |
| 328 | + /**  | 
                                                        |
| 329 | + * @return double  | 
                                                        |
| 330 | + */  | 
                                                        |
| 327 | 331 |    function flt_fleet_speed($user) { | 
                                                        
| 328 | 332 | $speeds = array();  | 
                                                        
| 329 | 333 |      if(!empty($this->mapUnitIdToDb)) { | 
                                                        
@@ -88,7 +88,7 @@ discard block  | 
                                                    ||
| 88 | 88 | * @param Unit $value  | 
                                                        
| 89 | 89 | */  | 
                                                        
| 90 | 90 |    public function offsetSet($offset, $value) { | 
                                                        
| 91 | -    if(isset($this->mapUnitIdToDb[$value->unitId])) { | 
                                                        |
| 91 | +    if (isset($this->mapUnitIdToDb[$value->unitId])) { | 
                                                        |
| 92 | 92 |        classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId ' . $value->unitId . ' already exists'); | 
                                                        
| 93 | 93 | }  | 
                                                        
| 94 | 94 | $this->mapUnitIdToDb[$value->unitId] = $value;  | 
                                                        
@@ -96,7 +96,7 @@ discard block  | 
                                                    ||
| 96 | 96 | }  | 
                                                        
| 97 | 97 | |
| 98 | 98 |    public function offsetUnset($offset) { | 
                                                        
| 99 | -    if(!empty($this[$offset]->unitId)) { | 
                                                        |
| 99 | +    if (!empty($this[$offset]->unitId)) { | 
                                                        |
| 100 | 100 | // $unit_id = $this[$offset]->unitId;  | 
                                                        
| 101 | 101 | // $this->mapUnitIdToDb[$unit_id] = null;  | 
                                                        
| 102 | 102 | // unset($this->mapUnitIdToDb[$unit_id]);  | 
                                                        
@@ -117,20 +117,20 @@ discard block  | 
                                                    ||
| 117 | 117 |    public function dbLoad($dbId, $lockSkip = false) { | 
                                                        
| 118 | 118 | // $this->_reset();  | 
                                                        
| 119 | 119 | |
| 120 | -    if($dbId <= 0) { | 
                                                        |
| 120 | +    if ($dbId <= 0) { | 
                                                        |
| 121 | 121 | return;  | 
                                                        
| 122 | 122 | }  | 
                                                        
| 123 | 123 | |
| 124 | -    if(!is_object($this->locatedAt)) { | 
                                                        |
| 124 | +    if (!is_object($this->locatedAt)) { | 
                                                        |
| 125 | 125 |        classSupernova::$debug->error('UnitList::dbLoad have no locatedAt field set'); | 
                                                        
| 126 | 126 | }  | 
                                                        
| 127 | 127 | |
| 128 | 128 | $unit_array = classSupernova::db_get_unit_list_by_location(0, $this->getLocationType(), $this->getLocationDbId());  | 
                                                        
| 129 | -    if(!is_array($unit_array)) { | 
                                                        |
| 129 | +    if (!is_array($unit_array)) { | 
                                                        |
| 130 | 130 | return;  | 
                                                        
| 131 | 131 | }  | 
                                                        
| 132 | 132 | |
| 133 | -    foreach($unit_array as $unit_db_row) { | 
                                                        |
| 133 | +    foreach ($unit_array as $unit_db_row) { | 
                                                        |
| 134 | 134 | $unit = $this->_createElement();  | 
                                                        
| 135 | 135 | $unit->dbRowParse($unit_db_row);  | 
                                                        
| 136 | 136 | |
@@ -145,25 +145,25 @@ discard block  | 
                                                    ||
| 145 | 145 | }  | 
                                                        
| 146 | 146 | |
| 147 | 147 |    public function dbSave() { | 
                                                        
| 148 | -    if(!is_object($this->locatedAt)) { | 
                                                        |
| 148 | +    if (!is_object($this->locatedAt)) { | 
                                                        |
| 149 | 149 |        classSupernova::$debug->error('UnitList::dbSave have no locatedAt field set'); | 
                                                        
| 150 | 150 | }  | 
                                                        
| 151 | 151 | |
| 152 | -    foreach($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 152 | +    foreach ($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 153 | 153 | $unit_db_id = $unit->dbId;  | 
                                                        
| 154 | 154 | $unit->dbSave();  | 
                                                        
| 155 | 155 | |
| 156 | -      if($unit->isEmpty()) { | 
                                                        |
| 156 | +      if ($unit->isEmpty()) { | 
                                                        |
| 157 | 157 | // Removing unit object  | 
                                                        
| 158 | 158 | // TODO - change when there will be common bus for all objects  | 
                                                        
| 159 | 159 | // ...or should I? If COUNT is empty - it means that object does not exists in DB. So it should be deleted from PHP memory and cache too  | 
                                                        
| 160 | 160 | unset($this[$unit_db_id]);  | 
                                                        
| 161 | 161 |        } else { | 
                                                        
| 162 | -        if($unit->dbId <= 0) { | 
                                                        |
| 162 | +        if ($unit->dbId <= 0) { | 
                                                        |
| 163 | 163 |            classSupernova::$debug->error('Error writing unit to DB'); | 
                                                        
| 164 | 164 | }  | 
                                                        
| 165 | 165 | // If unit is new then putting unit object to container  | 
                                                        
| 166 | -        if(empty($this->_container[$unit->dbId])) { | 
                                                        |
| 166 | +        if (empty($this->_container[$unit->dbId])) { | 
                                                        |
| 167 | 167 | $this->_container[$unit->dbId] = $unit;  | 
                                                        
| 168 | 168 | }  | 
                                                        
| 169 | 169 | }  | 
                                                        
@@ -201,7 +201,7 @@ discard block  | 
                                                    ||
| 201 | 201 | }  | 
                                                        
| 202 | 202 | |
| 203 | 203 |    public function unitGetCount($unit_id) { | 
                                                        
| 204 | -    if(empty($this->mapUnitIdToDb[$unit_id])) { | 
                                                        |
| 204 | +    if (empty($this->mapUnitIdToDb[$unit_id])) { | 
                                                        |
| 205 | 205 |        throw new Exception('Unit [' . $unit_id . '] is not exists in UnitList'); | 
                                                        
| 206 | 206 | }  | 
                                                        
| 207 | 207 | return $this->mapUnitIdToDb[$unit_id]->count;  | 
                                                        
@@ -216,14 +216,14 @@ discard block  | 
                                                    ||
| 216 | 216 | * @param bool $replace_value  | 
                                                        
| 217 | 217 | */  | 
                                                        
| 218 | 218 |    public function unitAdjustCount($unit_id, $unit_count = 0, $replace_value = false) { | 
                                                        
| 219 | -    if(empty($this->mapUnitIdToDb[$unit_id])) { | 
                                                        |
| 219 | +    if (empty($this->mapUnitIdToDb[$unit_id])) { | 
                                                        |
| 220 | 220 | // If unit not exists - creating one and setting all attributes  | 
                                                        
| 221 | 221 | $this->mapUnitIdToDb[$unit_id] = $this->_createElement();  | 
                                                        
| 222 | 222 | $this->mapUnitIdToDb[$unit_id]->setUnitId($unit_id);  | 
                                                        
| 223 | 223 | $this->mapUnitIdToDb[$unit_id]->setLocatedAt($this);  | 
                                                        
| 224 | 224 | }  | 
                                                        
| 225 | 225 | |
| 226 | -    if($replace_value) { | 
                                                        |
| 226 | +    if ($replace_value) { | 
                                                        |
| 227 | 227 | $this->mapUnitIdToDb[$unit_id]->count = $unit_count;  | 
                                                        
| 228 | 228 |      } else { | 
                                                        
| 229 | 229 | $this->mapUnitIdToDb[$unit_id]->adjustCount($unit_count);  | 
                                                        
@@ -237,7 +237,7 @@ discard block  | 
                                                    ||
| 237 | 237 | */  | 
                                                        
| 238 | 238 |    public function unitsGetArray() { | 
                                                        
| 239 | 239 | $result = array();  | 
                                                        
| 240 | -    foreach($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 240 | +    foreach ($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 241 | 241 | $result[$unit->unitId] = $unit->count;  | 
                                                        
| 242 | 242 | }  | 
                                                        
| 243 | 243 | |
@@ -245,7 +245,7 @@ discard block  | 
                                                    ||
| 245 | 245 | }  | 
                                                        
| 246 | 246 | |
| 247 | 247 |    public function unitsCountApplyLossMultiplier($ships_lost_multiplier) { | 
                                                        
| 248 | -    foreach($this->mapUnitIdToDb as $unit_id => $unit) { | 
                                                        |
| 248 | +    foreach ($this->mapUnitIdToDb as $unit_id => $unit) { | 
                                                        |
| 249 | 249 | $unit->count = floor($unit->count * $ships_lost_multiplier);  | 
                                                        
| 250 | 250 | }  | 
                                                        
| 251 | 251 | }  | 
                                                        
@@ -271,8 +271,8 @@ discard block  | 
                                                    ||
| 271 | 271 | |
| 272 | 272 |    public function unitsPropertySumById($unit_id = 0, $propertyName = 'count') { | 
                                                        
| 273 | 273 | $result = 0;  | 
                                                        
| 274 | -    foreach($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 275 | -      if(!$unit_id || $unit->unitId == $unit_id) { | 
                                                        |
| 274 | +    foreach ($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 275 | +      if (!$unit_id || $unit->unitId == $unit_id) { | 
                                                        |
| 276 | 276 | $result += $unit->$propertyName;  | 
                                                        
| 277 | 277 | }  | 
                                                        
| 278 | 278 | }  | 
                                                        
@@ -289,15 +289,15 @@ discard block  | 
                                                    ||
| 289 | 289 | * @var Fleet $objFleet  | 
                                                        
| 290 | 290 | */  | 
                                                        
| 291 | 291 | $objFleet = $this->getLocatedAt();  | 
                                                        
| 292 | -    if(empty($objFleet)) { | 
                                                        |
| 292 | +    if (empty($objFleet)) { | 
                                                        |
| 293 | 293 |        throw new Exception('No fleet owner on UnitList::unitsRender() in ' . __FILE__ . '@' . __LINE__); | 
                                                        
| 294 | 294 | }  | 
                                                        
| 295 | 295 | |
| 296 | 296 | $tplShips = array();  | 
                                                        
| 297 | -    foreach($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 297 | +    foreach ($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 298 | 298 | $ship_id = $unit->unitId;  | 
                                                        
| 299 | 299 | $ship_count = $unit->count;  | 
                                                        
| 300 | -      if(!UnitShip::is_in_group($ship_id) || $ship_count <= 0) { | 
                                                        |
| 300 | +      if (!UnitShip::is_in_group($ship_id) || $ship_count <= 0) { | 
                                                        |
| 301 | 301 | continue;  | 
                                                        
| 302 | 302 | }  | 
                                                        
| 303 | 303 | |
@@ -326,9 +326,9 @@ discard block  | 
                                                    ||
| 326 | 326 | // TODO - REDO!!!!  | 
                                                        
| 327 | 327 |    function flt_fleet_speed($user) { | 
                                                        
| 328 | 328 | $speeds = array();  | 
                                                        
| 329 | -    if(!empty($this->mapUnitIdToDb)) { | 
                                                        |
| 330 | -      foreach($this->mapUnitIdToDb as $ship_id => $unit) { | 
                                                        |
| 331 | -        if($unit->getCount() > 0 && in_array($unit->unitId, sn_get_groups(array('fleet', 'missile')))) { | 
                                                        |
| 329 | +    if (!empty($this->mapUnitIdToDb)) { | 
                                                        |
| 330 | +      foreach ($this->mapUnitIdToDb as $ship_id => $unit) { | 
                                                        |
| 331 | +        if ($unit->getCount() > 0 && in_array($unit->unitId, sn_get_groups(array('fleet', 'missile')))) { | 
                                                        |
| 332 | 332 | $single_ship_data = get_ship_data($unit->unitId, $user);  | 
                                                        
| 333 | 333 | $speeds[] = $single_ship_data['speed'];  | 
                                                        
| 334 | 334 | }  | 
                                                        
@@ -349,11 +349,11 @@ discard block  | 
                                                    ||
| 349 | 349 | $fleet_speed = $this->flt_fleet_speed($dbOwnerRow);  | 
                                                        
| 350 | 350 | $real_speed = $speed_percent * sqrt($fleet_speed);  | 
                                                        
| 351 | 351 | |
| 352 | -    if($fleet_speed && $game_fleet_speed) { | 
                                                        |
| 352 | +    if ($fleet_speed && $game_fleet_speed) { | 
                                                        |
| 353 | 353 | $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed));  | 
                                                        
| 354 | 354 | |
| 355 | -      foreach($this->mapUnitIdToDb as $ship_id => $unit) { | 
                                                        |
| 356 | -        if(!$unit->unitId || $unit->getCount() <= 0) { | 
                                                        |
| 355 | +      foreach ($this->mapUnitIdToDb as $ship_id => $unit) { | 
                                                        |
| 356 | +        if (!$unit->unitId || $unit->getCount() <= 0) { | 
                                                        |
| 357 | 357 | continue;  | 
                                                        
| 358 | 358 | }  | 
                                                        
| 359 | 359 | |
@@ -384,8 +384,8 @@ discard block  | 
                                                    ||
| 384 | 384 | * @return bool  | 
                                                        
| 385 | 385 | */  | 
                                                        
| 386 | 386 |    public function unitsInGroup($group) { | 
                                                        
| 387 | -    foreach($this->mapUnitIdToDb as $unitId => $unit) { | 
                                                        |
| 388 | -      if(!in_array($unitId, $group)) { | 
                                                        |
| 387 | +    foreach ($this->mapUnitIdToDb as $unitId => $unit) { | 
                                                        |
| 388 | +      if (!in_array($unitId, $group)) { | 
                                                        |
| 389 | 389 | return false;  | 
                                                        
| 390 | 390 | }  | 
                                                        
| 391 | 391 | }  | 
                                                        
@@ -394,9 +394,9 @@ discard block  | 
                                                    ||
| 394 | 394 | }  | 
                                                        
| 395 | 395 | |
| 396 | 396 |    public function unitsIsAllMovable($dbOwnerRow) { | 
                                                        
| 397 | -    foreach($this->mapUnitIdToDb as $unitId => $unit) { | 
                                                        |
| 397 | +    foreach ($this->mapUnitIdToDb as $unitId => $unit) { | 
                                                        |
| 398 | 398 | $single_ship_data = get_ship_data($unit->unitId, $dbOwnerRow);  | 
                                                        
| 399 | -      if($single_ship_data['speed'] <= 0) { | 
                                                        |
| 399 | +      if ($single_ship_data['speed'] <= 0) { | 
                                                        |
| 400 | 400 | return false;  | 
                                                        
| 401 | 401 | }  | 
                                                        
| 402 | 402 | }  | 
                                                        
@@ -475,7 +475,7 @@ discard block  | 
                                                    ||
| 475 | 475 | |
| 476 | 476 |      print('</tr>'); | 
                                                        
| 477 | 477 | |
| 478 | -    foreach($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 478 | +    foreach ($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 479 | 479 |        print('<tr>'); | 
                                                        
| 480 | 480 | |
| 481 | 481 |        print('<td>'); | 
                                                        
@@ -526,14 +526,14 @@ discard block  | 
                                                    ||
| 526 | 526 | |
| 527 | 527 | |
| 528 | 528 |    public function unitZeroDbId() { | 
                                                        
| 529 | -    foreach($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 529 | +    foreach ($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 530 | 530 | $unit->zeroDbId();  | 
                                                        
| 531 | 531 | }  | 
                                                        
| 532 | 532 | }  | 
                                                        
| 533 | 533 | |
| 534 | 534 | |
| 535 | 535 |    public function unitZeroCount() { | 
                                                        
| 536 | -    foreach($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 536 | +    foreach ($this->mapUnitIdToDb as $unit) { | 
                                                        |
| 537 | 537 | $unit->count = 0;  | 
                                                        
| 538 | 538 | }  | 
                                                        
| 539 | 539 | }  | 
                                                        
@@ -14,24 +14,24 @@ discard block  | 
                                                    ||
| 14 | 14 |  function sn_function_call($func_name, $func_arg = array()) { | 
                                                        
| 15 | 15 |    // All data in classSupernova::$functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>') | 
                                                        
| 16 | 16 | |
| 17 | -  if(is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) { | 
                                                        |
| 17 | +  if (is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) { | 
                                                        |
| 18 | 18 | // Chain-callable functions should be made as following:  | 
                                                        
| 19 | 19 | // 1. Never use incomplete calls with parameters "by default"  | 
                                                        
| 20 | 20 | // 2. Reserve last parameter for cumulative result  | 
                                                        
| 21 | 21 | // 3. Use same format for original value and cumulative result (if there is original value)  | 
                                                        
| 22 | 22 | // 4. Honor cumulative result  | 
                                                        
| 23 | 23 | // 5. Return cumulative result  | 
                                                        
| 24 | -    foreach(classSupernova::$functions[$func_name] as $func_chain_name) { | 
                                                        |
| 24 | +    foreach (classSupernova::$functions[$func_name] as $func_chain_name) { | 
                                                        |
| 25 | 25 | // По идее - это уже тут не нужно, потому что оно все должно быть callable к этому моменту  | 
                                                        
| 26 | 26 | // Но для старых модулей...  | 
                                                        
| 27 | -      if(is_callable($func_chain_name)) { | 
                                                        |
| 27 | +      if (is_callable($func_chain_name)) { | 
                                                        |
| 28 | 28 | $result = call_user_func_array($func_chain_name, $func_arg);  | 
                                                        
| 29 | 29 | }  | 
                                                        
| 30 | 30 | }  | 
                                                        
| 31 | 31 |    } else { | 
                                                        
| 32 | 32 | // TODO: This is left for backward compatibility. Appropriate code should be rewrote!  | 
                                                        
| 33 | 33 |      $func_name = isset(classSupernova::$functions[$func_name]) && is_callable(classSupernova::$functions[$func_name]) ? classSupernova::$functions[$func_name] : ('sn_' . $func_name); | 
                                                        
| 34 | -    if(is_callable($func_name)) { | 
                                                        |
| 34 | +    if (is_callable($func_name)) { | 
                                                        |
| 35 | 35 | $result = call_user_func_array($func_name, $func_arg);  | 
                                                        
| 36 | 36 | }  | 
                                                        
| 37 | 37 | }  | 
                                                        
@@ -46,9 +46,9 @@ discard block  | 
                                                    ||
| 46 | 46 | * @param string $page_name - имя страницы, для которого должен был быть выполнен хук  | 
                                                        
| 47 | 47 | */  | 
                                                        
| 48 | 48 |  function execute_hooks(&$hook_list, &$template, $hook_type = null, $page_name = null) { | 
                                                        
| 49 | -  if(!empty($hook_list)) { | 
                                                        |
| 50 | -    foreach($hook_list as $hook) { | 
                                                        |
| 51 | -      if(is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { | 
                                                        |
| 49 | +  if (!empty($hook_list)) { | 
                                                        |
| 50 | +    foreach ($hook_list as $hook) { | 
                                                        |
| 51 | +      if (is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { | 
                                                        |
| 52 | 52 | $template = call_user_func($hook_call, $template, $hook_type, $page_name);  | 
                                                        
| 53 | 53 | }  | 
                                                        
| 54 | 54 | }  | 
                                                        
@@ -147,9 +147,9 @@ discard block  | 
                                                    ||
| 147 | 147 | */  | 
                                                        
| 148 | 148 |  function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) { | 
                                                        
| 149 | 149 | $n = floatval($n);  | 
                                                        
| 150 | -  if(is_int($floor)) { | 
                                                        |
| 150 | +  if (is_int($floor)) { | 
                                                        |
| 151 | 151 | $n = round($n, $floor); // , PHP_ROUND_HALF_DOWN  | 
                                                        
| 152 | -  } elseif($floor === true) { | 
                                                        |
| 152 | +  } elseif ($floor === true) { | 
                                                        |
| 153 | 153 | $n = floor($n);  | 
                                                        
| 154 | 154 | $floor = 0;  | 
                                                        
| 155 | 155 |    } else { | 
                                                        
@@ -159,14 +159,14 @@ discard block  | 
                                                    ||
| 159 | 159 | $ret = $n;  | 
                                                        
| 160 | 160 | |
| 161 | 161 | $suffix = '';  | 
                                                        
| 162 | -  if($limit) { | 
                                                        |
| 163 | -    if($ret > 0) { | 
                                                        |
| 164 | -      while($ret > $limit) { | 
                                                        |
| 162 | +  if ($limit) { | 
                                                        |
| 163 | +    if ($ret > 0) { | 
                                                        |
| 164 | +      while ($ret > $limit) { | 
                                                        |
| 165 | 165 | $suffix .= 'k';  | 
                                                        
| 166 | 166 | $ret = round($ret / 1000);  | 
                                                        
| 167 | 167 | }  | 
                                                        
| 168 | 168 |      } else { | 
                                                        
| 169 | -      while($ret < -$limit) { | 
                                                        |
| 169 | +      while ($ret < -$limit) { | 
                                                        |
| 170 | 170 | $suffix .= 'k';  | 
                                                        
| 171 | 171 | $ret = round($ret / 1000);  | 
                                                        
| 172 | 172 | }  | 
                                                        
@@ -176,16 +176,16 @@ discard block  | 
                                                    ||
| 176 | 176 | $ret = number_format($ret, $floor, ',', '.');  | 
                                                        
| 177 | 177 | $ret .= $suffix;  | 
                                                        
| 178 | 178 | |
| 179 | -  if($color !== false) { | 
                                                        |
| 180 | -    if($color === true) { | 
                                                        |
| 179 | +  if ($color !== false) { | 
                                                        |
| 180 | +    if ($color === true) { | 
                                                        |
| 181 | 181 | $class = $n == 0 ? 'zero' : ($n > 0 ? 'positive' : 'negative');  | 
                                                        
| 182 | -    } elseif($color >= 0) { | 
                                                        |
| 182 | +    } elseif ($color >= 0) { | 
                                                        |
| 183 | 183 | $class = $n == $color ? 'zero' : ($n < $color ? 'positive' : 'negative');  | 
                                                        
| 184 | 184 |      } else { | 
                                                        
| 185 | 185 | $class = ($n == -$color) ? 'zero' : ($n < -$color ? 'negative' : 'positive');  | 
                                                        
| 186 | 186 | }  | 
                                                        
| 187 | 187 | |
| 188 | -    if(!isset($style)) { | 
                                                        |
| 188 | +    if (!isset($style)) { | 
                                                        |
| 189 | 189 |        $ret = "<span class='{$class}'>{$ret}</span>"; | 
                                                        
| 190 | 190 |      } else { | 
                                                        
| 191 | 191 |        $ret = $style ? $ret = $class : $ret = array('text' => $ret, 'class' => $class); | 
                                                        
@@ -314,11 +314,11 @@ discard block  | 
                                                    ||
| 314 | 314 | |
| 315 | 315 |  function sys_get_param_phone($param_name, $default = '') { | 
                                                        
| 316 | 316 | $phone_raw = sys_get_param_str_unsafe($param_name, $default = '');  | 
                                                        
| 317 | -  if($phone_raw) { | 
                                                        |
| 317 | +  if ($phone_raw) { | 
                                                        |
| 318 | 318 | $phone = $phone_raw[0] == '+' ? '+' : '';  | 
                                                        
| 319 | -    for($i = 0; $i < strlen($phone_raw); $i++) { | 
                                                        |
| 319 | +    for ($i = 0; $i < strlen($phone_raw); $i++) { | 
                                                        |
| 320 | 320 | $ord = ord($phone_raw[$i]);  | 
                                                        
| 321 | -      if($ord >= 48 && $ord <= 57) { | 
                                                        |
| 321 | +      if ($ord >= 48 && $ord <= 57) { | 
                                                        |
| 322 | 322 | $phone .= $phone_raw[$i];  | 
                                                        
| 323 | 323 | }  | 
                                                        
| 324 | 324 | }  | 
                                                        
@@ -335,14 +335,14 @@ discard block  | 
                                                    ||
| 335 | 335 | }  | 
                                                        
| 336 | 336 | |
| 337 | 337 |  function CheckAbandonPlanetState(&$planet) { | 
                                                        
| 338 | -  if($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) { | 
                                                        |
| 338 | +  if ($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) { | 
                                                        |
| 339 | 339 | db_planet_delete_by_id($planet['id']);  | 
                                                        
| 340 | 340 | }  | 
                                                        
| 341 | 341 | }  | 
                                                        
| 342 | 342 | |
| 343 | 343 |  function eco_get_total_cost($unit_id, $unit_level) { | 
                                                        
| 344 | 344 | static $rate, $sn_group_resources_all, $sn_group_resources_loot;  | 
                                                        
| 345 | -  if(!$rate) { | 
                                                        |
| 345 | +  if (!$rate) { | 
                                                        |
| 346 | 346 |      $sn_group_resources_all = sn_get_groups('resources_all'); | 
                                                        
| 347 | 347 |      $sn_group_resources_loot = sn_get_groups('resources_loot'); | 
                                                        
| 348 | 348 | |
@@ -352,19 +352,19 @@ discard block  | 
                                                    ||
| 352 | 352 | }  | 
                                                        
| 353 | 353 | |
| 354 | 354 | $unit_cost_data = get_unit_param($unit_id, 'cost');  | 
                                                        
| 355 | -  if(!is_array($unit_cost_data)) { | 
                                                        |
| 355 | +  if (!is_array($unit_cost_data)) { | 
                                                        |
| 356 | 356 |      return array('total' => 0); | 
                                                        
| 357 | 357 | }  | 
                                                        
| 358 | 358 | $factor = isset($unit_cost_data['factor']) ? $unit_cost_data['factor'] : 1;  | 
                                                        
| 359 | 359 | $cost_array = array(BUILD_CREATE => array(), 'total' => 0);  | 
                                                        
| 360 | 360 | $unit_level = $unit_level > 0 ? $unit_level : 0;  | 
                                                        
| 361 | -  foreach($unit_cost_data as $resource_id => $resource_amount) { | 
                                                        |
| 362 | -    if(!in_array($resource_id, $sn_group_resources_all)) { | 
                                                        |
| 361 | +  foreach ($unit_cost_data as $resource_id => $resource_amount) { | 
                                                        |
| 362 | +    if (!in_array($resource_id, $sn_group_resources_all)) { | 
                                                        |
| 363 | 363 | continue;  | 
                                                        
| 364 | 364 | }  | 
                                                        
| 365 | 365 | // $cost_array[BUILD_CREATE][$resource_id] = $resource_amount * ($factor == 1 ? $unit_level : ((pow($factor, $unit_level) - $factor) / ($factor - 1)));  | 
                                                        
| 366 | 366 | $cost_array[BUILD_CREATE][$resource_id] = round($resource_amount * ($factor == 1 ? $unit_level : ((1 - pow($factor, $unit_level)) / (1 - $factor))));  | 
                                                        
| 367 | -    if(in_array($resource_id, $sn_group_resources_loot)) { | 
                                                        |
| 367 | +    if (in_array($resource_id, $sn_group_resources_loot)) { | 
                                                        |
| 368 | 368 | $cost_array['total'] += $cost_array[BUILD_CREATE][$resource_id] * $rate[$resource_id];  | 
                                                        
| 369 | 369 | }  | 
                                                        
| 370 | 370 | }  | 
                                                        
@@ -448,19 +448,19 @@ discard block  | 
                                                    ||
| 448 | 448 | $mercenary_level = 0;  | 
                                                        
| 449 | 449 | $unit_db_name = pname_resource_name($unit_id);  | 
                                                        
| 450 | 450 | |
| 451 | -  if(in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { | 
                                                        |
| 451 | +  if (in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { | 
                                                        |
| 452 | 452 | $unit = classSupernova::db_get_unit_by_location($user['id'], LOC_USER, $user['id'], $unit_id);  | 
                                                        
| 453 | 453 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0;  | 
                                                        
| 454 | -  } elseif(in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { | 
                                                        |
| 454 | +  } elseif (in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { | 
                                                        |
| 455 | 455 | $unit = classSupernova::db_get_unit_by_location(is_array($user) ? $user['id'] : $planet['id_owner'], LOC_PLANET, $planet['id'], $unit_id);  | 
                                                        
| 456 | 456 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0;  | 
                                                        
| 457 | -  } elseif(in_array($unit_id, sn_get_groups('governors'))) { | 
                                                        |
| 457 | +  } elseif (in_array($unit_id, sn_get_groups('governors'))) { | 
                                                        |
| 458 | 458 | $mercenary_level = $unit_id == $planet['PLANET_GOVERNOR_ID'] ? $planet['PLANET_GOVERNOR_LEVEL'] : 0;  | 
                                                        
| 459 | -  } elseif($unit_id == RES_DARK_MATTER) { | 
                                                        |
| 459 | +  } elseif ($unit_id == RES_DARK_MATTER) { | 
                                                        |
| 460 | 460 | $mercenary_level = $user[$unit_db_name] + ($plain || $user['user_as_ally'] ? 0 : classSupernova::$auth->account->account_metamatter);  | 
                                                        
| 461 | -  } elseif($unit_id == RES_METAMATTER) { | 
                                                        |
| 461 | +  } elseif ($unit_id == RES_METAMATTER) { | 
                                                        |
| 462 | 462 | $mercenary_level = classSupernova::$auth->account->account_metamatter; //$user[$unit_db_name];  | 
                                                        
| 463 | -  } elseif(in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { | 
                                                        |
| 463 | +  } elseif (in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { | 
                                                        |
| 464 | 464 | $mercenary_level = !empty($planet) ? $planet[$unit_db_name] : $user[$unit_db_name];  | 
                                                        
| 465 | 465 | }  | 
                                                        
| 466 | 466 | |
@@ -470,19 +470,19 @@ discard block  | 
                                                    ||
| 470 | 470 |  function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) { return sn_function_call(__FUNCTION__, array(&$user, $planet, $mercenaries, $value)); } | 
                                                        
| 471 | 471 | |
| 472 | 472 |  function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) { | 
                                                        
| 473 | -  if(!is_array($mercenaries)) { | 
                                                        |
| 473 | +  if (!is_array($mercenaries)) { | 
                                                        |
| 474 | 474 | $mercenaries = array($mercenaries);  | 
                                                        
| 475 | 475 | }  | 
                                                        
| 476 | 476 | |
| 477 | 477 | $base_value = isset($base_value) ? $base_value : $value;  | 
                                                        
| 478 | 478 | |
| 479 | -  foreach($mercenaries as $mercenary_id) { | 
                                                        |
| 479 | +  foreach ($mercenaries as $mercenary_id) { | 
                                                        |
| 480 | 480 | $mercenary_level = mrc_get_level($user, $planet, $mercenary_id);  | 
                                                        
| 481 | 481 | |
| 482 | 482 | $mercenary = get_unit_param($mercenary_id);  | 
                                                        
| 483 | 483 | $mercenary_bonus = $mercenary['bonus'];  | 
                                                        
| 484 | 484 | |
| 485 | -    switch($mercenary['bonus_type']) { | 
                                                        |
| 485 | +    switch ($mercenary['bonus_type']) { | 
                                                        |
| 486 | 486 | case BONUS_PERCENT_CUMULATIVE:  | 
                                                        
| 487 | 487 | $value *= 1 + $mercenary_level * $mercenary_bonus / 100;  | 
                                                        
| 488 | 488 | break;  | 
                                                        
@@ -513,7 +513,7 @@ discard block  | 
                                                    ||
| 513 | 513 | $allowed_length = strlen($allowed_chars);  | 
                                                        
| 514 | 514 | |
| 515 | 515 | $random_string = '';  | 
                                                        
| 516 | -  for($i = 0; $i < $length; $i++) { | 
                                                        |
| 516 | +  for ($i = 0; $i < $length; $i++) { | 
                                                        |
| 517 | 517 | $random_string .= $allowed_chars[mt_rand(0, $allowed_length - 1)];  | 
                                                        
| 518 | 518 | }  | 
                                                        
| 519 | 519 | |
@@ -533,12 +533,12 @@ discard block  | 
                                                    ||
| 533 | 533 | |
| 534 | 534 | $options = '';  | 
                                                        
| 535 | 535 | $option_list = array();  | 
                                                        
| 536 | -  foreach($user_option_list as $option_group_id => $option_group) { | 
                                                        |
| 536 | +  foreach ($user_option_list as $option_group_id => $option_group) { | 
                                                        |
| 537 | 537 | $option_list[$option_group_id] = array();  | 
                                                        
| 538 | -    foreach($option_group as $option_name => $option_value) { | 
                                                        |
| 539 | -      if(!isset($user[$option_name])) { | 
                                                        |
| 538 | +    foreach ($option_group as $option_name => $option_value) { | 
                                                        |
| 539 | +      if (!isset($user[$option_name])) { | 
                                                        |
| 540 | 540 | $user[$option_name] = $option_value;  | 
                                                        
| 541 | -      } elseif($user[$option_name] == '') { | 
                                                        |
| 541 | +      } elseif ($user[$option_name] == '') { | 
                                                        |
| 542 | 542 | $user[$option_name] = 0;  | 
                                                        
| 543 | 543 | }  | 
                                                        
| 544 | 544 |        $options .= "{$option_name}^{$user[$option_name]}|"; | 
                                                        
@@ -558,16 +558,16 @@ discard block  | 
                                                    ||
| 558 | 558 | $option_list = array();  | 
                                                        
| 559 | 559 |    $option_string_list = explode('|', $user['options']); | 
                                                        
| 560 | 560 | |
| 561 | -  foreach($option_string_list as $option_string) { | 
                                                        |
| 561 | +  foreach ($option_string_list as $option_string) { | 
                                                        |
| 562 | 562 |      list($option_name, $option_value) = explode('^', $option_string); | 
                                                        
| 563 | 563 | $option_list[$option_name] = $option_value;  | 
                                                        
| 564 | 564 | }  | 
                                                        
| 565 | 565 | |
| 566 | 566 | $final_list = array();  | 
                                                        
| 567 | -  foreach($user_option_list as $option_group_id => $option_group) { | 
                                                        |
| 567 | +  foreach ($user_option_list as $option_group_id => $option_group) { | 
                                                        |
| 568 | 568 | $final_list[$option_group_id] = array();  | 
                                                        
| 569 | -    foreach($option_group as $option_name => $option_value) { | 
                                                        |
| 570 | -      if(!isset($option_list[$option_name])) { | 
                                                        |
| 569 | +    foreach ($option_group as $option_name => $option_value) { | 
                                                        |
| 570 | +      if (!isset($option_list[$option_name])) { | 
                                                        |
| 571 | 571 | $option_list[$option_name] = $option_value;  | 
                                                        
| 572 | 572 | }  | 
                                                        
| 573 | 573 | $user[$option_name] = $final_list[$option_group_id][$option_name] = $option_list[$option_name];  | 
                                                        
@@ -581,12 +581,12 @@ discard block  | 
                                                    ||
| 581 | 581 | |
| 582 | 582 |  function sys_unit_str2arr($fleet_string) { | 
                                                        
| 583 | 583 | $fleet_array = array();  | 
                                                        
| 584 | -  if(!empty($fleet_string)) { | 
                                                        |
| 584 | +  if (!empty($fleet_string)) { | 
                                                        |
| 585 | 585 |      $arrTemp = explode(';', $fleet_string); | 
                                                        
| 586 | -    foreach($arrTemp as $temp) { | 
                                                        |
| 587 | -      if($temp) { | 
                                                        |
| 586 | +    foreach ($arrTemp as $temp) { | 
                                                        |
| 587 | +      if ($temp) { | 
                                                        |
| 588 | 588 |          $temp = explode(',', $temp); | 
                                                        
| 589 | -        if(!empty($temp[0]) && !empty($temp[1])) { | 
                                                        |
| 589 | +        if (!empty($temp[0]) && !empty($temp[1])) { | 
                                                        |
| 590 | 590 | $fleet_array[$temp[0]] += $temp[1];  | 
                                                        
| 591 | 591 | }  | 
                                                        
| 592 | 592 | }  | 
                                                        
@@ -598,13 +598,13 @@ discard block  | 
                                                    ||
| 598 | 598 | |
| 599 | 599 |  function sys_unit_arr2str($unit_list) { | 
                                                        
| 600 | 600 | $fleet_string = array();  | 
                                                        
| 601 | -  if(isset($unit_list)) { | 
                                                        |
| 602 | -    if(!is_array($unit_list)) { | 
                                                        |
| 601 | +  if (isset($unit_list)) { | 
                                                        |
| 602 | +    if (!is_array($unit_list)) { | 
                                                        |
| 603 | 603 | $unit_list = array($unit_list => 1);  | 
                                                        
| 604 | 604 | }  | 
                                                        
| 605 | 605 | |
| 606 | -    foreach($unit_list as $unit_id => $unit_count) { | 
                                                        |
| 607 | -      if($unit_id && $unit_count) { | 
                                                        |
| 606 | +    foreach ($unit_list as $unit_id => $unit_count) { | 
                                                        |
| 607 | +      if ($unit_id && $unit_count) { | 
                                                        |
| 608 | 608 |          $fleet_string[] = "{$unit_id},{$unit_count}"; | 
                                                        
| 609 | 609 | }  | 
                                                        
| 610 | 610 | }  | 
                                                        
@@ -630,7 +630,7 @@ discard block  | 
                                                    ||
| 630 | 630 |    $body = str_replace("\r\n", "\n", $body); | 
                                                        
| 631 | 631 |    $body = str_replace("\n", "\r\n", $body); | 
                                                        
| 632 | 632 | |
| 633 | -  if($html) { | 
                                                        |
| 633 | +  if ($html) { | 
                                                        |
| 634 | 634 | $body = '<html><head><base href="' . SN_ROOT_VIRTUAL . '"></head><body>' . nl2br($body) . '</body></html>';  | 
                                                        
| 635 | 635 | }  | 
                                                        
| 636 | 636 | |
@@ -674,21 +674,21 @@ discard block  | 
                                                    ||
| 674 | 674 | }  | 
                                                        
| 675 | 675 | |
| 676 | 676 |  function sn_ali_fill_user_ally(&$user) { | 
                                                        
| 677 | -  if(!$user['ally_id']) { | 
                                                        |
| 677 | +  if (!$user['ally_id']) { | 
                                                        |
| 678 | 678 | return;  | 
                                                        
| 679 | 679 | }  | 
                                                        
| 680 | 680 | |
| 681 | -  if(!isset($user['ally'])) { | 
                                                        |
| 681 | +  if (!isset($user['ally'])) { | 
                                                        |
| 682 | 682 | $user['ally'] = db_ally_get_by_id($user['ally_id']);  | 
                                                        
| 683 | 683 | }  | 
                                                        
| 684 | 684 | |
| 685 | -  if(!isset($user['ally']['player'])) { | 
                                                        |
| 685 | +  if (!isset($user['ally']['player'])) { | 
                                                        |
| 686 | 686 | $user['ally']['player'] = db_user_by_id($user['ally']['ally_user_id'], true, '*', false);  | 
                                                        
| 687 | 687 | }  | 
                                                        
| 688 | 688 | }  | 
                                                        
| 689 | 689 | |
| 690 | 690 |  function sn_get_url_contents($url) { | 
                                                        
| 691 | -  if(function_exists('curl_init')) { | 
                                                        |
| 691 | +  if (function_exists('curl_init')) { | 
                                                        |
| 692 | 692 | $crl = curl_init();  | 
                                                        
| 693 | 693 | $timeout = 5;  | 
                                                        
| 694 | 694 | curl_setopt($crl, CURLOPT_URL, $url);  | 
                                                        
@@ -723,10 +723,10 @@ discard block  | 
                                                    ||
| 723 | 723 | |
| 724 | 724 |  function get_ship_data($ship_id, $user) { | 
                                                        
| 725 | 725 | $ship_data = array();  | 
                                                        
| 726 | -  if(in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { | 
                                                        |
| 727 | -    foreach(get_unit_param($ship_id, 'engine') as $engine_info) { | 
                                                        |
| 726 | +  if (in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { | 
                                                        |
| 727 | +    foreach (get_unit_param($ship_id, 'engine') as $engine_info) { | 
                                                        |
| 728 | 728 | $tech_level = intval(mrc_get_level($user, null, $engine_info['tech']));  | 
                                                        
| 729 | -      if(empty($ship_data) || $tech_level >= $engine_info['min_level']) { | 
                                                        |
| 729 | +      if (empty($ship_data) || $tech_level >= $engine_info['min_level']) { | 
                                                        |
| 730 | 730 | $ship_data = $engine_info;  | 
                                                        
| 731 | 731 | $ship_data['tech_level'] = $tech_level;  | 
                                                        
| 732 | 732 | }  | 
                                                        
@@ -738,7 +738,7 @@ discard block  | 
                                                    ||
| 738 | 738 | return $ship_data;  | 
                                                        
| 739 | 739 | }  | 
                                                        
| 740 | 740 | |
| 741 | -if(!function_exists('strptime')) { | 
                                                        |
| 741 | +if (!function_exists('strptime')) { | 
                                                        |
| 742 | 742 |    function strptime($date, $format) { | 
                                                        
| 743 | 743 | $masks = array(  | 
                                                        
| 744 | 744 |        '%d' => '(?P<d>[0-9]{2})', | 
                                                        
@@ -751,12 +751,12 @@ discard block  | 
                                                    ||
| 751 | 751 | );  | 
                                                        
| 752 | 752 | |
| 753 | 753 | $rexep = "#" . strtr(preg_quote($format), $masks) . "#";  | 
                                                        
| 754 | -    if(preg_match($rexep, $date, $out)) { | 
                                                        |
| 754 | +    if (preg_match($rexep, $date, $out)) { | 
                                                        |
| 755 | 755 | $ret = array(  | 
                                                        
| 756 | - "tm_sec" => (int)$out['S'],  | 
                                                        |
| 757 | - "tm_min" => (int)$out['M'],  | 
                                                        |
| 758 | - "tm_hour" => (int)$out['H'],  | 
                                                        |
| 759 | - "tm_mday" => (int)$out['d'],  | 
                                                        |
| 756 | + "tm_sec" => (int) $out['S'],  | 
                                                        |
| 757 | + "tm_min" => (int) $out['M'],  | 
                                                        |
| 758 | + "tm_hour" => (int) $out['H'],  | 
                                                        |
| 759 | + "tm_mday" => (int) $out['d'],  | 
                                                        |
| 760 | 760 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0,  | 
                                                        
| 761 | 761 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0,  | 
                                                        
| 762 | 762 | );  | 
                                                        
@@ -771,7 +771,7 @@ discard block  | 
                                                    ||
| 771 | 771 |  function sn_sys_sector_buy($redirect = 'overview.php') { | 
                                                        
| 772 | 772 | global $user, $planetrow;  | 
                                                        
| 773 | 773 | |
| 774 | -  if(!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { | 
                                                        |
| 774 | +  if (!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { | 
                                                        |
| 775 | 775 | return;  | 
                                                        
| 776 | 776 | }  | 
                                                        
| 777 | 777 | |
@@ -784,9 +784,9 @@ discard block  | 
                                                    ||
| 784 | 784 | // $planetrow = $planetrow['planet'];  | 
                                                        
| 785 | 785 | $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true);  | 
                                                        
| 786 | 786 | $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER];  | 
                                                        
| 787 | -  if($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { | 
                                                        |
| 787 | +  if ($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { | 
                                                        |
| 788 | 788 | $planet_name_text = uni_render_planet($planetrow);  | 
                                                        
| 789 | - if(rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'],  | 
                                                        |
| 789 | + if (rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'],  | 
                                                        |
| 790 | 790 | $user['username'], $user['id'], $planet_name_text, classLocale::$lang['sys_planet_type'][$planetrow['planet_type']], $planetrow['id'], $sector_cost)  | 
                                                        
| 791 | 791 |      )) { | 
                                                        
| 792 | 792 | $sector_db_name = pname_resource_name(UNIT_SECTOR);  | 
                                                        
@@ -801,30 +801,30 @@ discard block  | 
                                                    ||
| 801 | 801 | }  | 
                                                        
| 802 | 802 | |
| 803 | 803 |  function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') { | 
                                                        
| 804 | -  if(isset($handler_list) && is_array($handler_list) && !empty($handler_list)) { | 
                                                        |
| 805 | -    foreach($handler_list as $function_name => $function_data) { | 
                                                        |
| 806 | -      if(is_string($function_data)) { | 
                                                        |
| 804 | +  if (isset($handler_list) && is_array($handler_list) && !empty($handler_list)) { | 
                                                        |
| 805 | +    foreach ($handler_list as $function_name => $function_data) { | 
                                                        |
| 806 | +      if (is_string($function_data)) { | 
                                                        |
| 807 | 807 | $override_with = &$function_data;  | 
                                                        
| 808 | -      } elseif(isset($function_data['callable'])) { | 
                                                        |
| 808 | +      } elseif (isset($function_data['callable'])) { | 
                                                        |
| 809 | 809 | $override_with = &$function_data['callable'];  | 
                                                        
| 810 | 810 | }  | 
                                                        
| 811 | 811 | |
| 812 | 812 | $overwrite = $override_with[0] == '*';  | 
                                                        
| 813 | -      if($overwrite) { | 
                                                        |
| 813 | +      if ($overwrite) { | 
                                                        |
| 814 | 814 | $override_with = substr($override_with, 1);  | 
                                                        
| 815 | 815 | }  | 
                                                        
| 816 | 816 | |
| 817 | -      if(($point_position = strpos($override_with, '.')) === false && $class_module_name) { | 
                                                        |
| 817 | +      if (($point_position = strpos($override_with, '.')) === false && $class_module_name) { | 
                                                        |
| 818 | 818 | $override_with = array($class_module_name, $override_with);  | 
                                                        
| 819 | -      } elseif($point_position == 0) { | 
                                                        |
| 819 | +      } elseif ($point_position == 0) { | 
                                                        |
| 820 | 820 | $override_with = substr($override_with, 1);  | 
                                                        
| 821 | -      } elseif($point_position > 0) { | 
                                                        |
| 821 | +      } elseif ($point_position > 0) { | 
                                                        |
| 822 | 822 | $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1));  | 
                                                        
| 823 | 823 | }  | 
                                                        
| 824 | 824 | |
| 825 | -      if($overwrite) { | 
                                                        |
| 825 | +      if ($overwrite) { | 
                                                        |
| 826 | 826 | $functions[$function_name] = array();  | 
                                                        
| 827 | -      } elseif(!isset($functions[$function_name])) { | 
                                                        |
| 827 | +      } elseif (!isset($functions[$function_name])) { | 
                                                        |
| 828 | 828 | $functions[$function_name] = array();  | 
                                                        
| 829 | 829 | $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : '');  | 
                                                        
| 830 | 830 | $functions[$function_name][] = $sn_function_name;  | 
                                                        
@@ -840,15 +840,15 @@ discard block  | 
                                                    ||
| 840 | 840 |  function player_nick_render_to_html($result, $options = false) { | 
                                                        
| 841 | 841 | // TODO - обрабатывать разные случаи: $user, $render_nick_array, $string  | 
                                                        
| 842 | 842 | |
| 843 | -  if(is_string($result) && strpos($result, ':{i:')) { | 
                                                        |
| 843 | +  if (is_string($result) && strpos($result, ':{i:')) { | 
                                                        |
| 844 | 844 | $result = player_nick_uncompact($result);  | 
                                                        
| 845 | 845 | }  | 
                                                        
| 846 | 846 | |
| 847 | -  if(is_array($result)) { | 
                                                        |
| 848 | -    if(isset($result['id'])) { | 
                                                        |
| 847 | +  if (is_array($result)) { | 
                                                        |
| 848 | +    if (isset($result['id'])) { | 
                                                        |
| 849 | 849 | $result = player_nick_render_current_to_array($result, $options);  | 
                                                        
| 850 | 850 | }  | 
                                                        
| 851 | -    if(!isset($result[NICK_HTML])) { | 
                                                        |
| 851 | +    if (!isset($result[NICK_HTML])) { | 
                                                        |
| 852 | 852 | $result = player_nick_render_array_to_html($result);  | 
                                                        
| 853 | 853 | }  | 
                                                        
| 854 | 854 | unset($result[NICK_HTML]);  | 
                                                        
@@ -871,7 +871,7 @@ discard block  | 
                                                    ||
| 871 | 871 |    try { | 
                                                        
| 872 | 872 | $result = unserialize($nick_string);  | 
                                                        
| 873 | 873 | // ksort($result); // Всегда ksort-ый в player_nick_compact()  | 
                                                        
| 874 | -  } catch(exception $e) { | 
                                                        |
| 874 | +  } catch (exception $e) { | 
                                                        |
| 875 | 875 |      $result = strpos($nick_string, ':{i:') ? null : $nick_string; // fallback if it is already string - for old chat strings, for example | 
                                                        
| 876 | 876 | }  | 
                                                        
| 877 | 877 | |
@@ -884,20 +884,20 @@ discard block  | 
                                                    ||
| 884 | 884 | global $user;  | 
                                                        
| 885 | 885 | |
| 886 | 886 | // ALL STRING ARE UNSAFE!!!  | 
                                                        
| 887 | -  if(isset($nick_array[NICK_BIRTHSDAY])) { | 
                                                        |
| 887 | +  if (isset($nick_array[NICK_BIRTHSDAY])) { | 
                                                        |
| 888 | 888 | $result[NICK_BIRTHSDAY] = '<img src="design/images/birthday.png" />';  | 
                                                        
| 889 | 889 | }  | 
                                                        
| 890 | 890 | |
| 891 | -  if(isset($nick_array[NICK_VACATION])) { | 
                                                        |
| 891 | +  if (isset($nick_array[NICK_VACATION])) { | 
                                                        |
| 892 | 892 | $result[NICK_VACATION] = '<img src="design/images/icon_vacation.png" />';  | 
                                                        
| 893 | 893 | }  | 
                                                        
| 894 | 894 | |
| 895 | -  if(isset($nick_array[NICK_GENDER])) { | 
                                                        |
| 895 | +  if (isset($nick_array[NICK_GENDER])) { | 
                                                        |
| 896 | 896 | $result[NICK_GENDER] = '<img src="' . ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH) . 'images/gender_' . $nick_array[NICK_GENDER] . '.png" />';  | 
                                                        
| 897 | 897 | }  | 
                                                        
| 898 | 898 | |
| 899 | -  if(isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { | 
                                                        |
| 900 | -    switch($nick_array[NICK_AUTH_LEVEL]) { | 
                                                        |
| 899 | +  if (isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { | 
                                                        |
| 900 | +    switch ($nick_array[NICK_AUTH_LEVEL]) { | 
                                                        |
| 901 | 901 | case 4:  | 
                                                        
| 902 | 902 | $highlight = classSupernova::$config->chat_highlight_developer;  | 
                                                        
| 903 | 903 | break;  | 
                                                        
@@ -918,20 +918,20 @@ discard block  | 
                                                    ||
| 918 | 918 | $highlight = isset($nick_array[NICK_PREMIUM]) ? classSupernova::$config->chat_highlight_premium : '';  | 
                                                        
| 919 | 919 | }  | 
                                                        
| 920 | 920 | |
| 921 | -    if($highlight) { | 
                                                        |
| 921 | +    if ($highlight) { | 
                                                        |
| 922 | 922 |        list($result[NICK_HIGHLIGHT], $result[NICK_HIGHLIGHT_END]) = explode('$1', $highlight); | 
                                                        
| 923 | 923 | }  | 
                                                        
| 924 | 924 |      // $result = preg_replace("#(.+)#", $highlight, $result); | 
                                                        
| 925 | 925 | }  | 
                                                        
| 926 | 926 | |
| 927 | -  if(isset($nick_array[NICK_CLASS])) { | 
                                                        |
| 927 | +  if (isset($nick_array[NICK_CLASS])) { | 
                                                        |
| 928 | 928 | $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] . '>';  | 
                                                        
| 929 | 929 | $result[NICK_CLASS_END] = '</span>';  | 
                                                        
| 930 | 930 | }  | 
                                                        
| 931 | 931 | |
| 932 | 932 | $result[NICK_NICK] = sys_safe_output($nick_array[NICK_NICK]);  | 
                                                        
| 933 | 933 | |
| 934 | -  if(isset($nick_array[NICK_ALLY])) { | 
                                                        |
| 934 | +  if (isset($nick_array[NICK_ALLY])) { | 
                                                        |
| 935 | 935 | $result[NICK_ALLY] = '[' . sys_safe_output($nick_array[NICK_ALLY]) . ']';  | 
                                                        
| 936 | 936 | }  | 
                                                        
| 937 | 937 | |
@@ -955,32 +955,32 @@ discard block  | 
                                                    ||
| 955 | 955 | */  | 
                                                        
| 956 | 956 | |
| 957 | 957 | |
| 958 | -  if($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { | 
                                                        |
| 958 | +  if ($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { | 
                                                        |
| 959 | 959 | $result[NICK_BIRTHSDAY] = '';  | 
                                                        
| 960 | 960 | }  | 
                                                        
| 961 | 961 | |
| 962 | -  if($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { | 
                                                        |
| 962 | +  if ($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { | 
                                                        |
| 963 | 963 | $result[NICK_GENDER] = $render_user['gender'] == GENDER_UNKNOWN ? 'unknown' : ($render_user['gender'] == GENDER_FEMALE ? 'female' : 'male');  | 
                                                        
| 964 | 964 | }  | 
                                                        
| 965 | 965 | |
| 966 | -  if(($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { | 
                                                        |
| 966 | +  if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { | 
                                                        |
| 967 | 967 | $result[NICK_VACATION] = $render_user['vacation'];  | 
                                                        
| 968 | 968 | }  | 
                                                        
| 969 | 969 | |
| 970 | -  if($options === true || (isset($options['color']) && $options['color'])) { | 
                                                        |
| 971 | -    if($user_auth_level = $render_user['authlevel']) { | 
                                                        |
| 970 | +  if ($options === true || (isset($options['color']) && $options['color'])) { | 
                                                        |
| 971 | +    if ($user_auth_level = $render_user['authlevel']) { | 
                                                        |
| 972 | 972 | $result[NICK_AUTH_LEVEL] = $user_auth_level;  | 
                                                        
| 973 | 973 | }  | 
                                                        
| 974 | -    if($user_premium = mrc_get_level($render_user, null, UNIT_PREMIUM)) { | 
                                                        |
| 974 | +    if ($user_premium = mrc_get_level($render_user, null, UNIT_PREMIUM)) { | 
                                                        |
| 975 | 975 | $result[NICK_PREMIUM] = $user_premium;  | 
                                                        
| 976 | 976 | }  | 
                                                        
| 977 | 977 | }  | 
                                                        
| 978 | 978 | |
| 979 | -  if((isset($options['class']) && $options['class'])) { | 
                                                        |
| 979 | +  if ((isset($options['class']) && $options['class'])) { | 
                                                        |
| 980 | 980 | $result[NICK_CLASS] = (isset($result_options[NICK_CLASS]) ? ' ' . $result_options[NICK_CLASS] : '') . $options['class'];  | 
                                                        
| 981 | 981 | }  | 
                                                        
| 982 | 982 | |
| 983 | -  if($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { | 
                                                        |
| 983 | +  if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { | 
                                                        |
| 984 | 984 | $result[NICK_ALLY] = $render_user['ally_tag'];  | 
                                                        
| 985 | 985 | }  | 
                                                        
| 986 | 986 | |
@@ -996,25 +996,25 @@ discard block  | 
                                                    ||
| 996 | 996 | |
| 997 | 997 | $user_skip_list = array();  | 
                                                        
| 998 | 998 | |
| 999 | -  if(classSupernova::$config->stats_hide_admins) { | 
                                                        |
| 999 | +  if (classSupernova::$config->stats_hide_admins) { | 
                                                        |
| 1000 | 1000 | $user_skip_list[] = '`authlevel` > 0';  | 
                                                        
| 1001 | 1001 | }  | 
                                                        
| 1002 | 1002 | |
| 1003 | -  if(classSupernova::$config->stats_hide_player_list) { | 
                                                        |
| 1003 | +  if (classSupernova::$config->stats_hide_player_list) { | 
                                                        |
| 1004 | 1004 |      $temp = explode(',', classSupernova::$config->stats_hide_player_list); | 
                                                        
| 1005 | -    foreach($temp as $user_id) { | 
                                                        |
| 1005 | +    foreach ($temp as $user_id) { | 
                                                        |
| 1006 | 1006 | $user_id = floatval($user_id);  | 
                                                        
| 1007 | -      if($user_id) { | 
                                                        |
| 1007 | +      if ($user_id) { | 
                                                        |
| 1008 | 1008 | $user_skip_list[] = '`id` = ' . $user_id;  | 
                                                        
| 1009 | 1009 | }  | 
                                                        
| 1010 | 1010 | }  | 
                                                        
| 1011 | 1011 | }  | 
                                                        
| 1012 | 1012 | |
| 1013 | -  if(!empty($user_skip_list)) { | 
                                                        |
| 1013 | +  if (!empty($user_skip_list)) { | 
                                                        |
| 1014 | 1014 |      $user_skip_list = implode(' OR ', $user_skip_list); | 
                                                        
| 1015 | 1015 | $user_skip_query = db_user_list($user_skip_list);  | 
                                                        
| 1016 | -    if(!empty($user_skip_query)) { | 
                                                        |
| 1017 | -      foreach($user_skip_query as $user_skip_row) { | 
                                                        |
| 1016 | +    if (!empty($user_skip_query)) { | 
                                                        |
| 1017 | +      foreach ($user_skip_query as $user_skip_row) { | 
                                                        |
| 1018 | 1018 | $result[$user_skip_row['id']] = $user_skip_row['id'];  | 
                                                        
| 1019 | 1019 | }  | 
                                                        
| 1020 | 1020 | }  | 
                                                        
@@ -1045,7 +1045,7 @@ discard block  | 
                                                    ||
| 1045 | 1045 | |
| 1046 | 1046 |  function sn_sn_get_groups($groups, &$result) { | 
                                                        
| 1047 | 1047 | $result = is_array($result) ? $result : array();  | 
                                                        
| 1048 | -  foreach($groups = is_array($groups) ? $groups : array($groups) as $group_name) { | 
                                                        |
| 1048 | +  foreach ($groups = is_array($groups) ? $groups : array($groups) as $group_name) { | 
                                                        |
| 1049 | 1049 | $result += is_array($a_group = get_unit_param(UNIT_GROUP, $group_name)) ? $a_group : array();  | 
                                                        
| 1050 | 1050 | }  | 
                                                        
| 1051 | 1051 | |
@@ -1071,8 +1071,8 @@ discard block  | 
                                                    ||
| 1071 | 1071 | $sn_data_unit = get_unit_param($unit_id);  | 
                                                        
| 1072 | 1072 | |
| 1073 | 1073 | $result = is_array($result) ? $result : array();  | 
                                                        
| 1074 | -  if($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) { | 
                                                        |
| 1075 | -    foreach($sn_data_unit[$field] as $require_id => $require_level) { | 
                                                        |
| 1074 | +  if ($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) { | 
                                                        |
| 1075 | +    foreach ($sn_data_unit[$field] as $require_id => $require_level) { | 
                                                        |
| 1076 | 1076 | $level_got = mrc_get_level($user, $planetrow, $require_id);  | 
                                                        
| 1077 | 1077 | $level_basic = mrc_get_level($user, $planetrow, $require_id, false, true);  | 
                                                        
| 1078 | 1078 | $result[] = array(  | 
                                                        
@@ -1096,16 +1096,16 @@ discard block  | 
                                                    ||
| 1096 | 1096 | |
| 1097 | 1097 | $ranks = array();  | 
                                                        
| 1098 | 1098 | |
| 1099 | -  if($ally['ranklist']) { | 
                                                        |
| 1099 | +  if ($ally['ranklist']) { | 
                                                        |
| 1100 | 1100 |      $str_ranks = explode(';', $ally['ranklist']); | 
                                                        
| 1101 | -    foreach($str_ranks as $str_rank) { | 
                                                        |
| 1102 | -      if(!$str_rank) { | 
                                                        |
| 1101 | +    foreach ($str_ranks as $str_rank) { | 
                                                        |
| 1102 | +      if (!$str_rank) { | 
                                                        |
| 1103 | 1103 | continue;  | 
                                                        
| 1104 | 1104 | }  | 
                                                        
| 1105 | 1105 | |
| 1106 | 1106 |        $tmp = explode(',', $str_rank); | 
                                                        
| 1107 | 1107 | $rank_id = count($ranks);  | 
                                                        
| 1108 | -      foreach($ally_rights as $key => $value) { | 
                                                        |
| 1108 | +      foreach ($ally_rights as $key => $value) { | 
                                                        |
| 1109 | 1109 | $ranks[$rank_id][$value] = $tmp[$key];  | 
                                                        
| 1110 | 1110 | }  | 
                                                        
| 1111 | 1111 | }  | 
                                                        
@@ -1121,8 +1121,8 @@ discard block  | 
                                                    ||
| 1121 | 1121 | }  | 
                                                        
| 1122 | 1122 | |
| 1123 | 1123 |  function array_merge_recursive_numeric($array1, $array2) { | 
                                                        
| 1124 | -  if(!empty($array2) && is_array($array2)) { | 
                                                        |
| 1125 | -    foreach($array2 as $key => $value) { | 
                                                        |
| 1124 | +  if (!empty($array2) && is_array($array2)) { | 
                                                        |
| 1125 | +    foreach ($array2 as $key => $value) { | 
                                                        |
| 1126 | 1126 |  //    if(!isset($array1[$key]) || !is_array($array1[$key])) { | 
                                                        
| 1127 | 1127 | // $array1[$key] = $value;  | 
                                                        
| 1128 | 1128 |  //    } else { | 
                                                        
@@ -1137,7 +1137,7 @@ discard block  | 
                                                    ||
| 1137 | 1137 | |
| 1138 | 1138 |  function sn_sys_array_cumulative_sum(&$array) { | 
                                                        
| 1139 | 1139 | $accum = 0;  | 
                                                        
| 1140 | -  foreach($array as &$value) { | 
                                                        |
| 1140 | +  foreach ($array as &$value) { | 
                                                        |
| 1141 | 1141 | $accum += $value;  | 
                                                        
| 1142 | 1142 | $value = $accum;  | 
                                                        
| 1143 | 1143 | }  | 
                                                        
@@ -1147,7 +1147,7 @@ discard block  | 
                                                    ||
| 1147 | 1147 |    $sn_data_density = sn_get_groups('planet_density'); | 
                                                        
| 1148 | 1148 | $density_price_chart = array();  | 
                                                        
| 1149 | 1149 | |
| 1150 | -  foreach($sn_data_density as $density_id => $density_data) { | 
                                                        |
| 1150 | +  foreach ($sn_data_density as $density_id => $density_data) { | 
                                                        |
| 1151 | 1151 | // Отсекаем записи с RARITY = 0 - служебные записи и супер-ядра  | 
                                                        
| 1152 | 1152 | $density_data[UNIT_PLANET_DENSITY_RARITY] ? $density_price_chart[$density_id] = $density_data[UNIT_PLANET_DENSITY_RARITY] : false;  | 
                                                        
| 1153 | 1153 | }  | 
                                                        
@@ -1155,7 +1155,7 @@ discard block  | 
                                                    ||
| 1155 | 1155 | |
| 1156 | 1156 | $total_rarity = array_sum($density_price_chart);  | 
                                                        
| 1157 | 1157 | |
| 1158 | -  foreach($density_price_chart as &$density_data) { | 
                                                        |
| 1158 | +  foreach ($density_price_chart as &$density_data) { | 
                                                        |
| 1159 | 1159 | $density_data = ceil($total_rarity / $density_data * $planet_row['field_max'] * PLANET_DENSITY_TO_DARK_MATTER_RATE);  | 
                                                        
| 1160 | 1160 | }  | 
                                                        
| 1161 | 1161 | |
@@ -1163,16 +1163,16 @@ discard block  | 
                                                    ||
| 1163 | 1163 | }  | 
                                                        
| 1164 | 1164 | |
| 1165 | 1165 |  function sn_sys_planet_core_transmute(&$user, &$planetrow) { | 
                                                        
| 1166 | -  if(!sys_get_param_str('transmute')) { | 
                                                        |
| 1166 | +  if (!sys_get_param_str('transmute')) { | 
                                                        |
| 1167 | 1167 | return array();  | 
                                                        
| 1168 | 1168 | }  | 
                                                        
| 1169 | 1169 | |
| 1170 | 1170 |    try { | 
                                                        
| 1171 | -    if($planetrow['planet_type'] != PT_PLANET) { | 
                                                        |
| 1171 | +    if ($planetrow['planet_type'] != PT_PLANET) { | 
                                                        |
| 1172 | 1172 | throw new exception(classLocale::$lang['ov_core_err_not_a_planet'], ERR_ERROR);  | 
                                                        
| 1173 | 1173 | }  | 
                                                        
| 1174 | 1174 | |
| 1175 | -    if($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { | 
                                                        |
| 1175 | +    if ($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { | 
                                                        |
| 1176 | 1176 | throw new exception(classLocale::$lang['ov_core_err_same_density'], ERR_WARNING);  | 
                                                        
| 1177 | 1177 | }  | 
                                                        
| 1178 | 1178 | |
@@ -1186,7 +1186,7 @@ discard block  | 
                                                    ||
| 1186 | 1186 | $planet_density_index = $planetrow['density_index'];  | 
                                                        
| 1187 | 1187 | |
| 1188 | 1188 | $density_price_chart = planet_density_price_chart($planetrow);  | 
                                                        
| 1189 | -    if(!isset($density_price_chart[$new_density_index])) { | 
                                                        |
| 1189 | +    if (!isset($density_price_chart[$new_density_index])) { | 
                                                        |
| 1190 | 1190 | // Hack attempt  | 
                                                        
| 1191 | 1191 | throw new exception(classLocale::$lang['ov_core_err_denisty_type_wrong'], ERR_ERROR);  | 
                                                        
| 1192 | 1192 | }  | 
                                                        
@@ -1195,13 +1195,13 @@ discard block  | 
                                                    ||
| 1195 | 1195 | // $transmute_cost = get_unit_param(UNIT_PLANET_DENSITY, 'cost');  | 
                                                        
| 1196 | 1196 | // $transmute_cost = $transmute_cost[RES_DARK_MATTER] * $density_price_chart[$new_density_index];  | 
                                                        
| 1197 | 1197 | $transmute_cost = $density_price_chart[$new_density_index];  | 
                                                        
| 1198 | -    if($user_dark_matter < $transmute_cost) { | 
                                                        |
| 1198 | +    if ($user_dark_matter < $transmute_cost) { | 
                                                        |
| 1199 | 1199 | throw new exception(classLocale::$lang['ov_core_err_no_dark_matter'], ERR_ERROR);  | 
                                                        
| 1200 | 1200 | }  | 
                                                        
| 1201 | 1201 | |
| 1202 | 1202 |      $sn_data_planet_density = sn_get_groups('planet_density'); | 
                                                        
| 1203 | -    foreach($sn_data_planet_density as $key => $value) { | 
                                                        |
| 1204 | -      if($key == $new_density_index) { | 
                                                        |
| 1203 | +    foreach ($sn_data_planet_density as $key => $value) { | 
                                                        |
| 1204 | +      if ($key == $new_density_index) { | 
                                                        |
| 1205 | 1205 | break;  | 
                                                        
| 1206 | 1206 | }  | 
                                                        
| 1207 | 1207 | $prev_density_index = $key;  | 
                                                        
@@ -1232,7 +1232,7 @@ discard block  | 
                                                    ||
| 1232 | 1232 | 'STATUS' => ERR_NONE,  | 
                                                        
| 1233 | 1233 | 'MESSAGE' => sprintf(classLocale::$lang['ov_core_err_none'], classLocale::$lang['uni_planet_density_types'][$planet_density_index], classLocale::$lang['uni_planet_density_types'][$new_density_index], $new_density),  | 
                                                        
| 1234 | 1234 | );  | 
                                                        
| 1235 | -  } catch(exception $e) { | 
                                                        |
| 1235 | +  } catch (exception $e) { | 
                                                        |
| 1236 | 1236 | sn_db_transaction_rollback();  | 
                                                        
| 1237 | 1237 | $result = array(  | 
                                                        
| 1238 | 1238 | 'STATUS' => $e->getCode(),  | 
                                                        
@@ -1245,8 +1245,8 @@ discard block  | 
                                                    ||
| 1245 | 1245 | |
| 1246 | 1246 |  function sn_module_get_active_count($group = '*') { | 
                                                        
| 1247 | 1247 | $active_modules = 0;  | 
                                                        
| 1248 | -  if(isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) { | 
                                                        |
| 1249 | -    foreach(sn_module::$sn_module_list[$group] as $payment_module) { | 
                                                        |
| 1248 | +  if (isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) { | 
                                                        |
| 1249 | +    foreach (sn_module::$sn_module_list[$group] as $payment_module) { | 
                                                        |
| 1250 | 1250 | $active_modules += $payment_module->manifest['active'];  | 
                                                        
| 1251 | 1251 | }  | 
                                                        
| 1252 | 1252 | }  | 
                                                        
@@ -1257,7 +1257,7 @@ discard block  | 
                                                    ||
| 1257 | 1257 |  function get_resource_exchange() { | 
                                                        
| 1258 | 1258 | static $rates;  | 
                                                        
| 1259 | 1259 | |
| 1260 | -  if(!$rates) { | 
                                                        |
| 1260 | +  if (!$rates) { | 
                                                        |
| 1261 | 1261 | $rates = array(  | 
                                                        
| 1262 | 1262 | RES_METAL => 'rpg_exchange_metal',  | 
                                                        
| 1263 | 1263 | RES_CRYSTAL => 'rpg_exchange_crystal',  | 
                                                        
@@ -1265,7 +1265,7 @@ discard block  | 
                                                    ||
| 1265 | 1265 | RES_DARK_MATTER => 'rpg_exchange_darkMatter',  | 
                                                        
| 1266 | 1266 | );  | 
                                                        
| 1267 | 1267 | |
| 1268 | -    foreach($rates as &$rate) { | 
                                                        |
| 1268 | +    foreach ($rates as &$rate) { | 
                                                        |
| 1269 | 1269 | $rate = classSupernova::$config->$rate;  | 
                                                        
| 1270 | 1270 | }  | 
                                                        
| 1271 | 1271 | }  | 
                                                        
@@ -1276,12 +1276,12 @@ discard block  | 
                                                    ||
| 1276 | 1276 |  function get_unit_cost_in(&$cost, $in_resource = RES_METAL) { | 
                                                        
| 1277 | 1277 | static $rates;  | 
                                                        
| 1278 | 1278 | |
| 1279 | -  if(!$rates) { | 
                                                        |
| 1279 | +  if (!$rates) { | 
                                                        |
| 1280 | 1280 | $rates = get_resource_exchange();  | 
                                                        
| 1281 | 1281 | }  | 
                                                        
| 1282 | 1282 | |
| 1283 | 1283 | $metal_cost = 0;  | 
                                                        
| 1284 | -  foreach($cost as $resource_id => $resource_value) { | 
                                                        |
| 1284 | +  foreach ($cost as $resource_id => $resource_value) { | 
                                                        |
| 1285 | 1285 | $metal_cost += $rates[$resource_id] * $resource_value;  | 
                                                        
| 1286 | 1286 | }  | 
                                                        
| 1287 | 1287 | |
@@ -1291,8 +1291,8 @@ discard block  | 
                                                    ||
| 1291 | 1291 |  function get_player_max_expeditons(&$user, $astrotech = -1) { return sn_function_call(__FUNCTION__, array(&$user, $astrotech, &$result)); } | 
                                                        
| 1292 | 1292 | |
| 1293 | 1293 |  function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) { | 
                                                        
| 1294 | -  if($astrotech == -1) { | 
                                                        |
| 1295 | -    if(!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) { | 
                                                        |
| 1294 | +  if ($astrotech == -1) { | 
                                                        |
| 1295 | +    if (!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) { | 
                                                        |
| 1296 | 1296 | $astrotech = mrc_get_level($user, null, TECH_ASTROTECH);  | 
                                                        
| 1297 | 1297 | $user[UNIT_PLAYER_EXPEDITIONS_MAX] = $astrotech >= 1 ? floor(sqrt($astrotech - 1)) : 0;  | 
                                                        
| 1298 | 1298 | }  | 
                                                        
@@ -1308,8 +1308,8 @@ discard block  | 
                                                    ||
| 1308 | 1308 | }  | 
                                                        
| 1309 | 1309 | |
| 1310 | 1310 |  function get_player_max_colonies(&$user, $astrotech = -1) { | 
                                                        
| 1311 | -  if($astrotech == -1) { | 
                                                        |
| 1312 | -    if(!isset($user[UNIT_PLAYER_COLONIES_MAX])) { | 
                                                        |
| 1311 | +  if ($astrotech == -1) { | 
                                                        |
| 1312 | +    if (!isset($user[UNIT_PLAYER_COLONIES_MAX])) { | 
                                                        |
| 1313 | 1313 | |
| 1314 | 1314 | $expeditions = get_player_max_expeditons($user);  | 
                                                        
| 1315 | 1315 | $astrotech = mrc_get_level($user, null, TECH_ASTROTECH);  | 
                                                        
@@ -1354,10 +1354,10 @@ discard block  | 
                                                    ||
| 1354 | 1354 | |
| 1355 | 1355 | // pdump($powerup_unit, '$powerup_unit');  | 
                                                        
| 1356 | 1356 | $level_current = $term_original = $time_left = 0;  | 
                                                        
| 1357 | -  if($is_upgrade) { | 
                                                        |
| 1357 | +  if ($is_upgrade) { | 
                                                        |
| 1358 | 1358 | $time_finish = strtotime($powerup_unit['unit_time_finish']);  | 
                                                        
| 1359 | 1359 | $time_left = max(0, $time_finish - SN_TIME_NOW);  | 
                                                        
| 1360 | -    if($time_left > 0) { | 
                                                        |
| 1360 | +    if ($time_left > 0) { | 
                                                        |
| 1361 | 1361 | $term_original = $time_finish - strtotime($powerup_unit['unit_time_start']);  | 
                                                        
| 1362 | 1362 | $level_current = $powerup_unit['unit_level'];  | 
                                                        
| 1363 | 1363 | }  | 
                                                        
@@ -1365,22 +1365,22 @@ discard block  | 
                                                    ||
| 1365 | 1365 | |
| 1366 | 1366 | $level_max = $level_max > $powerup_data[P_MAX_STACK] ? $level_max : $powerup_data[P_MAX_STACK];  | 
                                                        
| 1367 | 1367 | $original_cost = 0;  | 
                                                        
| 1368 | -  for($i = 1; $i <= $level_max; $i++) { | 
                                                        |
| 1368 | +  for ($i = 1; $i <= $level_max; $i++) { | 
                                                        |
| 1369 | 1369 | $base_cost = eco_get_total_cost($powerup_id, $i);  | 
                                                        
| 1370 | 1370 | $base_cost = $base_cost[BUILD_CREATE][RES_DARK_MATTER];  | 
                                                        
| 1371 | -    foreach($sn_powerup_buy_discounts as $period => $discount) { | 
                                                        |
| 1371 | +    foreach ($sn_powerup_buy_discounts as $period => $discount) { | 
                                                        |
| 1372 | 1372 | $upgrade_price = floor($base_cost * $discount * $period / PERIOD_MONTH);  | 
                                                        
| 1373 | 1373 | $result[$i][$period] = $upgrade_price;  | 
                                                        
| 1374 | 1374 | $original_cost = $is_upgrade && $i == $level_current && $period <= $term_original ? $upgrade_price : $original_cost;  | 
                                                        
| 1375 | 1375 | }  | 
                                                        
| 1376 | 1376 | }  | 
                                                        
| 1377 | 1377 | |
| 1378 | -  if($is_upgrade && $time_left) { | 
                                                        |
| 1378 | +  if ($is_upgrade && $time_left) { | 
                                                        |
| 1379 | 1379 | $term_original = round($term_original / PERIOD_DAY);  | 
                                                        
| 1380 | 1380 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original);  | 
                                                        
| 1381 | 1381 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0;  | 
                                                        
| 1382 | 1382 | |
| 1383 | -    array_walk_recursive($result, function (&$value) use ($cost_left) { | 
                                                        |
| 1383 | +    array_walk_recursive($result, function(&$value) use ($cost_left) { | 
                                                        |
| 1384 | 1384 | $value -= $cost_left;  | 
                                                        
| 1385 | 1385 | });  | 
                                                        
| 1386 | 1386 | }  | 
                                                        
@@ -1436,7 +1436,7 @@ discard block  | 
                                                    ||
| 1436 | 1436 | |
| 1437 | 1437 |  function print_rr($var, $capture = false) { | 
                                                        
| 1438 | 1438 | $print = '<pre>' . htmlspecialchars(print_r($var, true)) . '</pre>';  | 
                                                        
| 1439 | -  if($capture) { | 
                                                        |
| 1439 | +  if ($capture) { | 
                                                        |
| 1440 | 1440 | return $print;  | 
                                                        
| 1441 | 1441 |    } else { | 
                                                        
| 1442 | 1442 | print($print);  | 
                                                        
@@ -1515,8 +1515,8 @@ discard block  | 
                                                    ||
| 1515 | 1515 | * @return mixed  | 
                                                        
| 1516 | 1516 | */  | 
                                                        
| 1517 | 1517 |  function sortUnitRenderedList(&$ListToSort, $sort_option, $sort_option_inverse) { | 
                                                        
| 1518 | -  if($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { | 
                                                        |
| 1519 | -    switch($sort_option) { | 
                                                        |
| 1518 | +  if ($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { | 
                                                        |
| 1519 | +    switch ($sort_option) { | 
                                                        |
| 1520 | 1520 | case PLAYER_OPTION_SORT_NAME:  | 
                                                        
| 1521 | 1521 | $sort_option_field = 'NAME';  | 
                                                        
| 1522 | 1522 | break;  | 
                                                        
@@ -1537,7 +1537,7 @@ discard block  | 
                                                    ||
| 1537 | 1537 | break;  | 
                                                        
| 1538 | 1538 | }  | 
                                                        
| 1539 | 1539 | $sort_option_inverse_closure = $sort_option_inverse ? -1 : 1;  | 
                                                        
| 1540 | -    usort($ListToSort, function ($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { | 
                                                        |
| 1540 | +    usort($ListToSort, function($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { | 
                                                        |
| 1541 | 1541 | return $a[$sort_option_field] < $b[$sort_option_field] ? -1 * $sort_option_inverse_closure : (  | 
                                                        
| 1542 | 1542 | $a[$sort_option_field] > $b[$sort_option_field] ? 1 * $sort_option_inverse_closure : 0  | 
                                                        
| 1543 | 1543 | );  | 
                                                        
@@ -19,10 +19,10 @@ discard block  | 
                                                    ||
| 19 | 19 | global $template_result;  | 
                                                        
| 20 | 20 | $classLocale = classLocale::$lang;  | 
                                                        
| 21 | 21 | |
| 22 | -  if($ally_id = sys_get_param_id('ally_id')) { | 
                                                        |
| 22 | +  if ($ally_id = sys_get_param_id('ally_id')) { | 
                                                        |
| 23 | 23 |      define('SN_IN_ALLY', true); | 
                                                        
| 24 | 24 | $ranks = ally_get_ranks($auser['ally']);  | 
                                                        
| 25 | -    if($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { | 
                                                        |
| 25 | +    if ($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { | 
                                                        |
| 26 | 26 | $user = &$auser['ally']['player'];  | 
                                                        
| 27 | 27 | $planet = array(  | 
                                                        
| 28 | 28 | 'metal' => $user['metal'],  | 
                                                        
@@ -32,11 +32,11 @@ discard block  | 
                                                    ||
| 32 | 32 | }  | 
                                                        
| 33 | 33 | }  | 
                                                        
| 34 | 34 | |
| 35 | -  if(!$user) { | 
                                                        |
| 35 | +  if (!$user) { | 
                                                        |
| 36 | 36 | $user = &$auser;  | 
                                                        
| 37 | 37 | }  | 
                                                        
| 38 | 38 | |
| 39 | -  switch($action = sys_get_param_escaped('action')) { | 
                                                        |
| 39 | +  switch ($action = sys_get_param_escaped('action')) { | 
                                                        |
| 40 | 40 | case 'create': // Add unit to que for build  | 
                                                        
| 41 | 41 | case 'create_autoconvert': // Add unit to que for build  | 
                                                        
| 42 | 42 | case 'destroy': // Add unit to que for remove  | 
                                                        
@@ -53,28 +53,28 @@ discard block  | 
                                                    ||
| 53 | 53 | |
| 54 | 54 |    $group_missile = sn_get_groups('missile'); | 
                                                        
| 55 | 55 | $silo_capacity_free = 0;  | 
                                                        
| 56 | -  if($que_type == QUE_STRUCTURES) { | 
                                                        |
| 56 | +  if ($que_type == QUE_STRUCTURES) { | 
                                                        |
| 57 | 57 |      $build_unit_list = sn_get_groups('build_allow'); | 
                                                        
| 58 | 58 | $build_unit_list = $build_unit_list[$planet['planet_type']];  | 
                                                        
| 59 | 59 | $artifact_id = ART_NANO_BUILDER;  | 
                                                        
| 60 | 60 | $page_header = classLocale::$lang['tech'][UNIT_STRUCTURES];  | 
                                                        
| 61 | -  } elseif($que_type == QUE_RESEARCH) { | 
                                                        |
| 62 | -    if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) { | 
                                                        |
| 61 | +  } elseif ($que_type == QUE_RESEARCH) { | 
                                                        |
| 62 | +    if (!mrc_get_level($user, $planet, STRUC_LABORATORY)) { | 
                                                        |
| 63 | 63 | message(classLocale::$lang['no_laboratory'], classLocale::$lang['tech'][UNIT_TECHNOLOGIES]);  | 
                                                        
| 64 | 64 | }  | 
                                                        
| 65 | 65 | |
| 66 | -    if(eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { | 
                                                        |
| 66 | +    if (eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { | 
                                                        |
| 67 | 67 | message(classLocale::$lang['eco_bld_msg_err_laboratory_upgrading'], classLocale::$lang['tech'][UNIT_TECHNOLOGIES]);  | 
                                                        
| 68 | 68 | }  | 
                                                        
| 69 | 69 |      $build_unit_list = sn_get_groups('tech'); | 
                                                        
| 70 | 70 | $artifact_id = ART_HEURISTIC_CHIP;  | 
                                                        
| 71 | 71 |      $page_header = classLocale::$lang['tech'][UNIT_TECHNOLOGIES] . ($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); | 
                                                        
| 72 | -  } elseif($que_type == QUE_MERCENARY) { | 
                                                        |
| 72 | +  } elseif ($que_type == QUE_MERCENARY) { | 
                                                        |
| 73 | 73 |      $build_unit_list = sn_get_groups('mercenaries'); | 
                                                        
| 74 | 74 | $artifact_id = 0;  | 
                                                        
| 75 | 75 |      $page_header = classLocale::$lang['tech'][UNIT_MERCENARIES] . ($user['user_as_ally'] ? " {$classLocale['sys_of_ally']} {$user['username']}" : ''); | 
                                                        
| 76 | 76 |    } else { | 
                                                        
| 77 | -    if(mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { | 
                                                        |
| 77 | +    if (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { | 
                                                        |
| 78 | 78 | message(classLocale::$lang['need_hangar'], classLocale::$lang['tech'][STRUC_FACTORY_HANGAR]);  | 
                                                        
| 79 | 79 | }  | 
                                                        
| 80 | 80 | |
@@ -83,7 +83,7 @@ discard block  | 
                                                    ||
| 83 | 83 | $artifact_id = 0;  | 
                                                        
| 84 | 84 | |
| 85 | 85 | $silo_capacity_free = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY);  | 
                                                        
| 86 | -    foreach($group_missile as $unit_id) { | 
                                                        |
| 86 | +    foreach ($group_missile as $unit_id) { | 
                                                        |
| 87 | 87 | $silo_capacity_free -= (mrc_get_level($user, $planet, $unit_id, false, true) + (isset($in_que[$unit_id]) && $in_que[$unit_id] ? $in_que[$unit_id] : 0)) * get_unit_param($unit_id, P_UNIT_SIZE);  | 
                                                        
| 88 | 88 | }  | 
                                                        
| 89 | 89 | $silo_capacity_free = max(0, $silo_capacity_free);  | 
                                                        
@@ -94,7 +94,7 @@ discard block  | 
                                                    ||
| 94 | 94 | $config_resource_multiplier_plain = game_resource_multiplier(true);  | 
                                                        
| 95 | 95 | |
| 96 | 96 |    $template = gettemplate('buildings_builds', true); | 
                                                        
| 97 | -  if(!empty($operation_result)) { | 
                                                        |
| 97 | +  if (!empty($operation_result)) { | 
                                                        |
| 98 | 98 | $template_result['.']['result'][] = $operation_result;  | 
                                                        
| 99 | 99 | }  | 
                                                        
| 100 | 100 | |
@@ -124,7 +124,7 @@ discard block  | 
                                                    ||
| 124 | 124 | |
| 125 | 125 | $record_index = 0;  | 
                                                        
| 126 | 126 | |
| 127 | -  foreach($build_unit_list as $unit_id) { | 
                                                        |
| 127 | +  foreach ($build_unit_list as $unit_id) { | 
                                                        |
| 128 | 128 | $level_base = mrc_get_level($user, $planet, $unit_id, false, true);  | 
                                                        
| 129 | 129 | $level_effective = mrc_get_level($user, $planet, $unit_id);  | 
                                                        
| 130 | 130 | $level_in_que = $in_que[$unit_id];  | 
                                                        
@@ -147,12 +147,12 @@ discard block  | 
                                                    ||
| 147 | 147 | $can_build = $unit_info[P_MAX_STACK] ? max(0, $unit_info[P_MAX_STACK] - $level_in_que - $level_effective) : $build_data['CAN'][BUILD_CREATE];  | 
                                                        
| 148 | 148 | // Restricting $can_build by free silo capacity  | 
                                                        
| 149 | 149 | $can_build = ($unit_is_missile = in_array($unit_id, $group_missile)) ? min($can_build, floor($silo_capacity_free / $unit_info[P_UNIT_SIZE])) : $can_build;  | 
                                                        
| 150 | -    if(!$can_build) { | 
                                                        |
| 151 | -      if(!$build_data['CAN'][BUILD_CREATE]) { | 
                                                        |
| 150 | +    if (!$can_build) { | 
                                                        |
| 151 | +      if (!$build_data['CAN'][BUILD_CREATE]) { | 
                                                        |
| 152 | 152 | $build_data['RESULT'][BUILD_CREATE] = BUILD_NO_RESOURCES;  | 
                                                        
| 153 | -      } elseif($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { | 
                                                        |
| 153 | +      } elseif ($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { | 
                                                        |
| 154 | 154 | $build_data['RESULT'][BUILD_CREATE] = BUILD_SILO_FULL;  | 
                                                        
| 155 | -      } elseif($unit_info[P_MAX_STACK]) { | 
                                                        |
| 155 | +      } elseif ($unit_info[P_MAX_STACK]) { | 
                                                        |
| 156 | 156 | $build_data['RESULT'][BUILD_CREATE] = BUILD_MAX_REACHED;  | 
                                                        
| 157 | 157 | }  | 
                                                        
| 158 | 158 | }  | 
                                                        
@@ -219,14 +219,14 @@ discard block  | 
                                                    ||
| 219 | 219 | 'MAP_IS_RESOURCE' => !empty($unit_info[P_UNIT_PRODUCTION]),  | 
                                                        
| 220 | 220 | );  | 
                                                        
| 221 | 221 | |
| 222 | -    if($unit_stackable) { | 
                                                        |
| 222 | +    if ($unit_stackable) { | 
                                                        |
| 223 | 223 | $level_production_base = array(  | 
                                                        
| 224 | 224 | 'ACTUAL_SHIELD' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_info['shield'])),  | 
                                                        
| 225 | 225 | 'ACTUAL_ARMOR' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_info['armor'])),  | 
                                                        
| 226 | 226 | 'ACTUAL_WEAPON' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_info['attack'])),  | 
                                                        
| 227 | 227 | );  | 
                                                        
| 228 | 228 | |
| 229 | -      if($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { | 
                                                        |
| 229 | +      if ($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { | 
                                                        |
| 230 | 230 | $ship_data = get_ship_data($unit_id, $user);  | 
                                                        
| 231 | 231 | |
| 232 | 232 | $level_production_base += array(  | 
                                                        
@@ -236,9 +236,9 @@ discard block  | 
                                                    ||
| 236 | 236 | );  | 
                                                        
| 237 | 237 | }  | 
                                                        
| 238 | 238 | |
| 239 | -      if($unit_info[P_UNIT_PRODUCTION]) { | 
                                                        |
| 240 | -        foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { | 
                                                        |
| 241 | - if($resource_income =  | 
                                                        |
| 239 | +      if ($unit_info[P_UNIT_PRODUCTION]) { | 
                                                        |
| 240 | +        foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { | 
                                                        |
| 241 | + if ($resource_income =  | 
                                                        |
| 242 | 242 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc(1, 10, $user, $planet)  | 
                                                        
| 243 | 243 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier)  | 
                                                        
| 244 | 244 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))  | 
                                                        
@@ -248,11 +248,11 @@ discard block  | 
                                                    ||
| 248 | 248 | }  | 
                                                        
| 249 | 249 | }  | 
                                                        
| 250 | 250 | $production['.']['resource'][] = $level_production_base;  | 
                                                        
| 251 | -    } elseif($unit_info[P_UNIT_PRODUCTION]) { | 
                                                        |
| 251 | +    } elseif ($unit_info[P_UNIT_PRODUCTION]) { | 
                                                        |
| 252 | 252 | $level_production_base = array();  | 
                                                        
| 253 | 253 | $element_level_start = $level_effective + $in_que[$unit_id];  | 
                                                        
| 254 | -      foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { | 
                                                        |
| 255 | - if($resource_income =  | 
                                                        |
| 254 | +      foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { | 
                                                        |
| 255 | + if ($resource_income =  | 
                                                        |
| 256 | 256 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($element_level_start, 10, $user, $planet)  | 
                                                        
| 257 | 257 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier)  | 
                                                        
| 258 | 258 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))  | 
                                                        
@@ -262,10 +262,10 @@ discard block  | 
                                                    ||
| 262 | 262 | }  | 
                                                        
| 263 | 263 | |
| 264 | 264 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1;  | 
                                                        
| 265 | -      for($i = 0; $i < 6; $i++) { | 
                                                        |
| 265 | +      for ($i = 0; $i < 6; $i++) { | 
                                                        |
| 266 | 266 |          $level_production = array('LEVEL' => $level_start + $i); | 
                                                        
| 267 | -        foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { | 
                                                        |
| 268 | - if(  | 
                                                        |
| 267 | +        foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { | 
                                                        |
| 268 | + if (  | 
                                                        |
| 269 | 269 | $resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($level_start + $i, 10, $user, $planet)  | 
                                                        
| 270 | 270 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier)  | 
                                                        
| 271 | 271 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))  | 
                                                        
@@ -276,7 +276,7 @@ discard block  | 
                                                    ||
| 276 | 276 | }  | 
                                                        
| 277 | 277 | $production['.']['resource'][] = $level_production;  | 
                                                        
| 278 | 278 | }  | 
                                                        
| 279 | -    } elseif($unit_id == TECH_ASTROTECH) { | 
                                                        |
| 279 | +    } elseif ($unit_id == TECH_ASTROTECH) { | 
                                                        |
| 280 | 280 | $element_level_start = $level_effective + $in_que[$unit_id];  | 
                                                        
| 281 | 281 | $level_production_base = array(  | 
                                                        
| 282 | 282 | UNIT_PLAYER_EXPEDITIONS_MAX => get_player_max_expeditons($user, $element_level_start),  | 
                                                        
@@ -284,7 +284,7 @@ discard block  | 
                                                    ||
| 284 | 284 | );  | 
                                                        
| 285 | 285 | |
| 286 | 286 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1;  | 
                                                        
| 287 | -      for($i = 0; $i < 6; $i++) { | 
                                                        |
| 287 | +      for ($i = 0; $i < 6; $i++) { | 
                                                        |
| 288 | 288 |          $level_production = array('LEVEL' => $level_start + $i); | 
                                                        
| 289 | 289 | $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i);  | 
                                                        
| 290 | 290 | $level_production['D' . UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX];  | 
                                                        
@@ -305,7 +305,7 @@ discard block  | 
                                                    ||
| 305 | 305 | $template_result['.']['production'][] = $production;  | 
                                                        
| 306 | 306 | }  | 
                                                        
| 307 | 307 | |
| 308 | -  foreach(classLocale::$lang['player_option_building_sort'] as $sort_id => $sort_text) { | 
                                                        |
| 308 | +  foreach (classLocale::$lang['player_option_building_sort'] as $sort_id => $sort_text) { | 
                                                        |
| 309 | 309 |      $template->assign_block_vars('sort_values', array( | 
                                                        
| 310 | 310 | 'VALUE' => $sort_id,  | 
                                                        
| 311 | 311 | 'TEXT' => $sort_text,  |