mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
tools/generate-bedrock-data-from-packets: make duplicate reporting less spammy
This commit is contained in:
parent
4cc858829f
commit
540f088eda
@ -440,17 +440,22 @@ class ParserPacketHandler extends PacketHandler{
|
|||||||
//how the data is ordered doesn't matter as long as it's reproducible
|
//how the data is ordered doesn't matter as long as it's reproducible
|
||||||
foreach($recipes as $_type => $entries){
|
foreach($recipes as $_type => $entries){
|
||||||
$_sortedRecipes = [];
|
$_sortedRecipes = [];
|
||||||
|
$_seen = [];
|
||||||
foreach($entries as $entry){
|
foreach($entries as $entry){
|
||||||
$entry = self::sort($entry);
|
$entry = self::sort($entry);
|
||||||
$_key = json_encode($entry);
|
$_key = json_encode($entry);
|
||||||
while(isset($_sortedRecipes[$_key])){
|
$duplicates = $_seen[$_key] ??= 0;
|
||||||
echo "warning: duplicated $_type recipe: $_key\n";
|
$_seen[$_key]++;
|
||||||
$_key .= "a";
|
$suffix = chr(ord("a") + $duplicates);
|
||||||
}
|
$_sortedRecipes[$_key . $suffix] = $entry;
|
||||||
$_sortedRecipes[$_key] = $entry;
|
|
||||||
}
|
}
|
||||||
ksort($_sortedRecipes, SORT_STRING);
|
ksort($_sortedRecipes, SORT_STRING);
|
||||||
$recipes[$_type] = array_values($_sortedRecipes);
|
$recipes[$_type] = array_values($_sortedRecipes);
|
||||||
|
foreach($_seen as $_key => $_seenCount){
|
||||||
|
if($_seenCount > 1){
|
||||||
|
fwrite(STDERR, "warning: $_type recipe $_key was seen $_seenCount times\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ksort($recipes, SORT_STRING);
|
ksort($recipes, SORT_STRING);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user