Skip to content

Commit 86f8513

Browse files
committed
build_menu: clarify logic for altar preview
1 parent 5871640 commit 86f8513

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/building/building.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ enum e_fancy_state {
140140
class building_work_camp;
141141
class building_farm;
142142

143-
building* building_get(int id);
143+
building* building_get(building_id id);
144144

145145
class building {
146146
public:

src/building/building_menu.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "core/game_environment.h"
1313
#include "io/gamefiles/lang.h"
1414
#include "building/industry.h"
15+
#include "building/building_temple_complex.h"
1516

1617
#include "dev/debug.h"
1718
#include "js/js_game.h"
@@ -382,11 +383,11 @@ void building_menu_update_temple_complexes() {
382383
}
383384

384385
// check if upgrades have been placed
385-
building* b = building_get(temple_complex_id);
386-
const bool temple_has_altar = (b->data.monuments.temple_complex_attachments & 2); // altar
386+
auto b = building_get_ex<building_temple_complex>(temple_complex_id);
387+
const bool temple_has_altar = b && b->has_attachement(etc_attachement_altar);
387388
building_menu_toggle_building(BUILDING_TEMPLE_COMPLEX_ALTAR, !temple_has_altar);
388389

389-
const bool temple_has_oracle = (b->data.monuments.temple_complex_attachments & 1); // oracle
390+
const bool temple_has_oracle = b && b->has_attachement(etc_attachement_oracle);
390391
building_menu_toggle_building(BUILDING_TEMPLE_COMPLEX_ORACLE, !temple_has_oracle);
391392

392393
// all upgrades have been placed!

src/building/construction/build_planner.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -800,21 +800,22 @@ void build_planner::update_special_case_orientations_check() {
800800
}
801801
}
802802

803-
const bool templeAltar = (special_flags & e_building_flag::TempleUpgradeAltar);
804-
const bool templeOracle = (special_flags & e_building_flag::TempleUpgradeOracle);
805-
if (templeAltar || templeOracle) {
803+
const bool temple_altar = (special_flags & e_building_flag::TempleUpgradeAltar);
804+
const bool temple_oracle = (special_flags & e_building_flag::TempleUpgradeOracle);
805+
const int temple_options = (temple_altar ? etc_attachement_altar : 0) | (temple_oracle ? etc_attachement_oracle : 0);
806+
if (temple_altar || temple_oracle) {
806807
auto target = building_at(end)->main()->dcast_temple_complex();
807808
if (!target) {
808809
immediate_warning_id = WARNING_TEMPLE_UPGRADE_PLACEMENT_NEED_TEMPLE;
809810
can_place = CAN_NOT_PLACE;
810-
} else if (target->data.monuments.temple_complex_attachments & additional_req_param1) {
811+
} else if (target->has_attachement((e_temple_compex_attachement)temple_options) ) {
811812
immediate_warning_id = WARNING_TEMPLE_UPGRADE_ONLY_ONE;
812813
can_place = CAN_NOT_PLACE;
813814
} else {
814815
int dir_absolute = (5 - (target->data.monuments.variant / 2)) % 4;
815816
dir_relative = city_view_relative_orientation(dir_absolute);
816817
relative_orientation = (1 + dir_relative) % 2;
817-
end = temple_complex_part_target(&target->base, additional_req_param1);
818+
end = target->tile();
818819
update_orientations(false);
819820
}
820821
}

0 commit comments

Comments
 (0)