Skip to content

Commit c6a4736

Browse files
author
s.kushnirenko
committed
dock: update functionality that handle moored ships
1 parent c6b9fac commit c6a4736

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
lines changed

src/building/building.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,11 @@ class building {
171171
struct dock_t {
172172
short queued_docker_id;
173173
int dock_tiles[2];
174-
unsigned char num_ships;
175-
signed char orientation;
174+
uint8_t num_ships;
175+
char orientation;
176176
short docker_ids[3];
177177
short trade_ship_id;
178+
uint8_t docker_anim_frame;
178179
} dock;
179180
struct market_t {
180181
short inventory[8];

src/building/building_dock.cpp

+13-19
Original file line numberDiff line numberDiff line change
@@ -248,27 +248,21 @@ int building_dock::window_info_handle_mouse(const mouse *m, object_info &c) {
248248
}
249249

250250
bool building_dock::draw_ornaments_and_animations_height(painter &ctx, vec2i point, tile2i t, color color_mask) {
251-
int num_dockers = count_idle_dockers();
252-
if (num_dockers > 0) {
251+
int num_idle_dockers = count_idle_dockers();
252+
if (num_idle_dockers > 0) {
253253
int image_dock = map_image_at(t);
254-
int image_dockers = image_id_from_group(GROUP_BUILDING_DOCK_DOCKERS);
254+
animation_t anim_dockers;
255255
int image_dock_base = dock_m.anim["base"].first_img();
256-
if (image_dock == image_dock_base)
257-
image_dockers += 0;
258-
else if (image_dock == image_dock_base + 1)
259-
image_dockers += 3;
260-
else if (image_dock == image_dock_base + 2)
261-
image_dockers += 6;
262-
else
263-
image_dockers += 9;
264-
265-
if (num_dockers == 2)
266-
image_dockers += 1;
267-
else if (num_dockers == 3)
268-
image_dockers += 2;
269-
270-
const image_t* img = image_get(image_dockers);
271-
ImageDraw::img_generic(ctx, image_dockers, t.x() + img->animation.sprite_offset.x, t.y() + img->animation.sprite_offset.y, color_mask);
256+
if (image_dock == image_dock_base) anim_dockers = dock_m.anim["work_n"];
257+
else if (image_dock == image_dock_base + 1) anim_dockers = dock_m.anim["work_w"];
258+
else if (image_dock == image_dock_base + 2) anim_dockers = dock_m.anim["work_s"];
259+
else anim_dockers = dock_m.anim["work_e"];
260+
261+
data.dock.docker_anim_frame++;
262+
data.dock.docker_anim_frame %= (anim_dockers.max_frames * anim_dockers.duration);
263+
int img_id = anim_dockers.first_img() + (data.dock.docker_anim_frame / anim_dockers.duration) * 4;
264+
const image_t* img = image_get(img_id);
265+
ImageDraw::img_generic(ctx, img_id, point + anim_dockers.pos, color_mask);
272266
}
273267
return false;
274268
}

src/graphics/image_groups.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ enum e_pack {
583583
////////////////// SPRAMBIENT
584584

585585
//#define GROUP_FIGURE_CARGO_FLOTSAM PACK_SPR_AMBIENT, 0 // 1 + 15831
586-
#define GROUP_BUILDING_DOCK_DOCKERS PACK_SPR_AMBIENT, 55 // 171
586+
//#define GROUP_BUILDING_DOCK_DOCKERS PACK_SPR_AMBIENT, 55 // 171
587587
#define GROUP_FIGURE_SHAD_NE PACK_SPR_AMBIENT, 1 // 37 + 15831
588588
#define GROUP_FIGURE_SHAD_SE PACK_SPR_AMBIENT, 2 // 50 + 15831
589589
#define GROUP_FIGURE_SHAD_SW PACK_SPR_AMBIENT, 3 // 63 + 15831

src/scripts/building_info.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,10 @@ building_dock = {
597597
animations : {
598598
preview : { pack:PACK_TERRAIN, id:49 },
599599
base : { pack:PACK_TERRAIN, id:49 },
600-
work : { pack:PACK_TERRAIN, id:49, offset:1, max_frames:12 }
600+
work_n : { pos:[125, -47], pack:PACK_SPR_AMBIENT, id:55, offset:3, max_frames:25, duration:8 },
601+
work_w : { pos:[55, -27], pack:PACK_SPR_AMBIENT, id:55, offset:1, max_frames:25, duration:4 },
602+
work_s : { pos:[55, -27], pack:PACK_SPR_AMBIENT, id:55, offset:2, max_frames:25, duration:4 },
603+
work_e : { pos:[55, -27], pack:PACK_SPR_AMBIENT, id:55, offset:3, max_frames:25, duration:4 }
601604
},
602605
labor_category : LABOR_CATEGORY_INDUSTRY_COMMERCE,
603606
building_size : 3,

0 commit comments

Comments
 (0)