bridge_map.c
author rubidium
Fri, 22 Jun 2007 20:01:02 +0000
branch0.5
changeset 5509 0b111f4e6dc9
parent 4559 c853d2440065
child 5573 afa6f92a71fd
permissions -rw-r--r--
(svn r10274) [0.5] -Backport from trunk (r9961, r10023, r10028, r10030, r10038, r10147):
- Fix: Some bits were unset when loading old TTD savegames when they shouldn't be unset (r10147)
- Fix: Sprite resulting from '?' substitution was reloaded into the cache entry for SPR_IMG_QUERY instead of the original sprite cache entry. This resulted in unaccounted missing sprite cache memory, and was exacerbated because the original missing sprite was not cached, so it did it again and again and again. Slowdowns and boom (r10038)
- Fix: One could build on (some) slopes when building on slopes was disabled [FS#823] (r10030)
- Fix: When deleting the first engine of a train with multiple engines, only reopen the train window if the player had the original train window open. This fixes 'random' windows opening for multiple players of the same company (r10028)
- Fix: When selling trains, if there were no wagons between multiheaded engines the rear part could be checked despite having already been deleted (10023)
- Fix: Some files were still in iso8859-15 instead of UTF-8 (r9961)
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
}