Skip to content

Commit 23b27e9

Browse files
committed
building: correct save wharf orientation
1 parent c9116bd commit 23b27e9

5 files changed

+29
-9
lines changed

src/building/building.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -1189,11 +1189,9 @@ static void read_type_data(io_buffer *iob, building *b, size_t version) {
11891189
iob->bind____skip(26);
11901190
iob->bind____skip(57);
11911191
iob->bind(BIND_SIGNATURE_UINT8, &data.farm.worker_frame);
1192-
} else {
1192+
} else if (building_is_entertainment(b->type)) {
11931193
iob->bind____skip(26);
1194-
iob->bind____skip(56);
1195-
iob->bind(BIND_SIGNATURE_UINT8, &data.guild.max_workers);
1196-
iob->bind____skip(1);
1194+
iob->bind____skip(58);
11971195
iob->bind(BIND_SIGNATURE_UINT8, &data.entertainment.num_shows);
11981196
iob->bind(BIND_SIGNATURE_UINT8, &data.entertainment.juggler_visited);
11991197
iob->bind(BIND_SIGNATURE_UINT8, &data.entertainment.musician_visited);
@@ -1208,6 +1206,12 @@ static void read_type_data(io_buffer *iob, building *b, size_t version) {
12081206
iob->bind(BIND_SIGNATURE_UINT8, &data.entertainment.consume_material_id);
12091207
iob->bind(BIND_SIGNATURE_UINT8, &data.entertainment.spawned_entertainer_days);
12101208
iob->bind(BIND_SIGNATURE_UINT32, &data.entertainment.booth_corner_grid_offset);
1209+
} else if (b->type == BUILDING_WARSHIP_WHARF) {
1210+
iob->bind(BIND_SIGNATURE_UINT8, &data.wharf.orientation);
1211+
} else {
1212+
iob->bind____skip(26);
1213+
iob->bind____skip(56);
1214+
iob->bind(BIND_SIGNATURE_UINT8, &data.guild.max_workers);
12111215
}
12121216
}
12131217

@@ -1273,9 +1277,10 @@ io_buffer* iob_buildings = new io_buffer([](io_buffer* iob, size_t version) {
12731277
iob->bind(BIND_SIGNATURE_UINT8, &b->health_proof);
12741278
iob->bind(BIND_SIGNATURE_INT16, &b->formation_id);
12751279

1276-
read_type_data(iob, b, version); // 42 bytes for C3, 102 for PH
1280+
read_type_data(iob, b, version); // 102 for PH
12771281

12781282
int currind = iob->get_offset() - sind;
1283+
assert(currind > 0);
12791284
iob->bind____skip(184 - currind);
12801285

12811286
iob->bind(BIND_SIGNATURE_INT32, &b->tax_income_or_storage);

src/building/building.h

+5
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ class building {
247247
unsigned short work_camp_id;
248248
unsigned char worker_id;
249249
} industry;
250+
251+
struct {
252+
uint8_t orientation;
253+
} wharf;
254+
250255
struct entertainment_t {
251256
uint8_t spawned_entertainer_days;
252257
uint8_t num_shows;

src/building/building_warship_wharf.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ void building_warship_wharf::static_params::load(archive arch) {
1111
}
1212

1313
void building_warship_wharf::on_create(int orientation) {
14-
data.industry.orientation = orientation;
14+
data.wharf.orientation = orientation;
1515
}
1616

1717
void building_warship_wharf::on_place(int orientation, int variant) {
@@ -27,7 +27,7 @@ void building_warship_wharf::on_place_update_tiles(int orientation, int variant)
2727
}
2828

2929
void building_warship_wharf::update_map_orientation(int orientation) {
30-
int image_offset = city_view_relative_orientation(data.industry.orientation);
30+
int image_offset = city_view_relative_orientation(data.wharf.orientation);
3131
int image_id = anim(animkeys().base).first_img() + image_offset;
3232
map_water_add_building(id(), tile(), size(), image_id);
3333
}

src/building/building_wharf.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
#include "city/labor.h"
55
#include "grid/water.h"
66

7-
buildings::model_t<building_transport_wharf> transport_wharf_m;
7+
building_transport_wharf::static_params transport_wharf_m;
8+
9+
void building_transport_wharf::static_params::load(archive arch) {
10+
11+
}
812

913
void building_wharf::on_create(int orientation) {
10-
data.industry.orientation = orientation;
14+
data.wharf.orientation = orientation;
1115
}
1216

1317
void building_wharf::on_place_update_tiles(int orientation, int variant) {

src/building/building_wharf.h

+6
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,11 @@ class building_transport_wharf : public building_wharf {
1616
public:
1717
BUILDING_METAINFO(BUILDING_TRANSPORT_WHARF, building_transport_wharf)
1818
building_transport_wharf(building &b) : building_wharf(b) {}
19+
20+
struct static_params : public buildings::model_t<building_transport_wharf> {
21+
virtual void load(archive arch) override;
22+
};
23+
24+
static const static_params &current_params() { return (const static_params &)params(TYPE); }
1925
};
2026

0 commit comments

Comments
 (0)