road_cmd.c
changeset 1281 dd226de69402
parent 1280 33a251c30758
child 1313 f1013ec3d318
equal deleted inserted replaced
1280:33a251c30758 1281:dd226de69402
   147 
   147 
   148 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
   148 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
   149 
   149 
   150 	FindLandscapeHeight(&ti, x, y);
   150 	FindLandscapeHeight(&ti, x, y);
   151 	tile = ti.tile;
   151 	tile = ti.tile;
   152 	if(_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR)
   152 	if (_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR)
   153 		t = GetTown(_map2[tile]); // needed for town rating penalty
   153 		t = GetTown(_map2[tile]); // needed for town rating penalty
   154 	else
   154 	else
   155 		t = NULL;
   155 		t = NULL;
   156 
   156 
   157 	// allow deleting road under bridge
   157 	// allow deleting road under bridge
   205 				if (t2&1) cost += _price.remove_road;
   205 				if (t2&1) cost += _price.remove_road;
   206 			} while(t2>>=1);
   206 			} while(t2>>=1);
   207 
   207 
   208 			// check if you're allowed to remove the street owned by a town
   208 			// check if you're allowed to remove the street owned by a town
   209 			// removal allowance depends on difficulty setting
   209 			// removal allowance depends on difficulty setting
   210 			if(_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR) {
   210 			if (_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR) {
   211 				if (!CheckforTownRating(tile, flags, t, ROAD_REMOVE))
   211 				if (!CheckforTownRating(tile, flags, t, ROAD_REMOVE))
   212 					return CMD_ERROR;
   212 					return CMD_ERROR;
   213 			}
   213 			}
   214 
   214 
   215 			if (flags & DC_EXEC) {
   215 			if (flags & DC_EXEC) {
   216 				// checks if the owner is town than decrease town rating by 50 until you have
   216 				// checks if the owner is town than decrease town rating by 50 until you have
   217 				// a "Poor" town rating
   217 				// a "Poor" town rating
   218 				if(_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR)
   218 				if (_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR)
   219 					ChangeTownRating(t, -_road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
   219 					ChangeTownRating(t, -_road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
   220 
   220 
   221 				_map5[tile] ^= c;
   221 				_map5[tile] ^= c;
   222 				if ((_map5[tile]&0xF) == 0)
   222 				if ((_map5[tile]&0xF) == 0)
   223 					DoClearSquare(tile);
   223 					DoClearSquare(tile);
   965 
   965 
   966 	if (_map5[tile] & 0xE0)
   966 	if (_map5[tile] & 0xE0)
   967 		return;
   967 		return;
   968 
   968 
   969 	if (((_map3_hi[tile] & 0x70) >> 4) < 6) {
   969 	if (((_map3_hi[tile] & 0x70) >> 4) < 6) {
   970 		if(_map_owner[tile] == OWNER_TOWN)
   970 		t = ClosestTownFromTile(tile, (uint)-1);
   971 			t = GetTown(_map2[tile]);
       
   972 		else
       
   973 			t = ClosestTownFromTile(tile, (uint)-1);
       
   974 
   971 
   975 		grp = 0;
   972 		grp = 0;
   976 		if (t != NULL) {
   973 		if (t != NULL) {
   977 			/* In SE, set the owner to OWNER_TOWN */
   974 			/* In SE, set the owner to OWNER_TOWN */
   978 			if (_game_mode == GM_EDITOR && _map_owner[tile] != OWNER_TOWN) {
   975 			if (_game_mode == GM_EDITOR && _map_owner[tile] != OWNER_TOWN) {