bridge_map.c
author bjarni
Fri, 08 Sep 2006 10:47:39 +0000
changeset 4574 497540b4a75f
parent 4559 c853d2440065
child 5573 afa6f92a71fd
permissions -rw-r--r--
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
To do this, the player struct contains an array, that contains the count of each engine type that the player owns
Those arrays are updated each time a vehicle is build or deleted and is calculated on load (it's not saved)
It's possible to access the arrays outside of the autoreplace GUI, so feel free to read from them in other patches as well
3214
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff changeset
     1
/* $Id$ */
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff changeset
     2
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff changeset
     3
#include "stdafx.h"
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff changeset
     4
#include "openttd.h"
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff changeset
     5
#include "bridge_map.h"
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff changeset
     6
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff changeset
     7
3225
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
     8
TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
     9
{
4559
c853d2440065 (svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents: 3977
diff changeset
    10
	TileIndexDiff delta = TileOffsByDiagDir(dir);
3225
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
    11
3977
edb5b94e2094 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3933
diff changeset
    12
	assert(DiagDirToAxis(dir) == GetBridgeAxis(tile));
edb5b94e2094 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3933
diff changeset
    13
edb5b94e2094 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3933
diff changeset
    14
	do {
edb5b94e2094 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3933
diff changeset
    15
		tile += delta;
edb5b94e2094 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3933
diff changeset
    16
	} while (!IsBridgeRamp(tile));
3225
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
    17
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
    18
	return tile;
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
    19
}
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
    20
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
    21
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
    22
TileIndex GetSouthernBridgeEnd(TileIndex t)
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
    23
{
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
    24
	return GetBridgeEnd(t, AxisToDiagDir(GetBridgeAxis(t)));
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
    25
}
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
    26
655763f3861c (svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents: 3214
diff changeset
    27
3214
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff changeset
    28
TileIndex GetOtherBridgeEnd(TileIndex tile)
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff changeset
    29
{
4559
c853d2440065 (svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents: 3977
diff changeset
    30
	TileIndexDiff delta = TileOffsByDiagDir(GetBridgeRampDirection(tile));
3933
a5f08e17f4a0 (svn r5070) Merged the bridge branch
celestar
parents: 3225
diff changeset
    31
3977
edb5b94e2094 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3933
diff changeset
    32
	do {
edb5b94e2094 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3933
diff changeset
    33
		tile += delta;
edb5b94e2094 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3933
diff changeset
    34
	} while (!IsBridgeRamp(tile));
3933
a5f08e17f4a0 (svn r5070) Merged the bridge branch
celestar
parents: 3225
diff changeset
    35
3977
edb5b94e2094 (svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents: 3933
diff changeset
    36
	return tile;
3214
172b409bf612 (svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff changeset
    37
}