while ($result = mysql_fetch_assoc($mess)) { //$str = substr($result['message'], 0, 85); $str = $result['message']; $usr = $result['user']; $msg .= "<tr><td align=\"left\">".$usr.":</td><td>".$str."</td></tr>"; } $msg .= '</table>'; */ $recyclers_send = min(ceil(($planetrow['debris_metal'] + $planetrow['debris_crystal']) / $sn_data[SHIP_RECYCLER]['capacity']), $planetrow[$sn_data[SHIP_RECYCLER]['name']]); int_planet_pretemplate($planetrow, $template); foreach (array(QUE_STRUCTURES => $sn_data['groups']['ques'][QUE_STRUCTURES]) as $que_id => $que_type_data) { $template->assign_block_vars('ques', array(ID => $que_id, NAME => $lang['sys_ques'][$que_id], LENGTH => count($que['que'][$que_id]))); if ($que['que'][$que_id]) { foreach ($que['que'][$que_id] as $que_item) { $template->assign_block_vars('que', $que_item); } } } $que_hangar_length = tpl_assign_hangar(QUE_HANGAR, $planetrow, $template); $template->assign_block_vars('ques', array(ID => QUE_HANGAR, NAME => $lang['sys_ques'][QUE_HANGAR], LENGTH => $que_hangar_length)); $unit_id = intval($planetrow['b_tech_id']); $time_rest = $planetrow['b_tech'] - $time_now; $time_rest = $time_rest >= 0 ? $time_rest : 0; $template->assign_block_vars('ques', array(ID => QUE_RESEARCH, NAME => $lang['sys_ques'][QUE_RESEARCH], LENGTH => $unit_id && $time_rest ? 1 : 0)); if ($unit_id && $time_rest) { $template->assign_block_vars('que', array('ID' => $unit_id, 'QUE' => QUE_RESEARCH, 'NAME' => $lang['tech'][$unit_id], 'TIME' => $time_rest, 'TIME_FULL' => $time_rest, 'AMOUNT' => 1, 'LEVEL' => $user[$sn_data[$unit_id]['name']] + 1)); } $template->assign_vars(array('TIME_NOW' => $time_now, 'USER_ID' => $user['id'], 'user_username' => $user['username'], 'USER_AUTHLEVEL' => $user['authlevel'], 'NEW_MESSAGES' => $user['new_message'], 'NEW_LEVEL_MINER' => $level_miner, 'NEW_LEVEL_RAID' => $level_raid, 'planet_diameter' => pretty_number($planetrow['diameter']), 'planet_field_current' => $planetrow['field_current'], 'planet_field_max' => eco_planet_fields_max($planetrow), 'PLANET_FILL' => floor($planetrow['field_current'] / eco_planet_fields_max($planetrow) * 100), 'PLANET_FILL_BAR' => $planet_fill, 'metal_debris' => pretty_number($planetrow['debris_metal']), 'crystal_debris' => pretty_number($planetrow['debris_crystal']), 'RECYCLERS_SEND' => $recyclers_send, 'planet_temp_min' => $planetrow['temp_min'], 'planet_temp_max' => $planetrow['temp_max'], 'ADMIN_EMAIL' => $config->game_adminEmail)); display(parsetemplate($template, $parse), "{$lang['ov_overview']} - {$lang['sys_planet_type'][$planetrow['planet_type']]} {$planetrow['name']} [{$planetrow['galaxy']}:{$planetrow['system']}:{$planetrow['planet']}]"); break; }
$planet_recyclers_orbiting += mrc_get_level($user, $planetrow, $recycler_id); } int_planet_pretemplate($planetrow, $template); $sn_group_ques = sn_get_groups('ques'); foreach (array(QUE_STRUCTURES => $sn_group_ques[QUE_STRUCTURES]) as $que_id => $que_type_data) { $this_que = $que['ques'][$que_id][$user['id']][$planetrow['id']]; $template->assign_block_vars('ques', array('ID' => $que_id, 'NAME' => $lang['sys_ques'][$que_id], 'LENGTH' => empty($this_que) ? 0 : count($this_que))); if (!empty($this_que)) { foreach ($this_que as $que_item) { $template->assign_block_vars('que', que_tpl_parse_element($que_item)); } } } $que_hangar_length = tpl_assign_hangar($template, $planetrow, SUBQUE_FLEET); $template->assign_block_vars('ques', array('ID' => QUE_HANGAR, 'NAME' => $lang['sys_ques'][QUE_HANGAR], 'LENGTH' => $que_hangar_length)); $que_hangar_length = tpl_assign_hangar($template, $planetrow, SUBQUE_DEFENSE); $template->assign_block_vars('ques', array('ID' => SUBQUE_DEFENSE, 'NAME' => $lang['sys_ques'][SUBQUE_DEFENSE], 'LENGTH' => $que_hangar_length)); $overview_planet_rows = $user['opt_int_overview_planet_rows']; $overview_planet_columns = $user['opt_int_overview_planet_columns']; if ($overview_planet_rows <= 0 && $overview_planet_columns <= 0) { $overview_planet_rows = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_rows']; $overview_planet_columns = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_columns']; } if ($overview_planet_rows > 0 && $overview_planet_columns <= 0) { $overview_planet_columns = ceil($planet_count / $overview_planet_rows); } $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true); $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER]; $governor_level = $planetrow['PLANET_GOVERNOR_ID'] ? mrc_get_level($user, $planetrow, $planetrow['PLANET_GOVERNOR_ID'], false, true) : 0; $template->assign_vars(array('TIME_NOW' => SN_TIME_NOW, 'USER_ID' => $user['id'], 'user_username' => $user['username'], 'USER_AUTHLEVEL' => $user['authlevel'], 'NEW_MESSAGES' => $user['new_message'], 'NEW_LEVEL_MINER' => $level_miner, 'NEW_LEVEL_RAID' => $level_raid, 'planet_diameter' => pretty_number($planetrow['diameter']), 'planet_field_current' => $planetrow['field_current'], 'planet_field_max' => eco_planet_fields_max($planetrow), 'PLANET_FILL' => floor($planetrow['field_current'] / eco_planet_fields_max($planetrow) * 100), 'PLANET_FILL_BAR' => $planet_fill, 'metal_debris' => pretty_number($planetrow['debris_metal']), 'crystal_debris' => pretty_number($planetrow['debris_crystal']), 'PLANET_RECYCLERS' => $planet_recyclers_orbiting, 'planet_image' => $planetrow['image'], 'planet_temp_min' => $planetrow['temp_min'], 'planet_temp_avg' => round(($planetrow['temp_min'] + $planetrow['temp_max']) / 2), 'planet_temp_max' => $planetrow['temp_max'], 'planet_density' => $planetrow['density'], 'planet_density_index' => $planetrow['density_index'], 'planet_density_text' => $lang['uni_planet_density_types'][$planetrow['density_index']], 'GATE_LEVEL' => mrc_get_level($user, $planetrow, STRUC_MOON_GATE), 'GATE_JUMP_REST_TIME' => uni_get_time_to_jump($planetrow), 'ADMIN_EMAIL' => $config->game_adminEmail, 'PLANET_GOVERNOR_ID' => $planetrow['PLANET_GOVERNOR_ID'], 'PLANET_GOVERNOR_LEVEL' => $governor_level, 'PLANET_GOVERNOR_LEVEL_PLUS' => $governor_level ? mrc_get_level($user, $planetrow, $planetrow['PLANET_GOVERNOR_ID']) - $governor_level : 0, 'PLANET_GOVERNOR_NAME' => $lang['tech'][$planetrow['PLANET_GOVERNOR_ID']], 'LIST_ROW_COUNT' => $overview_planet_rows, 'LIST_COLUMN_COUNT' => $overview_planet_columns, 'SECTOR_CAN_BUY' => $sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER), 'SECTOR_COST' => $sector_cost, 'SECTOR_COST_TEXT' => pretty_number($sector_cost))); tpl_set_resource_info($template, $planetrow, $fleets_to_planet, 2);
function eco_build_hangar($que_type, $user, &$planet, $que) { global $sn_data, $lang, $dpath, $debug, $time_now; $GET_action = sys_get_param_str('action'); $GET_mode = sys_get_param_str('mode'); $POST_fmenge = $_POST['fmenge']; if (isset($GET_action)) { switch ($GET_action) { case 'trim': $ElementQueue = explode(';', $planet['b_hangar_id']); while (!empty($ElementQueue) && $ElementLine == '') { $ElementIndex = count($ElementQueue) - 1; $ElementLine = $ElementQueue[$ElementIndex]; unset($ElementQueue[$ElementIndex]); } if ($ElementLine) { $Element = explode(',', $ElementLine); $ResourcesToUpd[metal] += floor($sn_data[$Element[0]]['metal'] * $Element[1]); $ResourcesToUpd[crystal] += floor($sn_data[$Element[0]]['crystal'] * $Element[1]); $ResourcesToUpd[deuterium] += floor($sn_data[$Element[0]]['deuterium'] * $Element[1]); doquery("UPDATE `{{planets}}` SET\r\n `metal` = metal + '{$ResourcesToUpd['metal']}', `crystal` = crystal + '{$ResourcesToUpd['crystal']}', `deuterium` = deuterium + '{$ResourcesToUpd['deuterium']}'," . (empty($ElementQueue) ? '`b_hangar` = 0,' : '') . "`b_hangar_id` = '" . implode(';', $ElementQueue) . "' WHERE `id` = '{$planet['id']}' LIMIT 1;"); } // PREVENT SUBMITS? header("location: {$_SERVER['PHP_SELF']}?mode={$GET_mode}"); exit; break; case 'clear': $ElementQueue = explode(';', $planet['b_hangar_id']); foreach ($ElementQueue as $ElementLine => $Element) { if ($Element != '') { $Element = explode(',', $Element); $ResourcesToUpd[metal] += floor($sn_data[$Element[0]]['metal'] * $Element[1]); $ResourcesToUpd[crystal] += floor($sn_data[$Element[0]]['crystal'] * $Element[1]); $ResourcesToUpd[deuterium] += floor($sn_data[$Element[0]]['deuterium'] * $Element[1]); } } doquery("UPDATE `{{planets}}` SET\r\n `metal` = metal + '{$ResourcesToUpd['metal']}', `crystal` = crystal + '{$ResourcesToUpd['crystal']}', `deuterium` = deuterium + '{$ResourcesToUpd['deuterium']}',\r\n `b_hangar` = '', `b_hangar_id` = '' WHERE `id` = '{$planet['id']}' LIMIT 1;"); // PREVENT SUBMITS? header("location: {$_SERVER['PHP_SELF']}?mode={$GET_mode}"); exit; break; } } $page_error = ''; $page_mode = $que_type == SUBQUE_FLEET ? 'fleet' : 'defense'; $sn_data_group = $sn_data['groups'][$page_mode]; if (isset($POST_fmenge) && !eco_hangar_is_building($que)) { doquery('START TRANSACTION;'); $planet = doquery("SELECT * FROM {{planets}} WHERE `id` = '{$planet['id']}' LIMIT 1 FOR UPDATE;", '', true); $units_cost = array(); $hangar = $planet['b_hangar_id']; $built = GetRestrictedConstructionNum($planet); $SiloSpace = max(0, $planet[$sn_data[44]['name']] * 10 - $built[502] - $built[503] * 2); foreach ($POST_fmenge as $Element => $Count) { $Element = intval($Element); $Count = min(max(0, intval($Count)), MAX_FLEET_OR_DEFS_PER_ROW); if (!($Count && $Element && in_array($Element, $sn_data_group) && eco_can_build_unit($user, $planet, $Element))) { continue; } // On verifie combien on sait faire de cet element au max $MaxElements = GetMaxConstructibleElements($Element, $planet); switch ($Element) { case 502: $Count = min($SiloSpace, $Count, $MaxElements); $SiloSpace -= $Count; break; case 503: $Count = min(floor($SiloSpace / 2), $Count, $MaxElements); $SiloSpace -= $Count * 2; break; case 407: case 408: case 409: $Count = $built[$Element] >= 1 ? 0 : 1; break; default: $Count = min($Count, $MaxElements); break; } $unit_resources = GetElementRessources($Element, $Count); foreach ($unit_resources as $res_name => $res_amount) { $units_cost[$res_name] += $res_amount; } $hangar .= "{$Element},{$Count};"; } if ($hangar != $planet['b_hangar_id']) { $new_planet_data = $planet; $can_build_def = true; $query_string = ''; foreach ($units_cost as $res_name => $res_amount) { if ($res_amount <= 0) { continue; } if ($planet[$res_name] < $res_amount) { $can_build_def = false; $page_error = $lang['eco_bld_resources_not_enough']; break; } $new_planet_data[$res_name] -= $res_amount; $query_string .= "`{$res_name}` = `{$res_name}` - {$res_amount},"; } if ($can_build_def && $query_string) { $planet = $new_planet_data; $planet['b_hangar_id'] = $hangar; $query_string .= "`b_hangar_id` = '{$hangar}'"; doquery("UPDATE {{planets}} SET {$query_string} WHERE `id` = '{$planet['id']}' LIMIT 1;"); } } doquery('COMMIT'); } // ------------------------------------------------------------------------------------------------------- // S'il n'y a pas de Chantier ... if ($planet[$sn_data[21]['name']] == 0) { // Veuillez avoir l'obligeance de construire le Chantier Spacial !! message($lang['need_hangar'], $lang['tech'][21]); } $built = GetRestrictedConstructionNum($planet); $SiloSpace = max(0, $planet[$sn_data[44]['name']] * 10 - $built[502] - $built[503] * 2); $template = gettemplate("buildings_hangar", true); // ------------------------------------------------------------------------------------------------------- // Construction de la page du Chantier (car si j'arrive ici ... c'est que j'ai tout ce qu'il faut pour ... $TabIndex = 0; foreach ($sn_data_group as $Element) { $unit_message = ''; if (eco_can_build_unit($user, $planet, $Element)) { // On regarde si on peut en acheter au moins 1 $CanBuildOne = IsElementBuyable($user, $planet, $Element, false); // Disponibilité actuelle $ElementCount = $planet[$sn_data[$Element]['name']]; // On affiche le temps de construction (c'est toujours tellement plus joli) $baubar = GetMaxConstructibleElements($Element, $planet); switch ($Element) { case 502: $baubar = min($SiloSpace, $baubar); $restrict = 1; break; case 503: $baubar = min(floor($SiloSpace / 2), $baubar); $restrict = 1; break; case 407: case 408: case 409: $baubar = $built[$Element] >= 1 ? 0 : min(1, $baubar); $restrict = 2; break; default: $restrict = 0; break; } // Case nombre d'elements a construire if ($CanBuildOne) { if (!eco_hangar_is_building($que)) { if ($restrict == 2 and $baubar == 0) { $unit_message .= $lang['only_one']; } elseif ($restrict == 1 and !$baubar) { $unit_message .= $lang['b_no_silo_space']; } else { $TabIndex++; } } else { $unit_message = $lang['fleet_on_update']; } } $build_data = eco_get_build_data($user, $planet, $Element, 0); $temp[RES_METAL] = floor($planet['metal'] - $build_data[BUILD_CREATE][RES_METAL]); // + $fleet_list['own']['total'][RES_METAL] $temp[RES_CRYSTAL] = floor($planet['crystal'] - $build_data[BUILD_CREATE][RES_CRYSTAL]); // + $fleet_list['own']['total'][RES_CRYSTAL] $temp[RES_DEUTERIUM] = floor($planet['deuterium'] - $build_data[BUILD_CREATE][RES_DEUTERIUM]); // + $fleet_list['own']['total'][RES_DEUTERIUM] $template->assign_block_vars('production', array('ID' => $Element, 'NAME' => $lang['tech'][$Element], 'DESCRIPTION' => $lang['info'][$Element]['description_short'], 'LEVEL' => $ElementCount, 'LEVEL_OLD' => $CurentPlanet[$sn_data[$Element]['name']], 'LEVEL_CHANGE' => $que['in_que'][$Element], 'BUILD_CAN' => min($baubar, $build_data['CAN'][BUILD_CREATE]), 'TIME' => pretty_time($build_data[BUILD_CREATE][RES_TIME]), 'METAL' => $build_data[BUILD_CREATE][RES_METAL], 'CRYSTAL' => $build_data[BUILD_CREATE][RES_CRYSTAL], 'DEUTERIUM' => $build_data[BUILD_CREATE][RES_DEUTERIUM], 'METAL_PRINT' => pretty_number($build_data[BUILD_CREATE][RES_METAL], true, $planet['metal']), 'CRYSTAL_PRINT' => pretty_number($build_data[BUILD_CREATE][RES_CRYSTAL], true, $planet['crystal']), 'DEUTERIUM_PRINT' => pretty_number($build_data[BUILD_CREATE][RES_DEUTERIUM], true, $planet['deuterium']), 'DESTROY_CAN' => $build_data['CAN'][BUILD_DESTROY], 'DESTROY_TIME' => pretty_time($build_data[BUILD_DESTROY][RES_TIME]), 'DESTROY_METAL' => $build_data[BUILD_DESTROY][RES_METAL], 'DESTROY_CRYSTAL' => $build_data[BUILD_DESTROY][RES_CRYSTAL], 'DESTROY_DEUTERIUM' => $build_data[BUILD_DESTROY][RES_DEUTERIUM], 'METAL_REST' => pretty_number($temp[RES_METAL], true, true), 'CRYSTAL_REST' => pretty_number($temp[RES_CRYSTAL], true, true), 'DEUTERIUM_REST' => pretty_number($temp[RES_DEUTERIUM], true, true), 'METAL_REST_NUM' => $temp[RES_METAL], 'CRYSTAL_REST_NUM' => $temp[RES_CRYSTAL], 'DEUTERIUM_REST_NUM' => $temp[RES_DEUTERIUM], 'METAL_BALANCE' => $caps['metal_perhour'][$Element], 'CRYSTAL_BALANCE' => $caps['crystal_perhour'][$Element], 'DEUTERIUM_BALANCE' => $caps['deuterium_perhour'][$Element], 'ENERGY_BALANCE' => $energy_balance, 'ARMOR' => pretty_number($sn_data[$Element]['armor']), 'SHIELD' => pretty_number($sn_data[$Element]['shield']), 'WEAPON' => pretty_number($sn_data[$Element]['attack']), 'TABINDEX' => $TabIndex, 'MESSAGE' => $unit_message)); } } $template->assign_vars(array('noresearch' => $NoFleetMessage, 'error_msg' => $page_error, 'MODE' => $que_type, 'QUE_ID' => $que_type, 'TIME_NOW' => $time_now)); tpl_assign_hangar($que_type, $planet, $template); display(parsetemplate($template), $lang[$page_mode]); }