mirror of https://github.com/OpenTTD/OpenTTD
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
parent
313754011d
commit
fbe939b31f
|
@ -5,6 +5,7 @@
|
||||||
#include "../../debug.h"
|
#include "../../debug.h"
|
||||||
#include "../../functions.h"
|
#include "../../functions.h"
|
||||||
#include "../../map.h"
|
#include "../../map.h"
|
||||||
|
#include "../../road_map.h"
|
||||||
#include "../../tile.h"
|
#include "../../tile.h"
|
||||||
#include "../../command.h"
|
#include "../../command.h"
|
||||||
#include "trolly.h"
|
#include "trolly.h"
|
||||||
|
@ -255,9 +256,8 @@ int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
|
||||||
return AI_DoCommand(tile, i, 0, flag, CMD_BUILD_ROAD_VEH);
|
return AI_DoCommand(tile, i, 0, flag, CMD_BUILD_ROAD_VEH);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag)
|
int AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag)
|
||||||
{
|
{
|
||||||
static const byte _roadbits_by_dir[4] = {2,1,8,4};
|
|
||||||
int ret, ret2;
|
int ret, ret2;
|
||||||
if (p->ainew.tbt == AI_TRAIN)
|
if (p->ainew.tbt == AI_TRAIN)
|
||||||
return AI_DoCommand(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
|
return AI_DoCommand(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
|
||||||
|
@ -265,7 +265,7 @@ int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag)
|
||||||
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);
|
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);
|
||||||
if (CmdFailed(ret)) return ret;
|
if (CmdFailed(ret)) return ret;
|
||||||
// Try to build the road from the depot
|
// Try to build the road from the depot
|
||||||
ret2 = AI_DoCommand(tile + TileOffsByDir(direction), _roadbits_by_dir[direction], 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
|
ret2 = AI_DoCommand(tile + TileOffsByDir(direction), DiagDirToRoadBits(ReverseDiagDir(direction)), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
|
||||||
// If it fails, ignore it..
|
// If it fails, ignore it..
|
||||||
if (CmdFailed(ret2)) return ret;
|
if (CmdFailed(ret2)) return ret;
|
||||||
return ret + ret2;
|
return ret + ret2;
|
||||||
|
|
|
@ -372,7 +372,7 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
|
||||||
|
|
||||||
extern uint GetRailFoundation(uint tileh, uint bits);
|
extern uint GetRailFoundation(uint tileh, uint bits);
|
||||||
extern uint GetRoadFoundation(uint tileh, uint bits);
|
extern uint GetRoadFoundation(uint tileh, uint bits);
|
||||||
extern uint GetBridgeFoundation(uint tileh, byte direction);
|
extern uint GetBridgeFoundation(uint tileh, Axis); // XXX function declaration in .c
|
||||||
enum {
|
enum {
|
||||||
BRIDGE_NO_FOUNDATION = 1 << 0 | 1 << 3 | 1 << 6 | 1 << 9 | 1 << 12,
|
BRIDGE_NO_FOUNDATION = 1 << 0 | 1 << 3 | 1 << 6 | 1 << 9 | 1 << 12,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1024,7 +1024,6 @@ static void AiNew_State_BuildPath(Player *p)
|
||||||
// This means we are done building!
|
// This means we are done building!
|
||||||
|
|
||||||
if (p->ainew.tbt == AI_TRUCK && !_patches.roadveh_queue) {
|
if (p->ainew.tbt == AI_TRUCK && !_patches.roadveh_queue) {
|
||||||
static const byte _roadbits_by_dir[4] = {2,1,8,4};
|
|
||||||
// If they not queue, they have to go up and down to try again at a station...
|
// If they not queue, they have to go up and down to try again at a station...
|
||||||
// We don't want that, so try building some road left or right of the station
|
// We don't want that, so try building some road left or right of the station
|
||||||
int dir1, dir2, dir3;
|
int dir1, dir2, dir3;
|
||||||
|
@ -1047,7 +1046,7 @@ static void AiNew_State_BuildPath(Player *p)
|
||||||
dir3 = p->ainew.to_direction;
|
dir3 = p->ainew.to_direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = AI_DoCommand(tile, _roadbits_by_dir[dir1], 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
|
ret = AI_DoCommand(tile, DiagDirToRoadBits(ReverseDiagDir(dir1)), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
|
||||||
if (!CmdFailed(ret)) {
|
if (!CmdFailed(ret)) {
|
||||||
dir1 = TileOffsByDir(dir1);
|
dir1 = TileOffsByDir(dir1);
|
||||||
if (IsTileType(tile + dir1, MP_CLEAR) || IsTileType(tile + dir1, MP_TREES)) {
|
if (IsTileType(tile + dir1, MP_CLEAR) || IsTileType(tile + dir1, MP_TREES)) {
|
||||||
|
@ -1059,7 +1058,7 @@ static void AiNew_State_BuildPath(Player *p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = AI_DoCommand(tile, _roadbits_by_dir[dir2], 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
|
ret = AI_DoCommand(tile, DiagDirToRoadBits(ReverseDiagDir(dir2)), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
|
||||||
if (!CmdFailed(ret)) {
|
if (!CmdFailed(ret)) {
|
||||||
dir2 = TileOffsByDir(dir2);
|
dir2 = TileOffsByDir(dir2);
|
||||||
if (IsTileType(tile + dir2, MP_CLEAR) || IsTileType(tile + dir2, MP_TREES)) {
|
if (IsTileType(tile + dir2, MP_CLEAR) || IsTileType(tile + dir2, MP_TREES)) {
|
||||||
|
@ -1071,7 +1070,7 @@ static void AiNew_State_BuildPath(Player *p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = AI_DoCommand(tile, _roadbits_by_dir[dir3^2], 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
|
ret = AI_DoCommand(tile, DiagDirToRoadBits(dir3), 0, DC_EXEC | DC_NO_WATER, CMD_BUILD_ROAD);
|
||||||
if (!CmdFailed(ret)) {
|
if (!CmdFailed(ret)) {
|
||||||
dir3 = TileOffsByDir(dir3);
|
dir3 = TileOffsByDir(dir3);
|
||||||
if (IsTileType(tile + dir3, MP_CLEAR) || IsTileType(tile + dir3, MP_TREES)) {
|
if (IsTileType(tile + dir3, MP_CLEAR) || IsTileType(tile + dir3, MP_TREES)) {
|
||||||
|
|
|
@ -256,6 +256,6 @@ int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag)
|
||||||
int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag);
|
int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag);
|
||||||
int AiNew_PickVehicle(Player *p);
|
int AiNew_PickVehicle(Player *p);
|
||||||
int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag);
|
int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag);
|
||||||
int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag);
|
int AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag);
|
||||||
|
|
||||||
#endif /* AI_TROLLY_H */
|
#endif /* AI_TROLLY_H */
|
||||||
|
|
|
@ -91,7 +91,7 @@ static bool HaveHangarInOrderList(Vehicle *v)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int GetAircraftImage(const Vehicle *v, byte direction)
|
int GetAircraftImage(const Vehicle* v, Direction direction)
|
||||||
{
|
{
|
||||||
int spritenum = v->spritenum;
|
int spritenum = v->spritenum;
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number)
|
||||||
static void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection)
|
static void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection)
|
||||||
{
|
{
|
||||||
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
|
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
|
||||||
DrawSprite(GetAircraftImage(v, 6) | pal, x + 25, y + 10);
|
DrawSprite(GetAircraftImage(v, DIR_W) | pal, x + 25, y + 10);
|
||||||
if (v->subtype == 0) DrawSprite(SPR_ROTOR_STOPPED, x + 25, y + 5);
|
if (v->subtype == 0) DrawSprite(SPR_ROTOR_STOPPED, x + 25, y + 5);
|
||||||
if (v->index == selection) {
|
if (v->index == selection) {
|
||||||
DrawFrameRect(x - 1, y - 1, x + 58, y + 21, 0xF, FR_BORDERONLY);
|
DrawFrameRect(x - 1, y - 1, x + 58, y + 21, 0xF, FR_BORDERONLY);
|
||||||
|
@ -730,7 +730,7 @@ static void AircraftDepotClickAircraft(Window *w, int x, int y)
|
||||||
if (v != NULL) {
|
if (v != NULL) {
|
||||||
WP(w,traindepot_d).sel = v->index;
|
WP(w,traindepot_d).sel = v->index;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
SetObjectToPlaceWnd(GetVehiclePalette(v) | GetAircraftImage(v, 6), 4, w);
|
SetObjectToPlaceWnd(GetVehiclePalette(v) | GetAircraftImage(v, DIR_W), 4, w);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,11 @@ typedef enum Direction {
|
||||||
INVALID_DIR = 0xFF,
|
INVALID_DIR = 0xFF,
|
||||||
} Direction;
|
} Direction;
|
||||||
|
|
||||||
|
static inline Direction ReverseDir(Direction d)
|
||||||
|
{
|
||||||
|
return (Direction)(4 ^ d);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Direction commonly used as the direction of entering and leaving tiles, 4-way */
|
/* Direction commonly used as the direction of entering and leaving tiles, 4-way */
|
||||||
typedef enum DiagDirection {
|
typedef enum DiagDirection {
|
||||||
|
|
|
@ -74,7 +74,7 @@ static void DisasterVehicleUpdateImage(Vehicle *v)
|
||||||
v->cur_image = img;
|
v->cur_image = img;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InitializeDisasterVehicle(Vehicle *v, int x, int y, byte z, byte direction, byte subtype)
|
static void InitializeDisasterVehicle(Vehicle* v, int x, int y, byte z, Direction direction, byte subtype)
|
||||||
{
|
{
|
||||||
v->type = VEH_Disaster;
|
v->type = VEH_Disaster;
|
||||||
v->x_pos = x;
|
v->x_pos = x;
|
||||||
|
@ -552,7 +552,7 @@ static void DisasterTick_4(Vehicle *v)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeDisasterVehicle(u, -6*16, v->y_pos, 135, 5, 11);
|
InitializeDisasterVehicle(u, -6 * 16, v->y_pos, 135, DIR_SW, 11);
|
||||||
u->u.disaster.unk2 = v->index;
|
u->u.disaster.unk2 = v->index;
|
||||||
|
|
||||||
w = ForceAllocateSpecialVehicle();
|
w = ForceAllocateSpecialVehicle();
|
||||||
|
@ -560,7 +560,7 @@ static void DisasterTick_4(Vehicle *v)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
u->next = w;
|
u->next = w;
|
||||||
InitializeDisasterVehicle(w, -6*16, v->y_pos, 0, 5, 12);
|
InitializeDisasterVehicle(w, -6 * 16, v->y_pos, 0, DIR_SW, 12);
|
||||||
w->vehstatus |= VS_DISASTER;
|
w->vehstatus |= VS_DISASTER;
|
||||||
} else if (v->current_order.station < 1) {
|
} else if (v->current_order.station < 1) {
|
||||||
|
|
||||||
|
@ -720,13 +720,13 @@ static void Disaster0_Init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeDisasterVehicle(v, x, 0, 135, 3, 0);
|
InitializeDisasterVehicle(v, x, 0, 135, DIR_SE, 0);
|
||||||
|
|
||||||
// Allocate shadow too?
|
// Allocate shadow too?
|
||||||
u = ForceAllocateSpecialVehicle();
|
u = ForceAllocateSpecialVehicle();
|
||||||
if (u != NULL) {
|
if (u != NULL) {
|
||||||
v->next = u;
|
v->next = u;
|
||||||
InitializeDisasterVehicle(u, x, 0, 0, 3, 1);
|
InitializeDisasterVehicle(u, x, 0, 0, DIR_SE, 1);
|
||||||
u->vehstatus |= VS_DISASTER;
|
u->vehstatus |= VS_DISASTER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -741,7 +741,7 @@ static void Disaster1_Init(void)
|
||||||
|
|
||||||
x = TileX(Random()) * 16 + 8;
|
x = TileX(Random()) * 16 + 8;
|
||||||
|
|
||||||
InitializeDisasterVehicle(v, x, 0, 135, 3, 2);
|
InitializeDisasterVehicle(v, x, 0, 135, DIR_SE, 2);
|
||||||
v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2);
|
v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2);
|
||||||
v->age = 0;
|
v->age = 0;
|
||||||
|
|
||||||
|
@ -749,7 +749,7 @@ static void Disaster1_Init(void)
|
||||||
u = ForceAllocateSpecialVehicle();
|
u = ForceAllocateSpecialVehicle();
|
||||||
if (u != NULL) {
|
if (u != NULL) {
|
||||||
v->next = u;
|
v->next = u;
|
||||||
InitializeDisasterVehicle(u,x,0,0,3,3);
|
InitializeDisasterVehicle(u, x, 0, 0, DIR_SE, 3);
|
||||||
u->vehstatus |= VS_DISASTER;
|
u->vehstatus |= VS_DISASTER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -780,12 +780,12 @@ static void Disaster2_Init(void)
|
||||||
x = (MapSizeX() + 9) * 16 - 1;
|
x = (MapSizeX() + 9) * 16 - 1;
|
||||||
y = TileY(found->xy) * 16 + 37;
|
y = TileY(found->xy) * 16 + 37;
|
||||||
|
|
||||||
InitializeDisasterVehicle(v,x,y, 135,1,4);
|
InitializeDisasterVehicle(v, x, y, 135, DIR_NE, 4);
|
||||||
|
|
||||||
u = ForceAllocateSpecialVehicle();
|
u = ForceAllocateSpecialVehicle();
|
||||||
if (u != NULL) {
|
if (u != NULL) {
|
||||||
v->next = u;
|
v->next = u;
|
||||||
InitializeDisasterVehicle(u,x,y,0,3,5);
|
InitializeDisasterVehicle(u, x, y, 0, DIR_SE, 5);
|
||||||
u->vehstatus |= VS_DISASTER;
|
u->vehstatus |= VS_DISASTER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -816,18 +816,18 @@ static void Disaster3_Init(void)
|
||||||
x = -16 * 16;
|
x = -16 * 16;
|
||||||
y = TileY(found->xy) * 16 + 37;
|
y = TileY(found->xy) * 16 + 37;
|
||||||
|
|
||||||
InitializeDisasterVehicle(v,x,y, 135,5,6);
|
InitializeDisasterVehicle(v, x, y, 135, DIR_SW, 6);
|
||||||
|
|
||||||
u = ForceAllocateSpecialVehicle();
|
u = ForceAllocateSpecialVehicle();
|
||||||
if (u != NULL) {
|
if (u != NULL) {
|
||||||
v->next = u;
|
v->next = u;
|
||||||
InitializeDisasterVehicle(u,x,y,0,5,7);
|
InitializeDisasterVehicle(u, x, y, 0, DIR_SW, 7);
|
||||||
u->vehstatus |= VS_DISASTER;
|
u->vehstatus |= VS_DISASTER;
|
||||||
|
|
||||||
w = ForceAllocateSpecialVehicle();
|
w = ForceAllocateSpecialVehicle();
|
||||||
if (w != NULL) {
|
if (w != NULL) {
|
||||||
u->next = w;
|
u->next = w;
|
||||||
InitializeDisasterVehicle(w,x,y,140,5,8);
|
InitializeDisasterVehicle(w, x, y, 140, DIR_SW, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -842,7 +842,7 @@ static void Disaster4_Init(void)
|
||||||
x = TileX(Random()) * 16 + 8;
|
x = TileX(Random()) * 16 + 8;
|
||||||
|
|
||||||
y = MapMaxX() * 16 - 1;
|
y = MapMaxX() * 16 - 1;
|
||||||
InitializeDisasterVehicle(v, x, y, 135, 7, 9);
|
InitializeDisasterVehicle(v, x, y, 135, DIR_NW, 9);
|
||||||
v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2);
|
v->dest_tile = TileXY(MapSizeX() / 2, MapSizeY() / 2);
|
||||||
v->age = 0;
|
v->age = 0;
|
||||||
|
|
||||||
|
@ -850,7 +850,7 @@ static void Disaster4_Init(void)
|
||||||
u = ForceAllocateSpecialVehicle();
|
u = ForceAllocateSpecialVehicle();
|
||||||
if (u != NULL) {
|
if (u != NULL) {
|
||||||
v->next = u;
|
v->next = u;
|
||||||
InitializeDisasterVehicle(u,x,y,0,7,10);
|
InitializeDisasterVehicle(u, x, y, 0, DIR_NW, 10);
|
||||||
u->vehstatus |= VS_DISASTER;
|
u->vehstatus |= VS_DISASTER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -860,7 +860,7 @@ static void Disaster5_Init(void)
|
||||||
{
|
{
|
||||||
Vehicle *v = ForceAllocateSpecialVehicle();
|
Vehicle *v = ForceAllocateSpecialVehicle();
|
||||||
int x,y;
|
int x,y;
|
||||||
byte dir;
|
Direction dir;
|
||||||
uint32 r;
|
uint32 r;
|
||||||
|
|
||||||
if (v == NULL) return;
|
if (v == NULL) return;
|
||||||
|
@ -868,10 +868,14 @@ static void Disaster5_Init(void)
|
||||||
r = Random();
|
r = Random();
|
||||||
x = TileX(r) * 16 + 8;
|
x = TileX(r) * 16 + 8;
|
||||||
|
|
||||||
y = 8;
|
if (r & 0x80000000) {
|
||||||
dir = 3;
|
y = MapMaxX() * 16 - 8 - 1;
|
||||||
if (r & 0x80000000) { y = MapMaxX() * 16 - 8 - 1; dir = 7; }
|
dir = DIR_NW;
|
||||||
InitializeDisasterVehicle(v, x, y, 0, dir,13);
|
} else {
|
||||||
|
y = 8;
|
||||||
|
dir = DIR_SE;
|
||||||
|
}
|
||||||
|
InitializeDisasterVehicle(v, x, y, 0, dir, 13);
|
||||||
v->age = 0;
|
v->age = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -880,7 +884,7 @@ static void Disaster6_Init(void)
|
||||||
{
|
{
|
||||||
Vehicle *v = ForceAllocateSpecialVehicle();
|
Vehicle *v = ForceAllocateSpecialVehicle();
|
||||||
int x,y;
|
int x,y;
|
||||||
byte dir;
|
Direction dir;
|
||||||
uint32 r;
|
uint32 r;
|
||||||
|
|
||||||
if (v == NULL) return;
|
if (v == NULL) return;
|
||||||
|
@ -888,10 +892,14 @@ static void Disaster6_Init(void)
|
||||||
r = Random();
|
r = Random();
|
||||||
x = TileX(r) * 16 + 8;
|
x = TileX(r) * 16 + 8;
|
||||||
|
|
||||||
y = 8;
|
if (r & 0x80000000) {
|
||||||
dir = 3;
|
y = MapMaxX() * 16 - 8 - 1;
|
||||||
if (r & 0x80000000) { y = MapMaxX() * 16 - 8 - 1; dir = 7; }
|
dir = DIR_NW;
|
||||||
InitializeDisasterVehicle(v, x, y, 0, dir,14);
|
} else {
|
||||||
|
y = 8;
|
||||||
|
dir = DIR_SE;
|
||||||
|
}
|
||||||
|
InitializeDisasterVehicle(v, x, y, 0, dir, 14);
|
||||||
v->age = 0;
|
v->age = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
static void ShowBuildDockStationPicker(void);
|
static void ShowBuildDockStationPicker(void);
|
||||||
static void ShowBuildDocksDepotPicker(void);
|
static void ShowBuildDocksDepotPicker(void);
|
||||||
|
|
||||||
static byte _ship_depot_direction;
|
static Axis _ship_depot_direction;
|
||||||
|
|
||||||
void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
|
@ -293,7 +293,7 @@ static void ShowBuildDockStationPicker(void)
|
||||||
|
|
||||||
static void UpdateDocksDirection(void)
|
static void UpdateDocksDirection(void)
|
||||||
{
|
{
|
||||||
if (_ship_depot_direction != 0) {
|
if (_ship_depot_direction != AXIS_X) {
|
||||||
SetTileSelectSize(1, 2);
|
SetTileSelectSize(1, 2);
|
||||||
} else {
|
} else {
|
||||||
SetTileSelectSize(2, 1);
|
SetTileSelectSize(2, 1);
|
||||||
|
@ -362,5 +362,5 @@ static void ShowBuildDocksDepotPicker(void)
|
||||||
|
|
||||||
void InitializeDockGui(void)
|
void InitializeDockGui(void)
|
||||||
{
|
{
|
||||||
_ship_depot_direction = 0;
|
_ship_depot_direction = AXIS_X;
|
||||||
}
|
}
|
||||||
|
|
|
@ -907,7 +907,7 @@ static bool IsBadFarmFieldTile2(TileIndex tile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetupFarmFieldFence(TileIndex tile, int size, byte type, int direction)
|
static void SetupFarmFieldFence(TileIndex tile, int size, byte type, Axis direction)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
tile = TILE_MASK(tile);
|
tile = TILE_MASK(tile);
|
||||||
|
@ -917,14 +917,14 @@ static void SetupFarmFieldFence(TileIndex tile, int size, byte type, int directi
|
||||||
|
|
||||||
if (or == 1 && CHANCE16(1, 7)) or = 2;
|
if (or == 1 && CHANCE16(1, 7)) or = 2;
|
||||||
|
|
||||||
if (direction) {
|
if (direction == AXIS_X) {
|
||||||
SetFenceSW(tile, or);
|
|
||||||
} else {
|
|
||||||
SetFenceSE(tile, or);
|
SetFenceSE(tile, or);
|
||||||
|
} else {
|
||||||
|
SetFenceSW(tile, or);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tile += direction ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
|
tile += (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||||
} while (--size);
|
} while (--size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -984,10 +984,10 @@ static void PlantFarmField(TileIndex tile)
|
||||||
type = _plantfarmfield_type[Random() & 0xF];
|
type = _plantfarmfield_type[Random() & 0xF];
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupFarmFieldFence(tile - TileDiffXY(1, 0), size_y, type, 1);
|
SetupFarmFieldFence(tile - TileDiffXY(1, 0), size_y, type, AXIS_Y);
|
||||||
SetupFarmFieldFence(tile - TileDiffXY(0, 1), size_x, type, 0);
|
SetupFarmFieldFence(tile - TileDiffXY(0, 1), size_x, type, AXIS_X);
|
||||||
SetupFarmFieldFence(tile + TileDiffXY(size_x - 1, 0), size_y, type, 1);
|
SetupFarmFieldFence(tile + TileDiffXY(size_x - 1, 0), size_y, type, AXIS_Y);
|
||||||
SetupFarmFieldFence(tile + TileDiffXY(0, size_y - 1), size_x, type, 0);
|
SetupFarmFieldFence(tile + TileDiffXY(0, size_y - 1), size_x, type, AXIS_X);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MaybePlantFarmField(const Industry* i)
|
static void MaybePlantFarmField(const Industry* i)
|
||||||
|
|
|
@ -388,7 +388,7 @@ static const SpriteGroup *GetVehicleSpriteGroup(EngineID engine, const Vehicle *
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetCustomEngineSprite(EngineID engine, const Vehicle *v, byte direction)
|
int GetCustomEngineSprite(EngineID engine, const Vehicle* v, Direction direction)
|
||||||
{
|
{
|
||||||
const SpriteGroup *group;
|
const SpriteGroup *group;
|
||||||
const RealSpriteGroup *rsg;
|
const RealSpriteGroup *rsg;
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#ifndef NEWGRF_ENGINE_H
|
#ifndef NEWGRF_ENGINE_H
|
||||||
#define NEWGRF_ENGINE_H
|
#define NEWGRF_ENGINE_H
|
||||||
|
|
||||||
|
#include "direction.h"
|
||||||
|
|
||||||
/** @file newgrf_engine.h
|
/** @file newgrf_engine.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -15,7 +17,7 @@ VARDEF const uint32 cargo_classes[16];
|
||||||
void SetWagonOverrideSprites(EngineID engine, struct SpriteGroup *group, byte *train_id, int trains);
|
void SetWagonOverrideSprites(EngineID engine, struct SpriteGroup *group, byte *train_id, int trains);
|
||||||
void SetCustomEngineSprites(EngineID engine, byte cargo, struct SpriteGroup *group);
|
void SetCustomEngineSprites(EngineID engine, byte cargo, struct SpriteGroup *group);
|
||||||
// loaded is in percents, overriding_engine 0xffff is none
|
// loaded is in percents, overriding_engine 0xffff is none
|
||||||
int GetCustomEngineSprite(EngineID engine, const Vehicle *v, byte direction);
|
int GetCustomEngineSprite(EngineID engine, const Vehicle* v, Direction direction);
|
||||||
uint16 GetCallBackResult(uint16 callback_info, EngineID engine, const Vehicle *v);
|
uint16 GetCallBackResult(uint16 callback_info, EngineID engine, const Vehicle *v);
|
||||||
bool UsesWagonOverride(const Vehicle *v);
|
bool UsesWagonOverride(const Vehicle *v);
|
||||||
#define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction)
|
#define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction)
|
||||||
|
|
|
@ -210,7 +210,7 @@ static const int8 _get_tunlen_inc[5] = { -16, 0, 16, 0, -16 };
|
||||||
/* Returns the end tile and the length of a tunnel. The length does not
|
/* Returns the end tile and the length of a tunnel. The length does not
|
||||||
* include the starting tile (entry), it does include the end tile (exit).
|
* include the starting tile (entry), it does include the end tile (exit).
|
||||||
*/
|
*/
|
||||||
FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, uint direction)
|
FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, DiagDirection direction)
|
||||||
{
|
{
|
||||||
FindLengthOfTunnelResult flotr;
|
FindLengthOfTunnelResult flotr;
|
||||||
int x,y;
|
int x,y;
|
||||||
|
@ -246,7 +246,7 @@ FindLengthOfTunnelResult FindLengthOfTunnel(TileIndex tile, uint direction)
|
||||||
|
|
||||||
static const uint16 _tpfmode1_and[4] = { 0x1009, 0x16, 0x520, 0x2A00 };
|
static const uint16 _tpfmode1_and[4] = { 0x1009, 0x16, 0x520, 0x2A00 };
|
||||||
|
|
||||||
static uint SkipToEndOfTunnel(TrackPathFinder *tpf, TileIndex tile, int direction)
|
static uint SkipToEndOfTunnel(TrackPathFinder* tpf, TileIndex tile, DiagDirection direction)
|
||||||
{
|
{
|
||||||
FindLengthOfTunnelResult flotr;
|
FindLengthOfTunnelResult flotr;
|
||||||
TPFSetTileBit(tpf, tile, 14);
|
TPFSetTileBit(tpf, tile, 14);
|
||||||
|
|
14
rail_cmd.c
14
rail_cmd.c
|
@ -1788,8 +1788,8 @@ bool UpdateSignalsOnSegment(TileIndex tile, Direction dir)
|
||||||
|
|
||||||
void SetSignalsOnBothDir(TileIndex tile, byte track)
|
void SetSignalsOnBothDir(TileIndex tile, byte track)
|
||||||
{
|
{
|
||||||
static const byte _search_dir_1[6] = {1, 3, 1, 3, 5, 3};
|
static const Direction _search_dir_1[] = { DIR_NE, DIR_SE, DIR_NE, DIR_SE, DIR_SW, DIR_SE };
|
||||||
static const byte _search_dir_2[6] = {5, 7, 7, 5, 7, 1};
|
static const Direction _search_dir_2[] = { DIR_SW, DIR_NW, DIR_NW, DIR_SW, DIR_NW, DIR_NE };
|
||||||
|
|
||||||
UpdateSignalsOnSegment(tile, _search_dir_1[track]);
|
UpdateSignalsOnSegment(tile, _search_dir_1[track]);
|
||||||
UpdateSignalsOnSegment(tile, _search_dir_2[track]);
|
UpdateSignalsOnSegment(tile, _search_dir_2[track]);
|
||||||
|
@ -2069,15 +2069,13 @@ static const byte _deltacoord_leaveoffset[8] = {
|
||||||
-1, 0, 1, 0, /* x */
|
-1, 0, 1, 0, /* x */
|
||||||
0, 1, 0, -1 /* y */
|
0, 1, 0, -1 /* y */
|
||||||
};
|
};
|
||||||
static const byte _enter_directions[4] = {5, 7, 1, 3};
|
|
||||||
static const byte _leave_directions[4] = {1, 3, 5, 7};
|
|
||||||
static const byte _depot_track_mask[4] = {1, 2, 1, 2};
|
static const byte _depot_track_mask[4] = {1, 2, 1, 2};
|
||||||
|
|
||||||
static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y)
|
static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y)
|
||||||
{
|
{
|
||||||
byte fract_coord;
|
byte fract_coord;
|
||||||
byte fract_coord_leave;
|
byte fract_coord_leave;
|
||||||
int dir;
|
DiagDirection dir;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
// this routine applies only to trains in depot tiles
|
// this routine applies only to trains in depot tiles
|
||||||
|
@ -2102,11 +2100,11 @@ static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y)
|
||||||
/* make sure a train is not entering the tile from behind */
|
/* make sure a train is not entering the tile from behind */
|
||||||
return 8;
|
return 8;
|
||||||
} else if (_fractcoords_enter[dir] == fract_coord) {
|
} else if (_fractcoords_enter[dir] == fract_coord) {
|
||||||
if (_enter_directions[dir] == v->direction) {
|
if (DiagDirToDir(ReverseDiagDir(dir)) == v->direction) {
|
||||||
/* enter the depot */
|
/* enter the depot */
|
||||||
v->u.rail.track = 0x80,
|
v->u.rail.track = 0x80,
|
||||||
v->vehstatus |= VS_HIDDEN; /* hide it */
|
v->vehstatus |= VS_HIDDEN; /* hide it */
|
||||||
v->direction ^= 4;
|
v->direction = ReverseDir(v->direction);
|
||||||
if (v->next == NULL)
|
if (v->next == NULL)
|
||||||
TrainEnterDepot(v, tile);
|
TrainEnterDepot(v, tile);
|
||||||
v->tile = tile;
|
v->tile = tile;
|
||||||
|
@ -2114,7 +2112,7 @@ static uint32 VehicleEnter_Track(Vehicle *v, TileIndex tile, int x, int y)
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
} else if (fract_coord_leave == fract_coord) {
|
} else if (fract_coord_leave == fract_coord) {
|
||||||
if (_leave_directions[dir] == v->direction) {
|
if (DiagDirToDir(dir) == v->direction) {
|
||||||
/* leave the depot? */
|
/* leave the depot? */
|
||||||
if ((v = v->next) != NULL) {
|
if ((v = v->next) != NULL) {
|
||||||
v->vehstatus &= ~VS_HIDDEN;
|
v->vehstatus &= ~VS_HIDDEN;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
static RailType _cur_railtype;
|
static RailType _cur_railtype;
|
||||||
static bool _remove_button_clicked;
|
static bool _remove_button_clicked;
|
||||||
static byte _build_depot_direction;
|
static DiagDirection _build_depot_direction;
|
||||||
static byte _waypoint_count = 1;
|
static byte _waypoint_count = 1;
|
||||||
static byte _cur_waypoint_type;
|
static byte _cur_waypoint_type;
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ static const uint16 _place_depot_extra[12] = {
|
||||||
void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
if (success) {
|
if (success) {
|
||||||
int dir = p2;
|
DiagDirection dir = p2;
|
||||||
|
|
||||||
SndPlayTileFx(SND_20_SPLAT_2, tile);
|
SndPlayTileFx(SND_20_SPLAT_2, tile);
|
||||||
ResetObjectToPlace();
|
ResetObjectToPlace();
|
||||||
|
@ -901,7 +901,7 @@ static void ShowBuildWaypointPicker(void)
|
||||||
|
|
||||||
void InitializeRailGui(void)
|
void InitializeRailGui(void)
|
||||||
{
|
{
|
||||||
_build_depot_direction = 3;
|
_build_depot_direction = DIAGDIR_NW;
|
||||||
_railstation.numtracks = 1;
|
_railstation.numtracks = 1;
|
||||||
_railstation.platlength = 1;
|
_railstation.platlength = 1;
|
||||||
_railstation.dragdrop = true;
|
_railstation.dragdrop = true;
|
||||||
|
|
|
@ -60,7 +60,7 @@ static const uint16 _road_pf_table_3[4] = {
|
||||||
0x910, 0x1600, 0x2005, 0x2A
|
0x910, 0x1600, 0x2005, 0x2A
|
||||||
};
|
};
|
||||||
|
|
||||||
int GetRoadVehImage(const Vehicle *v, byte direction)
|
int GetRoadVehImage(const Vehicle* v, Direction direction)
|
||||||
{
|
{
|
||||||
int img = v->spritenum;
|
int img = v->spritenum;
|
||||||
int image;
|
int image;
|
||||||
|
@ -718,7 +718,7 @@ typedef struct RoadVehFindData {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
const Vehicle* veh;
|
const Vehicle* veh;
|
||||||
byte dir;
|
Direction dir;
|
||||||
} RoadVehFindData;
|
} RoadVehFindData;
|
||||||
|
|
||||||
static void* EnumCheckRoadVehClose(Vehicle *v, void* data)
|
static void* EnumCheckRoadVehClose(Vehicle *v, void* data)
|
||||||
|
@ -744,7 +744,7 @@ static void* EnumCheckRoadVehClose(Vehicle *v, void* data)
|
||||||
v : NULL;
|
v : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vehicle *RoadVehFindCloseTo(Vehicle *v, int x, int y, byte dir)
|
static Vehicle* RoadVehFindCloseTo(Vehicle* v, int x, int y, Direction dir)
|
||||||
{
|
{
|
||||||
RoadVehFindData rvf;
|
RoadVehFindData rvf;
|
||||||
Vehicle *u;
|
Vehicle *u;
|
||||||
|
@ -833,12 +833,12 @@ static bool RoadVehAccelerate(Vehicle *v)
|
||||||
return (t < v->progress);
|
return (t < v->progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
static byte RoadVehGetNewDirection(Vehicle *v, int x, int y)
|
static Direction RoadVehGetNewDirection(const Vehicle* v, int x, int y)
|
||||||
{
|
{
|
||||||
static const byte _roadveh_new_dir[11] = {
|
static const Direction _roadveh_new_dir[] = {
|
||||||
0, 7, 6, 0,
|
DIR_N , DIR_NW, DIR_W , 0,
|
||||||
1, 0, 5, 0,
|
DIR_NE, DIR_N , DIR_SW, 0,
|
||||||
2, 3, 4
|
DIR_E , DIR_SE, DIR_S
|
||||||
};
|
};
|
||||||
|
|
||||||
x = x - v->x_pos + 1;
|
x = x - v->x_pos + 1;
|
||||||
|
@ -848,10 +848,11 @@ static byte RoadVehGetNewDirection(Vehicle *v, int x, int y)
|
||||||
return _roadveh_new_dir[y * 4 + x];
|
return _roadveh_new_dir[y * 4 + x];
|
||||||
}
|
}
|
||||||
|
|
||||||
static byte RoadVehGetSlidingDirection(Vehicle *v, int x, int y)
|
static Direction RoadVehGetSlidingDirection(const Vehicle* v, int x, int y)
|
||||||
{
|
{
|
||||||
byte b = RoadVehGetNewDirection(v, x, y);
|
Direction b = RoadVehGetNewDirection(v, x, y);
|
||||||
byte d = v->direction;
|
Direction d = v->direction;
|
||||||
|
|
||||||
if (b == d) return d;
|
if (b == d) return d;
|
||||||
d = (d + 1) & 7;
|
d = (d + 1) & 7;
|
||||||
if (b == d) return d;
|
if (b == d) return d;
|
||||||
|
@ -980,7 +981,7 @@ static bool EnumRoadTrackFindDist(TileIndex tile, void* data, int track, uint le
|
||||||
|
|
||||||
// Returns direction to choose
|
// Returns direction to choose
|
||||||
// or -1 if the direction is currently blocked
|
// or -1 if the direction is currently blocked
|
||||||
static int RoadFindPathToDest(Vehicle *v, TileIndex tile, int enterdir)
|
static int RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection enterdir)
|
||||||
{
|
{
|
||||||
#define return_track(x) {best_track = x; goto found_best_track; }
|
#define return_track(x) {best_track = x; goto found_best_track; }
|
||||||
|
|
||||||
|
@ -1154,7 +1155,8 @@ static const byte _roadveh_data_2[4] = { 0,1,8,9 };
|
||||||
|
|
||||||
static void RoadVehController(Vehicle *v)
|
static void RoadVehController(Vehicle *v)
|
||||||
{
|
{
|
||||||
byte new_dir, old_dir;
|
Direction new_dir;
|
||||||
|
Direction old_dir;
|
||||||
RoadDriveEntry rd;
|
RoadDriveEntry rd;
|
||||||
int x,y;
|
int x,y;
|
||||||
uint32 r;
|
uint32 r;
|
||||||
|
@ -1273,7 +1275,7 @@ static void RoadVehController(Vehicle *v)
|
||||||
TileIndex tile = v->tile + TileOffsByDir(rd.x & 3);
|
TileIndex tile = v->tile + TileOffsByDir(rd.x & 3);
|
||||||
int dir = RoadFindPathToDest(v, tile, rd.x & 3);
|
int dir = RoadFindPathToDest(v, tile, rd.x & 3);
|
||||||
uint32 r;
|
uint32 r;
|
||||||
byte newdir;
|
Direction newdir;
|
||||||
const RoadDriveEntry *rdp;
|
const RoadDriveEntry *rdp;
|
||||||
|
|
||||||
if (dir == -1) {
|
if (dir == -1) {
|
||||||
|
@ -1339,7 +1341,7 @@ again:
|
||||||
int dir = RoadFindPathToDest(v, v->tile, rd.x & 3);
|
int dir = RoadFindPathToDest(v, v->tile, rd.x & 3);
|
||||||
uint32 r;
|
uint32 r;
|
||||||
int tmp;
|
int tmp;
|
||||||
byte newdir;
|
Direction newdir;
|
||||||
const RoadDriveEntry *rdp;
|
const RoadDriveEntry *rdp;
|
||||||
|
|
||||||
if (dir == -1) {
|
if (dir == -1) {
|
||||||
|
|
|
@ -65,7 +65,7 @@ void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number)
|
||||||
static void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection)
|
static void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection)
|
||||||
{
|
{
|
||||||
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
|
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
|
||||||
DrawSprite(GetRoadVehImage(v, 6) | pal, x + 14, y + 6);
|
DrawSprite(GetRoadVehImage(v, DIR_W) | pal, x + 14, y + 6);
|
||||||
|
|
||||||
if (v->index == selection) {
|
if (v->index == selection) {
|
||||||
DrawFrameRect(x - 1, y - 1, x + 28, y + 12, 15, FR_BORDERONLY);
|
DrawFrameRect(x - 1, y - 1, x + 28, y + 12, 15, FR_BORDERONLY);
|
||||||
|
@ -636,7 +636,7 @@ static void RoadDepotClickVeh(Window *w, int x, int y)
|
||||||
if (v != NULL) {
|
if (v != NULL) {
|
||||||
WP(w,traindepot_d).sel = v->index;
|
WP(w,traindepot_d).sel = v->index;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
SetObjectToPlaceWnd(GetVehiclePalette(v) | GetRoadVehImage(v, 6), 4, w);
|
SetObjectToPlaceWnd(GetVehiclePalette(v) | GetRoadVehImage(v, DIR_W), 4, w);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
27
ship_cmd.c
27
ship_cmd.c
|
@ -44,7 +44,7 @@ void DrawShipEngine(int x, int y, EngineID engine, uint32 image_ormod)
|
||||||
DrawSprite((6 + _ship_sprites[spritenum]) | image_ormod, x, y);
|
DrawSprite((6 + _ship_sprites[spritenum]) | image_ormod, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetShipImage(const Vehicle *v, byte direction)
|
int GetShipImage(const Vehicle* v, Direction direction)
|
||||||
{
|
{
|
||||||
int spritenum = v->spritenum;
|
int spritenum = v->spritenum;
|
||||||
|
|
||||||
|
@ -579,10 +579,10 @@ static int ChooseShipTrack(Vehicle *v, TileIndex tile, int enterdir, uint tracks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const byte _new_vehicle_direction_table[11] = {
|
static const Direction _new_vehicle_direction_table[] = {
|
||||||
0, 7, 6, 0,
|
DIR_N , DIR_NW, DIR_W , 0,
|
||||||
1, 0, 5, 0,
|
DIR_NE, DIR_N , DIR_SW, 0,
|
||||||
2, 3, 4,
|
DIR_E , DIR_SE, DIR_S
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ShipGetNewDirectionFromTiles(TileIndex new_tile, TileIndex old_tile)
|
static int ShipGetNewDirectionFromTiles(TileIndex new_tile, TileIndex old_tile)
|
||||||
|
@ -646,7 +646,9 @@ static void ShipController(Vehicle *v)
|
||||||
GetNewVehiclePosResult gp;
|
GetNewVehiclePosResult gp;
|
||||||
uint32 r;
|
uint32 r;
|
||||||
const byte *b;
|
const byte *b;
|
||||||
int dir,track,tracks;
|
Direction dir;
|
||||||
|
int track;
|
||||||
|
int tracks;
|
||||||
|
|
||||||
v->tick_counter++;
|
v->tick_counter++;
|
||||||
|
|
||||||
|
@ -736,23 +738,24 @@ static void ShipController(Vehicle *v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
DiagDirection diagdir;
|
||||||
// new tile
|
// new tile
|
||||||
if (TileX(gp.new_tile) >= MapMaxX() || TileY(gp.new_tile) >= MapMaxY())
|
if (TileX(gp.new_tile) >= MapMaxX() || TileY(gp.new_tile) >= MapMaxY())
|
||||||
goto reverse_direction;
|
goto reverse_direction;
|
||||||
|
|
||||||
dir = ShipGetNewDirectionFromTiles(gp.new_tile, gp.old_tile);
|
dir = ShipGetNewDirectionFromTiles(gp.new_tile, gp.old_tile);
|
||||||
assert(dir == 1 || dir == 3 || dir == 5 || dir == 7);
|
assert(dir == DIR_NE || dir == DIR_SE || dir == DIR_SW || dir == DIR_NW);
|
||||||
dir>>=1;
|
diagdir = DirToDiagDir(dir);
|
||||||
tracks = GetAvailShipTracks(gp.new_tile, dir);
|
tracks = GetAvailShipTracks(gp.new_tile, diagdir);
|
||||||
if (tracks == 0)
|
if (tracks == 0)
|
||||||
goto reverse_direction;
|
goto reverse_direction;
|
||||||
|
|
||||||
// Choose a direction, and continue if we find one
|
// Choose a direction, and continue if we find one
|
||||||
track = ChooseShipTrack(v, gp.new_tile, dir, tracks);
|
track = ChooseShipTrack(v, gp.new_tile, diagdir, tracks);
|
||||||
if (track < 0)
|
if (track < 0)
|
||||||
goto reverse_direction;
|
goto reverse_direction;
|
||||||
|
|
||||||
b = _ship_subcoord[dir][track];
|
b = _ship_subcoord[diagdir][track];
|
||||||
|
|
||||||
gp.x = (gp.x&~0xF) | b[0];
|
gp.x = (gp.x&~0xF) | b[0];
|
||||||
gp.y = (gp.y&~0xF) | b[1];
|
gp.y = (gp.y&~0xF) | b[1];
|
||||||
|
@ -783,7 +786,7 @@ getout:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
reverse_direction:
|
reverse_direction:
|
||||||
dir = v->direction ^ 4;
|
dir = ReverseDir(v->direction);
|
||||||
v->direction = dir;
|
v->direction = dir;
|
||||||
goto getout;
|
goto getout;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ void DrawShipPurchaseInfo(int x, int y, EngineID engine_number)
|
||||||
|
|
||||||
static void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection)
|
static void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection)
|
||||||
{
|
{
|
||||||
DrawSprite(GetShipImage(v, 6) | GetVehiclePalette(v), x + 32, y + 10);
|
DrawSprite(GetShipImage(v, DIR_W) | GetVehiclePalette(v), x + 32, y + 10);
|
||||||
|
|
||||||
if (v->index == selection) {
|
if (v->index == selection) {
|
||||||
DrawFrameRect(x - 5, y - 1, x + 67, y + 21, 15, FR_BORDERONLY);
|
DrawFrameRect(x - 5, y - 1, x + 67, y + 21, 15, FR_BORDERONLY);
|
||||||
|
@ -713,7 +713,7 @@ static void ShipDepotClick(Window *w, int x, int y)
|
||||||
if (v != NULL) {
|
if (v != NULL) {
|
||||||
WP(w,traindepot_d).sel = v->index;
|
WP(w,traindepot_d).sel = v->index;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
SetObjectToPlaceWnd(GetVehiclePalette(v) | GetShipImage(v, 6), 4, w);
|
SetObjectToPlaceWnd(GetVehiclePalette(v) | GetShipImage(v, DIR_W), 4, w);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -817,7 +817,7 @@ int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invali
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool CanExpandRailroadStation(Station *st, uint *fin, int direction)
|
static bool CanExpandRailroadStation(Station* st, uint* fin, Axis axis)
|
||||||
{
|
{
|
||||||
uint curw = st->trainst_w, curh = st->trainst_h;
|
uint curw = st->trainst_w, curh = st->trainst_h;
|
||||||
TileIndex tile = fin[0];
|
TileIndex tile = fin[0];
|
||||||
|
@ -832,8 +832,8 @@ static bool CanExpandRailroadStation(Station *st, uint *fin, int direction)
|
||||||
curh = max(TileY(st->train_tile) + curh, TileY(tile) + h) - y;
|
curh = max(TileY(st->train_tile) + curh, TileY(tile) + h) - y;
|
||||||
tile = TileXY(x, y);
|
tile = TileXY(x, y);
|
||||||
} else {
|
} else {
|
||||||
// check so the direction is the same
|
// check so the orientation is the same
|
||||||
if ((_m[st->train_tile].m5 & 1) != direction) {
|
if ((_m[st->train_tile].m5 & 1U) != axis) {
|
||||||
_error_message = STR_306D_NONUNIFORM_STATIONS_DISALLOWED;
|
_error_message = STR_306D_NONUNIFORM_STATIONS_DISALLOWED;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -934,7 +934,7 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
int32 cost, ret;
|
int32 cost, ret;
|
||||||
StationID est;
|
StationID est;
|
||||||
int plat_len, numtracks;
|
int plat_len, numtracks;
|
||||||
int direction;
|
Axis axis;
|
||||||
uint finalvalues[3];
|
uint finalvalues[3];
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
@ -946,16 +946,16 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
if (!ValParamRailtype(p2 & 0xF)) return CMD_ERROR;
|
if (!ValParamRailtype(p2 & 0xF)) return CMD_ERROR;
|
||||||
|
|
||||||
/* unpack parameters */
|
/* unpack parameters */
|
||||||
direction = p1 & 1;
|
axis = p1 & 1;
|
||||||
numtracks = GB(p1, 8, 8);
|
numtracks = GB(p1, 8, 8);
|
||||||
plat_len = GB(p1, 16, 8);
|
plat_len = GB(p1, 16, 8);
|
||||||
/* w = length, h = num_tracks */
|
/* w = length, h = num_tracks */
|
||||||
if (direction) {
|
if (axis == AXIS_X) {
|
||||||
h_org = plat_len;
|
|
||||||
w_org = numtracks;
|
|
||||||
} else {
|
|
||||||
w_org = plat_len;
|
w_org = plat_len;
|
||||||
h_org = numtracks;
|
h_org = numtracks;
|
||||||
|
} else {
|
||||||
|
h_org = plat_len;
|
||||||
|
w_org = numtracks;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h_org > _patches.station_spread || w_org > _patches.station_spread) return CMD_ERROR;
|
if (h_org > _patches.station_spread || w_org > _patches.station_spread) return CMD_ERROR;
|
||||||
|
@ -969,7 +969,7 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
est = INVALID_STATION;
|
est = INVALID_STATION;
|
||||||
// If DC_EXEC is in flag, do not want to pass it to CheckFlatLandBelow, because of a nice bug
|
// If DC_EXEC is in flag, do not want to pass it to CheckFlatLandBelow, because of a nice bug
|
||||||
// for detail info, see: https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365
|
// for detail info, see: https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365
|
||||||
if (CmdFailed(ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags&~DC_EXEC, 5 << direction, _patches.nonuniform_stations ? &est : NULL))) return CMD_ERROR;
|
if (CmdFailed(ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags&~DC_EXEC, 5 << axis, _patches.nonuniform_stations ? &est : NULL))) return CMD_ERROR;
|
||||||
cost = ret + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len;
|
cost = ret + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len;
|
||||||
|
|
||||||
// Make sure there are no similar stations around us.
|
// Make sure there are no similar stations around us.
|
||||||
|
@ -991,7 +991,7 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
// check if we want to expanding an already existing station?
|
// check if we want to expanding an already existing station?
|
||||||
if (_is_old_ai_player || !_patches.join_stations)
|
if (_is_old_ai_player || !_patches.join_stations)
|
||||||
return_cmd_error(STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD);
|
return_cmd_error(STR_3005_TOO_CLOSE_TO_ANOTHER_RAILROAD);
|
||||||
if (!CanExpandRailroadStation(st, finalvalues, direction))
|
if (!CanExpandRailroadStation(st, finalvalues, axis))
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,7 +1021,7 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
// Now really clear the land below the station
|
// Now really clear the land below the station
|
||||||
// It should never return CMD_ERROR.. but you never know ;)
|
// It should never return CMD_ERROR.. but you never know ;)
|
||||||
// (a bit strange function name for it, but it really does clear the land, when DC_EXEC is in flags)
|
// (a bit strange function name for it, but it really does clear the land, when DC_EXEC is in flags)
|
||||||
if (CmdFailed(CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << direction, _patches.nonuniform_stations ? &est : NULL))) return CMD_ERROR;
|
if (CmdFailed(CheckFlatLandBelow(tile_org, w_org, h_org, flags, 5 << axis, _patches.nonuniform_stations ? &est : NULL))) return CMD_ERROR;
|
||||||
|
|
||||||
st->train_tile = finalvalues[0];
|
st->train_tile = finalvalues[0];
|
||||||
if (!st->facilities) st->xy = finalvalues[0];
|
if (!st->facilities) st->xy = finalvalues[0];
|
||||||
|
@ -1033,8 +1033,8 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
st->build_date = _date;
|
st->build_date = _date;
|
||||||
|
|
||||||
tile_delta = direction ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
|
tile_delta = (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||||
track = direction ? TRACK_Y : TRACK_X;
|
track = (axis == AXIS_X ? TRACK_X : TRACK_Y);
|
||||||
|
|
||||||
statspec = (p2 & 0x10) != 0 ? GetCustomStation(STAT_CLASS_DFLT, p2 >> 8) : NULL;
|
statspec = (p2 & 0x10) != 0 ? GetCustomStation(STAT_CLASS_DFLT, p2 >> 8) : NULL;
|
||||||
layout_ptr = alloca(numtracks * plat_len);
|
layout_ptr = alloca(numtracks * plat_len);
|
||||||
|
@ -1051,7 +1051,7 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
station_index, /* map2 parameter */
|
station_index, /* map2 parameter */
|
||||||
p2 & 0xFF, /* map3lo parameter */
|
p2 & 0xFF, /* map3lo parameter */
|
||||||
p2 >> 8, /* map3hi parameter */
|
p2 >> 8, /* map3hi parameter */
|
||||||
(*layout_ptr++) + direction /* map5 parameter */
|
(*layout_ptr++) + axis /* map5 parameter */
|
||||||
);
|
);
|
||||||
|
|
||||||
tile += tile_delta;
|
tile += tile_delta;
|
||||||
|
@ -1172,27 +1172,27 @@ uint GetStationPlatforms(const Station *st, TileIndex tile)
|
||||||
{
|
{
|
||||||
TileIndex t;
|
TileIndex t;
|
||||||
TileIndexDiff delta;
|
TileIndexDiff delta;
|
||||||
int dir;
|
Axis dir;
|
||||||
uint len;
|
uint len;
|
||||||
assert(TileBelongsToRailStation(st, tile));
|
assert(TileBelongsToRailStation(st, tile));
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
dir = _m[tile].m5 & 1;
|
dir = _m[tile].m5 & 1;
|
||||||
delta = dir ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
|
delta = (dir == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||||
|
|
||||||
// find starting tile..
|
// find starting tile..
|
||||||
t = tile;
|
t = tile;
|
||||||
do {
|
do {
|
||||||
t -= delta;
|
t -= delta;
|
||||||
len++;
|
len++;
|
||||||
} while (TileBelongsToRailStation(st, t) && (_m[t].m5 & 1) == dir);
|
} while (TileBelongsToRailStation(st, t) && (_m[t].m5 & 1U) == dir);
|
||||||
|
|
||||||
// find ending tile
|
// find ending tile
|
||||||
t = tile;
|
t = tile;
|
||||||
do {
|
do {
|
||||||
t += delta;
|
t += delta;
|
||||||
len++;
|
len++;
|
||||||
} while (TileBelongsToRailStation(st, t) && (_m[t].m5 & 1) == dir);
|
} while (TileBelongsToRailStation(st, t) && (_m[t].m5 & 1U) == dir);
|
||||||
|
|
||||||
return len - 1;
|
return len - 1;
|
||||||
}
|
}
|
||||||
|
@ -1806,17 +1806,17 @@ int32 CmdBuildDock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
TileIndex tile = TileVirtXY(x, y);
|
TileIndex tile = TileVirtXY(x, y);
|
||||||
TileIndex tile_cur;
|
TileIndex tile_cur;
|
||||||
int direction;
|
DiagDirection direction;
|
||||||
int32 cost;
|
int32 cost;
|
||||||
Station *st;
|
Station *st;
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
switch (GetTileSlope(tile, NULL)) {
|
switch (GetTileSlope(tile, NULL)) {
|
||||||
case 3: direction = 0; break;
|
case 3: direction = DIAGDIR_NE; break;
|
||||||
case 6: direction = 3; break;
|
case 6: direction = DIAGDIR_NW; break;
|
||||||
case 9: direction = 1; break;
|
case 9: direction = DIAGDIR_SE; break;
|
||||||
case 12: direction = 2; break;
|
case 12: direction = DIAGDIR_SW; break;
|
||||||
default: return_cmd_error(STR_304B_SITE_UNSUITABLE);
|
default: return_cmd_error(STR_304B_SITE_UNSUITABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1898,7 +1898,8 @@ int32 CmdBuildDock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
MP_MAP2 | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR |
|
MP_MAP2 | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR |
|
||||||
MP_MAP5,
|
MP_MAP5,
|
||||||
st->index,
|
st->index,
|
||||||
(direction&1) + 0x50);
|
DiagDirToAxis(direction) + 0x50
|
||||||
|
);
|
||||||
|
|
||||||
UpdateStationVirtCoordDirty(st);
|
UpdateStationVirtCoordDirty(st);
|
||||||
UpdateStationAcceptance(st, false);
|
UpdateStationAcceptance(st, false);
|
||||||
|
|
34
train_cmd.c
34
train_cmd.c
|
@ -239,8 +239,8 @@ static int GetTrainAcceleration(Vehicle *v, bool mode)
|
||||||
|
|
||||||
//first find the curve speed limit
|
//first find the curve speed limit
|
||||||
for (u = v; u->next != NULL; u = u->next, pos++) {
|
for (u = v; u->next != NULL; u = u->next, pos++) {
|
||||||
int dir = u->direction;
|
Direction dir = u->direction;
|
||||||
int ndir = u->next->direction;
|
Direction ndir = u->next->direction;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
|
@ -373,7 +373,7 @@ static void UpdateTrainAcceleration(Vehicle* v)
|
||||||
v->acceleration = clamp(power / weight * 4, 1, 255);
|
v->acceleration = clamp(power / weight * 4, 1, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetTrainImage(const Vehicle *v, byte direction)
|
int GetTrainImage(const Vehicle* v, Direction direction)
|
||||||
{
|
{
|
||||||
int img = v->spritenum;
|
int img = v->spritenum;
|
||||||
int base;
|
int base;
|
||||||
|
@ -1444,8 +1444,8 @@ static void ReverseTrainSwapVeh(Vehicle *v, int l, int r)
|
||||||
swap_byte(&a->direction, &b->direction);
|
swap_byte(&a->direction, &b->direction);
|
||||||
|
|
||||||
/* toggle direction */
|
/* toggle direction */
|
||||||
if (!(a->u.rail.track & 0x80)) a->direction ^= 4;
|
if (!(a->u.rail.track & 0x80)) a->direction = ReverseDir(a->direction);
|
||||||
if (!(b->u.rail.track & 0x80)) b->direction ^= 4;
|
if (!(b->u.rail.track & 0x80)) b->direction = ReverseDir(b->direction);
|
||||||
|
|
||||||
/* swap more variables */
|
/* swap more variables */
|
||||||
swap_int32(&a->x_pos, &b->x_pos);
|
swap_int32(&a->x_pos, &b->x_pos);
|
||||||
|
@ -1462,7 +1462,7 @@ static void ReverseTrainSwapVeh(Vehicle *v, int l, int r)
|
||||||
VehicleEnterTile(a, a->tile, a->x_pos, a->y_pos);
|
VehicleEnterTile(a, a->tile, a->x_pos, a->y_pos);
|
||||||
VehicleEnterTile(b, b->tile, b->x_pos, b->y_pos);
|
VehicleEnterTile(b, b->tile, b->x_pos, b->y_pos);
|
||||||
} else {
|
} else {
|
||||||
if (!(a->u.rail.track & 0x80)) a->direction ^= 4;
|
if (!(a->u.rail.track & 0x80)) a->direction = ReverseDir(a->direction);
|
||||||
UpdateVarsAfterSwap(a);
|
UpdateVarsAfterSwap(a);
|
||||||
|
|
||||||
VehicleEnterTile(a, a->tile, a->x_pos, a->y_pos);
|
VehicleEnterTile(a, a->tile, a->x_pos, a->y_pos);
|
||||||
|
@ -2492,10 +2492,10 @@ static byte AfterSetTrainPos(Vehicle *v, bool new_tile)
|
||||||
return old_z;
|
return old_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const byte _new_vehicle_direction_table[11] = {
|
static const Direction _new_vehicle_direction_table[11] = {
|
||||||
0, 7, 6, 0,
|
DIR_N , DIR_NW, DIR_W , 0,
|
||||||
1, 0, 5, 0,
|
DIR_NE, DIR_N , DIR_SW, 0,
|
||||||
2, 3, 4,
|
DIR_E , DIR_SE, DIR_S
|
||||||
};
|
};
|
||||||
|
|
||||||
static Direction GetNewVehicleDirectionByTile(TileIndex new_tile, TileIndex old_tile)
|
static Direction GetNewVehicleDirectionByTile(TileIndex new_tile, TileIndex old_tile)
|
||||||
|
@ -2589,7 +2589,7 @@ static const RailtypeSlowdownParams _railtype_slowdown[3] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Modify the speed of the vehicle due to a turn */
|
/* Modify the speed of the vehicle due to a turn */
|
||||||
static void AffectSpeedByDirChange(Vehicle *v, byte new_dir)
|
static void AffectSpeedByDirChange(Vehicle* v, Direction new_dir)
|
||||||
{
|
{
|
||||||
byte diff;
|
byte diff;
|
||||||
const RailtypeSlowdownParams *rsp;
|
const RailtypeSlowdownParams *rsp;
|
||||||
|
@ -2617,9 +2617,9 @@ static void AffectSpeedByZChange(Vehicle *v, byte old_z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const byte _otherside_signal_directions[14] = {
|
static const Direction _otherside_signal_directions[] = {
|
||||||
1, 3, 1, 3, 5, 3, 0, 0,
|
DIR_NE, DIR_SE, DIR_NE, DIR_SE, DIR_SW, DIR_SE, 0, 0,
|
||||||
5, 7, 7, 5, 7, 1,
|
DIR_SW, DIR_NW, DIR_NW, DIR_SW, DIR_NW, DIR_NE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void TrainMovedChangeSignals(TileIndex tile, DiagDirection dir)
|
static void TrainMovedChangeSignals(TileIndex tile, DiagDirection dir)
|
||||||
|
@ -2732,7 +2732,7 @@ static void CheckTrainCollision(Vehicle *v)
|
||||||
|
|
||||||
typedef struct VehicleAtSignalData {
|
typedef struct VehicleAtSignalData {
|
||||||
TileIndex tile;
|
TileIndex tile;
|
||||||
byte direction;
|
Direction direction;
|
||||||
} VehicleAtSignalData;
|
} VehicleAtSignalData;
|
||||||
|
|
||||||
static void *CheckVehicleAtSignal(Vehicle *v, void *data)
|
static void *CheckVehicleAtSignal(Vehicle *v, void *data)
|
||||||
|
@ -2757,7 +2757,7 @@ static void TrainController(Vehicle *v)
|
||||||
DiagDirection enterdir;
|
DiagDirection enterdir;
|
||||||
Direction dir;
|
Direction dir;
|
||||||
Direction newdir;
|
Direction newdir;
|
||||||
byte chosen_dir;
|
Direction chosen_dir;
|
||||||
byte chosen_track;
|
byte chosen_track;
|
||||||
byte old_z;
|
byte old_z;
|
||||||
|
|
||||||
|
@ -2938,7 +2938,7 @@ red_light: {
|
||||||
TileIndex o_tile = gp.new_tile + TileOffsByDir(enterdir);
|
TileIndex o_tile = gp.new_tile + TileOffsByDir(enterdir);
|
||||||
VehicleAtSignalData vasd;
|
VehicleAtSignalData vasd;
|
||||||
vasd.tile = o_tile;
|
vasd.tile = o_tile;
|
||||||
vasd.direction = dir ^ 4;
|
vasd.direction = ReverseDir(dir);
|
||||||
|
|
||||||
/* check if a train is waiting on the other side */
|
/* check if a train is waiting on the other side */
|
||||||
if (VehicleFromPos(o_tile, &vasd, CheckVehicleAtSignal) == NULL) return;
|
if (VehicleFromPos(o_tile, &vasd, CheckVehicleAtSignal) == NULL) return;
|
||||||
|
|
|
@ -362,7 +362,7 @@ static void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip,
|
||||||
|
|
||||||
if (dx + width <= count) {
|
if (dx + width <= count) {
|
||||||
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
|
PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
|
||||||
DrawSprite(GetTrainImage(v, 6) | pal, x + 14 + WagonLengthToPixels(dx), y + 6 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
|
DrawSprite(GetTrainImage(v, DIR_W) | pal, x + 14 + WagonLengthToPixels(dx), y + 6 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
|
||||||
if (v->index == selection)
|
if (v->index == selection)
|
||||||
DrawFrameRect(x - 1 + WagonLengthToPixels(dx), y - 1, x + WagonLengthToPixels(dx + width) - 1, y + 12, 15, FR_BORDERONLY);
|
DrawFrameRect(x - 1 + WagonLengthToPixels(dx), y - 1, x + WagonLengthToPixels(dx + width) - 1, y + 12, 15, FR_BORDERONLY);
|
||||||
}
|
}
|
||||||
|
@ -577,7 +577,7 @@ static void TrainDepotClickTrain(Window *w, int x, int y)
|
||||||
TrainDepotMoveVehicle(v, sel, gdvp.head);
|
TrainDepotMoveVehicle(v, sel, gdvp.head);
|
||||||
} else if (v != NULL) {
|
} else if (v != NULL) {
|
||||||
WP(w,traindepot_d).sel = v->index;
|
WP(w,traindepot_d).sel = v->index;
|
||||||
SetObjectToPlaceWnd(GetVehiclePalette(v) | GetTrainImage(v, 6), 4, w);
|
SetObjectToPlaceWnd(GetVehiclePalette(v) | GetTrainImage(v, DIR_W), 4, w);
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -119,7 +119,7 @@ static inline int GetBridgeType(TileIndex tile)
|
||||||
* is_start_tile = false <-- end tile
|
* is_start_tile = false <-- end tile
|
||||||
* is_start_tile = true <-- start tile
|
* is_start_tile = true <-- start tile
|
||||||
*/
|
*/
|
||||||
static uint32 CheckBridgeSlope(uint direction, uint tileh, bool is_start_tile)
|
static uint32 CheckBridgeSlope(Axis direction, uint tileh, bool is_start_tile)
|
||||||
{
|
{
|
||||||
if (IsSteepTileh(tileh)) return CMD_ERROR;
|
if (IsSteepTileh(tileh)) return CMD_ERROR;
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ static uint32 CheckBridgeSlope(uint direction, uint tileh, bool is_start_tile)
|
||||||
- direction X: tiles 0, 12
|
- direction X: tiles 0, 12
|
||||||
- direction Y: tiles 0, 9
|
- direction Y: tiles 0, 9
|
||||||
*/
|
*/
|
||||||
if ((direction ? 0x201 : 0x1001) & (1 << tileh)) return 0;
|
if ((direction == AXIS_X ? 0x1001 : 0x201) & (1 << tileh)) return 0;
|
||||||
|
|
||||||
// disallow certain start tiles to avoid certain crooked bridges
|
// disallow certain start tiles to avoid certain crooked bridges
|
||||||
if (tileh == 2) return CMD_ERROR;
|
if (tileh == 2) return CMD_ERROR;
|
||||||
|
@ -139,7 +139,7 @@ static uint32 CheckBridgeSlope(uint direction, uint tileh, bool is_start_tile)
|
||||||
- direction X: tiles 0, 3
|
- direction X: tiles 0, 3
|
||||||
- direction Y: tiles 0, 6
|
- direction Y: tiles 0, 6
|
||||||
*/
|
*/
|
||||||
if ((direction? 0x41 : 0x9) & (1 << tileh)) return 0;
|
if ((direction == AXIS_X ? 0x9 : 0x41) & (1 << tileh)) return 0;
|
||||||
|
|
||||||
// disallow certain end tiles to avoid certain crooked bridges
|
// disallow certain end tiles to avoid certain crooked bridges
|
||||||
if (tileh == 8) return CMD_ERROR;
|
if (tileh == 8) return CMD_ERROR;
|
||||||
|
@ -149,8 +149,8 @@ static uint32 CheckBridgeSlope(uint direction, uint tileh, bool is_start_tile)
|
||||||
* start-tile: X 2,1 Y 2,4 (2 was disabled before)
|
* start-tile: X 2,1 Y 2,4 (2 was disabled before)
|
||||||
* end-tile: X 8,4 Y 8,1 (8 was disabled before)
|
* end-tile: X 8,4 Y 8,1 (8 was disabled before)
|
||||||
*/
|
*/
|
||||||
if ((tileh == 1 && is_start_tile != (bool)direction) ||
|
if ((tileh == 1 && is_start_tile != (direction != AXIS_X)) ||
|
||||||
(tileh == 4 && is_start_tile == (bool)direction)) {
|
(tileh == 4 && is_start_tile == (direction != AXIS_X))) {
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
TileInfo ti_start, ti_end, ti; /* OPT: only 2 of those are ever used */
|
TileInfo ti_start, ti_end, ti; /* OPT: only 2 of those are ever used */
|
||||||
uint bridge_len;
|
uint bridge_len;
|
||||||
uint odd_middle_part;
|
uint odd_middle_part;
|
||||||
uint direction;
|
Axis direction;
|
||||||
uint i;
|
uint i;
|
||||||
int32 cost, terraformcost, ret;
|
int32 cost, terraformcost, ret;
|
||||||
bool allow_on_slopes;
|
bool allow_on_slopes;
|
||||||
|
@ -225,17 +225,16 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
sx = TileX(p1) * 16;
|
sx = TileX(p1) * 16;
|
||||||
sy = TileY(p1) * 16;
|
sy = TileY(p1) * 16;
|
||||||
|
|
||||||
direction = 0;
|
|
||||||
|
|
||||||
/* check if valid, and make sure that (x,y) are smaller than (sx,sy) */
|
/* check if valid, and make sure that (x,y) are smaller than (sx,sy) */
|
||||||
if (x == sx) {
|
if (x == sx) {
|
||||||
if (y == sy) return_cmd_error(STR_5008_CANNOT_START_AND_END_ON);
|
if (y == sy) return_cmd_error(STR_5008_CANNOT_START_AND_END_ON);
|
||||||
direction = 1;
|
direction = AXIS_Y;
|
||||||
if (y > sy) {
|
if (y > sy) {
|
||||||
intswap(y,sy);
|
intswap(y,sy);
|
||||||
intswap(x,sx);
|
intswap(x,sx);
|
||||||
}
|
}
|
||||||
} else if (y == sy) {
|
} else if (y == sy) {
|
||||||
|
direction = AXIS_X;
|
||||||
if (x > sx) {
|
if (x > sx) {
|
||||||
intswap(y,sy);
|
intswap(y,sy);
|
||||||
intswap(x,sx);
|
intswap(x,sx);
|
||||||
|
@ -327,10 +326,10 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
odd_middle_part = (bridge_len % 2) ? (bridge_len / 2) : bridge_len;
|
odd_middle_part = (bridge_len % 2) ? (bridge_len / 2) : bridge_len;
|
||||||
|
|
||||||
for (i = 0; i != bridge_len; i++) {
|
for (i = 0; i != bridge_len; i++) {
|
||||||
if (direction != 0) {
|
if (direction == AXIS_X) {
|
||||||
y += 16;
|
|
||||||
} else {
|
|
||||||
x += 16;
|
x += 16;
|
||||||
|
} else {
|
||||||
|
y += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
FindLandscapeHeight(&ti, x, y);
|
FindLandscapeHeight(&ti, x, y);
|
||||||
|
@ -349,13 +348,15 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if (ti.map5 != (direction == 0 ? 2 : 1)) goto not_valid_below;
|
if (ti.map5 != (direction == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X)) {
|
||||||
|
goto not_valid_below;
|
||||||
|
}
|
||||||
m5 = 0xE0;
|
m5 = 0xE0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_STREET:
|
case MP_STREET:
|
||||||
if (GetRoadType(ti.tile) != ROAD_NORMAL ||
|
if (GetRoadType(ti.tile) != ROAD_NORMAL ||
|
||||||
GetRoadBits(ti.tile) != (direction == 0 ? ROAD_Y : ROAD_X)) {
|
GetRoadBits(ti.tile) != (direction == AXIS_X ? ROAD_Y : ROAD_X)) {
|
||||||
goto not_valid_below;
|
goto not_valid_below;
|
||||||
}
|
}
|
||||||
m5 = 0xE8;
|
m5 = 0xE8;
|
||||||
|
@ -408,7 +409,7 @@ not_valid_below:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSignalsOnBothDir(ti_start.tile, (direction & 1) ? 1 : 0);
|
SetSignalsOnBothDir(ti_start.tile, direction == AXIS_X ? TRACK_X : TRACK_Y);
|
||||||
|
|
||||||
/* for human player that builds the bridge he gets a selection to choose from bridges (DC_QUERY_COST)
|
/* for human player that builds the bridge he gets a selection to choose from bridges (DC_QUERY_COST)
|
||||||
It's unnecessary to execute this command every time for every bridge. So it is done only
|
It's unnecessary to execute this command every time for every bridge. So it is done only
|
||||||
|
@ -546,7 +547,6 @@ static int32 DoClearTunnel(TileIndex tile, uint32 flags)
|
||||||
Town *t;
|
Town *t;
|
||||||
TileIndex endtile;
|
TileIndex endtile;
|
||||||
uint length;
|
uint length;
|
||||||
static const byte _updsignals_tunnel_dir[4] = { 5, 7, 1, 3};
|
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
|
@ -574,8 +574,7 @@ static int32 DoClearTunnel(TileIndex tile, uint32 flags)
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
// We first need to request the direction before calling DoClearSquare
|
// We first need to request the direction before calling DoClearSquare
|
||||||
// else the direction is always 0.. dah!! ;)
|
// else the direction is always 0.. dah!! ;)
|
||||||
DiagDirection tile_dir = GetTunnelDirection(tile);
|
DiagDirection dir = GetTunnelDirection(tile);
|
||||||
DiagDirection endtile_dir = GetTunnelDirection(endtile);
|
|
||||||
|
|
||||||
// Adjust the town's player rating. Do this before removing the tile owner info.
|
// Adjust the town's player rating. Do this before removing the tile owner info.
|
||||||
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR)
|
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR)
|
||||||
|
@ -583,22 +582,22 @@ static int32 DoClearTunnel(TileIndex tile, uint32 flags)
|
||||||
|
|
||||||
DoClearSquare(tile);
|
DoClearSquare(tile);
|
||||||
DoClearSquare(endtile);
|
DoClearSquare(endtile);
|
||||||
UpdateSignalsOnSegment(tile, _updsignals_tunnel_dir[tile_dir]);
|
UpdateSignalsOnSegment(tile, DiagDirToDir(ReverseDiagDir(dir)));
|
||||||
UpdateSignalsOnSegment(endtile, _updsignals_tunnel_dir[endtile_dir]);
|
UpdateSignalsOnSegment(endtile, DiagDirToDir(dir));
|
||||||
}
|
}
|
||||||
return _price.clear_tunnel * (length + 1);
|
return _price.clear_tunnel * (length + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TileIndex FindEdgesOfBridge(TileIndex tile, TileIndex *endtile)
|
static TileIndex FindEdgesOfBridge(TileIndex tile, TileIndex *endtile)
|
||||||
{
|
{
|
||||||
int direction = GB(_m[tile].m5, 0, 1);
|
Axis direction = GB(_m[tile].m5, 0, 1);
|
||||||
TileIndex start;
|
TileIndex start;
|
||||||
|
|
||||||
// find start of bridge
|
// find start of bridge
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (IsTileType(tile, MP_TUNNELBRIDGE) && (_m[tile].m5 & 0xE0) == 0x80)
|
if (IsTileType(tile, MP_TUNNELBRIDGE) && (_m[tile].m5 & 0xE0) == 0x80)
|
||||||
break;
|
break;
|
||||||
tile += direction ? TileDiffXY(0, -1) : TileDiffXY(-1, 0);
|
tile += (direction == AXIS_X ? TileDiffXY(-1, 0) : TileDiffXY(0, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
start = tile;
|
start = tile;
|
||||||
|
@ -607,7 +606,7 @@ static TileIndex FindEdgesOfBridge(TileIndex tile, TileIndex *endtile)
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (IsTileType(tile, MP_TUNNELBRIDGE) && (_m[tile].m5 & 0xE0) == 0xA0)
|
if (IsTileType(tile, MP_TUNNELBRIDGE) && (_m[tile].m5 & 0xE0) == 0xA0)
|
||||||
break;
|
break;
|
||||||
tile += direction ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
|
tile += (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
*endtile = tile;
|
*endtile = tile;
|
||||||
|
@ -620,7 +619,7 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
|
||||||
TileIndex endtile;
|
TileIndex endtile;
|
||||||
Vehicle *v;
|
Vehicle *v;
|
||||||
Town *t;
|
Town *t;
|
||||||
int direction;
|
Axis direction;
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
|
@ -672,8 +671,8 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
|
||||||
Omit tile and endtile, since these are already checked, thus solving the problem
|
Omit tile and endtile, since these are already checked, thus solving the problem
|
||||||
of bridges over water, or higher bridges, where z is not increased, eg level bridge
|
of bridges over water, or higher bridges, where z is not increased, eg level bridge
|
||||||
*/
|
*/
|
||||||
tile += direction ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
|
tile += (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||||
endtile -= direction ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
|
endtile -= (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||||
/* Bridges on slopes might have their Z-value offset..correct this */
|
/* Bridges on slopes might have their Z-value offset..correct this */
|
||||||
v = FindVehicleBetween(tile, endtile, TilePixelHeight(tile) + 8 + GetCorrectTileHeight(tile));
|
v = FindVehicleBetween(tile, endtile, TilePixelHeight(tile) + 8 + GetCorrectTileHeight(tile));
|
||||||
if (v != NULL) {
|
if (v != NULL) {
|
||||||
|
@ -682,9 +681,8 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Put the tiles back to start/end position */
|
/* Put the tiles back to start/end position */
|
||||||
tile -= direction ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
|
tile -= (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||||
endtile += direction ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
|
endtile += (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||||
|
|
||||||
|
|
||||||
t = ClosestTownFromTile(tile, (uint)-1); //needed for town rating penalty
|
t = ClosestTownFromTile(tile, (uint)-1); //needed for town rating penalty
|
||||||
// check if you're allowed to remove the bridge owned by a town.
|
// check if you're allowed to remove the bridge owned by a town.
|
||||||
|
@ -726,17 +724,17 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
|
||||||
clear_it:;
|
clear_it:;
|
||||||
DoClearSquare(c);
|
DoClearSquare(c);
|
||||||
}
|
}
|
||||||
c += direction ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
|
c += (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||||
} while (c <= endtile);
|
} while (c <= endtile);
|
||||||
|
|
||||||
SetSignalsOnBothDir(tile, direction);
|
SetSignalsOnBothDir(tile, direction == AXIS_X ? TRACK_X : TRACK_Y);
|
||||||
SetSignalsOnBothDir(endtile, direction);
|
SetSignalsOnBothDir(endtile, direction == AXIS_X ? TRACK_X : TRACK_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (direction) {
|
if (direction == AXIS_X) {
|
||||||
return (TileY(endtile) - TileY(tile) + 1) * _price.clear_bridge;
|
|
||||||
} else {
|
|
||||||
return (TileX(endtile) - TileX(tile) + 1) * _price.clear_bridge;
|
return (TileX(endtile) - TileX(tile) + 1) * _price.clear_bridge;
|
||||||
|
} else {
|
||||||
|
return (TileY(endtile) - TileY(tile) + 1) * _price.clear_bridge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -918,7 +916,7 @@ static void DrawBridgePillars(const TileInfo *ti, int x, int y, int z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint GetBridgeFoundation(uint tileh, byte direction)
|
uint GetBridgeFoundation(uint tileh, Axis axis)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
// normal level sloped building (7, 11, 13, 14)
|
// normal level sloped building (7, 11, 13, 14)
|
||||||
|
@ -931,8 +929,8 @@ uint GetBridgeFoundation(uint tileh, byte direction)
|
||||||
(i += 2, tileh == 4) ||
|
(i += 2, tileh == 4) ||
|
||||||
(i += 2, tileh == 8)
|
(i += 2, tileh == 8)
|
||||||
) && (
|
) && (
|
||||||
direction == 0 ||
|
axis == AXIS_X ||
|
||||||
(i++, direction == 1)
|
(i++, axis == AXIS_Y)
|
||||||
)) {
|
)) {
|
||||||
return i + 15;
|
return i + 15;
|
||||||
}
|
}
|
||||||
|
|
13
vehicle.c
13
vehicle.c
|
@ -1921,15 +1921,16 @@ bool GetNewVehiclePos(const Vehicle *v, GetNewVehiclePosResult *gp)
|
||||||
return gp->old_tile == gp->new_tile;
|
return gp->old_tile == gp->new_tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const byte _new_direction_table[9] = {
|
static const Direction _new_direction_table[] = {
|
||||||
0, 7, 6,
|
DIR_N , DIR_NW, DIR_W ,
|
||||||
1, 3, 5,
|
DIR_NE, DIR_SE, DIR_SW,
|
||||||
2, 3, 4,
|
DIR_E , DIR_SE, DIR_S
|
||||||
};
|
};
|
||||||
|
|
||||||
byte GetDirectionTowards(const Vehicle *v, int x, int y)
|
Direction GetDirectionTowards(const Vehicle* v, int x, int y)
|
||||||
{
|
{
|
||||||
byte dirdiff, dir;
|
Direction dir;
|
||||||
|
byte dirdiff;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (y >= v->y_pos) {
|
if (y >= v->y_pos) {
|
||||||
|
|
10
vehicle.h
10
vehicle.h
|
@ -269,10 +269,10 @@ void ViewportAddVehicles(DrawPixelInfo *dpi);
|
||||||
void TrainEnterDepot(Vehicle *v, TileIndex tile);
|
void TrainEnterDepot(Vehicle *v, TileIndex tile);
|
||||||
|
|
||||||
/* train_cmd.h */
|
/* train_cmd.h */
|
||||||
int GetTrainImage(const Vehicle *v, byte direction);
|
int GetTrainImage(const Vehicle* v, Direction direction);
|
||||||
int GetAircraftImage(const Vehicle *v, byte direction);
|
int GetAircraftImage(const Vehicle* v, Direction direction);
|
||||||
int GetRoadVehImage(const Vehicle *v, byte direction);
|
int GetRoadVehImage(const Vehicle* v, Direction direction);
|
||||||
int GetShipImage(const Vehicle *v, byte direction);
|
int GetShipImage(const Vehicle* v, Direction direction);
|
||||||
|
|
||||||
Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type);
|
Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type);
|
||||||
Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type);
|
Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type);
|
||||||
|
@ -332,7 +332,7 @@ Trackdir GetVehicleTrackdir(const Vehicle* v);
|
||||||
|
|
||||||
/* returns true if staying in the same tile */
|
/* returns true if staying in the same tile */
|
||||||
bool GetNewVehiclePos(const Vehicle *v, GetNewVehiclePosResult *gp);
|
bool GetNewVehiclePos(const Vehicle *v, GetNewVehiclePosResult *gp);
|
||||||
byte GetDirectionTowards(const Vehicle *v, int x, int y);
|
Direction GetDirectionTowards(const Vehicle* v, int x, int y);
|
||||||
|
|
||||||
#define BEGIN_ENUM_WAGONS(v) do {
|
#define BEGIN_ENUM_WAGONS(v) do {
|
||||||
#define END_ENUM_WAGONS(v) } while ( (v=v->next) != NULL);
|
#define END_ENUM_WAGONS(v) } while ( (v=v->next) != NULL);
|
||||||
|
|
17
water_cmd.c
17
water_cmd.c
|
@ -127,7 +127,7 @@ static int32 RemoveShipDepot(TileIndex tile, uint32 flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// build a shiplift
|
// build a shiplift
|
||||||
static int32 DoBuildShiplift(TileIndex tile, int dir, uint32 flags)
|
static int32 DoBuildShiplift(TileIndex tile, DiagDirection dir, uint32 flags)
|
||||||
{
|
{
|
||||||
int32 ret;
|
int32 ret;
|
||||||
int delta;
|
int delta;
|
||||||
|
@ -189,17 +189,18 @@ static void MarkTilesAroundDirty(TileIndex tile)
|
||||||
int32 CmdBuildLock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
int32 CmdBuildLock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
TileIndex tile = TileVirtXY(x, y);
|
TileIndex tile = TileVirtXY(x, y);
|
||||||
uint tileh;
|
DiagDirection dir;
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
tileh = GetTileSlope(tile, NULL);
|
|
||||||
|
|
||||||
if (tileh == 3 || tileh == 6 || tileh == 9 || tileh == 12) {
|
switch (GetTileSlope(tile, NULL)) {
|
||||||
static const byte _shiplift_dirs[16] = {0, 0, 0, 2, 0, 0, 1, 0, 0, 3, 0, 0, 0};
|
case 3: dir = DIAGDIR_SW; break;
|
||||||
return DoBuildShiplift(tile, _shiplift_dirs[tileh], flags);
|
case 6: dir = DIAGDIR_SE; break;
|
||||||
|
case 9: dir = DIAGDIR_NW; break;
|
||||||
|
case 12: dir = DIAGDIR_NE; break;
|
||||||
|
default: return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
|
||||||
}
|
}
|
||||||
|
return DoBuildShiplift(tile, dir, flags);
|
||||||
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Build a piece of canal.
|
/** Build a piece of canal.
|
||||||
|
|
|
@ -292,7 +292,7 @@ int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
int direction = _m[tile].m5 & RAIL_WAYPOINT_TRACK_MASK;
|
Axis direction = _m[tile].m5 & RAIL_WAYPOINT_TRACK_MASK;
|
||||||
|
|
||||||
wp = GetWaypointByTile(tile);
|
wp = GetWaypointByTile(tile);
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
} else {
|
} else {
|
||||||
DoClearSquare(tile);
|
DoClearSquare(tile);
|
||||||
SetSignalsOnBothDir(tile, direction);
|
SetSignalsOnBothDir(tile, direction == AXIS_X ? TRACK_X : TRACK_Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue