Program: 171345
Project: 171345
Buggy source:
public void endTurn(int turnTime,boolean advanceTime){
  if (advanceTime) {
    minutesPassed+=turnTime;
    setResponses(currentDialogueNode,false);
  }
  boolean newDay=((int)(minutesPassed / (60 * 24)) != (int)(((minutesPassed - turnTime) / (60 * 24))));
  handleAtmosphericConditions(turnTime);
  NPCMap.entrySet().removeIf(e -> (e.getValue().getLocationPlace().getPlaceType() == Dominion.CITY_STREET && !Main.game.getPlayer().getLocation().equals(e.getValue().getLocation())));
  isInNPCUpdateLoop=true;
  for (  NPC npc : NPCMap.values()) {
    npc.calculateStatusEffects(turnTime);
    if (npc.isPendingClothingDressing()) {
      npc.equipClothing(true,true);
      npc.setPendingClothingDressing(false);
    }
    if (!npc.isPregnant() && !npc.isSlave() && npc.getHistory() == History.PROSTITUTE && !npc.hasStatusEffect(StatusEffect.PROMISCUITY_PILL) && !npc.getLocation().equals(Main.game.getPlayer().getLocation())) {
      npc.useItem(AbstractItemType.generateItem(ItemType.PROMISCUITY_PILL),npc,false);
    }
    if (npc.hasStatusEffect(StatusEffect.PREGNANT_3) && (minutesPassed - npc.getTimeProgressedToFinalPregnancyStage()) > (12 * 60)) {
      if (npc == lilaya) {
        if (!Main.game.getDialogueFlags().reactedToPregnancyLilaya) {
          npc.endPregnancy(true);
        }
      }
 else {
        npc.endPregnancy(true);
        if (npc == kate) {
          Main.game.getDialogueFlags().reactedToKatePregnancy=false;
        }
      }
    }
    if (npc.getLocation().equals(Main.game.getPlayer().getLocation()) && npc.getWorldLocation() == Main.game.getPlayer().getWorldLocation()) {
      for (      CoverableArea ca : CoverableArea.values()) {
        if (npc.isCoverableAreaExposed(ca) && ca != CoverableArea.MOUTH) {
          npc.getPlayerKnowsAreasMap().put(ca,true);
        }
      }
    }
    if (newDay) {
      npc.dailyReset();
      if (npc.isSlave()) {
        npc.incrementAffection(npc.getOwner(),npc.getDailyAffectionChange());
        npc.incrementObedience(npc.getDailyObedienceChange());
        npc.resetSlaveFlags();
      }
    }
  }
  isInNPCUpdateLoop=false;
  for (  NPC npc : npcsToRemove) {
    NPCMap.remove(npc.getId());
  }
  for (  NPC npc : npcsToAdd) {
    NPCMap.put(npc.getId(),npc);
  }
  npcsToRemove.clear();
  npcsToAdd.clear();
  if (!isInCombat()) {
    currentCell=activeWorld.getCell(player.getLocation());
    if (Main.game.getCurrentDialogueNode() != MiscDialogue.STATUS_EFFECTS) {
      Main.game.getPlayer().calculateStatusEffects(turnTime);
    }
    if (!inSex && !currentDialogueNode.isRegenerationDisabled()) {
      if (Main.game.getPlayer().getStaminaPercentage() < 1)       Main.game.getPlayer().incrementStamina(turnTime * 0.1f);
      if (Main.game.getPlayer().getHealthPercentage() < 1)       Main.game.getPlayer().incrementHealth(turnTime * 0.1f);
      if (Main.game.getPlayer().getManaPercentage() < 1)       Main.game.getPlayer().incrementMana(turnTime * 0.1f);
    }
  }
  RenderingEngine.ENGINE.renderButtons();
  Main.mainController.updateUI();
  Main.mainController.getTooltip().hide();
  if (!Main.game.getPlayer().getStatusEffectDescriptions().isEmpty() && Main.game.getCurrentDialogueNode() != MiscDialogue.STATUS_EFFECTS) {
    if (Main.game.getCurrentDialogueNode().getMapDisplay() == MapDisplay.NORMAL)     Main.game.saveDialogueNode();
    Main.game.setContent(new Response("String_Node_Str","String_Node_Str",MiscDialogue.STATUS_EFFECTS){
      @Override public void effects(){
        if (!Main.game.getPlayer().hasQuest(QuestLine.SIDE_ENCHANTMENT_DISCOVERY) && Main.game.getPlayer().hasNonArcaneEssences()) {
          Main.game.getTextEndStringBuilder().append(Main.game.getPlayer().incrementQuest(QuestLine.SIDE_ENCHANTMENT_DISCOVERY));
        }
        if (!Main.game.getPlayer().hasQuest(QuestLine.SIDE_JINXED_CLOTHING) && Main.game.getPlayer().hasStatusEffect(StatusEffect.CLOTHING_JINXED)) {
          Main.game.getTextEndStringBuilder().append(Main.game.getPlayer().incrementQuest(QuestLine.SIDE_JINXED_CLOTHING));
        }
        if (!Main.game.getPlayer().hasQuest(QuestLine.SIDE_FIRST_TIME_PREGNANCY) && Main.game.getPlayer().isVisiblyPregnant()) {
          Main.game.getTextEndStringBuilder().append(Main.game.getPlayer().incrementQuest(QuestLine.SIDE_FIRST_TIME_PREGNANCY));
        }
      }
    }
);
    Main.game.getPlayer().getStatusEffectDescriptions().clear();
  }
}

