Skip to content

Commit 2531eeb

Browse files
author
s.kushnirenko
committed
buildings: create temple class and moved logic from common building
1 parent 8e403e6 commit 2531eeb

18 files changed

+111
-95
lines changed

src/building/building.cpp

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "building/rotation.h"
55
#include "building/building_type.h"
66
#include "building/storage.h"
7+
#include "building/building_temple.h"
78
#include "building/building_statue.h"
89
#include "building/building_work_camp.h"
910
#include "building/building_bazaar.h"
@@ -324,6 +325,14 @@ building_impl *building::dcast() {
324325
case BUILDING_GEMSTONE_MINE: _ptr = new building_mine_gems(*this); break;
325326
case BUILDING_COPPER_MINE: _ptr = new building_mine_copper(*this); break;
326327

328+
case BUILDING_TEMPLE_OSIRIS:
329+
case BUILDING_TEMPLE_RA:
330+
case BUILDING_TEMPLE_PTAH:
331+
case BUILDING_TEMPLE_SETH:
332+
case BUILDING_TEMPLE_BAST:
333+
_ptr = new building_temple(*this);
334+
break;
335+
327336
case BUILDING_VILLAGE_PALACE:
328337
case BUILDING_TOWN_PALACE:
329338
case BUILDING_CITY_PALACE:
@@ -488,35 +497,9 @@ void building::clear_related_data() {
488497

489498
e_overlay building::get_overlay() const {
490499
switch (type) {
491-
case BUILDING_SHRINE_OSIRIS:
492-
case BUILDING_TEMPLE_OSIRIS:
493-
return OVERLAY_RELIGION_OSIRIS;
494-
495-
case BUILDING_SHRINE_RA:
496-
case BUILDING_TEMPLE_RA:
497-
return OVERLAY_RELIGION_RA;
498-
499-
case BUILDING_SHRINE_PTAH:
500-
case BUILDING_TEMPLE_PTAH:
501-
return OVERLAY_RELIGION_PTAH;
502-
503-
case BUILDING_SHRINE_SETH:
504-
case BUILDING_TEMPLE_SETH:
505-
return OVERLAY_RELIGION_SETH;
506-
507-
case BUILDING_SHRINE_BAST:
508-
case BUILDING_TEMPLE_BAST:
509-
return OVERLAY_RELIGION_BAST;
510-
511-
case BUILDING_ARCHITECT_POST: return OVERLAY_DAMAGE;
512-
case BUILDING_FIREHOUSE: return OVERLAY_FIRE;
513500
case BUILDING_POLICE_STATION: return OVERLAY_CRIME;
514-
case BUILDING_APOTHECARY: return OVERLAY_APOTHECARY;
515501
case BUILDING_COURTHOUSE: return OVERLAY_COUTHOUSE;
516502
case BUILDING_SCRIBAL_SCHOOL: return OVERLAY_SCRIBAL_SCHOOL;
517-
518-
case BUILDING_BOOTH:
519-
return OVERLAY_BOOTH;
520503
}
521504

522505
return const_cast<building*>(this)->dcast()->get_overlay();

src/building/building.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ class building {
331331
void spawn_figure_dentist();
332332
void spawn_figure_mortuary();
333333
void spawn_figure_magistrate();
334-
void spawn_figure_temple();
335334
void set_greate_palace_graphic();
336335
void spawn_figure_tax_collector();
337336
void spawn_figure_industry();

src/building/building_architect_post.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,4 @@ void building_architect_post::window_info_background(object_info &c) {
4949

5050
void building_architect_post::spawn_figure() {
5151
common_spawn_roamer(FIGURE_ARCHITECT, 50, FIGURE_ACTION_60_ENGINEER_CREATED);
52-
}
53-
52+
}

src/building/building_architect_post.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ class building_architect_post : public building_impl {
66
public:
77
building_architect_post(building &b) : building_impl(b) {}
88
virtual void spawn_figure() override;
9+
virtual e_overlay get_overlay() const override { return OVERLAY_DAMAGE; }
910
virtual void window_info_background(object_info &c) override;
1011
};

src/building/building_booth.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ class building_booth : public building_impl {
88
virtual void window_info_background(object_info &c) override;
99
virtual void spawn_figure() override;
1010
virtual bool draw_ornaments_and_animations_height(painter &ctx, vec2i point, tile2i tile, color mask) override;
11+
virtual e_overlay get_overlay() const override { return OVERLAY_BOOTH; }
1112
virtual int get_fire_risk(int value) const override { return value / 10; }
1213
};

src/building/building_firehouse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ class building_firehouse : public building_impl {
77
building_firehouse(building &b) : building_impl(b) {}
88
virtual void spawn_figure() override;
99
virtual void window_info_background(object_info &c) override;
10+
virtual e_overlay get_overlay() const override { return OVERLAY_FIRE; }
1011
virtual int animation_speed(int speed) const override { return 4; }
1112
};

src/building/building_health.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class building_apothecary : public building_impl {
77
building_apothecary(building &b) : building_impl(b) {}
88
virtual void window_info_background(object_info &c) override;
99
virtual void spawn_figure() override;
10+
virtual e_overlay get_overlay() const override { return OVERLAY_APOTHECARY; }
1011
virtual int animation_speed(int speed) const override { return 3; }
1112
};
1213

src/building/building_shrine.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ static void building_shrine_draw_info(object_info& c, const char* type, int text
3030
}
3131
}
3232

33+
e_overlay building_shrine::get_overlay() const {
34+
switch (type()) {
35+
case BUILDING_SHRINE_OSIRIS: return OVERLAY_RELIGION_OSIRIS;
36+
case BUILDING_SHRINE_RA: return OVERLAY_RELIGION_RA;
37+
case BUILDING_SHRINE_PTAH: return OVERLAY_RELIGION_PTAH;
38+
case BUILDING_SHRINE_SETH: return OVERLAY_RELIGION_SETH;
39+
case BUILDING_SHRINE_BAST: return OVERLAY_RELIGION_BAST;
40+
}
41+
42+
return OVERLAY_NONE;
43+
}
44+
3345
void building_shrine::window_info_background(object_info &ctx) {
3446
switch (base.type) {
3547
case BUILDING_SHRINE_OSIRIS:

src/building/building_shrine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
class building_shrine : public building_impl {
66
public:
77
building_shrine(building &b) : building_impl(b) {}
8-
8+
virtual e_overlay get_overlay() const override;
99
virtual void window_info_background(object_info &ctx) override;
1010
};

src/building/building_temple.cpp

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,56 @@ static void building_temple_draw_temple(object_info& c, const char* type, int gr
3030
}
3131
}
3232

33-
void building_temple_osiris_draw_info(object_info& c) {
34-
building_temple_draw_temple(c, "temple_osiris", 92, 21);
35-
}
36-
void building_temple_ra_draw_info(object_info& c) {
37-
building_temple_draw_temple(c, "temple_ra", 93, 22);
33+
e_overlay building_temple::get_overlay() const {
34+
switch(type()) {
35+
case BUILDING_TEMPLE_OSIRIS: return OVERLAY_RELIGION_OSIRIS;
36+
case BUILDING_TEMPLE_RA: return OVERLAY_RELIGION_RA;
37+
case BUILDING_TEMPLE_PTAH: return OVERLAY_RELIGION_PTAH;
38+
case BUILDING_TEMPLE_SETH: return OVERLAY_RELIGION_SETH;
39+
case BUILDING_TEMPLE_BAST: return OVERLAY_RELIGION_BAST;
40+
}
41+
42+
return OVERLAY_NONE;
3843
}
39-
void building_temple_ptah_draw_info(object_info& c) {
40-
building_temple_draw_temple(c, "temple_ptah", 94, 23);
44+
45+
e_sound_channel_city building_temple::sound_channel() const {
46+
switch (type()) {
47+
case BUILDING_TEMPLE_OSIRIS: return SOUND_CHANNEL_CITY_TEMPLE_OSIRIS;
48+
case BUILDING_TEMPLE_RA: return SOUND_CHANNEL_CITY_TEMPLE_RA;
49+
case BUILDING_TEMPLE_PTAH: return SOUND_CHANNEL_CITY_TEMPLE_PTAH;
50+
case BUILDING_TEMPLE_SETH: return SOUND_CHANNEL_CITY_TEMPLE_SETH;
51+
case BUILDING_TEMPLE_BAST: return SOUND_CHANNEL_CITY_TEMPLE_BAST;
52+
}
53+
54+
return SOUND_CHANNEL_CITY_NONE;
4155
}
42-
void building_temple_seth_draw_info(object_info& c) {
43-
building_temple_draw_temple(c, "temple_seth", 95, 24);
56+
57+
void building_temple::window_info_background(object_info &c) {
58+
switch (type()) {
59+
case BUILDING_TEMPLE_OSIRIS:
60+
building_temple_draw_temple(c, "temple_osiris", 92, 21);
61+
break;
62+
63+
case BUILDING_TEMPLE_RA:
64+
building_temple_draw_temple(c, "temple_ra", 93, 22);
65+
break;
66+
67+
case BUILDING_TEMPLE_PTAH:
68+
building_temple_draw_temple(c, "temple_ptah", 94, 23);
69+
break;
70+
71+
case BUILDING_TEMPLE_SETH:
72+
building_temple_draw_temple(c, "temple_seth", 95, 24);
73+
break;
74+
75+
case BUILDING_TEMPLE_BAST:
76+
building_temple_draw_temple(c, "temple_bast", 96, 25);
77+
break;
78+
}
4479
}
45-
void building_temple_bast_draw_info(object_info& c) {
46-
building_temple_draw_temple(c, "temple_bast", 96, 25);
80+
81+
void building_temple::spawn_figure() {
82+
if (is_main()) {
83+
common_spawn_roamer(FIGURE_PRIEST, 50, FIGURE_ACTION_125_ROAMING);
84+
}
4785
}

0 commit comments

Comments
 (0)