First, supply is set for corps HQs. If a corps HQ has submitted an order for supplies and the requested source has supplies, a valid supply line to the HQ, and is friendly, we use it. If no order was sent or the order was invalid, the code picks. The code chooses from among all friendly-controlled cities with supplies and a valid supply line. The closest city is chosen; when two cities are equally close, a city controlled by the unit's side is preferred over one controlled by an ally; when two cities with the same control are equally close, choice is essentially random. The position report shows the city that will be used for the next turn, although that can change if the game data is edited (for example, if one state turns control of a city over to another).
After that, units get supply. If they specified a CHQ or a city to use, it is used if it is valid. For a city to be valid, they must be in the city, it must be friendly controlled, and have supplies. For a CHQ to be valid, it must be friendly, within 2 squares, have either supplies on board or supply from a city, and not already supplying 18 units. If no order was sent or the order was invalid, the code picks a source. The unit will use an HQ if it can. If more than one HQ is available, it uses the closest; if two are equally close, it prefers one from its own state; if two from the same state are equally close, choice is random. The position report states the one that will be used, barring an change in the game data (eg, disbanding a CHQ). If no HQ is available, if the unit is in a friendly city with supplies it will draw from that city.