Skip to content

Commit

Permalink
dock: update functionality that handle moored ships
Browse files Browse the repository at this point in the history
  • Loading branch information
s.kushnirenko committed Jun 25, 2024
1 parent c6b9fac commit c6a4736
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
5 changes: 3 additions & 2 deletions src/building/building.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ class building {
struct dock_t {
short queued_docker_id;
int dock_tiles[2];
unsigned char num_ships;
signed char orientation;
uint8_t num_ships;
char orientation;
short docker_ids[3];
short trade_ship_id;
uint8_t docker_anim_frame;
} dock;
struct market_t {
short inventory[8];
Expand Down
32 changes: 13 additions & 19 deletions src/building/building_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,27 +248,21 @@ int building_dock::window_info_handle_mouse(const mouse *m, object_info &c) {
}

bool building_dock::draw_ornaments_and_animations_height(painter &ctx, vec2i point, tile2i t, color color_mask) {
int num_dockers = count_idle_dockers();
if (num_dockers > 0) {
int num_idle_dockers = count_idle_dockers();
if (num_idle_dockers > 0) {
int image_dock = map_image_at(t);
int image_dockers = image_id_from_group(GROUP_BUILDING_DOCK_DOCKERS);
animation_t anim_dockers;
int image_dock_base = dock_m.anim["base"].first_img();
if (image_dock == image_dock_base)
image_dockers += 0;
else if (image_dock == image_dock_base + 1)
image_dockers += 3;
else if (image_dock == image_dock_base + 2)
image_dockers += 6;
else
image_dockers += 9;

if (num_dockers == 2)
image_dockers += 1;
else if (num_dockers == 3)
image_dockers += 2;

const image_t* img = image_get(image_dockers);
ImageDraw::img_generic(ctx, image_dockers, t.x() + img->animation.sprite_offset.x, t.y() + img->animation.sprite_offset.y, color_mask);
if (image_dock == image_dock_base) anim_dockers = dock_m.anim["work_n"];
else if (image_dock == image_dock_base + 1) anim_dockers = dock_m.anim["work_w"];
else if (image_dock == image_dock_base + 2) anim_dockers = dock_m.anim["work_s"];
else anim_dockers = dock_m.anim["work_e"];

data.dock.docker_anim_frame++;
data.dock.docker_anim_frame %= (anim_dockers.max_frames * anim_dockers.duration);
int img_id = anim_dockers.first_img() + (data.dock.docker_anim_frame / anim_dockers.duration) * 4;
const image_t* img = image_get(img_id);
ImageDraw::img_generic(ctx, img_id, point + anim_dockers.pos, color_mask);
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/image_groups.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ enum e_pack {
////////////////// SPRAMBIENT

//#define GROUP_FIGURE_CARGO_FLOTSAM PACK_SPR_AMBIENT, 0 // 1 + 15831
#define GROUP_BUILDING_DOCK_DOCKERS PACK_SPR_AMBIENT, 55 // 171
//#define GROUP_BUILDING_DOCK_DOCKERS PACK_SPR_AMBIENT, 55 // 171
#define GROUP_FIGURE_SHAD_NE PACK_SPR_AMBIENT, 1 // 37 + 15831
#define GROUP_FIGURE_SHAD_SE PACK_SPR_AMBIENT, 2 // 50 + 15831
#define GROUP_FIGURE_SHAD_SW PACK_SPR_AMBIENT, 3 // 63 + 15831
Expand Down
5 changes: 4 additions & 1 deletion src/scripts/building_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,10 @@ building_dock = {
animations : {
preview : { pack:PACK_TERRAIN, id:49 },
base : { pack:PACK_TERRAIN, id:49 },
work : { pack:PACK_TERRAIN, id:49, offset:1, max_frames:12 }
work_n : { pos:[125, -47], pack:PACK_SPR_AMBIENT, id:55, offset:3, max_frames:25, duration:8 },
work_w : { pos:[55, -27], pack:PACK_SPR_AMBIENT, id:55, offset:1, max_frames:25, duration:4 },
work_s : { pos:[55, -27], pack:PACK_SPR_AMBIENT, id:55, offset:2, max_frames:25, duration:4 },
work_e : { pos:[55, -27], pack:PACK_SPR_AMBIENT, id:55, offset:3, max_frames:25, duration:4 }
},
labor_category : LABOR_CATEGORY_INDUSTRY_COMMERCE,
building_size : 3,
Expand Down

0 comments on commit c6a4736

Please sign in to comment.