From f6513d7bc5806904a55708a2ddb6673842e933bd Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 1 Mar 2014 01:02:21 +0100 Subject: [PATCH] rnd-20140301-1-src * added ultra-generic, ultra-flexible request door animation handling --- ChangeLog | 3 + src/conf_gfx.c | 36 +++++++++++ src/conf_var.c | 144 +++++++++++++++++++++++++++++++++++++++++++ src/conftime.h | 2 +- src/libgame/system.h | 2 + src/tools.c | 39 ++++++++---- 6 files changed, 214 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index bbd7e406..fd98ab0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2014-03-01 + * added ultra-generic, ultra-flexible request door animation handling + 2014-02-18 * fixed major bugs in handling single-player and multi-player tapes (for details, see http://www.artsoft.org/forum/viewtopic.php?t=2086) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 3eb72e80..317c11bd 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -5974,6 +5974,8 @@ struct ConfigInfo image_config[] = { "door_1.part_1.step_yoffset", "1" }, { "door_1.part_1.step_delay", "20" }, { "door_1.part_1.start_step", "0" }, + { "door_1.part_1.start_step_opening", "0" }, + { "door_1.part_1.start_step_closing", "0" }, { "door_1.part_1.draw_masked", "true" }, { "door_1.part_1.draw_order", "3" }, { "door_1.part_2.x", "0" }, @@ -5982,6 +5984,8 @@ struct ConfigInfo image_config[] = { "door_1.part_2.step_yoffset", "1" }, { "door_1.part_2.step_delay", "20" }, { "door_1.part_2.start_step", "0" }, + { "door_1.part_2.start_step_opening", "0" }, + { "door_1.part_2.start_step_closing", "0" }, { "door_1.part_2.draw_masked", "true" }, { "door_1.part_2.draw_order", "5" }, { "door_1.part_3.x", "0" }, @@ -5990,6 +5994,8 @@ struct ConfigInfo image_config[] = { "door_1.part_3.step_yoffset", "1" }, { "door_1.part_3.step_delay", "20" }, { "door_1.part_3.start_step", "0" }, + { "door_1.part_3.start_step_opening", "0" }, + { "door_1.part_3.start_step_closing", "0" }, { "door_1.part_3.draw_masked", "true" }, { "door_1.part_3.draw_order", "4" }, { "door_1.part_4.x", "0" }, @@ -5998,6 +6004,8 @@ struct ConfigInfo image_config[] = { "door_1.part_4.step_yoffset", "1" }, { "door_1.part_4.step_delay", "20" }, { "door_1.part_4.start_step", "0" }, + { "door_1.part_4.start_step_opening", "0" }, + { "door_1.part_4.start_step_closing", "0" }, { "door_1.part_4.draw_masked", "true" }, { "door_1.part_4.draw_order", "6" }, { "door_1.part_5.x", "0" }, @@ -6006,6 +6014,8 @@ struct ConfigInfo image_config[] = { "door_1.part_5.step_yoffset", "-1" }, { "door_1.part_5.step_delay", "20" }, { "door_1.part_5.start_step", "0" }, + { "door_1.part_5.start_step_opening", "0" }, + { "door_1.part_5.start_step_closing", "0" }, { "door_1.part_5.draw_masked", "true" }, { "door_1.part_5.draw_order", "1" }, { "door_1.part_6.x", "0" }, @@ -6014,6 +6024,8 @@ struct ConfigInfo image_config[] = { "door_1.part_6.step_yoffset", "-1" }, { "door_1.part_6.step_delay", "20" }, { "door_1.part_6.start_step", "0" }, + { "door_1.part_6.start_step_opening", "0" }, + { "door_1.part_6.start_step_closing", "0" }, { "door_1.part_6.draw_masked", "true" }, { "door_1.part_6.draw_order", "7" }, { "door_1.part_7.x", "0" }, @@ -6022,6 +6034,8 @@ struct ConfigInfo image_config[] = { "door_1.part_7.step_yoffset", "-1" }, { "door_1.part_7.step_delay", "20" }, { "door_1.part_7.start_step", "0" }, + { "door_1.part_7.start_step_opening", "0" }, + { "door_1.part_7.start_step_closing", "0" }, { "door_1.part_7.draw_masked", "true" }, { "door_1.part_7.draw_order", "2" }, { "door_1.part_8.x", "0" }, @@ -6030,6 +6044,8 @@ struct ConfigInfo image_config[] = { "door_1.part_8.step_yoffset", "-1" }, { "door_1.part_8.step_delay", "20" }, { "door_1.part_8.start_step", "0" }, + { "door_1.part_8.start_step_opening", "0" }, + { "door_1.part_8.start_step_closing", "0" }, { "door_1.part_8.draw_masked", "true" }, { "door_1.part_8.draw_order", "8" }, @@ -6039,6 +6055,8 @@ struct ConfigInfo image_config[] = { "door_2.part_1.step_yoffset", "1" }, { "door_2.part_1.step_delay", "20" }, { "door_2.part_1.start_step", "0" }, + { "door_2.part_1.start_step_opening", "0" }, + { "door_2.part_1.start_step_closing", "0" }, { "door_2.part_1.draw_masked", "true" }, { "door_2.part_1.draw_order", "2" }, { "door_2.part_2.x", "0" }, @@ -6047,6 +6065,8 @@ struct ConfigInfo image_config[] = { "door_2.part_2.step_yoffset", "1" }, { "door_2.part_2.step_delay", "20" }, { "door_2.part_2.start_step", "0" }, + { "door_2.part_2.start_step_opening", "0" }, + { "door_2.part_2.start_step_closing", "0" }, { "door_2.part_2.draw_masked", "true" }, { "door_2.part_2.draw_order", "3" }, { "door_2.part_3.x", "0" }, @@ -6055,6 +6075,8 @@ struct ConfigInfo image_config[] = { "door_2.part_3.step_yoffset", "-1" }, { "door_2.part_3.step_delay", "20" }, { "door_2.part_3.start_step", "0" }, + { "door_2.part_3.start_step_opening", "0" }, + { "door_2.part_3.start_step_closing", "0" }, { "door_2.part_3.draw_masked", "true" }, { "door_2.part_3.draw_order", "1" }, { "door_2.part_4.x", "0" }, @@ -6063,6 +6085,8 @@ struct ConfigInfo image_config[] = { "door_2.part_4.step_yoffset", "-1" }, { "door_2.part_4.step_delay", "20" }, { "door_2.part_4.start_step", "0" }, + { "door_2.part_4.start_step_opening", "0" }, + { "door_2.part_4.start_step_closing", "0" }, { "door_2.part_4.draw_masked", "true" }, { "door_2.part_4.draw_order", "4" }, { "door_2.part_5.x", "-1" }, @@ -6071,6 +6095,8 @@ struct ConfigInfo image_config[] = { "door_2.part_5.step_yoffset", "0" }, { "door_2.part_5.step_delay", "0" }, { "door_2.part_5.start_step", "0" }, + { "door_2.part_5.start_step_opening", "0" }, + { "door_2.part_5.start_step_closing", "0" }, { "door_2.part_5.draw_masked", "true" }, { "door_2.part_5.draw_order", "0" }, { "door_2.part_6.x", "-1" }, @@ -6079,6 +6105,8 @@ struct ConfigInfo image_config[] = { "door_2.part_6.step_yoffset", "0" }, { "door_2.part_6.step_delay", "0" }, { "door_2.part_6.start_step", "0" }, + { "door_2.part_6.start_step_opening", "0" }, + { "door_2.part_6.start_step_closing", "0" }, { "door_2.part_6.draw_masked", "true" }, { "door_2.part_6.draw_order", "0" }, { "door_2.part_7.x", "-1" }, @@ -6087,6 +6115,8 @@ struct ConfigInfo image_config[] = { "door_2.part_7.step_yoffset", "0" }, { "door_2.part_7.step_delay", "0" }, { "door_2.part_7.start_step", "0" }, + { "door_2.part_7.start_step_opening", "0" }, + { "door_2.part_7.start_step_closing", "0" }, { "door_2.part_7.draw_masked", "true" }, { "door_2.part_7.draw_order", "0" }, { "door_2.part_8.x", "-1" }, @@ -6095,6 +6125,8 @@ struct ConfigInfo image_config[] = { "door_2.part_8.step_yoffset", "0" }, { "door_2.part_8.step_delay", "0" }, { "door_2.part_8.start_step", "0" }, + { "door_2.part_8.start_step_opening", "0" }, + { "door_2.part_8.start_step_closing", "0" }, { "door_2.part_8.draw_masked", "true" }, { "door_2.part_8.draw_order", "0" }, @@ -6104,6 +6136,8 @@ struct ConfigInfo image_config[] = { "door_1.panel.step_yoffset", "1" }, { "door_1.panel.step_delay", "10" }, { "door_1.panel.start_step", "212" }, + { "door_1.panel.start_step_opening", "0" }, + { "door_1.panel.start_step_closing", "0" }, { "door_1.panel.draw_masked", "false" }, { "door_1.panel.draw_order", "0" }, @@ -6113,6 +6147,8 @@ struct ConfigInfo image_config[] = { "door_2.panel.step_yoffset", "1" }, { "door_2.panel.step_delay", "10" }, { "door_2.panel.start_step", "32" }, + { "door_2.panel.start_step_opening", "0" }, + { "door_2.panel.start_step_closing", "0" }, { "door_2.panel.draw_masked", "false" }, { "door_2.panel.draw_order", "0" }, diff --git a/src/conf_var.c b/src/conf_var.c index 0f760780..af5915b5 100644 --- a/src/conf_var.c +++ b/src/conf_var.c @@ -2116,6 +2116,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_1.part_1.start_step", &door_1.part_1.start_step }, + { + "door_1.part_1.start_step_opening", + &door_1.part_1.start_step_opening + }, + { + "door_1.part_1.start_step_closing", + &door_1.part_1.start_step_closing + }, { "door_1.part_1.draw_masked", &door_1.part_1.draw_masked @@ -2148,6 +2156,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_1.part_2.start_step", &door_1.part_2.start_step }, + { + "door_1.part_2.start_step_opening", + &door_1.part_2.start_step_opening + }, + { + "door_1.part_2.start_step_closing", + &door_1.part_2.start_step_closing + }, { "door_1.part_2.draw_masked", &door_1.part_2.draw_masked @@ -2180,6 +2196,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_1.part_3.start_step", &door_1.part_3.start_step }, + { + "door_1.part_3.start_step_opening", + &door_1.part_3.start_step_opening + }, + { + "door_1.part_3.start_step_closing", + &door_1.part_3.start_step_closing + }, { "door_1.part_3.draw_masked", &door_1.part_3.draw_masked @@ -2212,6 +2236,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_1.part_4.start_step", &door_1.part_4.start_step }, + { + "door_1.part_4.start_step_opening", + &door_1.part_4.start_step_opening + }, + { + "door_1.part_4.start_step_closing", + &door_1.part_4.start_step_closing + }, { "door_1.part_4.draw_masked", &door_1.part_4.draw_masked @@ -2244,6 +2276,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_1.part_5.start_step", &door_1.part_5.start_step }, + { + "door_1.part_5.start_step_opening", + &door_1.part_5.start_step_opening + }, + { + "door_1.part_5.start_step_closing", + &door_1.part_5.start_step_closing + }, { "door_1.part_5.draw_masked", &door_1.part_5.draw_masked @@ -2276,6 +2316,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_1.part_6.start_step", &door_1.part_6.start_step }, + { + "door_1.part_6.start_step_opening", + &door_1.part_6.start_step_opening + }, + { + "door_1.part_6.start_step_closing", + &door_1.part_6.start_step_closing + }, { "door_1.part_6.draw_masked", &door_1.part_6.draw_masked @@ -2308,6 +2356,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_1.part_7.start_step", &door_1.part_7.start_step }, + { + "door_1.part_7.start_step_opening", + &door_1.part_7.start_step_opening + }, + { + "door_1.part_7.start_step_closing", + &door_1.part_7.start_step_closing + }, { "door_1.part_7.draw_masked", &door_1.part_7.draw_masked @@ -2340,6 +2396,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_1.part_8.start_step", &door_1.part_8.start_step }, + { + "door_1.part_8.start_step_opening", + &door_1.part_8.start_step_opening + }, + { + "door_1.part_8.start_step_closing", + &door_1.part_8.start_step_closing + }, { "door_1.part_8.draw_masked", &door_1.part_8.draw_masked @@ -2372,6 +2436,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_2.part_1.start_step", &door_2.part_1.start_step }, + { + "door_2.part_1.start_step_opening", + &door_2.part_1.start_step_opening + }, + { + "door_2.part_1.start_step_closing", + &door_2.part_1.start_step_closing + }, { "door_2.part_1.draw_masked", &door_2.part_1.draw_masked @@ -2404,6 +2476,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_2.part_2.start_step", &door_2.part_2.start_step }, + { + "door_2.part_2.start_step_opening", + &door_2.part_2.start_step_opening + }, + { + "door_2.part_2.start_step_closing", + &door_2.part_2.start_step_closing + }, { "door_2.part_2.draw_masked", &door_2.part_2.draw_masked @@ -2436,6 +2516,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_2.part_3.start_step", &door_2.part_3.start_step }, + { + "door_2.part_3.start_step_opening", + &door_2.part_3.start_step_opening + }, + { + "door_2.part_3.start_step_closing", + &door_2.part_3.start_step_closing + }, { "door_2.part_3.draw_masked", &door_2.part_3.draw_masked @@ -2468,6 +2556,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_2.part_4.start_step", &door_2.part_4.start_step }, + { + "door_2.part_4.start_step_opening", + &door_2.part_4.start_step_opening + }, + { + "door_2.part_4.start_step_closing", + &door_2.part_4.start_step_closing + }, { "door_2.part_4.draw_masked", &door_2.part_4.draw_masked @@ -2500,6 +2596,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_2.part_5.start_step", &door_2.part_5.start_step }, + { + "door_2.part_5.start_step_opening", + &door_2.part_5.start_step_opening + }, + { + "door_2.part_5.start_step_closing", + &door_2.part_5.start_step_closing + }, { "door_2.part_5.draw_masked", &door_2.part_5.draw_masked @@ -2532,6 +2636,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_2.part_6.start_step", &door_2.part_6.start_step }, + { + "door_2.part_6.start_step_opening", + &door_2.part_6.start_step_opening + }, + { + "door_2.part_6.start_step_closing", + &door_2.part_6.start_step_closing + }, { "door_2.part_6.draw_masked", &door_2.part_6.draw_masked @@ -2564,6 +2676,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_2.part_7.start_step", &door_2.part_7.start_step }, + { + "door_2.part_7.start_step_opening", + &door_2.part_7.start_step_opening + }, + { + "door_2.part_7.start_step_closing", + &door_2.part_7.start_step_closing + }, { "door_2.part_7.draw_masked", &door_2.part_7.draw_masked @@ -2596,6 +2716,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_2.part_8.start_step", &door_2.part_8.start_step }, + { + "door_2.part_8.start_step_opening", + &door_2.part_8.start_step_opening + }, + { + "door_2.part_8.start_step_closing", + &door_2.part_8.start_step_closing + }, { "door_2.part_8.draw_masked", &door_2.part_8.draw_masked @@ -2628,6 +2756,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_1.panel.start_step", &door_1.panel.start_step }, + { + "door_1.panel.start_step_opening", + &door_1.panel.start_step_opening + }, + { + "door_1.panel.start_step_closing", + &door_1.panel.start_step_closing + }, { "door_1.panel.draw_masked", &door_1.panel.draw_masked @@ -2660,6 +2796,14 @@ struct TokenIntPtrInfo image_config_vars[] = "door_2.panel.start_step", &door_2.panel.start_step }, + { + "door_2.panel.start_step_opening", + &door_2.panel.start_step_opening + }, + { + "door_2.panel.start_step_closing", + &door_2.panel.start_step_closing + }, { "door_2.panel.draw_masked", &door_2.panel.draw_masked diff --git a/src/conftime.h b/src/conftime.h index 7e43d7b5..2154ffca 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-02-28 21:40" +#define COMPILE_DATE_STRING "2014-03-01 00:52" diff --git a/src/libgame/system.h b/src/libgame/system.h index 0d7f583c..b74b6fae 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1215,6 +1215,8 @@ struct DoorPartPosInfo int step_yoffset; int step_delay; int start_step; + int start_step_opening; + int start_step_closing; boolean draw_masked; int sort_priority; }; diff --git a/src/tools.c b/src/tools.c index 0348f112..d7f64e0a 100644 --- a/src/tools.c +++ b/src/tools.c @@ -5335,7 +5335,15 @@ void InitDoors() struct DoorPartControlInfo *dpc = &door_part_controls[i]; struct DoorPartOrderInfo *dpo = &door_part_order[i]; - /* fill structure for door part draw order */ + /* initialize "start_step_opening" and "start_step_closing", if needed */ + if (dpc->pos->start_step_opening == 0 && + dpc->pos->start_step_closing == 0) + { + dpc->pos->start_step_opening = dpc->pos->start_step; + dpc->pos->start_step_closing = dpc->pos->start_step; + } + + /* fill structure for door part draw order (sorted below) */ dpo->nr = i; dpo->sort_priority = dpc->pos->sort_priority; @@ -5523,13 +5531,21 @@ unsigned int MoveDoor(unsigned int door_state) for (i = 0; i < MAX_DOOR_PARTS; i++) { - struct DoorPartControlInfo *dpc = &door_part_controls[i]; - struct GraphicInfo *g = &graphic_info[dpc->graphic]; + int nr = door_part_order[i].nr; + struct DoorPartControlInfo *dpc = &door_part_controls[nr]; struct DoorPartPosInfo *pos = dpc->pos; + struct GraphicInfo *g = &graphic_info[dpc->graphic]; + int door_token = dpc->door_nr; + boolean is_panel = DOOR_PART_IS_PANEL(nr); int step_xoffset = ABS(pos->step_xoffset); int step_yoffset = ABS(pos->step_yoffset); int step_delay = pos->step_delay; - int start_step = pos->start_step; + int current_door_state = door_state & door_token; + boolean door_opening = ((current_door_state & DOOR_OPEN) != 0); + boolean door_closing = ((current_door_state & DOOR_CLOSE) != 0); + boolean part_opening = (is_panel ? door_closing : door_opening); + int start_step = (part_opening ? pos->start_step_opening : + pos->start_step_closing); float move_xsize = (step_xoffset ? g->width : 0); float move_ysize = (step_yoffset ? g->height : 0); int move_xsteps = (step_xoffset ? ceil(move_xsize / step_xoffset) : 0); @@ -5539,13 +5555,13 @@ unsigned int MoveDoor(unsigned int door_state) move_xsteps ? move_xsteps : move_ysteps) - start_step; int move_delay = move_steps * step_delay; - if (door_part_done[i]) + if (door_part_done[nr]) continue; max_move_delay = MAX(max_move_delay, move_delay); max_step_delay = (max_step_delay == 0 ? step_delay : euclid(max_step_delay, step_delay)); - num_steps[i] = move_steps; + num_steps[nr] = move_steps; #if 0 #if 0 @@ -5580,23 +5596,24 @@ unsigned int MoveDoor(unsigned int door_state) { int nr = door_part_order[i].nr; struct DoorPartControlInfo *dpc = &door_part_controls[nr]; + struct DoorPartPosInfo *pos = dpc->pos; + struct GraphicInfo *g = &graphic_info[dpc->graphic]; int door_token = dpc->door_nr; int door_index = DOOR_INDEX_FROM_TOKEN(door_token); boolean is_panel = DOOR_PART_IS_PANEL(nr); - struct GraphicInfo *g = &graphic_info[dpc->graphic]; - struct DoorPartPosInfo *pos = dpc->pos; struct XY *panel_pos = &panel_pos_list[door_index]; struct Rect *door_rect = &door_rect_list[door_index]; Bitmap *bitmap = (is_panel ? bitmap_db_door : g->bitmap); int current_door_state = door_state & door_token; boolean door_opening = ((current_door_state & DOOR_OPEN) != 0); boolean door_closing = ((current_door_state & DOOR_CLOSE) != 0); - boolean mode_opening = (is_panel ? door_closing : door_opening); - int start_step = pos->start_step; + boolean part_opening = (is_panel ? door_closing : door_opening); + int start_step = (part_opening ? pos->start_step_opening : + pos->start_step_closing); int step_delay = pos->step_delay; int step_factor = step_delay / max_step_delay; int k1 = (step_factor ? k / step_factor + 1 : k); - int k2 = (mode_opening ? k1 + start_step : num_steps[nr] - k1); + int k2 = (part_opening ? k1 + start_step : num_steps[nr] - k1); int kk = (k2 < 0 ? 0 : k2); int src_x, src_y, src_xx, src_yy; int dst_x, dst_y, dst_xx, dst_yy; -- 2.34.1