supernova-ws /
SuperNova
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * infos.php |
||
| 5 | * |
||
| 6 | * Information about every aspect of in-game objects: buildings, officiers, techs etc |
||
| 7 | * |
||
| 8 | * @version 1.1st Security checks & tests by Gorlum for http://supernova.ws |
||
| 9 | * @version 1.1 |
||
| 10 | * @copyright 2008 By Chlorel for XNova |
||
| 11 | */ |
||
| 12 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
| 13 | |||
| 14 | function ShowProductionTable($CurrentUser, $CurrentPlanet, $BuildID, $Template) { |
||
| 15 | $config_resource_multiplier = game_resource_multiplier(); |
||
| 16 | $config_resource_multiplier_plain = game_resource_multiplier(true); |
||
| 17 | |||
| 18 | $CurrentBuildtLvl = mrc_get_level($CurrentUser, $CurrentPlanet, $BuildID); |
||
| 19 | |||
| 20 | $BuildLevel = ($CurrentBuildtLvl > 0) ? $CurrentBuildtLvl : 1; |
||
| 21 | |||
| 22 | $modifiers = sn_get_groups('modifiers'); |
||
| 23 | |||
| 24 | $Prod[STRUC_MINE_METAL] = floor(mrc_modify_value( |
||
| 25 | $CurrentUser, |
||
| 26 | $CurrentPlanet, |
||
| 27 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
| 28 | $config_resource_multiplier * $unit_data[P_UNIT_PRODUCTION][RES_METAL]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
| 29 | )); |
||
| 30 | $Prod[STRUC_MINE_CRYSTAL] = floor(mrc_modify_value( |
||
| 31 | $CurrentUser, |
||
| 32 | $CurrentPlanet, |
||
| 33 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
| 34 | $config_resource_multiplier * $unit_data[P_UNIT_PRODUCTION][RES_CRYSTAL]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
| 35 | )); |
||
| 36 | $Prod[STRUC_MINE_DEUTERIUM] = floor(mrc_modify_value( |
||
| 37 | $CurrentUser, |
||
| 38 | $CurrentPlanet, |
||
| 39 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
| 40 | $config_resource_multiplier * $unit_data[P_UNIT_PRODUCTION][RES_DEUTERIUM]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
| 41 | )); |
||
| 42 | $Prod[STRUC_MINE_SOLAR] = floor(mrc_modify_value( |
||
| 43 | $CurrentUser, |
||
| 44 | $CurrentPlanet, |
||
| 45 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
| 46 | $config_resource_multiplier_plain * $unit_data[P_UNIT_PRODUCTION][RES_ENERGY]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
| 47 | )); |
||
| 48 | |||
| 49 | $ActualProd = floor($Prod[$BuildID]); |
||
| 50 | View Code Duplication | if($BuildID != STRUC_MINE_FUSION) { |
|
| 51 | $ActualNeed = floor($Prod[STRUC_MINE_SOLAR]); |
||
| 52 | } else { |
||
| 53 | $ActualNeed = floor($Prod[STRUC_MINE_DEUTERIUM]); |
||
| 54 | } |
||
| 55 | |||
| 56 | $BuildStartLvl = $CurrentBuildtLvl - 2; |
||
| 57 | if($BuildStartLvl < 1) { |
||
| 58 | $BuildStartLvl = 1; |
||
| 59 | } |
||
| 60 | $Table = ''; |
||
| 61 | $ProdFirst = 0; |
||
| 62 | for($BuildLevel = $BuildStartLvl; $BuildLevel < $BuildStartLvl + 10; $BuildLevel++) { |
||
| 63 | if($BuildID != STRUC_MOON_PHALANX) { |
||
| 64 | $Prod[STRUC_MINE_METAL] = floor(mrc_modify_value( |
||
| 65 | $CurrentUser, |
||
| 66 | $CurrentPlanet, |
||
| 67 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
| 68 | $config_resource_multiplier * $unit_data[P_UNIT_PRODUCTION][RES_METAL]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
| 69 | )); |
||
| 70 | $Prod[STRUC_MINE_CRYSTAL] = floor(mrc_modify_value( |
||
| 71 | $CurrentUser, |
||
| 72 | $CurrentPlanet, |
||
| 73 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
| 74 | $config_resource_multiplier * $unit_data[P_UNIT_PRODUCTION][RES_CRYSTAL]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
| 75 | )); |
||
| 76 | $Prod[STRUC_MINE_DEUTERIUM] = floor(mrc_modify_value( |
||
| 77 | $CurrentUser, |
||
| 78 | $CurrentPlanet, |
||
| 79 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
| 80 | $config_resource_multiplier * $unit_data[P_UNIT_PRODUCTION][RES_DEUTERIUM]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
| 81 | )); |
||
| 82 | $Prod[STRUC_MINE_SOLAR] = floor(mrc_modify_value( |
||
| 83 | $CurrentUser, |
||
| 84 | $CurrentPlanet, |
||
| 85 | $modifiers[MODIFIER_RESOURCE_PRODUCTION], |
||
| 86 | $config_resource_multiplier_plain * $unit_data[P_UNIT_PRODUCTION][RES_ENERGY]($BuildLevel, 100, $CurrentUser, $CurrentPlanet) |
||
| 87 | )); |
||
| 88 | |||
| 89 | $bloc['build_lvl'] = ($CurrentBuildtLvl == $BuildLevel) ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel; |
||
| 90 | if($ProdFirst > 0) { |
||
| 91 | if($BuildID != STRUC_MINE_FUSION) { |
||
| 92 | $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[$BuildID] - $ProdFirst)) . ")</font>"; |
||
| 93 | } else { |
||
| 94 | $bloc['build_gain'] = "<font color=\"lime\">(" . pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ProdFirst)) . ")</font>"; |
||
| 95 | } |
||
| 96 | } else { |
||
| 97 | $bloc['build_gain'] = ''; |
||
| 98 | } |
||
| 99 | if($BuildID != STRUC_MINE_FUSION) { |
||
| 100 | $bloc['build_prod'] = pretty_number(floor($Prod[$BuildID])); |
||
| 101 | $bloc['build_prod_diff'] = pretty_number(floor($Prod[$BuildID] - $ActualProd), true, true); |
||
| 102 | $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR]), true, true); |
||
| 103 | $bloc['build_need_diff'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ActualNeed), true, true); |
||
| 104 | } else { |
||
| 105 | $bloc['build_prod'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR])); |
||
| 106 | $bloc['build_prod_diff'] = pretty_number(floor($Prod[STRUC_MINE_SOLAR] - $ActualProd), true, true); |
||
| 107 | $bloc['build_need'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM]), true, true); |
||
| 108 | $bloc['build_need_diff'] = pretty_number(floor($Prod[STRUC_MINE_DEUTERIUM] - $ActualNeed), true, true); |
||
| 109 | } |
||
| 110 | View Code Duplication | if($ProdFirst == 0) { |
|
| 111 | if($BuildID != STRUC_MINE_FUSION) { |
||
| 112 | $ProdFirst = floor($Prod[$BuildID]); |
||
| 113 | } else { |
||
| 114 | $ProdFirst = floor($Prod[STRUC_MINE_SOLAR]); |
||
| 115 | } |
||
| 116 | } |
||
| 117 | } else { |
||
| 118 | // Cas particulier de la phalange |
||
| 119 | $bloc['build_lvl'] = ($CurrentBuildtLvl == $BuildLevel) ? "<font color=\"#ff0000\">" . $BuildLevel . "</font>" : $BuildLevel; |
||
| 120 | $bloc['build_range'] = ($BuildLevel * $BuildLevel) - 1; |
||
| 121 | } |
||
| 122 | $Table .= parsetemplate($Template, $bloc); |
||
| 123 | } |
||
| 124 | |||
| 125 | return $Table; |
||
| 126 | } |
||
| 127 | |||
| 128 | function eco_render_rapid_fire($unit_id) { |
||
| 129 | $classLocale = classLocale::$lang; |
||
| 130 | |||
| 131 | $unit_data = get_unit_param($unit_id); |
||
| 132 | $unit_durability = $unit_data['shield'] + $unit_data['armor']; |
||
| 133 | |||
| 134 | $str_rapid_from = ''; |
||
| 135 | $str_rapid_to = ''; |
||
| 136 | foreach(sn_get_groups(array('fleet', 'defense_active')) as $enemy_id) { |
||
| 137 | $enemy_data = get_unit_param($enemy_id); |
||
| 138 | $enemy_durability = $enemy_data['shield'] + $enemy_data['armor']; |
||
| 139 | |||
| 140 | $rapid = floor($unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability); |
||
| 141 | if($rapid >= 1) { |
||
| 142 | $str_rapid_to .= "{$classLocale['nfo_rf_again']} {$classLocale['tech'][$enemy_id]} <font color=\"#00ff00\">{$rapid}</font><br>"; |
||
| 143 | } |
||
| 144 | |||
| 145 | $rapid = floor($enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability); |
||
| 146 | if($rapid >= 1) { |
||
| 147 | $str_rapid_from .= "{$classLocale['tech'][$enemy_id]} {$classLocale['nfo_rf_from']} <font color=\"#ff0000\">{$rapid}</font><br>"; |
||
| 148 | } |
||
| 149 | } |
||
| 150 | |||
| 151 | if($str_rapid_to && $str_rapid_from) { |
||
| 152 | $str_rapid_to .= '<hr>'; |
||
| 153 | } |
||
| 154 | |||
| 155 | return array('to' => $str_rapid_to, 'from' => $str_rapid_from); |
||
| 156 | } |
||
| 157 | |||
| 158 | $unit_id = sys_get_param_id('gid'); |
||
| 159 | if($unit_id == RES_DARK_MATTER) { |
||
| 160 | sys_redirect('dark_matter.php'); |
||
| 161 | } |
||
| 162 | |||
| 163 | if($unit_id == RES_METAMATTER) { |
||
| 164 | sys_redirect('metamatter.php'); |
||
| 165 | } |
||
| 166 | |||
| 167 | lng_include('infos'); |
||
| 168 | if(!$unit_id || (!get_unit_param($unit_id) && !isset(classLocale::$lang['info'][$unit_id]))) { |
||
| 169 | sys_redirect('index.php?page=techtree'); |
||
| 170 | } |
||
| 171 | |||
| 172 | $template = gettemplate('novapedia', true); |
||
| 173 | |||
| 174 | $unit_data = get_unit_param($unit_id); |
||
| 175 | $unit_type = $unit_data['type']; |
||
| 176 | |||
| 177 | if($unit_type == UNIT_SHIPS) { |
||
| 178 | $template_result['UNIT_IS_SHIP'] = true; |
||
| 179 | |||
| 180 | $ship_data = get_ship_data($unit_id, $user); |
||
| 181 | |||
| 182 | $template_result += array( |
||
| 183 | 'BASE_SPEED' => pretty_number($ship_data['speed_base']), |
||
| 184 | 'ACTUAL_SPEED' => pretty_number($ship_data['speed']), |
||
| 185 | 'BASE_CONSUMPTION' => pretty_number($ship_data['consumption_base']), |
||
| 186 | 'ACTUAL_CONSUMPTION' => pretty_number($ship_data['consumption']), |
||
| 187 | |||
| 188 | 'BASE_CAPACITY' => pretty_number($unit_data['capacity']), |
||
| 189 | 'ACTUAL_CAPACITY' => pretty_number($ship_data['capacity']), |
||
| 190 | ); |
||
| 191 | |||
| 192 | $engine_template_info = array(); |
||
| 193 | foreach($unit_data['engine'] as $unit_engine_data) { |
||
| 194 | $unit_engine_data = get_engine_data($user, $unit_engine_data); |
||
| 195 | |||
| 196 | $engine_template_info[] = array( |
||
| 197 | 'NAME' => classLocale::$lang['tech'][$unit_engine_data['tech']], |
||
| 198 | 'MIN_LEVEL' => $unit_engine_data['min_level'], |
||
| 199 | 'USER_TECH_LEVEL' => mrc_get_level($user, null, $unit_engine_data['tech']), |
||
|
0 ignored issues
–
show
|
|||
| 200 | 'BASE_SPEED' => pretty_number($unit_engine_data['speed_base']), |
||
| 201 | 'BASE_CONSUMPTION' => pretty_number($unit_engine_data['consumption_base']), |
||
| 202 | 'ACTUAL_SPEED' => pretty_number($unit_engine_data['speed']), |
||
| 203 | 'ACTUAL_CONSUMPTION' => pretty_number($unit_engine_data['consumption']), |
||
| 204 | ); |
||
| 205 | } |
||
| 206 | $template_result['.']['engine'] = $engine_template_info; |
||
| 207 | |||
| 208 | } |
||
| 209 | |||
| 210 | |||
| 211 | $sn_data_group_combat = sn_get_groups('combat'); |
||
| 212 | if(in_array($unit_id, $sn_data_group_combat)) { |
||
| 213 | $template_result['UNIT_IS_COMBAT'] = true; |
||
| 214 | |||
| 215 | $unit_durability = $unit_data['shield'] + $unit_data['armor']; |
||
| 216 | |||
| 217 | $volley_arr = $rapid_to = $rapid_from = array(); |
||
| 218 | $str_rapid_from = ''; |
||
| 219 | $str_rapid_to = ''; |
||
| 220 | foreach($sn_data_group_combat as $enemy_id) { |
||
| 221 | $enemy_data = get_unit_param($enemy_id); |
||
| 222 | $enemy_durability = $enemy_data['shield'] + $enemy_data['armor']; |
||
| 223 | |||
| 224 | $rapid = $unit_data['attack'] * (isset($unit_data['amplify'][$enemy_id]) ? $unit_data['amplify'][$enemy_id] : 1) / $enemy_durability; |
||
| 225 | if($rapid >= 1) { |
||
| 226 | $volley_arr[$enemy_id]['TO'] = floor($rapid); |
||
| 227 | } |
||
| 228 | |||
| 229 | $rapid = $enemy_data['attack'] * (isset($enemy_data['amplify'][$unit_id]) ? $enemy_data['amplify'][$unit_id] : 1) / $unit_durability; |
||
| 230 | if($rapid >= 1) { |
||
| 231 | $volley_arr[$enemy_id]['FROM'] = floor($rapid); |
||
| 232 | } |
||
| 233 | } |
||
| 234 | foreach($volley_arr as $enemy_id => &$rapid) { |
||
| 235 | $rapid['ENEMY_ID'] = $enemy_id; |
||
| 236 | $rapid['ENEMY_NAME'] = classLocale::$lang['tech'][$enemy_id]; |
||
| 237 | } |
||
| 238 | $template_result['.']['volley'] = $volley_arr; |
||
| 239 | |||
| 240 | $template_result += array( |
||
| 241 | 'BASE_ARMOR' => pretty_number($unit_data['armor']), |
||
| 242 | 'BASE_SHIELD' => pretty_number($unit_data['shield']), |
||
| 243 | 'BASE_WEAPON' => pretty_number($unit_data['attack']), |
||
| 244 | |||
| 245 | 'ACTUAL_ARMOR' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_data['armor'])), |
||
| 246 | 'ACTUAL_SHIELD' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_data['shield'])), |
||
| 247 | 'ACTUAL_WEAPON' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_data['attack'])), |
||
| 248 | ); |
||
| 249 | |||
| 250 | } |
||
| 251 | |||
| 252 | if(classLocale::$lang['info'][$unit_id]['effect']) { |
||
| 253 | $template_result['UNIT_EFFECT'] = classLocale::$lang['info'][$unit_id]['effect']; |
||
| 254 | } |
||
| 255 | |||
| 256 | if($unit_data['bonus']) { |
||
| 257 | $unit_bonus = !$unit_data['bonus'] || $unit_data['bonus_type'] == BONUS_ABILITY ? '' : ( |
||
| 258 | ($unit_data['bonus'] >= 0 ? '+' : '') . $unit_data['bonus'] . ($unit_data['bonus_type'] == BONUS_PERCENT ? '%' : '') |
||
| 259 | ); |
||
| 260 | $template_result['UNIT_BONUS'] = $unit_bonus; |
||
| 261 | } |
||
| 262 | |||
| 263 | $template_result += array( |
||
| 264 | 'PAGE_HEADER' => classLocale::$lang['wiki_title'], |
||
| 265 | |||
| 266 | 'UNIT_ID' => $unit_id, |
||
| 267 | 'UNIT_NAME' => classLocale::$lang['tech'][$unit_id], |
||
| 268 | 'UNIT_TYPE' => $unit_type, |
||
| 269 | 'UNIT_TYPE_NAME' => classLocale::$lang['tech'][$unit_type], |
||
| 270 | 'UNIT_DESCRIPTION' => classLocale::$lang['info'][$unit_id]['description'], |
||
| 271 | ); |
||
| 272 | |||
| 273 | $template_result['.']['require'] = unit_requirements_render($user, $planetrow, $unit_id); |
||
| 274 | |||
| 275 | $template->assign_recursive($template_result); |
||
| 276 | display($template); |
||
| 277 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: