From e368b5f759ee0e72bcdc64acf88088c2efffb597 Mon Sep 17 00:00:00 2001 From: lighta Date: Sun, 3 Jan 2016 15:43:19 -0400 Subject: [PATCH] Update tools/convert_sql.pl to check if AegisName are duplicated and and a trailing _ if it's the case. --- tools/convert_sql.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/convert_sql.pl b/tools/convert_sql.pl index 4d66d9c770..cb17af22e5 100755 --- a/tools/convert_sql.pl +++ b/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=) { + 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); }