Bläddra i källkod

Update tools/convert_sql.pl to check if AegisName are duplicated and and a trailing _ if it's the case.

lighta 9 år sedan
förälder
incheckning
e368b5f759
1 ändrade filer med 11 tillägg och 0 borttagningar
  1. 11 0
      tools/convert_sql.pl

+ 11 - 0
tools/convert_sql.pl

@@ -85,12 +85,14 @@ sub Main {
 
 sub ConvertFile { my($sFilein,$sFileout,$sType)=@_;
 	my $sFHout;
+	my %hAEgisName = ();
 	print "Starting ConvertFile with: \n\t filein=$sFilein \n\t fileout=$sFileout \n";
 	open FHIN,"$sFilein" or die "ERROR: Can't read or locate $sFilein.\n";
 	open $sFHout,">$sFileout" or die "ERROR: Can't write $sFileout.\n";
 	
 	printf $sFHout ("%s\n",$create_table);
 	while(my $ligne=<FHIN>) {
+		my $sWasCom = 0;
 		if ($ligne =~ /^\s*$/ ) {
 				print $sFHout "\n";
 				next;
@@ -100,6 +102,7 @@ sub ConvertFile { my($sFilein,$sFileout,$sType)=@_;
 			if ($ligne =~ /^\/\//) {
 				printf $sFHout ("#");
 				$ligne = substr($ligne, 2);
+				$sWasCom = 1;
 			}
 			my @champ = ();
 			if ($sType =~ /mob_skill/i ) {
@@ -113,6 +116,14 @@ sub ConvertFile { my($sFilein,$sFileout,$sType)=@_;
 				printf $sFHout ("%s\n", $ligne);
 			} else {
 				printf $sFHout ("REPLACE INTO `%s` VALUES (", $db);
+				if($sWasCom == 0){ #check if aegis name is duplicate, (only for not com)
+					$hAEgisName{$champ[1]}++;
+					if($hAEgisName{$champ[1]} > 1){
+						print "Warning, aegisName=$champ[1] multiple occurence found, val=$hAEgisName{$champ[1]}, line=$ligne\n" ;
+						$champ[1] = $champ[1]."_"x($hAEgisName{$champ[1]}-1);
+						print "Converted into '$champ[1]'\n" ;
+					}
+				}				 
 				for (my $i=0; $i<$#champ; $i++) {
 					printField($sFHout,$champ[$i],",",$i);
 				}