dalerank / Akhenaten

An open source re-implementation of Pharaoh (1999) in the Julius/Augustus engine
GNU Affero General Public License v3.0
166 stars 11 forks source link

Well water overlay not working correctly #135

Closed Asdow closed 6 months ago

Asdow commented 6 months ago

Encountered this on the first mission. Building a well doesn't update water overlay with its range. The problem comes from map_update_wells_range() referencing building_list_small_items() and its size building_list_small_size() which is always 0 so the loop does not run. The only reference to building_list_small_add() is in determine_meeting_center() so it seems wells are never added to the list.

image

Also, when I changed the code to show the well range correctly, housing tooltip always displays text "No access to drinking water" even though it is in range of a well and the housing upgrade mechanic works. See screenshot

image

Changed code to test the well range drawing

void map_update_wells_range(void) {
    OZZY_PROFILER_SECTION("Game/Run/Tick/Wells Range Update");
    map_terrain_remove_all(TERRAIN_FOUNTAIN_RANGE);
     for (int i = 0; i < MAX_BUILDINGS; i++) {
         building* b = building_get(i);
        if (b->state == BUILDING_STATE_VALID && b->type == BUILDING_WELL)
            map_terrain_add_with_radius(b->tile.x(), b->tile.y(), 1, 3, TERRAIN_FOUNTAIN_RANGE);
    }
}
dalerank commented 6 months ago

Thanks, look for it

dalerank commented 6 months ago

@Asdow You can create a PR if you want for this, or I can fix it

Asdow commented 6 months ago

I can do it. Do you want me to keep using the small building list for it?

dalerank commented 6 months ago

better use

    buildings_valid_do([&] (building &b) {
       ....
    }, BUILDING_WELL);