LM340 was a second source for the LM7805, though there were later versions with higher current capability, and which came in both TO3 and TO220 packages.
With the resistor I would replace it with a 5W ceramic version, and use some stand off ceramic spacers to have the resistor as high off the board as possible, lead length permitting, so it ran cooler and did not cook the connector and the capacitor. the placement says this was a near last amendment to fix a power dissipation issue in the voltage regulator circuit, which was either failing regulation during thermal cycling, or with voltage input range testing at the upper limits for the input mains voltage range along with the thermal cycles as well.
The regulator probably was running at 130C on the die at the top end of ambient temperature in an enclosed test rack, and with the input voltage being at the upper mains limit for hours, the dies on certain would go into thermal shutdown and cycle the power supply, especially if the unit was delivering a high internal dissipation at the same time.