src/newgrf_house.cpp
branchnoai
changeset 9626 79f2b5a0cdd7
parent 9625 3301b1b3889c
child 9628 b5c2449616b5
equal deleted inserted replaced
9625:3301b1b3889c 9626:79f2b5a0cdd7
   167 	town_class_count = town->building_counts.class_count[class_id];
   167 	town_class_count = town->building_counts.class_count[class_id];
   168 
   168 
   169 	return map_class_count << 24 | town_class_count << 16 | map_id_count << 8 | town_id_count;
   169 	return map_class_count << 24 | town_class_count << 16 | map_id_count << 8 | town_id_count;
   170 }
   170 }
   171 
   171 
   172 static uint32 GetTerrainType(TileIndex tile)
       
   173 {
       
   174 	switch (_opt.landscape) {
       
   175 		case LT_TROPIC: return GetTropicZone(tile) == TROPICZONE_DESERT ? 1 : 2;
       
   176 		case LT_ARCTIC: return GetTileZ(tile) >= GetSnowLine() ? 4 : 0;
       
   177 		default:        return 0;
       
   178 	}
       
   179 }
       
   180 
       
   181 static uint32 GetGRFParameter(HouseID house_id, byte parameter)
   172 static uint32 GetGRFParameter(HouseID house_id, byte parameter)
   182 {
   173 {
   183 	const HouseSpec *hs = GetHouseSpecs(house_id);
   174 	const HouseSpec *hs = GetHouseSpecs(house_id);
   184 	const GRFFile *file = hs->grffile;
   175 	const GRFFile *file = hs->grffile;
   185 
   176 
   186 	if (parameter >= file->param_end) return 0;
   177 	if (parameter >= file->param_end) return 0;
   187 	return file->param[parameter];
   178 	return file->param[parameter];
       
   179 }
       
   180 
       
   181 uint32 GetNearbyTileInformation(byte parameter, TileIndex tile)
       
   182 {
       
   183 	uint32 tile_type;
       
   184 
       
   185 	tile = GetNearbyTile(parameter, tile);
       
   186 	tile_type = GetTerrainType(tile) << 2 | (IsTileType(tile, MP_WATER) ? 1 : 0) << 1;
       
   187 
       
   188 	return GetTileType(tile) << 24 | (TileHeight(tile) * 8) << 16 | tile_type << 8 | GetTileSlope(tile, NULL);
   188 }
   189 }
   189 
   190 
   190 /**
   191 /**
   191  * HouseGetVariable():
   192  * HouseGetVariable():
   192  *
   193  *
   236 			HouseID new_house = _house_mngr.GetID(parameter, hs->grffile->grfid);
   237 			HouseID new_house = _house_mngr.GetID(parameter, hs->grffile->grfid);
   237 			return new_house == INVALID_HOUSE_ID ? 0 : GetNumHouses(new_house, town);
   238 			return new_house == INVALID_HOUSE_ID ? 0 : GetNumHouses(new_house, town);
   238 		}
   239 		}
   239 
   240 
   240 		/* Land info for nearby tiles. */
   241 		/* Land info for nearby tiles. */
   241 		case 0x62: {
   242 		case 0x62: return GetNearbyTileInformation(parameter, tile);
   242 			int8 x = GB(parameter, 0, 4);
       
   243 			int8 y = GB(parameter, 4, 4);
       
   244 			byte tile_type;
       
   245 
       
   246 			if (x >= 8) x -= 16;
       
   247 			if (y >= 8) y -= 16;
       
   248 
       
   249 			tile += TileDiffXY(x, y);
       
   250 
       
   251 			tile_type = GetTerrainType(tile) << 2 | (IsTileType(tile, MP_WATER) ? 1 : 0) << 1;
       
   252 
       
   253 			return GetTileType(tile) << 24 | (TileHeight(tile) * 8) << 16 | tile_type << 8 | GetTileSlope(tile, NULL);
       
   254 		}
       
   255 
   243 
   256 		/* Read GRF parameter */
   244 		/* Read GRF parameter */
   257 		case 0x7F: return GetGRFParameter(object->u.house.house_id, parameter);
   245 		case 0x7F: return GetGRFParameter(object->u.house.house_id, parameter);
   258 	}
   246 	}
   259 
   247