<?
	function addLine($p, $o) {
		global $ArmyMoves, $ArmyMoveXeven, $ArmyMoveXodd, $ArmyMoveY, $hero, $moves;
		global $mapcell, $im2, $imgcolor, $color;

		$startinghex=$hero[$moves[$o][1]]->hex;
		$x=substr($startinghex,0,2);
		$x1=$x*$mapcell;
		$y=substr($startinghex,2,2);
		$y1=$y*$mapcell;
		$y1-=($mapcell/10);
		if (1&$y) { $x1-=$mapcell/2;}
#		echo "line $x,$y ";

		for ($i=1; $i<=14; $i++) {
			if ($moves[$o][$i+1]!="") {
				if (1&$y) {
					$x+=$ArmyMoveXodd[$moves[$o][$i+1]];
				} else {
					$x+=$ArmyMoveXeven[$moves[$o][$i+1]];
				}
				$y+=$ArmyMoveY[$moves[$o][$i+1]];
				
				if ($i!=1) { $x1=$x2; $y1=$y2; }
				$x2=$x*$mapcell;
				$y2=$y*$mapcell;
				$y2-=($mapcell/10);
				if (1&$y) { $x2-=$mapcell/2;}
				
#				echo " to $x,$y";
				
				imagesetthickness($im2, 2);
				imageline($im2, $x1, $y1, $x2, $y2, $color[$p]);
			}
		}
		imageellipse($im2, $x2, $y2, 5, 5, $color[$p]);
#		echo "<br>";
	}
	
	function assignNewImage() {
		global $im2, $colorT, $color, $imgcolor;

		$im2=@imagecreatefromgif (Inc("emptymask.gif"));
		$colorT=imagecolortransparent($im2);
		for ($i=1; $i<=25; $i++) {
			$color[$i] = ImageColorAllocate($im2, hexdec(substr($imgcolor[$i], 1, 2)), hexdec(substr($imgcolor[$i], 3, 2)), hexdec(substr($imgcolor[$i], 5, 2)));
		}
	}
	
	function saveImage($fnimage) {
		global $im2, $colorT, $basedir;
		
		imagecolortransparent($im2, $colorT);
		imagegif($im2, $basedir.$metoobasedir.'gfx/moves/'.$fnimage);
		imagedestroy($im2);
	}

	$p=$peopleorders;
	
	# create player moves image
	assignNewImage();
	for ($j=1; $j<=$orders; $j++) {
		addLine($p, $j);
	}
	saveImage("move-".$p."-".$game.".gif");

/*	# create or update all planned moves
	assignNewImage();
	for ($p=1; $p<=$userlin; $p++) {
		if ($moveexist[$p]) {
			for ($j=1; $j<=$movelin[$p]; $j++) {
				if (($move_player_gfx[$p][$j]==1) && ($move_type_gfx[$p][$j]==1)) {
					addLine($p, $j);
				}
			}
		}
	}
	saveImage("move-allplanned-".$game.".gif");*/
?>