src/tunnelbridge_cmd.cpp
changeset 9028 501b3b351df7
parent 9027 005a0b422107
child 9031 e260304797e6
equal deleted inserted replaced
9027:005a0b422107 9028:501b3b351df7
    42 
    42 
    43 /** Reset the data been eventually changed by the grf loaded. */
    43 /** Reset the data been eventually changed by the grf loaded. */
    44 void ResetBridges()
    44 void ResetBridges()
    45 {
    45 {
    46 	/* First, free sprite table data */
    46 	/* First, free sprite table data */
    47 	for (uint i = 0; i < MAX_BRIDGES; i++) {
    47 	for (BridgeType i = 0; i < MAX_BRIDGES; i++) {
    48 		if (_bridge[i].sprite_table != NULL) {
    48 		if (_bridge[i].sprite_table != NULL) {
    49 			for (uint j = 0; j < 7; j++) free(_bridge[i].sprite_table[j]);
    49 			for (uint j = 0; j < 7; j++) free(_bridge[i].sprite_table[j]);
    50 			free(_bridge[i].sprite_table);
    50 			free(_bridge[i].sprite_table);
    51 		}
    51 		}
    52 	}
    52 	}
   149 	if (f == FOUNDATION_NONE) return CommandCost();
   149 	if (f == FOUNDATION_NONE) return CommandCost();
   150 
   150 
   151 	return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
   151 	return CommandCost(EXPENSES_CONSTRUCTION, _price.terraform);
   152 }
   152 }
   153 
   153 
   154 bool CheckBridge_Stuff(byte bridge_type, uint bridge_len)
   154 bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len)
   155 {
   155 {
   156 	const Bridge *b = GetBridgeSpec(bridge_type);
   156 	const Bridge *b = GetBridgeSpec(bridge_type);
   157 	uint max; // max possible length of a bridge (with patch 100)
   157 	uint max; // max possible length of a bridge (with patch 100)
   158 
   158 
   159 	if (bridge_type >= MAX_BRIDGES) return false;
   159 	if (bridge_type >= MAX_BRIDGES) return false;
   174  * - p2 = (bit 8-..) - rail type or road types.
   174  * - p2 = (bit 8-..) - rail type or road types.
   175  * - p2 = (bit 15  ) - set means road bridge.
   175  * - p2 = (bit 15  ) - set means road bridge.
   176  */
   176  */
   177 CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
   177 CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
   178 {
   178 {
   179 	uint bridge_type;
   179 	BridgeType bridge_type;
   180 	RailType railtype = INVALID_RAILTYPE;
   180 	RailType railtype = INVALID_RAILTYPE;
   181 	RoadTypes roadtypes = ROADTYPES_NONE;
   181 	RoadTypes roadtypes = ROADTYPES_NONE;
   182 	uint x;
   182 	uint x;
   183 	uint y;
   183 	uint y;
   184 	uint sx;
   184 	uint sx;
   194 	uint bridge_len;
   194 	uint bridge_len;
   195 	Axis direction;
   195 	Axis direction;
   196 	CommandCost cost(EXPENSES_CONSTRUCTION);
   196 	CommandCost cost(EXPENSES_CONSTRUCTION);
   197 	CommandCost ret;
   197 	CommandCost ret;
   198 	bool replace_bridge = false;
   198 	bool replace_bridge = false;
   199 	uint replaced_bridge_type;
   199 	BridgeType replaced_bridge_type;
   200 	TransportType transport_type;
   200 	TransportType transport_type;
   201 
   201 
   202 	/* unpack parameters */
   202 	/* unpack parameters */
   203 	bridge_type = GB(p2, 0, 8);
   203 	bridge_type = GB(p2, 0, 8);
   204 
   204 
   706  * @param type Bridge type.
   706  * @param type Bridge type.
   707  * @param x Sprite X position of front pillar.
   707  * @param x Sprite X position of front pillar.
   708  * @param y Sprite Y position of front pillar.
   708  * @param y Sprite Y position of front pillar.
   709  * @param z_bridge Absolute height of bridge bottom.
   709  * @param z_bridge Absolute height of bridge bottom.
   710  */
   710  */
   711 static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis axis, uint type, int x, int y, int z_bridge)
   711 static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo* ti, Axis axis, BridgeType type, int x, int y, int z_bridge)
   712 {
   712 {
   713 	SpriteID image = psid->sprite;
   713 	SpriteID image = psid->sprite;
   714 	if (image != 0) {
   714 	if (image != 0) {
   715 		bool drawfarpillar = !HasBit(GetBridgeSpec(type)->flags, 0);
   715 		bool drawfarpillar = !HasBit(GetBridgeSpec(type)->flags, 0);
   716 
   716 
   992 	uint base_offset;
   992 	uint base_offset;
   993 	TileIndex rampnorth;
   993 	TileIndex rampnorth;
   994 	TileIndex rampsouth;
   994 	TileIndex rampsouth;
   995 	Axis axis;
   995 	Axis axis;
   996 	uint piece;
   996 	uint piece;
   997 	uint type;
   997 	BridgeType type;
   998 	int x;
   998 	int x;
   999 	int y;
   999 	int y;
  1000 	uint z;
  1000 	uint z;
  1001 
  1001 
  1002 	if (!IsBridgeAbove(ti->tile)) return;
  1002 	if (!IsBridgeAbove(ti->tile)) return;