road_cmd.c
changeset 1901 fb05044cf5c3
parent 1891 92a3b0aa0946
child 1902 5d653da1abb7
equal deleted inserted replaced
1900:f409d5517cb0 1901:fb05044cf5c3
    79 
    79 
    80 	// A railway crossing has the road owner in the map3_lo byte.
    80 	// A railway crossing has the road owner in the map3_lo byte.
    81 	if (IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) {
    81 	if (IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) {
    82 		owner = _map3_lo[tile];
    82 		owner = _map3_lo[tile];
    83 	} else {
    83 	} else {
    84 		owner = _map_owner[tile];
    84 		owner = GetTileOwner(tile);
    85 	}
    85 	}
    86 	// Only do the special processing if the road is owned
    86 	// Only do the special processing if the road is owned
    87 	// by a town
    87 	// by a town
    88 	if (owner != OWNER_TOWN) {
    88 	if (owner != OWNER_TOWN) {
    89 		return owner == OWNER_NONE || CheckOwnership(owner);
    89 		return owner == OWNER_NONE || CheckOwnership(owner);
   155 	// owner for railraod crossing is stored somewhere else
   155 	// owner for railraod crossing is stored somewhere else
   156 	// XXX - Fix this so for a given tiletype the owner of the type is in the same variable
   156 	// XXX - Fix this so for a given tiletype the owner of the type is in the same variable
   157 	if (IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) {
   157 	if (IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) {
   158 		owner = _map3_lo[tile];
   158 		owner = _map3_lo[tile];
   159 	} else
   159 	} else
   160 		owner = _map_owner[tile];
   160 		owner = GetTileOwner(tile);
   161 
   161 
   162 	if (owner == OWNER_TOWN && _game_mode != GM_EDITOR) {
   162 	if (owner == OWNER_TOWN && _game_mode != GM_EDITOR) {
   163 		if (IsTileType(tile, MP_TUNNELBRIDGE)) { // index of town is not saved for bridge (no space)
   163 		if (IsTileType(tile, MP_TUNNELBRIDGE)) { // index of town is not saved for bridge (no space)
   164 			t = ClosestTownFromTile(tile, _patches.dist_local_authority);
   164 			t = ClosestTownFromTile(tile, _patches.dist_local_authority);
   165 		} else
   165 		} else
   684 
   684 
   685 	if ( (m5 & 0xF0) == 0) {
   685 	if ( (m5 & 0xF0) == 0) {
   686 		byte b = m5 & 0xF;
   686 		byte b = m5 & 0xF;
   687 
   687 
   688 		if (! ((1 << b) & (M(1)|M(2)|M(4)|M(8))) ) {
   688 		if (! ((1 << b) & (M(1)|M(2)|M(4)|M(8))) ) {
   689 			if ( (!(flags & DC_AI_BUILDING) || _map_owner[tile]!=OWNER_TOWN) && flags&DC_AUTO)
   689 			if ((!(flags & DC_AI_BUILDING) || !IsTileOwner(tile, OWNER_TOWN)) && flags & DC_AUTO)
   690 				return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST);
   690 				return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST);
   691 		}
   691 		}
   692 		return DoCommandByTile(tile, b, 0, flags, CMD_REMOVE_ROAD);
   692 		return DoCommandByTile(tile, b, 0, flags, CMD_REMOVE_ROAD);
   693 	} else if ( (m5 & 0xE0) == 0) {
   693 	} else if ( (m5 & 0xE0) == 0) {
   694 		if (flags & DC_AUTO)
   694 		if (flags & DC_AUTO)
   833 		const DrawRoadSeqStruct *drss;
   833 		const DrawRoadSeqStruct *drss;
   834 
   834 
   835 		if (ti->tileh != 0) { DrawFoundation(ti, ti->tileh); }
   835 		if (ti->tileh != 0) { DrawFoundation(ti, ti->tileh); }
   836 
   836 
   837 		ormod = 0x315;
   837 		ormod = 0x315;
   838 		player = _map_owner[ti->tile];
   838 		player = GetTileOwner(ti->tile);
   839 		if (player < MAX_PLAYERS)
   839 		if (player < MAX_PLAYERS)
   840 			ormod = PLAYER_SPRITE_COLOR(player);
   840 			ormod = PLAYER_SPRITE_COLOR(player);
   841 
   841 
   842 		drss = _road_display_datas[ti->map5 & 0xF];
   842 		drss = _road_display_datas[ti->map5 & 0xF];
   843 
   843 
  1099 {
  1099 {
  1100 	int i = (_map5[tile] >> 4);
  1100 	int i = (_map5[tile] >> 4);
  1101 	if (i == 0)
  1101 	if (i == 0)
  1102 		i = ((_map3_hi[tile] & 0x70) >> 4) + 3;
  1102 		i = ((_map3_hi[tile] & 0x70) >> 4) + 3;
  1103 	td->str = _road_tile_strings[i - 1];
  1103 	td->str = _road_tile_strings[i - 1];
  1104 	td->owner = _map_owner[tile];
  1104 	td->owner = GetTileOwner(tile);
  1105 }
  1105 }
  1106 
  1106 
  1107 static const byte _roadveh_enter_depot_unk0[4] = {
  1107 static const byte _roadveh_enter_depot_unk0[4] = {
  1108 	8, 9, 0, 1
  1108 	8, 9, 0, 1
  1109 };
  1109 };
  1143 	// road/rail crossing where the road is owned by the current player?
  1143 	// road/rail crossing where the road is owned by the current player?
  1144 	if (old_player == _map3_lo[tile] && (_map5[tile]&0xF0) == 0x10) {
  1144 	if (old_player == _map3_lo[tile] && (_map5[tile]&0xF0) == 0x10) {
  1145 		_map3_lo[tile] = (new_player == 0xFF) ? OWNER_NONE : new_player;
  1145 		_map3_lo[tile] = (new_player == 0xFF) ? OWNER_NONE : new_player;
  1146 	}
  1146 	}
  1147 
  1147 
  1148 	if (_map_owner[tile] != old_player)
  1148 	if (!IsTileOwner(tile, old_player)) return;
  1149 		return;
       
  1150 
  1149 
  1151 	if (new_player != 255) {
  1150 	if (new_player != 255) {
  1152 		_map_owner[tile] = new_player;
  1151 		_map_owner[tile] = new_player;
  1153 	}	else {
  1152 	}	else {
  1154 		b = _map5[tile]&0xF0;
  1153 		b = _map5[tile]&0xF0;