tunnelbridge_cmd.c
changeset 2843 aa8f488a6637
parent 2763 a4d065e3261b
child 2870 0dc0bcee256a
equal deleted inserted replaced
2842:954112262878 2843:aa8f488a6637
   202 	uint odd_middle_part;
   202 	uint odd_middle_part;
   203 	uint direction;
   203 	uint direction;
   204 	uint i;
   204 	uint i;
   205 	int32 cost, terraformcost, ret;
   205 	int32 cost, terraformcost, ret;
   206 	bool allow_on_slopes;
   206 	bool allow_on_slopes;
       
   207 	bool reserved = false;
   207 
   208 
   208 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
   209 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
   209 
   210 
   210 	/* unpack parameters */
   211 	/* unpack parameters */
   211 	bridge_type = GB(p2, 0, 8);
   212 	bridge_type = GB(p2, 0, 8);
   349 				if (ti.map5 != 2) goto not_valid_below;
   350 				if (ti.map5 != 2) goto not_valid_below;
   350 			} else {
   351 			} else {
   351 				if (ti.map5 != 1) goto not_valid_below;
   352 				if (ti.map5 != 1) goto not_valid_below;
   352 			}
   353 			}
   353 			m5 = 0xE0;
   354 			m5 = 0xE0;
       
   355 			reserved = PBSTileReserved(ti.tile) != 0;
   354 		} else if (ti.type == MP_STREET) {
   356 		} else if (ti.type == MP_STREET) {
   355 			if (direction == 0) {
   357 			if (direction == 0) {
   356 				if (ti.map5 != 5) goto not_valid_below;
   358 				if (ti.map5 != 5) goto not_valid_below;
   357 			} else {
   359 			} else {
   358 				if (ti.map5 != 10) goto not_valid_below;
   360 				if (ti.map5 != 10) goto not_valid_below;
   397 					m5 = 2 + ((i % 2 == 0) ^ (i > odd_middle_part));
   399 					m5 = 2 + ((i % 2 == 0) ^ (i > odd_middle_part));
   398 			}
   400 			}
   399 
   401 
   400 			_m[ti.tile].m2 = (bridge_type << 4) | m5;
   402 			_m[ti.tile].m2 = (bridge_type << 4) | m5;
   401 			SB(_m[ti.tile].m3, 4, 4, railtype);
   403 			SB(_m[ti.tile].m3, 4, 4, railtype);
       
   404 
       
   405 			if (ti.type == MP_RAILWAY) {
       
   406 				// Set or clear PBS reservation status. direction here is of
       
   407 				// the bridge, not the track below.
       
   408 				if (reserved) {
       
   409 					PBSReserveTrack(ti.tile, direction ? TRACK_DIAG1 : TRACK_DIAG2);
       
   410 				} else {
       
   411 					PBSClearTrack(ti.tile, direction ? TRACK_DIAG1 : TRACK_DIAG2);
       
   412 				}
       
   413 			}
   402 
   414 
   403 			MarkTileDirtyByTile(ti.tile);
   415 			MarkTileDirtyByTile(ti.tile);
   404 		}
   416 		}
   405 	}
   417 	}
   406 
   418