<commit_before><?php
require_once(get_file_loc('SmrGalaxy.class.inc'));

// Get a list of all available planet types
$allowedTypes = array();
$db->query('SELECT * FROM planet_type');
while ($db->nextRecord()) {
	$allowedTypes[$db->getInt('planet_type_id')] = $db->getField('planet_type_name');
}
$template->assignByRef('AllowedTypes', $allowedTypes);

// Get the current number of each type of planet
$galaxy =& SmrGalaxy::getGalaxy($var['game_id'],$var['gal_on']);
$galSectors =& $galaxy->getSectors();
$numberOfPlanets = array();
foreach ($galSectors as &$galSector) {
	if($galSector->hasPlanet()) {
		$numberOfPlanets[$galSector->getPlanet()->getTypeID()]++;
	}
}

$template->assignByRef('Galaxy', $galaxy);
$template->assignByRef('NumberOfPlanets', $numberOfPlanets);

$numberOfNpcPlanets = (isset($planet_info['NPC']) ? $planet_info['NPC'] : 0);
$template->assign('NumberOfNpcPlanets', $numberOfNpcPlanets);

// Form to make planet changes
$container = create_container('1.6/universe_create_save_processing.php',
                              '1.6/universe_create_sectors.php', $var);
$template->assign('Form', create_echo_form($container));

// HREF to cancel and return to the previous page
$container = create_container('skeleton.php', '1.6/universe_create_sectors.php', $var);
$template->assign('CancelHREF', SmrSession::getNewHREF($container));

?>
<commit_msg>universe_create_planets.php: initialize planet counts to 0<commit_after><?php
require_once(get_file_loc('SmrGalaxy.class.inc'));

// Get a list of all available planet types
$allowedTypes = array();
$db->query('SELECT * FROM planet_type');
while ($db->nextRecord()) {
	$allowedTypes[$db->getInt('planet_type_id')] = $db->getField('planet_type_name');
}
$template->assignByRef('AllowedTypes', $allowedTypes);

// Initialize all planet counts to zero
$numberOfPlanets = array();
foreach (array_keys($allowedTypes) as $ID) {
	$numberOfPlanets[$ID] = 0;
}

// Get the current number of each type of planet
$galaxy =& SmrGalaxy::getGalaxy($var['game_id'],$var['gal_on']);
$galSectors =& $galaxy->getSectors();
foreach ($galSectors as &$galSector) {
	if($galSector->hasPlanet()) {
		$numberOfPlanets[$galSector->getPlanet()->getTypeID()]++;
	}
}

$template->assignByRef('Galaxy', $galaxy);
$template->assignByRef('NumberOfPlanets', $numberOfPlanets);

$numberOfNpcPlanets = (isset($planet_info['NPC']) ? $planet_info['NPC'] : 0);
$template->assign('NumberOfNpcPlanets', $numberOfNpcPlanets);

// Form to make planet changes
$container = create_container('1.6/universe_create_save_processing.php',
                              '1.6/universe_create_sectors.php', $var);
$template->assign('Form', create_echo_form($container));

// HREF to cancel and return to the previous page
$container = create_container('skeleton.php', '1.6/universe_create_sectors.php', $var);
$template->assign('CancelHREF', SmrSession::getNewHREF($container));

?>

{'fraction_non_alphanumeric': 0.17774715811229763, 'fraction_numerical': 0.005511539786427834, 'mean_word_length': 6.662269129287599, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5704756', 'n_tokens_mistral': 996, 'n_tokens_neox': 983, 'n_words': 173}