From fb7af97484b7f4ba999dcbb39dffe52216d0d29e Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Mon, 18 Nov 2024 23:32:32 +0000 Subject: [PATCH 01/15] Trying to see if tunnels work in low walls mode First I'm seeing in the wall height is calculated incorrectly --- src/bflib_coroutine.c | 2 +- src/map_columns.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/bflib_coroutine.c b/src/bflib_coroutine.c index 63b1799c3b..9f08cd5115 100644 --- a/src/bflib_coroutine.c +++ b/src/bflib_coroutine.c @@ -5,7 +5,7 @@ * "Improvised coroutine-like functions" * @par Purpose: * Implementation - * @author KeeperFF Team + * @author KeeperFX Team * @date 01 Nov 2020 * @par Copying and copyrights: * This program is free software; you can redistribute it and/or modify diff --git a/src/map_columns.c b/src/map_columns.c index 92b5c330be..8607f4ba19 100644 --- a/src/map_columns.c +++ b/src/map_columns.c @@ -240,17 +240,20 @@ void make_solidmask(struct Column *col) unsigned short find_column_height(struct Column *col) { - unsigned short h; + unsigned short h, highest; h = 0; + highest = 0; // Want to find height even if column has holes in if (col->solidmask == 0) - return h; - while (col->cubes[h] > 0) + return highest; + while (h < COLUMN_STACK_HEIGHT) { + if (col->cubes[h]>0) + { + highest = h; + } h++; - if (h >= COLUMN_STACK_HEIGHT) - return COLUMN_STACK_HEIGHT; } - return h; + return highest; } /** From b5507fc09b2bd6fa7a82284191980512263fd98b Mon Sep 17 00:00:00 2001 From: Loobinex Date: Tue, 19 Nov 2024 01:09:18 +0100 Subject: [PATCH 02/15] Used enum values for col->bitfields --- src/engine_render.c | 18 +++++++++--------- src/map_columns.c | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/engine_render.c b/src/engine_render.c index 7e889af23f..e53ef8a4d6 100644 --- a/src/engine_render.c +++ b/src/engine_render.c @@ -1160,7 +1160,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_cur = col->solidmask; - if ((mask_cur >= 8) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & 0xE) == 0)) { + if ((mask_cur >= 8) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_cur &= 3; } } @@ -1168,7 +1168,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_yp = col->solidmask; - if ((mask_yp >= 8) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & 0xE) == 0)) { + if ((mask_yp >= 8) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_yp &= 3; } } @@ -1234,7 +1234,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_cur = col->solidmask; - if ((mask_cur >= 8) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & 0xE) == 0)) { + if ((mask_cur >= 8) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_cur &= 3; } } @@ -1242,7 +1242,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_yp = col->solidmask; - if ((mask_yp >= 8) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & 0xE) == 0)) { + if ((mask_yp >= 8) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_yp &= 3; } } @@ -4467,7 +4467,7 @@ static void do_a_plane_of_engine_columns_cluedo(long stl_x, long stl_y, long pla solidmsk_cur = solidmsk_cur_raw; if (solidmsk_cur >= (1<<3)) { - if (((cur_mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((cur_colmn->bitfields & 0xE) == 0)) { + if (((cur_mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((cur_colmn->bitfields & CLF_CEILING_MASK) == 0)) { solidmsk_cur &= 3; } } @@ -4480,7 +4480,7 @@ static void do_a_plane_of_engine_columns_cluedo(long stl_x, long stl_y, long pla solidmsk_back = colmn->solidmask; if (solidmsk_back >= (1<<3)) { - if (((sib_mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((colmn->bitfields & 0xE) == 0)) { + if (((sib_mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((colmn->bitfields & CLF_CEILING_MASK) == 0)) { solidmsk_back &= 3; } } @@ -4492,7 +4492,7 @@ static void do_a_plane_of_engine_columns_cluedo(long stl_x, long stl_y, long pla solidmsk_front = colmn->solidmask; if (solidmsk_front >= (1<<3)) { - if (((sib_mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((colmn->bitfields & 0xE) == 0)) { + if (((sib_mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((colmn->bitfields & CLF_CEILING_MASK) == 0)) { solidmsk_front &= 3; } } @@ -4504,7 +4504,7 @@ static void do_a_plane_of_engine_columns_cluedo(long stl_x, long stl_y, long pla solidmsk_left = colmn->solidmask; if (solidmsk_left >= (1<<3)) { - if (((sib_mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((colmn->bitfields & 0xE) == 0)) { + if (((sib_mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((colmn->bitfields & CLF_CEILING_MASK) == 0)) { solidmsk_left &= 3; } } @@ -4516,7 +4516,7 @@ static void do_a_plane_of_engine_columns_cluedo(long stl_x, long stl_y, long pla solidmsk_right = colmn->solidmask; if (solidmsk_right >= (1<<3)) { - if (((sib_mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((colmn->bitfields & 0xE) == 0)) { + if (((sib_mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((colmn->bitfields & CLF_CEILING_MASK) == 0)) { solidmsk_right &= 3; } } diff --git a/src/map_columns.c b/src/map_columns.c index 8607f4ba19..146b2ab60b 100644 --- a/src/map_columns.c +++ b/src/map_columns.c @@ -68,7 +68,7 @@ TbBool column_invalid(const struct Column *colmn) */ long get_column_floor_filled_subtiles(const struct Column *col) { - return (col->bitfields & 0xF0) >> 4; + return (col->bitfields & CLF_FLOOR_MASK) >> 4; } /** @@ -81,7 +81,7 @@ long get_map_floor_filled_subtiles(const struct Map *mapblk) col = get_map_column(mapblk); if (column_invalid(col)) return 0; - return (col->bitfields & 0xF0) >> 4; + return (col->bitfields & CLF_FLOOR_MASK) >> 4; } /** @@ -95,7 +95,7 @@ long get_floor_filled_subtiles_at(MapSubtlCoord stl_x, MapSubtlCoord stl_y) col = get_column_at(stl_x, stl_y); if (column_invalid(col)) return 0; - return (col->bitfields & 0xF0) >> 4; + return (col->bitfields & CLF_FLOOR_MASK) >> 4; } /** @@ -105,8 +105,8 @@ long get_floor_filled_subtiles_at(MapSubtlCoord stl_x, MapSubtlCoord stl_y) */ void set_column_floor_filled_subtiles(struct Column *col, MapSubtlCoord n) { - col->bitfields &= ~0xF0; - col->bitfields |= (n<<4) & 0xF0; + col->bitfields &= ~CLF_FLOOR_MASK; + col->bitfields |= (n<<4) & CLF_FLOOR_MASK; } /** @@ -120,8 +120,8 @@ void set_map_floor_filled_subtiles(struct Map *mapblk, MapSubtlCoord n) col = get_map_column(mapblk); if (column_invalid(col)) return; - col->bitfields &= ~0xF0; - col->bitfields |= (n<<4) & 0xF0; + col->bitfields &= ~CLF_FLOOR_MASK; + col->bitfields |= (n<<4) & CLF_FLOOR_MASK; } /** @@ -475,14 +475,14 @@ void init_columns(void) } if (n >= COLUMN_STACK_HEIGHT) { - col->bitfields &= ~0x0E; + col->bitfields &= ~CLF_CEILING_MASK; } else { mskbit = 0; for (n=COLUMN_STACK_HEIGHT-1; n > 0; n--) { if (col->cubes[n] != 0) { - col->bitfields ^= (mskbit ^ col->bitfields) & 0xE; + col->bitfields ^= (mskbit ^ col->bitfields) & CLF_CEILING_MASK; } mskbit += 2; } From fe17872fe31623441f6cc9d1efb442a158da3aed Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Wed, 20 Nov 2024 00:28:23 +0000 Subject: [PATCH 03/15] Updated solidmask check to check if cubes exist at heights solidmask seemed to only count the number of solid cubes from the bottom (even though it shouldn't), so instead of checking if a column is 4 or more cubes tall, this checks if cube 4 (cubes[3]) or higher exists --- src/engine_render.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/engine_render.c b/src/engine_render.c index e53ef8a4d6..d277307941 100644 --- a/src/engine_render.c +++ b/src/engine_render.c @@ -1151,6 +1151,16 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, struct Column *col; unsigned long pfulmask_or; unsigned long pfulmask_and; + bool has_cube(const struct Column *col) { + for (int i = 3; i < COLUMN_STACK_HEIGHT; i++) { + if (col->cubes[i] > 0) { + return true; + } + } + return false; + } + + { unsigned long mask_cur; unsigned long mask_yp; @@ -1160,7 +1170,8 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_cur = col->solidmask; - if ((mask_cur >= 8) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + + if (has_cubes(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_cur &= 3; } } @@ -1168,7 +1179,8 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_yp = col->solidmask; - if ((mask_yp >= 8) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + + if (has_cubes(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_yp &= 3; } } @@ -1234,7 +1246,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_cur = col->solidmask; - if ((mask_cur >= 8) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cubes(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_cur &= 3; } } @@ -1242,7 +1254,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_yp = col->solidmask; - if ((mask_yp >= 8) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cubes(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_yp &= 3; } } From bea67ed96d09af1348185e31297534fd84879fd8 Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Wed, 20 Nov 2024 00:34:07 +0000 Subject: [PATCH 04/15] Update engine_render.c --- src/engine_render.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/engine_render.c b/src/engine_render.c index d277307941..95333d5d8b 100644 --- a/src/engine_render.c +++ b/src/engine_render.c @@ -1116,6 +1116,16 @@ static void fill_in_points_perspective(struct Camera *cam, long bstl_x, long bst } } +bool has_cube(const struct Column *col) +{ + for (int i = 3; i < COLUMN_STACK_HEIGHT; i++) { + if (col->cubes[i] > 0) { + return true; + } + } + return false; +} + static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, struct MinMax *mm) { if ((bstl_y < 0) || (bstl_y > gameadd.map_subtiles_y-1)) { @@ -1151,16 +1161,6 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, struct Column *col; unsigned long pfulmask_or; unsigned long pfulmask_and; - bool has_cube(const struct Column *col) { - for (int i = 3; i < COLUMN_STACK_HEIGHT; i++) { - if (col->cubes[i] > 0) { - return true; - } - } - return false; - } - - { unsigned long mask_cur; unsigned long mask_yp; From 2cf6e6ffe872f9a9faacf2540344d3a50ace05b3 Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Wed, 20 Nov 2024 00:54:52 +0000 Subject: [PATCH 05/15] changed to TbBool, added to header --- src/engine_render.c | 10 +++++----- src/engine_render.h | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/engine_render.c b/src/engine_render.c index 95333d5d8b..849ffe376b 100644 --- a/src/engine_render.c +++ b/src/engine_render.c @@ -1116,7 +1116,7 @@ static void fill_in_points_perspective(struct Camera *cam, long bstl_x, long bst } } -bool has_cube(const struct Column *col) +TbBool has_cube(const struct Column *col) { for (int i = 3; i < COLUMN_STACK_HEIGHT; i++) { if (col->cubes[i] > 0) { @@ -1171,7 +1171,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, col = get_map_column(mapblk); mask_cur = col->solidmask; - if (has_cubes(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cube(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_cur &= 3; } } @@ -1180,7 +1180,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, col = get_map_column(mapblk); mask_yp = col->solidmask; - if (has_cubes(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cube(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_yp &= 3; } } @@ -1246,7 +1246,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_cur = col->solidmask; - if (has_cubes(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cube(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_cur &= 3; } } @@ -1254,7 +1254,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_yp = col->solidmask; - if (has_cubes(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cube(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_yp &= 3; } } diff --git a/src/engine_render.h b/src/engine_render.h index dc5f94b484..64066544ed 100644 --- a/src/engine_render.h +++ b/src/engine_render.h @@ -145,6 +145,8 @@ void draw_map_volume_box(long cor1_x, long cor1_y, long cor2_x, long cor2_y, lon void update_engine_settings(struct PlayerInfo *player); void draw_view(struct Camera *cam, unsigned char a2); void draw_frontview_engine(struct Camera *cam); + +TbBool has_cube(const struct Column *col); /******************************************************************************/ #ifdef __cplusplus } From 12ab7b7bc2608aec71debbdae53f139499c997a8 Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Wed, 20 Nov 2024 01:00:59 +0000 Subject: [PATCH 06/15] struct not const struct --- src/engine_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine_render.c b/src/engine_render.c index 849ffe376b..201805ef2b 100644 --- a/src/engine_render.c +++ b/src/engine_render.c @@ -1116,7 +1116,7 @@ static void fill_in_points_perspective(struct Camera *cam, long bstl_x, long bst } } -TbBool has_cube(const struct Column *col) +TbBool has_cube(struct Column *col) { for (int i = 3; i < COLUMN_STACK_HEIGHT; i++) { if (col->cubes[i] > 0) { From aab0fdc342fcf26e40984dea74a9c5021c4a1adf Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Wed, 20 Nov 2024 01:05:28 +0000 Subject: [PATCH 07/15] header too --- src/engine_render.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine_render.h b/src/engine_render.h index 64066544ed..9f18da46b5 100644 --- a/src/engine_render.h +++ b/src/engine_render.h @@ -146,7 +146,7 @@ void update_engine_settings(struct PlayerInfo *player); void draw_view(struct Camera *cam, unsigned char a2); void draw_frontview_engine(struct Camera *cam); -TbBool has_cube(const struct Column *col); +TbBool has_cube(struct Column *col); /******************************************************************************/ #ifdef __cplusplus } From 1fa09a41f37f1c2e0fa2697e48f57de92acda6d8 Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Wed, 20 Nov 2024 01:11:23 +0000 Subject: [PATCH 08/15] Revert "Trying to see if tunnels work in low walls mode" This reverts commit fb7af97484b7f4ba999dcbb39dffe52216d0d29e. --- src/bflib_coroutine.c | 2 +- src/map_columns.c | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/bflib_coroutine.c b/src/bflib_coroutine.c index 9f08cd5115..63b1799c3b 100644 --- a/src/bflib_coroutine.c +++ b/src/bflib_coroutine.c @@ -5,7 +5,7 @@ * "Improvised coroutine-like functions" * @par Purpose: * Implementation - * @author KeeperFX Team + * @author KeeperFF Team * @date 01 Nov 2020 * @par Copying and copyrights: * This program is free software; you can redistribute it and/or modify diff --git a/src/map_columns.c b/src/map_columns.c index 146b2ab60b..3c1fdf92fd 100644 --- a/src/map_columns.c +++ b/src/map_columns.c @@ -240,20 +240,17 @@ void make_solidmask(struct Column *col) unsigned short find_column_height(struct Column *col) { - unsigned short h, highest; + unsigned short h; h = 0; - highest = 0; // Want to find height even if column has holes in if (col->solidmask == 0) - return highest; - while (h < COLUMN_STACK_HEIGHT) + return h; + while (col->cubes[h] > 0) { - if (col->cubes[h]>0) - { - highest = h; - } h++; + if (h >= COLUMN_STACK_HEIGHT) + return COLUMN_STACK_HEIGHT; } - return highest; + return h; } /** From 53c61619c6e199e427aef7c849f3585045f541e1 Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Wed, 20 Nov 2024 01:12:39 +0000 Subject: [PATCH 09/15] misc typos while i'm here --- src/bflib_coroutine.c | 2 +- src/lvl_filesdk1.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bflib_coroutine.c b/src/bflib_coroutine.c index 63b1799c3b..9f08cd5115 100644 --- a/src/bflib_coroutine.c +++ b/src/bflib_coroutine.c @@ -5,7 +5,7 @@ * "Improvised coroutine-like functions" * @par Purpose: * Implementation - * @author KeeperFF Team + * @author KeeperFX Team * @date 01 Nov 2020 * @par Copying and copyrights: * This program is free software; you can redistribute it and/or modify diff --git a/src/lvl_filesdk1.c b/src/lvl_filesdk1.c index 7e091c5471..c0fce98849 100644 --- a/src/lvl_filesdk1.c +++ b/src/lvl_filesdk1.c @@ -2,7 +2,7 @@ // Free implementation of Bullfrog's Dungeon Keeper strategy game. /******************************************************************************/ /** @file lvl_filesdk1.c - * Level files reading routines fore standard DK1 levels. + * Level files reading routines for standard DK1 levels. * @par Purpose: * Allows reading level files in DK1 format. * @par Comment: From 3e79003bf8f5f50173a349937e34f6643b2aff63 Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Wed, 20 Nov 2024 01:48:01 +0000 Subject: [PATCH 10/15] Update engine_render.c --- src/engine_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine_render.c b/src/engine_render.c index 201805ef2b..470c67df94 100644 --- a/src/engine_render.c +++ b/src/engine_render.c @@ -1118,7 +1118,7 @@ static void fill_in_points_perspective(struct Camera *cam, long bstl_x, long bst TbBool has_cube(struct Column *col) { - for (int i = 3; i < COLUMN_STACK_HEIGHT; i++) { + for (int i = 3; i < COLUMN_STACK_HEIGHT-1; i++) { if (col->cubes[i] > 0) { return true; } From 4c1627e75075a165739d8cd1558b3ba0a3ccb908 Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Thu, 21 Nov 2024 13:07:39 +0000 Subject: [PATCH 11/15] notes, temp revert of find_column_height --- src/engine_render.c | 2 +- src/map_columns.c | 65 ++++++++++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/engine_render.c b/src/engine_render.c index 470c67df94..7c0b456430 100644 --- a/src/engine_render.c +++ b/src/engine_render.c @@ -470,7 +470,7 @@ struct EngineCoord object_origin; short mx; short my; short mz; -unsigned char temp_cluedo_mode; // This is true(1) if the "short wall" have been enabled in the graphics options +unsigned char temp_cluedo_mode; // This is true(1) if "low walls/"short wall" has been enabled in the graphics options struct Thing *thing_being_displayed; TbSpriteData *keepsprite[KEEPSPRITE_LENGTH]; diff --git a/src/map_columns.c b/src/map_columns.c index 3c1fdf92fd..65d8d5ad7e 100644 --- a/src/map_columns.c +++ b/src/map_columns.c @@ -63,16 +63,22 @@ TbBool column_invalid(const struct Column *colmn) } /** - * Returns amount of filled subtiles at bottom of given column. + * These commands retrieve and set how much of the column intersects with the standard floor and ceiling + * + * + */ + +/** + * Returns amount of filled subtiles at bottom of given column (how many make up the floor). * @param col The column which filled height should be returned. */ long get_column_floor_filled_subtiles(const struct Column *col) { - return (col->bitfields & CLF_FLOOR_MASK) >> 4; + return (col->bitfields & CLF_FLOOR_MASK) >> 4; // Returns standard floor level or lower } /** - * Returns amount of filled subtiles at bottom of column at given map block. + * Returns amount of filled subtiles at bottom of column at given map block (how many make up the floor). * @param mapblk The map block for which column height should be returned. */ long get_map_floor_filled_subtiles(const struct Map *mapblk) @@ -81,11 +87,11 @@ long get_map_floor_filled_subtiles(const struct Map *mapblk) col = get_map_column(mapblk); if (column_invalid(col)) return 0; - return (col->bitfields & CLF_FLOOR_MASK) >> 4; + return (col->bitfields & CLF_FLOOR_MASK) >> 4; // Returns standard floor level or lower } /** - * Returns amount of filled subtiles at bottom of column at given coords. + * Returns amount of filled subtiles at bottom of column at given coords (how many make up the floor). * @param stl_x Subtile for which column height should be returned, X coord. * @param stl_y Subtile for which column height should be returned, Y coord. */ @@ -95,22 +101,22 @@ long get_floor_filled_subtiles_at(MapSubtlCoord stl_x, MapSubtlCoord stl_y) col = get_column_at(stl_x, stl_y); if (column_invalid(col)) return 0; - return (col->bitfields & CLF_FLOOR_MASK) >> 4; + return (col->bitfields & CLF_FLOOR_MASK) >> 4; // Returns standard floor level or lower } /** - * Sets amount of filled subtiles at bottom of given column. + * Sets amount of filled subtiles at bottom of given column (how many make up the floor). * @param col The column which filled height should be set. * @param n Amount of subtiles. */ void set_column_floor_filled_subtiles(struct Column *col, MapSubtlCoord n) { - col->bitfields &= ~CLF_FLOOR_MASK; - col->bitfields |= (n<<4) & CLF_FLOOR_MASK; + col->bitfields &= ~CLF_FLOOR_MASK; + col->bitfields |= (n<<4) & CLF_FLOOR_MASK; // sets standard floor level or lower } /** - * Sets amount of filled subtiles at bottom of a column at given map block. + * Sets amount of filled subtiles at bottom of a column at given map block (how many make up the floor). * @param mapblk The map block for which filled height should be set. * @param n Amount of subtiles. */ @@ -121,20 +127,20 @@ void set_map_floor_filled_subtiles(struct Map *mapblk, MapSubtlCoord n) if (column_invalid(col)) return; col->bitfields &= ~CLF_FLOOR_MASK; - col->bitfields |= (n<<4) & CLF_FLOOR_MASK; + col->bitfields |= (n<<4) & CLF_FLOOR_MASK; // sets standard floor level or lower } /** - * Returns amount of filled subtiles at top of given column. + * Returns amount of filled subtiles at top of given column (how many make up the ceiling). * @param col The column which filled height should be returned. */ long get_column_ceiling_filled_subtiles(const struct Column *col) { - return (col->bitfields & CLF_CEILING_MASK) >> 1; + return (col->bitfields & CLF_CEILING_MASK) >> 1; // Returns ceiling length or lower if column is shorter } /** - * Returns amount of filled subtiles at top of column at given map block. + * Returns amount of filled subtiles at top of column at given map block (how many make up the ceiling). * @param mapblk The map block for which column height should be returned. */ long get_map_ceiling_filled_subtiles(const struct Map *mapblk) @@ -240,17 +246,20 @@ void make_solidmask(struct Column *col) unsigned short find_column_height(struct Column *col) { - unsigned short h; + unsigned short h, highest; h = 0; + highest = 0; // Want to find height even if column has holes in if (col->solidmask == 0) - return h; - while (col->cubes[h] > 0) + return highest; + while (h < COLUMN_STACK_HEIGHT) { + if (col->cubes[h]>0) + { + highest = h; + } h++; - if (h >= COLUMN_STACK_HEIGHT) - return COLUMN_STACK_HEIGHT; } - return h; + return highest; } /** @@ -443,36 +452,36 @@ void init_columns(void) mskbit = 1; col->solidmask = 0; int n; - for (n=0; n < COLUMN_STACK_HEIGHT; n++) + for (n=0; n < COLUMN_STACK_HEIGHT; n++) { if (col->cubes[n] != 0) { - col->solidmask |= mskbit; + col->solidmask |= mskbit; //set nth bit to 1 if the cube is nonempty } mskbit *= 2; } - if (col->solidmask) + if (col->solidmask) // if column contains any cubes { for (n=0; n < COLUMN_STACK_HEIGHT; n++) { if (col->cubes[n] == 0) { - break; + break; // set the number of solid cubes from the floor } } } else { n = 0; } - set_column_floor_filled_subtiles(col, n); - n = get_column_floor_filled_subtiles(col); + set_column_floor_filled_subtiles(col, n); + n = get_column_floor_filled_subtiles(col); // adjusts n against floor level for (;n < COLUMN_STACK_HEIGHT; n++) { if (col->cubes[n] != 0) { - break; + break; // get first nonempty cube above floor } } if (n >= COLUMN_STACK_HEIGHT) { - col->bitfields &= ~CLF_CEILING_MASK; + col->bitfields &= ~CLF_CEILING_MASK; // zero out any that are in ceiling } else { mskbit = 0; From 7a5113b390860832a0fc7175614014b5d17927b7 Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:08:53 +0000 Subject: [PATCH 12/15] Update map_columns.c --- src/map_columns.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/map_columns.c b/src/map_columns.c index 65d8d5ad7e..d251f1acbb 100644 --- a/src/map_columns.c +++ b/src/map_columns.c @@ -354,7 +354,7 @@ long create_column(struct Column *col) { long result; struct Column *dst; - unsigned char v6; + unsigned char floor_level; unsigned char top_of_floor; // Find an empty column @@ -376,12 +376,12 @@ long create_column(struct Column *col) make_solidmask(dst); // Find lowest cube - for (v6 = 0; v6 < COLUMN_STACK_HEIGHT;v6++) + for (floor_level = 0; floor_level < COLUMN_STACK_HEIGHT;floor_level++) { - if ( dst->cubes[v6] == 0) + if ( dst->cubes[floor_level] == 0) // first empty cube from bottom break; } - top_of_floor = v6; + top_of_floor = floor_level; // set lowest cube info dst->bitfields &= ~CLF_FLOOR_MASK; dst->bitfields |= (top_of_floor << 4); @@ -396,7 +396,7 @@ long create_column(struct Column *col) unsigned char ceiling = top_of_floor; for (; ceiling < COLUMN_STACK_HEIGHT; ceiling++) { - if (dst->cubes[ceiling]) + if (dst->cubes[ceiling]) // first solid cube above that break; } @@ -406,14 +406,14 @@ long create_column(struct Column *col) } else { - unsigned short *v13 = &dst->cubes[7]; + unsigned short *ceiling_cube_id = &dst->cubes[7]; unsigned char v12 = 0; // Counting ceiling height for (int i = 0; i < COLUMN_STACK_HEIGHT-1; i++) { - if (*v13) + if (*ceiling_cube_id) dst->bitfields ^= (v12 ^ dst->bitfields) & CLF_CEILING_MASK; - --v13; + --ceiling_cube_id; v12 += 2; } } From 5bc211fa83d71970af90633804f727f113db936a Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:30:25 +0000 Subject: [PATCH 13/15] Update engine_render.c --- src/engine_render.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/engine_render.c b/src/engine_render.c index 7c0b456430..cb5b57883c 100644 --- a/src/engine_render.c +++ b/src/engine_render.c @@ -1116,10 +1116,10 @@ static void fill_in_points_perspective(struct Camera *cam, long bstl_x, long bst } } -TbBool has_cube(struct Column *col) +TbBool has_cube_higher_up(struct Column *col) { - for (int i = 3; i < COLUMN_STACK_HEIGHT-1; i++) { - if (col->cubes[i] > 0) { + for (int i = 3; i < COLUMN_STACK_HEIGHT; i++) { + if (col->cubes[i] != 0) { return true; } } @@ -1171,7 +1171,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, col = get_map_column(mapblk); mask_cur = col->solidmask; - if (has_cube(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_cur &= 3; } } @@ -1180,7 +1180,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, col = get_map_column(mapblk); mask_yp = col->solidmask; - if (has_cube(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_yp &= 3; } } @@ -1246,7 +1246,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_cur = col->solidmask; - if (has_cube(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_cur &= 3; } } @@ -1254,7 +1254,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_yp = col->solidmask; - if (has_cube(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_yp &= 3; } } From 82e5b4149c9687f80fd865edfd7f83b70d3a11e0 Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Thu, 21 Nov 2024 22:38:20 +0000 Subject: [PATCH 14/15] let's just try removing this bit --- src/engine_render.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine_render.c b/src/engine_render.c index cb5b57883c..3f0e0b0e04 100644 --- a/src/engine_render.c +++ b/src/engine_render.c @@ -1171,7 +1171,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, col = get_map_column(mapblk); mask_cur = col->solidmask; - if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0)) { mask_cur &= 3; } } @@ -1180,7 +1180,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, col = get_map_column(mapblk); mask_yp = col->solidmask; - if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0)) { mask_yp &= 3; } } @@ -1246,7 +1246,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_cur = col->solidmask; - if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0)) { mask_cur &= 3; } } @@ -1254,7 +1254,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_yp = col->solidmask; - if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { + if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0)) { mask_yp &= 3; } } From f77072d5cf2d09c07f26f166bdb63ac6f14a070c Mon Sep 17 00:00:00 2001 From: Spatulade <100633508+Spatulade@users.noreply.github.com> Date: Thu, 21 Nov 2024 23:17:52 +0000 Subject: [PATCH 15/15] reverted some stuff --- src/engine_render.c | 8 ++++---- src/map_columns.c | 15 ++++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/engine_render.c b/src/engine_render.c index 3f0e0b0e04..cb5b57883c 100644 --- a/src/engine_render.c +++ b/src/engine_render.c @@ -1171,7 +1171,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, col = get_map_column(mapblk); mask_cur = col->solidmask; - if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0)) { + if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_cur &= 3; } } @@ -1180,7 +1180,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, col = get_map_column(mapblk); mask_yp = col->solidmask; - if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0)) { + if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_yp &= 3; } } @@ -1246,7 +1246,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_cur = col->solidmask; - if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0)) { + if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_cur &= 3; } } @@ -1254,7 +1254,7 @@ static void fill_in_points_cluedo(struct Camera *cam, long bstl_x, long bstl_y, if (map_block_revealed(mapblk, my_player_number)) { col = get_map_column(mapblk); mask_yp = col->solidmask; - if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0)) { + if (has_cube_higher_up(col) && ((mapblk->flags & (SlbAtFlg_IsDoor|SlbAtFlg_IsRoom)) == 0) && ((col->bitfields & CLF_CEILING_MASK) == 0)) { mask_yp &= 3; } } diff --git a/src/map_columns.c b/src/map_columns.c index d251f1acbb..570dd1239d 100644 --- a/src/map_columns.c +++ b/src/map_columns.c @@ -246,20 +246,17 @@ void make_solidmask(struct Column *col) unsigned short find_column_height(struct Column *col) { - unsigned short h, highest; + unsigned short h; h = 0; - highest = 0; // Want to find height even if column has holes in if (col->solidmask == 0) - return highest; - while (h < COLUMN_STACK_HEIGHT) + return h; + while (col->cubes[h] > 0) { - if (col->cubes[h]>0) - { - highest = h; - } h++; + if (h >= COLUMN_STACK_HEIGHT) + return COLUMN_STACK_HEIGHT; } - return highest; + return h; } /**