| 538 | } |
| 539 | |
| 540 | bool compareCellColorMutation(std::vector<uint8_t> const& before, std::vector<uint8_t> const& after, std::set<int> const& allowedColors) |
| 541 | { |
| 542 | auto beforeGenome = GenomeDescriptionService::get().convertBytesToDescription(before); |
| 543 | auto afterGenome = GenomeDescriptionService::get().convertBytesToDescription(after); |
| 544 | if (afterGenome.header != beforeGenome.header) { |
| 545 | return false; |
| 546 | } |
| 547 | |
| 548 | for (auto const& [beforeCell, afterCell] : boost::combine(beforeGenome.cells, afterGenome.cells)) { |
| 549 | |
| 550 | auto beforeCellClone = beforeCell; |
| 551 | auto afterCellClone = afterCell; |
| 552 | beforeCellClone.color = 0; |
| 553 | beforeCellClone.cellFunction = std::nullopt; |
| 554 | afterCellClone.color = 0; |
| 555 | afterCellClone.cellFunction = std::nullopt; |
| 556 | if (beforeCellClone != afterCellClone) { |
| 557 | return false; |
| 558 | } |
| 559 | if (!allowedColors.contains(afterCell.color)) { |
| 560 | return false; |
| 561 | } |
| 562 | if (beforeCell.getCellFunctionType() == CellFunction_Constructor || beforeCell.getCellFunctionType() == CellFunction_Injector) { |
| 563 | auto beforeSubGenome = beforeCell.getGenome(); |
| 564 | auto afterSubGenome = afterCell.getGenome(); |
| 565 | if (beforeSubGenome && afterSubGenome) { |
| 566 | if (!compareCellColorMutation(*beforeSubGenome, *afterSubGenome, allowedColors)) { |
| 567 | return false; |
| 568 | } |
| 569 | } |
| 570 | } |
| 571 | } |
| 572 | return true; |
| 573 | } |
| 574 | |
| 575 | bool compareSubgenomeColorMutation(std::vector<uint8_t> const& before, std::vector<uint8_t> const& after, std::set<int> const& allowedColors) |
| 576 | { |
nothing calls this directly
no test coverage detected