(svn r7702) [cbh] - Moved around some functions and changes from r7687 abd 7697
--- a/bridge_cmd.c Sun Dec 31 12:28:51 2006 +0000
+++ b/bridge_cmd.c Sun Dec 31 16:03:49 2006 +0000
@@ -982,32 +982,7 @@
return 0;
}
-uint32 VehicleEnter_Railway_Bridge(Vehicle *v, TileIndex tile, int x, int y)
-{
- DiagDirection dir;
- uint8 dxy;
- assert(IsBridgeTile(v->tile));
- dir = GetBridgeRampDirection(v->tile);
- v->u.rail.track = 0x40;
- v->direction = DiagDirToDir(dir);
- CLRBIT(v->u.rail.flags, VRF_GOINGUP);
- CLRBIT(v->u.rail.flags, VRF_GOINGDOWN);
-
- switch (dir) {
- default: NOT_REACHED();
- case DIAGDIR_NE: dxy = 0xF8; break;
- case DIAGDIR_SE: dxy = 0x80; break;
- case DIAGDIR_SW: dxy = 0x08; break;
- case DIAGDIR_NW: dxy = 0x8F; break;
- }
- SB(x, 0, 4, GB(dxy, 4, 4));
- SB(y, 0, 4, GB(dxy, 0, 4));
- v->x_pos = x;
- v->y_pos = y;
- return 0;
-}
-
-static uint32 VehicleEnter_Railway_BridgeRamp(Vehicle *v, TileIndex tile, int x, int y)
+static uint32 VehicleEnter_Railway_Bridge(Vehicle *v, TileIndex tile, int x, int y)
{
int z = GetSlopeZ(x, y) - v->z_pos;
@@ -1043,7 +1018,7 @@
static uint32 VehicleEnter_Bridge(Vehicle *v, TileIndex tile, int x, int y)
{
- if (v->type == VEH_Train) return VehicleEnter_Railway_BridgeRamp(v, tile, x, y);
+ if (v->type == VEH_Train) return VehicleEnter_Railway_Bridge(v, tile, x, y);
if (v->type == VEH_Road) return VehicleEnter_Street_Bridge(v, tile, x, y);
--- a/train_cmd.c Sun Dec 31 12:28:51 2006 +0000
+++ b/train_cmd.c Sun Dec 31 16:03:49 2006 +0000
@@ -3014,6 +3014,34 @@
return NULL;
}
+/** Puts a train (logically) onto a bridge body.
+ * Sets the correct coordinates to traverse the bridge
+ * and aligns the vehicle with the bridge. The function
+ * assumes the train is on a bridge head about to enter
+ * the bridge.
+ */
+static void PutTrainOntoBridge(Vehicle *v)
+{
+ DiagDirection dir;
+ uint8 dxy;
+ assert(IsBridgeTile(v->tile));
+ dir = GetBridgeRampDirection(v->tile);
+ v->u.rail.track = 0x40;
+ v->direction = DiagDirToDir(dir);
+ CLRBIT(v->u.rail.flags, VRF_GOINGUP);
+ CLRBIT(v->u.rail.flags, VRF_GOINGDOWN);
+
+ switch (dir) {
+ default: NOT_REACHED();
+ case DIAGDIR_NE: dxy = 0xF8; break;
+ case DIAGDIR_SE: dxy = 0x80; break;
+ case DIAGDIR_SW: dxy = 0x08; break;
+ case DIAGDIR_NW: dxy = 0x8F; break;
+ }
+ SB(v->x_pos, 0, 4, GB(dxy, 4, 4));
+ SB(v->y_pos, 0, 4, GB(dxy, 0, 4));
+}
+
static void TrainController(Vehicle *v, bool update_image)
{
Vehicle *prev;
@@ -3077,8 +3105,7 @@
* to enter the tile that is under bridge. Enter the bridge wormhole instead. */
if (IsBridgeTile(gp.old_tile) && GetBridgeRampDirection(gp.old_tile) == enterdir) {
/* train entering the bridge body */
- extern uint32 VehicleEnter_Railway_Bridge(Vehicle *v, TileIndex tile, int x, int y);
- VehicleEnter_Railway_Bridge(v, gp.new_tile, gp.x, gp.y);
+ PutTrainOntoBridge(v);
UpdateTrainDeltaXY(v, v->direction);
if (update_image) v->cur_image = GetTrainImage(v, v->direction);
continue;