What exactly is required for a town building?

Update: After examining in detail a function on line 2166 of town_cmd.cpp, it is my opinion that the town chooses the building completely randomly based on two factors: the tile's "status" (which just controls whether a tile is 'available' for building on) and the town's "radius group". This is also corroborated by my experience in-game, which is that towns will build different types of houses based on how big the town is and which 'ring' the tile is in. Hopefully this is what you wanted, but I'll preserve the rest of my answer in case anybody else finds it useful.

Update 2: After reading your comment, I feel compelled to point out that the below paragraph should answer that question (on road access). Having said that, I'm a bit confused since I've never experienced the problem you're referring to - admittedly I greatly prefer "original" layout over 3x3 grid; perhaps it's simply my lack of experience in 3x3 grids that has caused the greatest amount of confusion in regards to this answer - for that, and the lack of organisation/coordination in later editions of the answer, I apologise.

It is my belief that for a square to build it must have road-access (otherwise the town will build a road for it), 'road-access' is defined by a road within 2 squares (ie an adjacent square must be a road). There is no particular way to build roads that will encourage or discourage building on a particular square - the town requires it, but will build the roads itself if necessary. There's no way to "force" a town to build in a particular square.

If you disallow town road-building, you will need to fill in road access according to the above rules in order for a square to build (road within 2 squares).

The old (fairly off-topic) answer:

I've played the game for a number of years now, and probably can't offer anything more definitive than said sources but I'll give it my best shot anyway.

The bit in bold is there because it is the factor that keeps cropping up in code, and I think is the most important factor in growth. If the town has not reached its goal, it will not grow (unless you are funding its growth).

Also worthy of note: funding a town twice in a row doesn't appear to be economically-sensible. It seems the town will be funded for growth for the next 3 months at the point you fund it - funding it again will not increase this to 6 months, it stays fixed at 3 months. The second funding is, therefore, wasted. (this is according to my interpretation of the source code)

The following factors affect whether a square will be built on [source confirmed]:

  • Terrain: square must be flat (unless an option for building on slopes is enabled)
  • Bridge: square must not have a bridge on it.
  • Road: square must be within 2 squares of a road
  • Building: square must not already have a building on it

According to the code as I've read it, these are the only factors affecting whether a specific square will be built on or not. As for when a square will be built on, see the rest of my answer about town growth rate (a much more complicated topic).

The following factors affect how quickly a town grows:

  • [source confirmed] The Local Authority option "fund new buildings" will cause the town to grow on the next tick and every tick for the next 3 months.
  • Terrain: flat terrain at the same level as the rest of the town is favoured over any other type, and squares are then chosen, it seems, by how close in level the terrain is.
  • [source confirmed] Town size: larger towns grow more quickly
  • Resources: passengers are one thing, but towns also grow faster if you ship goods, valuables and mail to them - in some terrains other things such as water will affect town growth
  • Road grid type: towns with 'original' layouts grow faster because they are less restricted in where they place their roads - note that towns will avoid building roads on sloping terrain more than they will avoid building anything else there (meaning you want to let them build roads however they want)
  • [source confirmed] Towns have a 'goal' of how much cargo needs to be delivered, when this goal is reached, the town will grow by a set amount.
  • [source confirmed] Time: towns will wait a set amount of time in between placing houses, when the time is up, it appears the town makes a decision based on other factors whether to (and where to) place a house.
  • [speculation based on source code] Nearby towns: it's possible that nearby towns hinder growth (yet to confirm, will need to read more)

The following things appear (to me) to be a placebo affect at best:

  • [source confirmed] "Helping" with road construction: the town, during its 'growth cycle', will automatically build any necessary roads - if there are already roads, the town will grow as if it built the roads itself. It may save you one or two ticks for a road to become fully built, but the time it takes for you to build the road isn't really worth it.
  • Shipping cargo away from the town: doesn't appear to have any affect on town growth speed, except that if you're shipping away then you're usually also shipping to. Experiments prove inconclusive.
  • Shipping cargo to local industry: inconclusive, this may or may not aid town growth - experiments have yielded differing results (perhaps some industries are better than others, many more experiments would be necessary to determine this and/or examination of the code).

The following factors definitely have nothing to do with town growth (but are worthy of note since many people think they may help/hinder):

  • Nearby railways, highways, etc.: towns don't much care about vehicles going near to them - just stations. From what I've seen, as long as the track/road/whatever isn't close enough that it directly impedes growth, it's fine. In fact, many times I've seen towns "gobble up" nearby railways by building across them. [source note] bridges and tunnels do affect whether or not a town will build on a particular square, and can be used to "pen in" towns, but will not affect the town's overall growth speed (and towns may 'escape' these pens, I've yet to experiment with that).
  • Using different classes of vehicle: surprisingly, some people think using more expensive vehicles has an affect on town growth. I've never seen any evidence whatsoever to support this.
  • Taking resources away from local industry: taking wood from a local forest, for example, may aid slightly in growth but I've not seen any significant impact. It certainly doesn't, as some people believe, hinder growth.
  • [source confirmed] Local Authority rating has nothing whatsoever to do with town growth. When the LA rating is modified in town.cpp, the code does not do anything to the town's growth rate. People may have this misconception due to the fact that towns that the player's company has high LA rating with grow faster because they're serviced better by the player's company. Same is true of non-player companies.

This answer is meant to be comprehensive but may not be exhaustive. I will come back and improve on it later on, when my girlfriend lets me play again (something about "becoming obsessive"... I dunno what she means, I mean 10 hours a day is healthy... isn't it?)