<?
	$nbtowns=0;

	$basedir = $DOCUMENT_ROOT;
	$filenb=0;
	MakeList('');
	chdir($basedir.$metoobasedir);
	$game=$game_checked;
	
	$filenb_touse=0;
	for ($nbf=1; $nbf<=$filenb; $nbf++) {
		if (strpos($filename[$nbf], "eutral.csv")!=false) {
			$filenb_touse++;
			$filename_touse[$filenb_touse]=$filename[$nbf];
			$filedir_touse[$filenb_touse]=$filedir[$nbf];
	 	}
		if ((strpos($filedir[$nbf], "turn")!=false) && (strpos($filename[$nbf], ".csv")!=false)) {
			$fileword=str_replace(" ","-",$filename[$nbf]);
			$fileword=str_replace(".","-",$fileword);
			$fileword = explode("-", $fileword);

				$filenb_touse++;
				$filename_touse[$filenb_touse]=$filename[$nbf];
				$filedir_touse[$filenb_touse]=$filedir[$nbf];
				$fileturn_touse[$filenb_touse]=$fileword[2];
				$filepeople_touse[$filenb_touse]=$fileword[3];
				$filesample_touse[$filenb_touse]=$fileword[1];
	 	}
	}
	
	$nbupdtodate=0;
	for ($nbf=1; $nbf<=$filenb; $nbf++) {

		$fn=$DOCUMENT_ROOT.$filedir_touse[$nbf].'/'.$filename_touse[$nbf];
		$fp = fopen ($fn, "r");
		if (filesize($fn)>0) { $content = fread($fp, filesize($fn)); }
		fclose($fp);
		Decrunch($content);

		for ($i=1; $i<=$lin; $i++) {
			switch ($cell[$i][1]) {
				case "town" :
					$nbtowns++;
					$town[$nbtowns] = new Town;
					$town[$nbtowns]->people=$peoplenb;
					$town[$nbtowns]->name=$cell[$i][2];
					$town[$nbtowns]->capital=$cell[$i][3];
					$town[$nbtowns]->hex=$cell[$i][4];
					$town[$nbtowns]->climate=$cell[$i][5];
					$town[$nbtowns]->size=$cell[$i][6];
					$town[$nbtowns]->fortif=$cell[$i][7];
					$town[$nbtowns]->loyalty=$cell[$i][8];
					$town[$nbtowns]->dock=$cell[$i][9];
					$town[$nbtowns]->hidden=$cell[$i][10];
					$town[$nbtowns]->sieged=$cell[$i][11];
					for ($sf2=1; $sf2<=8; $sf2++) {
						$town[$nbtowns]->localprod[$sf2]=$cell[$i][11+$sf2];
					}
					$town[$nbtowns]->ingame=$filesample_touse[$nbf];
				break;
			}
		}
	}

	for ($l=1; $l<=$nbtowns; $l++) {
		$x=substr($town[$l]->hex,0,2)*1;
		$y=substr($town[$l]->hex,2,2)*1;
		if ($towninhex_num[$x][$y]!=0) { $towninhex_num[$x][$y].=";"; }
		$towninhex_num[$x][$y].=$l;
	}
?>