<commit_before><?php

if ($var['target_sector'] == $player->getSectorID())
	forward(create_container('skeleton.php', $var['target_page']));

if($sector->getWarp() == $var['target_sector'])
	$turns = TURNS_PER_WARP;
else
	$turns = TURNS_PER_SECTOR;
//allow hidden players (admins that don't play) to move without pinging, hitting mines, losing turns
if (in_array($player->getAccountID(), Globals::getHiddenPlayers())) {
	//update plot
	if ($player->hasPlottedCourse()) {
		$path =& $player->getPlottedCourse();
		if ($path->getNextOnPath() == $var['target_sector']) {
			$path->followPath($sector->getWarp() == $var['target_sector']);
			$player->setPlottedCourse($path);
		}
		else
			$player->deletePlottedCourse();
	}
	
	//make them pop on CPL
	$player->updateLastCPLAction();
	$player->setSectorID($var['target_sector']);
	$player->update();
					
	// get new sector object
	$sector =& $player->getSector();
	$sector->markVisited($player);
	forward(create_container('skeleton.php', $var['target_page']));
}
$action = '';
if(isset($_REQUEST['action'])) {
	$action = $_REQUEST['action'];
	if ($action == 'No')
		forward(create_container('skeleton.php', $var['target_page']));
}

// you can't move while on planet
if ($player->isLandedOnPlanet())
	create_error('You can\'t activate your engine while you are on a planet!');

if ($player->getTurns() < $turns)
	create_error('You don\'t have enough turns to move!');

if (!$sector->isLinked($var['target_sector']))
	create_error('You cannot move to that sector!');

if ($player->getLastSectorID() != $var['target_sector']) {
	$sectorForces =& $sector->getForces();
	Sorter::sortByNumMethod($sectorForces,'getMines',true);
	$mine_owner_id = false;
	foreach($sectorForces as &$forces) {
		if(!$mine_owner_id && $forces->hasMines() && !$player->forceNAPAlliance($forces->getOwner())) {
			$mine_owner_id = $forces->getOwnerID();
			break;
		}
	} unset($forces);
	// set last sector
	$player->setLastSectorID($var['target_sector']);
	
	if($mine_owner_id) {
		if ($player->hasNewbieTurns()) {
			$turns = $sectorForces[$mine_owner_id]->getBumpTurnCost($ship);
			$player->takeTurns($turns,$turns);
			$container = create_container('skeleton.php', 'current_sector.php');
			$container['msg']= 'You have just flown past a sprinkle of mines.<br />Because of your newbie status you have been spared from the harsh reality of the forces.<br />It has cost you ' . $turns.' turn'.($turns==1?'':'s') . ' to navigate the minefield safely';
			forward($container);
		}
		else {
			$owner_id = $mine_owner_id;
			require_once('forces_minefield_processing.php');
			return;
		}
	}
}

// check if this came from a plotted course from db
if ($player->hasPlottedCourse()) {
	$path =& $player->getPlottedCourse();
	if ($path->getNextOnPath() == $var['target_sector']) {
		$path->followPath($sector->getWarp() == $var['target_sector']);
		$player->setPlottedCourse($path);
	}
	else
		$player->deletePlottedCourse();
}

// log action
$player->actionTaken('WalkSector',array('Sector'=>&$sector));

// send scout msg
$sector->leavingSector($player,MOVEMENT_WALK);

// Move the user around<commit_msg>Fix logging of sector movement<commit_after><?php

if ($var['target_sector'] == $player->getSectorID())
	forward(create_container('skeleton.php', $var['target_page']));

if($sector->getWarp() == $var['target_sector'])
	$turns = TURNS_PER_WARP;
else
	$turns = TURNS_PER_SECTOR;
//allow hidden players (admins that don't play) to move without pinging, hitting mines, losing turns
if (in_array($player->getAccountID(), Globals::getHiddenPlayers())) {
	//update plot
	if ($player->hasPlottedCourse()) {
		$path =& $player->getPlottedCourse();
		if ($path->getNextOnPath() == $var['target_sector']) {
			$path->followPath($sector->getWarp() == $var['target_sector']);
			$player->setPlottedCourse($path);
		}
		else
			$player->deletePlottedCourse();
	}
	
	//make them pop on CPL
	$player->updateLastCPLAction();
	$player->setSectorID($var['target_sector']);
	$player->update();
					
	// get new sector object
	$sector =& $player->getSector();
	$sector->markVisited($player);
	forward(create_container('skeleton.php', $var['target_page']));
}
$action = '';
if(isset($_REQUEST['action'])) {
	$action = $_REQUEST['action'];
	if ($action == 'No')
		forward(create_container('skeleton.php', $var['target_page']));
}

// you can't move while on planet
if ($player->isLandedOnPlanet())
	create_error('You can\'t activate your engine while you are on a planet!');

if ($player->getTurns() < $turns)
	create_error('You don\'t have enough turns to move!');

if (!$sector->isLinked($var['target_sector']))
	create_error('You cannot move to that sector!');

if ($player->getLastSectorID() != $var['target_sector']) {
	$sectorForces =& $sector->getForces();
	Sorter::sortByNumMethod($sectorForces,'getMines',true);
	$mine_owner_id = false;
	foreach($sectorForces as &$forces) {
		if(!$mine_owner_id && $forces->hasMines() && !$player->forceNAPAlliance($forces->getOwner())) {
			$mine_owner_id = $forces->getOwnerID();
			break;
		}
	} unset($forces);
	// set last sector
	$player->setLastSectorID($var['target_sector']);
	
	if($mine_owner_id) {
		if ($player->hasNewbieTurns()) {
			$turns = $sectorForces[$mine_owner_id]->getBumpTurnCost($ship);
			$player->takeTurns($turns,$turns);
			$container = create_container('skeleton.php', 'current_sector.php');
			$container['msg']= 'You have just flown past a sprinkle of mines.<br />Because of your newbie status you have been spared from the harsh reality of the forces.<br />It has cost you ' . $turns.' turn'.($turns==1?'':'s') . ' to navigate the minefield safely';
			forward($container);
		}
		else {
			$owner_id = $mine_owner_id;
			require_once('forces_minefield_processing.php');
			return;
		}
	}
}

// check if this came from a plotted course from db
if ($player->hasPlottedCourse()) {
	$path =& $player->getPlottedCourse();
	if ($path->getNextOnPath() == $var['target_sector']) {
		$path->followPath($sector->getWarp() == $var['target_sector']);
		$player->setPlottedCourse($path);
	}
	else
		$player->deletePlottedCourse();
}

// log action
$targetSector =& SmrSector::getSector($player->getGameID(), $var['target_sector']);
$player->actionTaken('WalkSector', array('Sector' => &$targetSector));

// send scout msg
$sector->leavingSector($player,MOVEMENT_WALK);

// Move the user around
{'fraction_non_alphanumeric': 0.19021397105097546, 'fraction_numerical': 0.00031466331025802394, 'mean_word_length': 5.726984126984127, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 84, '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': '7545688', 'n_tokens_mistral': 2337, 'n_tokens_neox': 2132, 'n_words': 440}