The profit does not come from the source code, but from the assets.
There are games which are fully opensource, but where you have to pay for the assets (and where the source code was released at the same time as the rest of the game). This was not the case for doom, but the demo for doom was free and came out at the same time; the engine was always freely available.
Yes, unity and unreal engine are game engines which are sold to game developers. Doom is a game which was sold to end users, and whose engine was free. Clearly those are different...
> The profit does not come from the source code, but from the assets.
The source code enables the profitability of the assets. In the end the distinction is irrelevant to this matter. This is like saying Facebook doesn’t make money from its platform but from its deals with advertisers.
There are games which are fully opensource, but where you have to pay for the assets (and where the source code was released at the same time as the rest of the game). This was not the case for doom, but the demo for doom was free and came out at the same time; the engine was always freely available.