This is an OpenTTD port to Java.
Current state: The game is basically playable - aircrafts, trains, ships and road vehicles are working. But Save/load is not completely tested.
You're welcome to take part in testing and/or development!
Screenshots:
OpenTTD is beautiful. But it still carries on most of the original TTD architectural solutions. Bit banging, obscure data structures and crazy assembler style encoding of tile state.
It's time to move on.
My goals:
As a result game code must be really easy to understand and modify.
Example:
Obscure and long:
FOR_ALL_INDUSTRIES(ind) {
if (ind->xy != 0 && (cargo_type == ind->accepts_cargo[0] || cargo_type
== ind->accepts_cargo[1] || cargo_type == ind->accepts_cargo[2]) &&
ind->produced_cargo[0] != CT_INVALID &&
ind->produced_cargo[0] != cargo_type &&
(t = DistanceManhattan(ind->xy, xy)) < 2 * u)
{
...
}
}
Easy to understand and short:
Industry.forEach( ind ->
{
if (ind.isValid() && ind.acceptsCargo(cargo_type)
&& !ind.producesCargo(cargo_type)
&& (t = Map.DistanceManhattan(ind.xy, xy)) < 2 * u[0])
{
...
}
});
One more example. Code:
static bool AnyTownExists(void)
{
const Town* t;
FOR_ALL_TOWNS(t) {
if (t->xy != 0) return true;
}
return false;
}
Becomes:
public static boolean anyTownExist()
{
return stream().anyMatch( t -> t.isValid() );
}