Skip to content

Commit 09dd0cd

Browse files
author
s.kushnirenko
committed
building: clay pit building makes with new model system
1 parent 21077d6 commit 09dd0cd

20 files changed

+85
-31
lines changed

src/building/building.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ static void building_new_fill_in_data_for_type(building* b, e_building_type type
170170
b->output_resource_first_id = RESOURCE_TIMBER;
171171
b->data.industry.max_gatheres = 1;
172172
break;
173-
case BUILDING_CLAY_PIT:
174-
b->output_resource_first_id = RESOURCE_CLAY;
175-
break;
176173
case BUILDING_WEAVER_WORKSHOP:
177174
b->data.industry.first_material_id = RESOURCE_FLAX;
178175
b->output_resource_first_id = RESOURCE_LINEN;
@@ -334,6 +331,7 @@ building_impl *building::dcast() {
334331
case BUILDING_STONE_QUARRY: _ptr = new building_quarry_stone(*this); break;
335332
case BUILDING_GOLD_MINE: _ptr = new building_mine_gold(*this); break;
336333
case BUILDING_WATER_SUPPLY: _ptr = new building_water_supply(*this); break;
334+
case BUILDING_CLAY_PIT: _ptr = new building_clay_pit(*this); break;
337335

338336
case BUILDING_VILLAGE_PALACE:
339337
case BUILDING_TOWN_PALACE:

src/building/building.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ class building {
359359
void update_road_access();
360360
void update_month();
361361
bool figure_generate();
362-
int get_fire_risk(int value);
363362

364363
void school_add_papyrus(int amount);
365364

@@ -391,6 +390,7 @@ class building_impl {
391390
virtual e_sound_channel_city sound_channel() const { return SOUND_CHANNEL_CITY_NONE; }
392391
virtual int animation_speed(int speed) const { return speed; }
393392
virtual int get_produce_uptick_per_day() const { return base.num_workers; }
393+
virtual int get_fire_risk(int value) const { return value; }
394394

395395
inline bool is_main() { return base.is_main(); }
396396
inline void check_labor_problem() { base.check_labor_problem(); }

src/building/building_animation.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include "building_animation.h"
2-
31
#include "building/building_type.h"
42
#include "grid/water_supply.h"
53

src/building/building_bandstand.h

+1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ class building_bandstand : public building_impl {
1010
virtual void window_info_background(object_info &c) override;
1111
virtual bool draw_ornaments_and_animations_height(painter &ctx, vec2i point, tile2i tile, color mask) override;
1212
virtual int animation_speed(int speed) const override { return 4; }
13+
virtual int get_fire_risk(int value) const override { return value / 10; }
1314
};

src/building/building_booth.h

+1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ 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 int get_fire_risk(int value) const override { return value / 10; }
1112
};

src/building/building_palace.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void config_load_building_palace_model() {
3333
village_palace_model.anim.load(arch);
3434
});
3535

36-
city_labor_set_category(village_palace_model.type, village_palace_model.labor_category);
36+
city_labor_set_category(village_palace_model);
3737
}
3838

3939
void building_palace::on_create() {

src/building/building_raw_material.cpp

+51-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@
1616
#include "graphics/text.h"
1717
#include "sound/sound_building.h"
1818
#include "game/game.h"
19+
#include "city/labor.h"
20+
#include "widget/city/ornaments.h"
21+
22+
#include "graphics/animation.h"
23+
24+
namespace model {
25+
26+
struct clay_pit_t {
27+
static constexpr e_building_type type = BUILDING_CLAY_PIT;
28+
e_labor_category labor_category;
29+
animations_t anim;
30+
};
31+
32+
clay_pit_t clay_pit;
33+
34+
}
35+
36+
ANK_REGISTER_CONFIG_ITERATOR(config_load_building_raw_materials);
37+
void config_load_building_raw_materials() {
38+
g_config_arch.r_section("building_clay_pit", [] (archive arch) {
39+
model::clay_pit.labor_category = arch.r_type<e_labor_category>("labor_category");
40+
model::clay_pit.anim.load(arch);
41+
});
42+
43+
city_labor_set_category(model::clay_pit);
44+
}
1945

2046
static void building_raw_material_draw_info(object_info& c, const char* type, e_resource resource) {
2147
auto &meta = building::get_info(type);
@@ -69,9 +95,6 @@ void building_copper_mine_draw_info(object_info& c) {
6995
void building_timber_yard_draw_info(object_info& c) {
7096
building_raw_material_draw_info(c, "timber_yard", RESOURCE_TIMBER);
7197
}
72-
void building_clay_pit_draw_info(object_info& c) {
73-
building_raw_material_draw_info(c, "clay_pit", RESOURCE_CLAY);
74-
}
7598
void building_reed_gatherer_draw_info(object_info& c) {
7699
building_raw_material_draw_info(c, "reed_farm", RESOURCE_REEDS);
77100
}
@@ -105,3 +128,28 @@ void building_quarry_stone::on_create() {
105128
void building_quarry_stone::window_info_background(object_info &c) {
106129
building_raw_material_draw_info(c, "plainstone_quarry", RESOURCE_STONE);
107130
}
131+
132+
void building_clay_pit::on_create() {
133+
base.output_resource_first_id = RESOURCE_CLAY;
134+
}
135+
136+
void building_clay_pit::window_info_background(object_info &c) {
137+
building_raw_material_draw_info(c, "clay_pit", RESOURCE_CLAY);
138+
}
139+
140+
int building_clay_pit::get_fire_risk(int value) const {
141+
if (config_get(CONFIG_GP_CH_CLAY_PIT_FIRE_RISK_REDUCED)) {
142+
return value / 2;
143+
}
144+
145+
return value;
146+
}
147+
148+
bool building_clay_pit::draw_ornaments_and_animations_height(painter &ctx, vec2i point, tile2i tile, color color_mask) {
149+
if (worker_percentage() > 50) {
150+
const animation_t &anim = model::clay_pit.anim["work"];
151+
building_draw_normal_anim(ctx, point, &base, tile, anim, color_mask);
152+
}
153+
154+
return true;
155+
}

src/building/building_raw_material.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@
55
void building_marble_quarry_draw_info(object_info& c);
66
void building_limestone_quarry_draw_info(object_info& c);
77
void building_timber_yard_draw_info(object_info& c);
8-
void building_clay_pit_draw_info(object_info& c);
98
void building_copper_mine_draw_info(object_info &c);
109
void building_reed_gatherer_draw_info(object_info& c);
1110
void building_sandstone_quarry_draw_info(object_info &c);
1211
void building_granite_quarry_draw_info(object_info &c);
1312

13+
class building_clay_pit : public building_impl {
14+
public:
15+
building_clay_pit(building &b) : building_impl(b) {}
16+
virtual void on_create() override;
17+
virtual void window_info_background(object_info &c) override;
18+
virtual int get_fire_risk(int value) const override;
19+
virtual e_sound_channel_city sound_channel() const override { return SOUND_CHANNEL_CITY_CLAY_PIT; }
20+
virtual bool draw_ornaments_and_animations_height(painter &ctx, vec2i point, tile2i tile, color color_mask) override;
21+
};
22+
1423
class building_mine_gold : public building_impl {
1524
public:
1625
building_mine_gold(building &b) : building_impl(b) {}

src/building/figure.cpp

-14
Original file line numberDiff line numberDiff line change
@@ -1132,20 +1132,6 @@ void building::school_add_papyrus(int amount) {
11321132
}
11331133
}
11341134

1135-
int building::get_fire_risk(int value) {
1136-
switch (type) {
1137-
case BUILDING_CLAY_PIT:
1138-
if (config_get(CONFIG_GP_CH_CLAY_PIT_FIRE_RISK_REDUCED))
1139-
return value / 2;
1140-
1141-
case BUILDING_BOOTH:
1142-
case BUILDING_BANDSTAND:
1143-
return value / 10;
1144-
}
1145-
1146-
return value;
1147-
}
1148-
11491135
void building_figure_generate() {
11501136
OZZY_PROFILER_SECTION("Game/Run/Tick/Figure Generate");
11511137
building_barracks_decay_tower_sentry_request();

src/building/maintenance.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void building_maintenance_check_fire_collapse(void) {
210210
expected_fire_risk += 50;
211211
}
212212

213-
expected_fire_risk = b.get_fire_risk(expected_fire_risk);
213+
expected_fire_risk = b.dcast()->get_fire_risk(expected_fire_risk);
214214
b.fire_risk += expected_fire_risk;
215215
// if (climate == CLIMATE_NORTHERN)
216216
// b->fire_risk = 0;

src/building/properties.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static building_properties properties[400] = {
115115
{2, 0, 0, 0}, // stone
116116
{2, 0, GROUP_BUILDING_LIMESTONE_QUARRY}, // limestone
117117
{2, 0, GROUP_BUILDING_TIMBER_YARD}, // wood
118-
{2, 0, GROUP_BUILDING_CLAY_PIT}, // clay
118+
{2, 0, 0, 0}, // clay
119119
{2, 0, 0, 0}, // beer
120120
{2, 0, GROUP_BUILDING_LINEN_WORKSHOP}, // linen
121121
{2, 0, GROUP_BUILDING_WEAPONS_WORKSHOP}, // weapons
@@ -269,6 +269,7 @@ void building_properties_init() {
269269
properties[BUILDING_VILLAGE_PALACE] = {4, 0, 0, 0, 0, IMG_VILLAGE_PALACE};
270270
properties[BUILDING_JUGGLER_SCHOOL] = {2, 0, 0, 0, 0, IMG_JUGGLER_SCHOOL};
271271
properties[BUILDING_HUNTING_LODGE] = {2, 0, 0, 0, 0, IMG_HUNTING_LODGE};
272+
properties[BUILDING_CLAY_PIT] = {2, 0, 0, 0, 0, IMG_CLAY_PIT};
272273
}
273274

274275
const building_properties* building_properties_for_type(e_building_type type) {

src/city/labor.h

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ e_labor_category category_for_building(building* b);
4343
const labor_category_data* city_labor_category(int category);
4444
void city_labor_set_category(e_building_type type, int category);
4545

46+
template<class T>
47+
void city_labor_set_category(const T &model) {
48+
city_labor_set_category(model.type, model.labor_category);
49+
}
50+
4651
void city_labor_calculate_workers(int num_plebs, int num_patricians);
4752

4853
void city_labor_allocate_workers(void);

src/graphics/image_groups.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ enum e_pack {
105105
#define GROUP_BUILDING_HOUSE_PALATIAL PACK_GENERAL, 35
106106
#define GROUP_BUILDING_HOUSE_VACANT_LOT PACK_GENERAL, 36
107107
#define GROUP_BUILDING_FARM_HOUSE PACK_GENERAL, 225 // 37
108-
#define GROUP_BUILDING_CLAY_PIT PACK_GENERAL, 40
108+
//#define GROUP_BUILDING_CLAY_PIT PACK_GENERAL, 40
109109
//#define GROUP_BUILDING_SCRIBAL_SCHOOL PACK_GENERAL, 42 // 41
110110
#define GROUP_BUILDING_LIBRARY PACK_GENERAL, 43 // 42
111111
#define GROUP_BUILDING_ACADEMY PACK_GENERAL, 43 // this isn't in Pharaoh

src/graphics/indexes.h

+1
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,4 @@ REGISTER_IMG(IMG_ADVISOR_BACKGROUND, 132)
134134
REGISTER_IMG(IMG_VILLAGE_PALACE, 133)
135135
REGISTER_IMG(IMG_JUGGLER_SCHOOL, 134)
136136
REGISTER_IMG(IMG_HUNTING_LODGE, 135)
137+
REGISTER_IMG(IMG_CLAY_PIT, 136)

src/scripts/building_info.js

+7
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ building_village_palace = {
5252
labor_category : LABOR_CATEGORY_GOVERNMENT,
5353
}
5454

55+
building_clay_pit = {
56+
animations : {
57+
work : { pos : [-1, -1], anim_id: IMG_CLAY_PIT }
58+
},
59+
labor_category : LABOR_CATEGORY_INDUSTRY_COMMERCE,
60+
}
61+
5562
building_hunting_lodge = {
5663
animations : {
5764
work : { pos : [-1, -1], anim_id: IMG_HUNTING_LODGE }

src/scripts/common.js

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var big_statue_images = []
2323
var top_menu_bar = {}
2424
var main_menu_window = {}
2525
var building_booth = {}
26+
var building_clay_pit = {}
2627
var building_hunting_lodge = {}
2728
var building_village_palace = {}
2829
var building_personal_mansion = {}

src/scripts/images.js

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ images = [
155155
{img: IMG_VILLAGE_PALACE, pack:PACK_GENERAL, id:47, offset:0},
156156
{img: IMG_JUGGLER_SCHOOL, pack:PACK_GENERAL, id:46, offset:0},
157157
{img: IMG_HUNTING_LODGE, pack:PACK_GENERAL, id:176, offset:0},
158+
{img: IMG_CLAY_PIT, pack:PACK_GENERAL, id:40, offset:0},
158159
]
159160

160161
cart_offsets = [

src/sound/city.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ int building_type_to_channel(building *b) {
153153
case BUILDING_WOOD_CUTTERS:
154154
return 0;
155155

156-
case BUILDING_CLAY_PIT: return SOUND_CHANNEL_CITY_CLAY_PIT;
157156
case BUILDING_POTTERY_WORKSHOP: return SOUND_CHANNEL_CITY_POTTERY_WORKSHOP;
158157
}
159158

src/widget/city/ornaments.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "ornaments.h"
22

3-
#include "building/building_animation.h"
43
#include "building/building.h"
54
#include "building/model.h"
65
#include "building/dock.h"

src/window/window_building_info.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,6 @@ static void draw_refresh_background() {
544544

545545
case BUILDING_LIMESTONE_QUARRY: building_limestone_quarry_draw_info(context); break;
546546
case BUILDING_WOOD_CUTTERS: building_timber_yard_draw_info(context); break;
547-
case BUILDING_CLAY_PIT: building_clay_pit_draw_info(context); break;
548547
case BUILDING_REED_GATHERER: building_reed_gatherer_draw_info(context); break;
549548
case BUILDING_COPPER_MINE: building_copper_mine_draw_info(context); break;
550549
case BUILDING_SANDSTONE_QUARRY: building_sandstone_quarry_draw_info(context); break;

0 commit comments

Comments
 (0)