Skip to content

Commit 074a50c

Browse files
author
s.kushnirenko
committed
buildings: moved apothecary code to own class from common
1 parent ba11365 commit 074a50c

11 files changed

+39
-27
lines changed

src/building/building.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "building/building_bandstand.h"
1515
#include "building/building_bricklayers_guild.h"
1616
#include "building/building_booth.h"
17+
#include "building/building_health.h"
1718
#include "city/buildings.h"
1819
#include "city/population.h"
1920
#include "city/warning.h"
@@ -330,6 +331,7 @@ building_impl *building::dcast() {
330331
case BUILDING_ARCHITECT_POST: _ptr = new building_architect_post(*this); break;
331332
case BUILDING_BANDSTAND: _ptr = new building_bandstand(*this); break;
332333
case BUILDING_BOOTH: _ptr = new building_booth(*this); break;
334+
case BUILDING_APOTHECARY: _ptr = new building_apothecary(*this); break;
333335

334336
case BUILDING_SMALL_MASTABA:
335337
case BUILDING_SMALL_MASTABA_SIDE:

src/building/building.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ class building {
328328
void set_water_supply_graphic();
329329
void spawn_figure_school();
330330
void spawn_figure_library();
331-
void spawn_figure_apothecary();
332331
void spawn_figure_dentist();
333332
void spawn_figure_mortuary();
334333
void spawn_figure_physician();
@@ -392,6 +391,7 @@ class building_impl {
392391
inline bool is_main() { return base.is_main(); }
393392
inline figure *create_roaming_figure(e_figure_type _type, e_figure_action created_action, e_building_slot slot) { return base.create_roaming_figure(_type, created_action, slot); }
394393
inline bool common_spawn_figure_trigger(int min_houses) { return base.common_spawn_figure_trigger(min_houses); }
394+
inline bool common_spawn_roamer(e_figure_type type, int min_houses, e_figure_action created_action) { return base.common_spawn_roamer(type, min_houses, created_action); }
395395

396396
building &base;
397397
building::impl_data_t &data;

src/building/building_architect_post.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ void building_architect_post::window_info_background(object_info &c) {
4848
}
4949

5050
void building_architect_post::spawn_figure() {
51-
base.common_spawn_roamer(FIGURE_ARCHITECT, 50, FIGURE_ACTION_60_ENGINEER_CREATED);
51+
common_spawn_roamer(FIGURE_ARCHITECT, 50, FIGURE_ACTION_60_ENGINEER_CREATED);
5252
}
5353

src/building/building_health.cpp

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "building_health.h"
22

33
#include "building/building.h"
4+
#include "building/figure.h"
45
#include "city/object_info.h"
56
#include "game/resource.h"
67
#include "graphics/elements/panel.h"
@@ -34,7 +35,7 @@ static void building_health_draw_info(object_info& c, int help_id, const char* t
3435
window_building_draw_employment(&c, 142);
3536
}
3637

37-
void building_apothecary_draw_info(object_info& c) {
38+
void building_apothecary::window_info_background(object_info& c) {
3839
building_health_draw_info(c, 63, "apothecary", e_text_building_apothecary, FIGURE_HERBALIST);
3940
}
4041

@@ -69,3 +70,22 @@ void building_physician_draw_info(object_info& c) {
6970
inner_panel_draw(c.offset.x + 16, c.offset.y + 136, c.width_blocks - 2, 4);
7071
window_building_draw_employment(&c, 142);
7172
}
73+
74+
void building_apothecary::spawn_figure() {
75+
common_spawn_roamer(FIGURE_HERBALIST, 50, FIGURE_ACTION_125_ROAMING);
76+
// check_labor_problem();
77+
// if (has_figure_of_type(FIGURE_DOCTOR))
78+
// return;
79+
// map_point road;
80+
// if (map_has_road_access(x, y, size, &road)) {
81+
// spawn_labor_seeker(50);
82+
// int spawn_delay = figure_spawn_timer();
83+
// if (spawn_delay == -1)
84+
// return;
85+
// figure_spawn_delay++;
86+
// if (figure_spawn_delay > spawn_delay) {
87+
// figure_spawn_delay = 0;
88+
// create_roaming_figure(road.x, road.y, FIGURE_DOCTOR);
89+
// }
90+
// }
91+
}

src/building/building_health.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
#pragma once
22

3-
struct object_info;
3+
#include "building/building.h"
4+
5+
class building_apothecary : public building_impl {
6+
public:
7+
building_apothecary(building &b) : building_impl(b) {}
8+
virtual void window_info_background(object_info &c) override;
9+
virtual void spawn_figure() override;
10+
};
411

5-
void building_apothecary_draw_info(object_info& c);
612
void building_dentist_draw_info(object_info& c);
713
void building_mortuary_draw_info(object_info& c);
814
void building_physician_draw_info(object_info& c);

src/building/figure.cpp

+1-19
Original file line numberDiff line numberDiff line change
@@ -543,24 +543,7 @@ void building::spawn_figure_mortuary() {
543543
// }
544544
// }
545545
}
546-
void building::spawn_figure_apothecary() {
547-
common_spawn_roamer(FIGURE_HERBALIST, 50);
548-
// check_labor_problem();
549-
// if (has_figure_of_type(FIGURE_DOCTOR))
550-
// return;
551-
// map_point road;
552-
// if (map_has_road_access(x, y, size, &road)) {
553-
// spawn_labor_seeker(50);
554-
// int spawn_delay = figure_spawn_timer();
555-
// if (spawn_delay == -1)
556-
// return;
557-
// figure_spawn_delay++;
558-
// if (figure_spawn_delay > spawn_delay) {
559-
// figure_spawn_delay = 0;
560-
// create_roaming_figure(road.x, road.y, FIGURE_DOCTOR);
561-
// }
562-
// }
563-
}
546+
564547
void building::spawn_figure_dentist() {
565548
common_spawn_roamer(FIGURE_DENTIST, 50);
566549
}
@@ -1274,7 +1257,6 @@ bool building::figure_generate() {
12741257
case BUILDING_SCRIBAL_SCHOOL: spawn_figure_school(); break;
12751258
case BUILDING_LIBRARY: spawn_figure_library(); break;
12761259
case BUILDING_WATER_LIFT: common_spawn_figure_trigger(50); break;
1277-
case BUILDING_APOTHECARY: spawn_figure_apothecary(); break;
12781260
case BUILDING_DENTIST: spawn_figure_dentist(); break;
12791261
case BUILDING_MORTUARY: spawn_figure_mortuary(); break;
12801262
case BUILDING_PHYSICIAN: spawn_figure_physician(); break;

src/building/properties.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static building_properties properties[400] = {
5252
{3, 1, 0, 0}, // statues ^^^
5353
{3, 1, GROUP_BUILDING_FORT}, // archers
5454
{3, 1, GROUP_BUILDING_FORT}, // infantry
55-
{1, 0, GROUP_BUILDING_APOTHECARY}, // apothecary
55+
{1, 0, 0, 0}, // apothecary
5656
{2, 0, GROUP_BUILDING_MORTUARY}, // mortuary
5757
{2, 0, 0, 0},
5858
{1, 0, GROUP_BUILDING_DENTIST}, // dentist
@@ -264,6 +264,7 @@ void building_properties_init() {
264264
properties[BUILDING_BAZAAR] = {2, 0, 0, 0, 0, IMG_BAZAAR};
265265
properties[BUILDING_BRICKLAYERS_GUILD] = {2, 0, 0, 0, 0, IMG_BRICKLAYERS_GUILD};
266266
properties[BUILDING_FIREHOUSE] = {1, 0, 0, 0, 0, IMG_BUILDING_FIREHOUSE};
267+
properties[BUILDING_APOTHECARY] = {1, 0, 0, 0, 0, IMG_BUILDING_APOTHECARY};
267268
}
268269

269270
const building_properties* building_properties_for_type(e_building_type type) {

src/graphics/image_groups.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ enum e_pack {
132132
#define GROUP_BUILDING_TIMBER_YARD PACK_GENERAL, 65
133133
#define GROUP_BUILDING_FORT PACK_GENERAL, 66
134134
#define GROUP_BUILDING_DENTIST PACK_GENERAL, 67
135-
#define GROUP_BUILDING_APOTHECARY PACK_GENERAL, 68
135+
//#define GROUP_BUILDING_APOTHECARY PACK_GENERAL, 68
136136
//#define GROUP_BUILDING_WATER_SUPPLY PACK_GENERAL, 69
137137
//#define GROUP_BUILDING_PHYSICIAN PACK_GENERAL, 70
138138
#define GROUP_BUILDING_MORTUARY PACK_GENERAL, 175 // 70

src/graphics/indexes.h

+1
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,4 @@ REGISTER_IMG(IMG_BIGSLED_CLAY, 125)
126126
REGISTER_IMG(IMG_BIGSLED_BRICKS, 126)
127127
REGISTER_IMG(IMG_SMALL_MASTABA_BRICKS, 127)
128128
REGISTER_IMG(IMG_BUILDING_FIREHOUSE, 128)
129+
REGISTER_IMG(IMG_BUILDING_APOTHECARY, 128)

src/scripts/images.js

+1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ images = [
147147
{img: IMG_BIGSLED_BRICKS, pack:PACK_SPR_MAIN, id:172},
148148
{img: IMG_SMALL_MASTABA_BRICKS, pack:PACK_MASTABA, id:1, offset:0},
149149
{img: IMG_BUILDING_FIREHOUSE, pack:PACK_GENERAL, id:78},
150+
{img: IMG_BUILDING_APOTHECARY, pack:PACK_GENERAL, id:68},
150151
]
151152

152153
cart_offsets = [

src/window/window_building_info.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,6 @@ static void draw_refresh_background() {
656656
case BUILDING_DANCE_SCHOOL: building_dancer_school_draw_info(context); break;
657657
case BUILDING_JUGGLER_SCHOOL: building_juggler_school_draw_info(context); break;
658658
case BUILDING_SENET_MASTER: building_bullfight_school_draw_info(context); break;
659-
case BUILDING_APOTHECARY: building_apothecary_draw_info(context); break;
660659
case BUILDING_MORTUARY: building_mortuary_draw_info(context); break;
661660
case BUILDING_PHYSICIAN: building_physician_draw_info(context); break;
662661
case BUILDING_DENTIST: building_dentist_draw_info(context); break;

0 commit comments

Comments
 (0)