tunnel_map.c
author truelight
Sat, 19 Aug 2006 10:00:30 +0000
changeset 4300 c7e43c47a2b9
parent 4291 f8b2e48ba70c
child 4559 aa0c13e39840
permissions -rw-r--r--
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
- New optional landscape generator (TerraGenesis Perlin)
- Load heightmaps (either BMP or PNG)
- Progress dialog while generating worlds (no longer a 'hanging' screen)
- New dialogs for NewGame, Create Scenario and Play Heightmap
- Easier to configure your landscape
- More things to configure (tree-placer, ..)
- Speedup of world generation
- New console command 'restart': restart the map EXACTLY as it was when you
first started it (needs a game made after or with this commit)
- New console command 'getseed': get the seed of your map and share it with
others (of course only works with generated maps)
- Many new, world generation related, things
- Many internal cleanups and rewrites
Many tnx to those people who helped making this:
Belugas, DaleStan, glx, KUDr, RichK67, Rubidium, and TrueLight (alfabetic)
Many tnx to those who helped testing:
Arnau, Bjarni, and tokai (alfabetic)
And to all other people who helped testing and sending comments / bugs
Stats: 673 lines changed, 3534 new lines, 79 new strings
3154
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     1
/* $Id$ */
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     2
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     3
#include "stdafx.h"
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     4
#include "openttd.h"
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     5
#include "tile.h"
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     6
#include "tunnel_map.h"
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     7
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     8
TileIndex GetOtherTunnelEnd(TileIndex tile)
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
     9
{
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    10
	DiagDirection dir = GetTunnelDirection(tile);
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    11
	TileIndexDiff delta = TileOffsByDir(dir);
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    12
	uint z = GetTileZ(tile);
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    13
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    14
	dir = ReverseDiagDir(dir);
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    15
	do {
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    16
		tile += delta;
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    17
	} while (
3184
118a520164e4 (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3156
diff changeset
    18
		!IsTunnelTile(tile) ||
3154
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    19
		GetTunnelDirection(tile) != dir ||
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    20
		GetTileZ(tile) != z
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    21
	);
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    22
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    23
	return tile;
6ab0cb6b7ab3 (svn r3777) Add some functions to handle tunnels
tron
parents:
diff changeset
    24
}
3156
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    25
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    26
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    27
static bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir)
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    28
{
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    29
	TileIndexDiff delta = TileOffsByDir(dir);
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    30
	uint height;
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    31
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    32
	do {
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    33
		tile -= delta;
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    34
		height = GetTileZ(tile);
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    35
	} while (z < height);
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    36
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    37
	return
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    38
		z == height &&
3184
118a520164e4 (svn r3830) Move IsTunnelTile() from tile.h to tunnel_map.h and add IsTunnel(), which just checks for a tunnel, but not the tile type as IsTunnelTile() does
tron
parents: 3156
diff changeset
    39
		IsTunnelTile(tile) &&
3156
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    40
		GetTunnelDirection(tile) == dir;
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    41
}
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    42
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    43
bool IsTunnelInWay(TileIndex tile, uint z)
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    44
{
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    45
	return
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    46
		IsTunnelInWayDir(tile, z, DIAGDIR_NE) ||
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    47
		IsTunnelInWayDir(tile, z, DIAGDIR_SE) ||
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    48
		IsTunnelInWayDir(tile, z, DIAGDIR_SW) ||
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    49
		IsTunnelInWayDir(tile, z, DIAGDIR_NW);
f4caf4197189 (svn r3779) Move CheckTunnelInWay() to a more appropriate place, invert its result and give it a less ambiguous name (IsTunnelInWay)
tron
parents: 3154
diff changeset
    50
}