Fixed version (ground truth):
public void endTurn(int turnTime,boolean advanceTime){
  if (advanceTime) {
    minutesPassed+=turnTime;
    setResponses(currentDialogueNode,false);
  }
  boolean newDay=((int)(minutesPassed / (60 * 24)) != (int)(((minutesPassed - turnTime) / (60 * 24))));
  handleAtmosphericConditions(turnTime);
  NPCMap.entrySet().removeIf(e -> (e.getValue().getLocationPlace().getPlaceType() != Dominion.CITY_BACK_ALLEYS && e.getValue() instanceof DominionAlleywayAttacker && !Main.game.getPlayer().getLocation().equals(e.getValue().getLocation())));
  isInNPCUpdateLoop=true;
  for (  NPC npc : NPCMap.values()) {
    npc.calculateStatusEffects(turnTime);
    if (npc.isPendingClothingDressing()) {
      npc.equipClothing(true,true);
      npc.setPendingClothingDressing(false);
    }
    if (!npc.isPregnant() && !npc.isSlave() && npc.getHistory() == History.PROSTITUTE && !npc.hasStatusEffect(StatusEffect.PROMISCUITY_PILL) && !npc.getLocation().equals(Main.game.getPlayer().getLocation())) {
      npc.useItem(AbstractItemType.generateItem(ItemType.PROMISCUITY_PILL),npc,false);
    }
    if (npc.hasStatusEffect(StatusEffect.PREGNANT_3) && (minutesPassed - npc.getTimeProgressedToFinalPregnancyStage()) > (12 * 60)) {
      if (npc == lilaya) {
        if (!Main.game.getDialogueFlags().reactedToPregnancyLilaya) {
          npc.endPregnancy(true);
        }
      }
 else {
        npc.endPregnancy(true);
        if (npc == kate) {
          Main.game.getDialogueFlags().reactedToKatePregnancy=false;
        }
      }
    }
    if (npc.getLocation().equals(Main.game.getPlayer().getLocation()) && npc.getWorldLocation() == Main.game.getPlayer().getWorldLocation()) {
      for (      CoverableArea ca : CoverableArea.values()) {
        if (npc.isCoverableAreaExposed(ca) && ca != CoverableArea.MOUTH) {
          npc.getPlayerKnowsAreasMap().put(ca,true);
        }
      }
    }
    if (newDay) {
      npc.dailyReset();
      if (npc.isSlave()) {
        npc.incrementAffection(npc.getOwner(),npc.getDailyAffectionChange());
        npc.incrementObedience(npc.getDailyObedienceChange());
        npc.resetSlaveFlags();
      }
    }
  }
  isInNPCUpdateLoop=false;
  for (  NPC npc : npcsToRemove) {
    NPCMap.remove(npc.getId());
  }
  for (  NPC npc : npcsToAdd) {
    NPCMap.put(npc.getId(),npc);
  }
  npcsToRemove.clear();
  npcsToAdd.clear();
  if (!isInCombat()) {
    currentCell=activeWorld.getCell(player.getLocation());
    if (Main.game.getCurrentDialogueNode() != MiscDialogue.STATUS_EFFECTS) {
      Main.game.getPlayer().calculateStatusEffects(turnTime);
    }
    if (!inSex && !currentDialogueNode.isRegenerationDisabled()) {
      if (Main.game.getPlayer().getStaminaPercentage() < 1)       Main.game.getPlayer().incrementStamina(turnTime * 0.1f);
      if (Main.game.getPlayer().getHealthPercentage() < 1)       Main.game.getPlayer().incrementHealth(turnTime * 0.1f);
      if (Main.game.getPlayer().getManaPercentage() < 1)       Main.game.getPlayer().incrementMana(turnTime * 0.1f);
    }
  }
  RenderingEngine.ENGINE.renderButtons();
  Main.mainController.updateUI();
  Main.mainController.getTooltip().hide();
  if (!Main.game.getPlayer().getStatusEffectDescriptions().isEmpty() && Main.game.getCurrentDialogueNode() != MiscDialogue.STATUS_EFFECTS) {
    if (Main.game.getCurrentDialogueNode().getMapDisplay() == MapDisplay.NORMAL)     Main.game.saveDialogueNode();
    Main.game.setContent(new Response("String_Node_Str","String_Node_Str",MiscDialogue.STATUS_EFFECTS){
      @Override public void effects(){
        if (!Main.game.getPlayer().hasQuest(QuestLine.SIDE_ENCHANTMENT_DISCOVERY) && Main.game.getPlayer().hasNonArcaneEssences()) {
          Main.game.getTextEndStringBuilder().append(Main.game.getPlayer().incrementQuest(QuestLine.SIDE_ENCHANTMENT_DISCOVERY));
        }
        if (!Main.game.getPlayer().hasQuest(QuestLine.SIDE_JINXED_CLOTHING) && Main.game.getPlayer().hasStatusEffect(StatusEffect.CLOTHING_JINXED)) {
          Main.game.getTextEndStringBuilder().append(Main.game.getPlayer().incrementQuest(QuestLine.SIDE_JINXED_CLOTHING));
        }
        if (!Main.game.getPlayer().hasQuest(QuestLine.SIDE_FIRST_TIME_PREGNANCY) && Main.game.getPlayer().isVisiblyPregnant()) {
          Main.game.getTextEndStringBuilder().append(Main.game.getPlayer().incrementQuest(QuestLine.SIDE_FIRST_TIME_PREGNANCY));
        }
      }
    }
);
    Main.game.getPlayer().getStatusEffectDescriptions().clear();
  }
}