aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--inc/cub3d.h1
-rw-r--r--inc/cub3d_structs.h11
-rw-r--r--src/ft_check_map_line.c6
-rw-r--r--src/ft_check_missing.c10
-rw-r--r--src/ft_detect.c14
-rw-r--r--src/ft_draw_map.c4
-rw-r--r--src/ft_draw_scene.c2
-rw-r--r--src/ft_draw_square.c2
-rw-r--r--src/ft_exit.c15
-rw-r--r--src/ft_get_map.c26
-rw-r--r--src/ft_get_player_spawn.c8
-rw-r--r--src/ft_get_sprite.c4
-rw-r--r--src/ft_get_tex.c16
-rw-r--r--src/ft_init_lists.c19
-rw-r--r--src/ft_init_map.c31
-rw-r--r--src/ft_key_events.c6
-rw-r--r--src/ft_map_error.c2
-rw-r--r--src/ft_parse_map.c10
-rw-r--r--src/ft_print_list.c18
-rw-r--r--src/ft_raycasting.c4
-rw-r--r--src/ft_select_get.c10
-rw-r--r--src/ft_set_minimap_scale.c13
23 files changed, 130 insertions, 103 deletions
diff --git a/Makefile b/Makefile
index 70a75e6..1325b75 100644
--- a/Makefile
+++ b/Makefile
@@ -47,6 +47,7 @@ SRCS_NAME += ft_print_list.c
SRCS_NAME += ft_rgb_to_hex.c
SRCS_NAME += ft_raycasting.c
SRCS_NAME += ft_init_s_ray.c
+SRCS_NAME += ft_init_map.c
SRCS_NAME += ft_detect.c
#------------------------------------------------------------------------------#
SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME})
diff --git a/inc/cub3d.h b/inc/cub3d.h
index 81692e4..a0e48fc 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -58,6 +58,7 @@
*/
int8_t ft_init_cub3d(t_cub **clist);
+t_map *ft_init_map(void);
void ft_hooks_and_loops(t_win *wl, t_cub *cl);
int ft_key_event(int keycode, t_cub *clist);
int ft_click_close(int keycode, t_cub *clist);
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index f40a438..08fc814 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -68,11 +68,7 @@ typedef struct s_ray
uint8_t hit;
} t_ray;
-/* typedef struct s_map */
-/* { */
-/* } t_map; */
-
-typedef struct s_cub
+typedef struct s_map
{
char *no_tex_path;
char *so_tex_path;
@@ -89,9 +85,14 @@ typedef struct s_cub
size_t map_start;
uint8_t isspawn;
uint8_t scale;
+} t_map;
+
+typedef struct s_cub
+{
uint8_t minimap;
struct s_win *wlist;
struct s_player *plist;
+ struct s_map *mlist;
struct s_ray rlist;
struct s_img img;
struct s_rgb f_rgb;
diff --git a/src/ft_check_map_line.c b/src/ft_check_map_line.c
index 1368b63..a53c9c8 100644
--- a/src/ft_check_map_line.c
+++ b/src/ft_check_map_line.c
@@ -46,8 +46,8 @@ int8_t
if (!ft_ischarset("012NSEW ", line[i]))
return (-1);
if (ft_ischarset("NSEW", line[i]))
- clist->isspawn += 1;
- if (clist->isspawn > 1)
+ clist->mlist->isspawn += 1;
+ if (clist->mlist->isspawn > 1)
return (-1);
}
else
@@ -58,7 +58,7 @@ int8_t
i++;
}
if (line[0] != '1' || line[i - 1] != '1'
- || ft_get_line_len(line) != clist->map_w)
+ || ft_get_line_len(line) != clist->mlist->map_w)
return (-1);
return (0);
}
diff --git a/src/ft_check_missing.c b/src/ft_check_missing.c
index ece2ba6..58ef223 100644
--- a/src/ft_check_missing.c
+++ b/src/ft_check_missing.c
@@ -27,15 +27,15 @@ int
int
ft_check_missing(t_cub *clist)
{
- if (!clist->no_tex_path[0])
+ if (!clist->mlist->no_tex_path[0])
return (ft_missing_error("north side texture", clist));
- else if (!clist->so_tex_path[0])
+ else if (!clist->mlist->so_tex_path[0])
return (ft_missing_error("south side texture", clist));
- else if (!clist->ea_tex_path[0])
+ else if (!clist->mlist->ea_tex_path[0])
return (ft_missing_error("east side texture", clist));
- else if (!clist->we_tex_path[0])
+ else if (!clist->mlist->we_tex_path[0])
return (ft_missing_error("west side texture", clist));
- else if (!clist->sprite_path[0])
+ else if (!clist->mlist->sprite_path[0])
return (ft_missing_error("sprite texture", clist));
else if (clist->wlist->x_size == 0 || clist->wlist->y_size == 0)
return (ft_missing_error("resolution", clist));
diff --git a/src/ft_detect.c b/src/ft_detect.c
index b83c9f1..3dafd67 100644
--- a/src/ft_detect.c
+++ b/src/ft_detect.c
@@ -9,13 +9,13 @@ ft_detection_init_y(t_cub *cl)
cl->rlist.y_ray_dir));
if (cl->rlist.y_ray_dir < 0)
{
- cl->y_step = -1;
+ cl->mlist->y_step = -1;
cl->rlist.y_side_dist = (cl->rlist.y_ray_pos -
cl->rlist.sqy) * cl->rlist.y_delta_dist;
}
else
{
- cl->y_step = 1;
+ cl->mlist->y_step = 1;
cl->rlist.y_side_dist = (cl->rlist.sqy + 1.0 -
cl->rlist.y_ray_pos) * cl->rlist.y_delta_dist;
}
@@ -29,13 +29,13 @@ ft_detection_init_x(t_cub *cl)
cl->rlist.x_ray_dir));
if (cl->rlist.x_ray_dir < 0)
{
- cl->x_step = -1;
+ cl->mlist->x_step = -1;
cl->rlist.x_side_dist = (cl->rlist.x_ray_pos -
cl->rlist.sqx) * cl->rlist.x_delta_dist;
}
else
{
- cl->x_step = 1;
+ cl->mlist->x_step = 1;
cl->rlist.x_side_dist = (cl->rlist.sqx + 1.0 -
cl->rlist.x_ray_pos) * cl->rlist.x_delta_dist;
}
@@ -52,16 +52,16 @@ ft_detect(t_cub *cl)
if (cl->rlist.x_side_dist < cl->rlist.y_side_dist)
{
cl->rlist.x_side_dist += cl->rlist.x_delta_dist;
- cl->rlist.sqx += cl->x_step;
+ cl->rlist.sqx += cl->mlist->x_step;
cl->rlist.side = 0;
}
else
{
cl->rlist.y_side_dist += cl->rlist.y_delta_dist;
- cl->rlist.sqy += cl->y_step;
+ cl->rlist.sqy += cl->mlist->y_step;
cl->rlist.side = 1;
}
- if (cl->map[cl->rlist.sqx][cl->rlist.sqy] == '1')
+ if (cl->mlist->map[cl->rlist.sqx][cl->rlist.sqy] == '1')
cl->rlist.hit = 1;
}
}
diff --git a/src/ft_draw_map.c b/src/ft_draw_map.c
index e32b4e9..86865fa 100644
--- a/src/ft_draw_map.c
+++ b/src/ft_draw_map.c
@@ -6,7 +6,7 @@ static void
{
const float x = plist->pos_x;
const float y = plist->pos_y - 1;
- const uint16_t scale = clist->scale;
+ const uint16_t scale = clist->mlist->scale;
ft_draw_square(
scale + (x * (scale)),
@@ -18,7 +18,7 @@ static void
void
ft_draw_map(char **map, t_cub *clist)
{
- const uint8_t scale = clist->scale;
+ const uint8_t scale = clist->mlist->scale;
size_t x;
size_t y;
diff --git a/src/ft_draw_scene.c b/src/ft_draw_scene.c
index 57cecd4..4a5b56e 100644
--- a/src/ft_draw_scene.c
+++ b/src/ft_draw_scene.c
@@ -26,7 +26,7 @@ void
&clist->img.sizeline, &clist->img.endian);
ft_castray(clist);
if (clist->minimap)
- ft_draw_map(clist->map, clist);
+ ft_draw_map(clist->mlist->map, clist);
mlx_put_image_to_window(clist->wlist->wlx,
clist->wlist->winptr, clist->img.img, 0, 0);
mlx_destroy_image(clist->wlist->wlx, clist->img.img);
diff --git a/src/ft_draw_square.c b/src/ft_draw_square.c
index 72cf904..9f9af56 100644
--- a/src/ft_draw_square.c
+++ b/src/ft_draw_square.c
@@ -18,7 +18,7 @@
void
ft_draw_square(int a, int b, int rgb, t_cub *clist)
{
- const uint16_t scale = clist->scale;
+ const uint16_t scale = clist->mlist->scale;
int x;
int y;
diff --git a/src/ft_exit.c b/src/ft_exit.c
index 5e7cd3f..8ada2e4 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -21,13 +21,14 @@
static void
ft_free_lists(t_cub *clist)
{
- ft_memdel((void**)&clist->no_tex_path);
- ft_memdel((void**)&clist->so_tex_path);
- ft_memdel((void**)&clist->ea_tex_path);
- ft_memdel((void**)&clist->we_tex_path);
- ft_memdel((void**)&clist->sprite_path);
- ft_memdel((void**)&clist->mapl);
- ft_free_words(clist->map);
+ ft_memdel((void**)&clist->mlist->no_tex_path);
+ ft_memdel((void**)&clist->mlist->so_tex_path);
+ ft_memdel((void**)&clist->mlist->ea_tex_path);
+ ft_memdel((void**)&clist->mlist->we_tex_path);
+ ft_memdel((void**)&clist->mlist->sprite_path);
+ ft_memdel((void**)&clist->mlist->mapl);
+ ft_free_words(clist->mlist->map);
+ ft_memdel((void**)&clist->mlist);
ft_memdel((void**)&clist->plist);
if (!clist->wlist->inited)
ft_memdel((void**)&clist->wlist->winptr);
diff --git a/src/ft_get_map.c b/src/ft_get_map.c
index 720f412..9148964 100644
--- a/src/ft_get_map.c
+++ b/src/ft_get_map.c
@@ -51,30 +51,30 @@ static void
static int8_t
ft_cat_mapl(char *line, size_t i, t_cub *clist)
{
- if (!(clist->mapl = (char *)ft_nrealloc(clist->mapl,
- ((clist->map_w + 1) * i) * sizeof(char),
- ((clist->map_w + 1) * (i + 1)) * sizeof(char))))
+ if (!(clist->mlist->mapl = (char *)ft_nrealloc(clist->mlist->mapl,
+ ((clist->mlist->map_w + 1) * i) * sizeof(char),
+ ((clist->mlist->map_w + 1) * (i + 1)) * sizeof(char))))
return (-1);
- ft_linecpy(line, clist->mapl, (clist->map_w + 1) * i);
+ ft_linecpy(line, clist->mlist->mapl, (clist->mlist->map_w + 1) * i);
return (0);
}
int
ft_get_map_first_line(char *line, t_cub *clist)
{
- clist->map_start = clist->line_chk;
+ clist->mlist->map_start = clist->mlist->line_chk;
if (!line[0])
{
ft_memdel((void**)&line);
return (-1);
}
- clist->map_w = ft_get_line_len(line);
+ clist->mlist->map_w = ft_get_line_len(line);
if (ft_check_map_line(line, 1, clist) < 0)
{
ft_memdel((void**)&line);
return (-1);
}
- ft_memdel((void**)&clist->mapl);
+ ft_memdel((void**)&clist->mlist->mapl);
if (ft_cat_mapl(line, 0, clist) < 0)
{
ft_memdel((void**)&line);
@@ -95,7 +95,7 @@ int
ret = 1;
while ((ret = get_next_line(fd, &line)) > 0)
{
- clist->line_chk += 1;
+ clist->mlist->line_chk += 1;
if (!line[0] || ft_check_map_line(line, 0, clist) < 0
|| ft_cat_mapl(line, i, clist) < 0)
{
@@ -106,10 +106,10 @@ int
i++;
}
ft_memdel((void**)&line);
- clist->mapl[((clist->map_w + 1) * i) - 1] = '\0';
- ft_free_words(clist->map);
- clist->map = ft_split(clist->mapl, '\n');
- clist->map_h = ft_get_map_h(clist->map);
- ft_memdel((void**)&clist->mapl);
+ clist->mlist->mapl[((clist->mlist->map_w + 1) * i) - 1] = '\0';
+ ft_free_words(clist->mlist->map);
+ clist->mlist->map = ft_split(clist->mlist->mapl, '\n');
+ clist->mlist->map_h = ft_get_map_h(clist->mlist->map);
+ ft_memdel((void**)&clist->mlist->mapl);
return (0);
}
diff --git a/src/ft_get_player_spawn.c b/src/ft_get_player_spawn.c
index cc41955..b803f25 100644
--- a/src/ft_get_player_spawn.c
+++ b/src/ft_get_player_spawn.c
@@ -37,15 +37,15 @@ void
x = 1;
y = 1;
- while (clist->map[y])
+ while (clist->mlist->map[y])
{
- while (clist->map[y][x])
+ while (clist->mlist->map[y][x])
{
- if (ft_ischarset("NSEW", clist->map[y][x]))
+ if (ft_ischarset("NSEW", clist->mlist->map[y][x]))
{
plist->pos_x = x;
plist->pos_y = y;
- plist->view_side = ft_get_view_side(clist->map[y][x]);
+ plist->view_side = ft_get_view_side(clist->mlist->map[y][x]);
return ;
}
x++;
diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c
index 490f538..c63c357 100644
--- a/src/ft_get_sprite.c
+++ b/src/ft_get_sprite.c
@@ -19,8 +19,8 @@ int8_t
{
if (!(*words) || !words[1] || words[2])
return (-1);
- ft_memdel((void**)&clist->sprite_path);
- if (!(clist->sprite_path = ft_strdup(*(words + 1))))
+ ft_memdel((void**)&clist->mlist->sprite_path);
+ if (!(clist->mlist->sprite_path = ft_strdup(*(words + 1))))
return (-1);
return (0);
}
diff --git a/src/ft_get_tex.c b/src/ft_get_tex.c
index 240f034..30b360a 100644
--- a/src/ft_get_tex.c
+++ b/src/ft_get_tex.c
@@ -20,8 +20,8 @@ int8_t
{
if (!(*words) || !(*(words + 1)) || (*(words + 2)))
return (-1);
- ft_memdel((void**)&clist->no_tex_path);
- if (!(clist->no_tex_path = ft_strdup(*(words + 1))))
+ ft_memdel((void**)&clist->mlist->no_tex_path);
+ if (!(clist->mlist->no_tex_path = ft_strdup(*(words + 1))))
return (-1);
return (0);
}
@@ -31,8 +31,8 @@ int8_t
{
if (!(*words) || !(*(words + 1)) || (*(words + 2)))
return (-1);
- ft_memdel((void**)&clist->so_tex_path);
- if (!(clist->so_tex_path = ft_strdup(*(words + 1))))
+ ft_memdel((void**)&clist->mlist->so_tex_path);
+ if (!(clist->mlist->so_tex_path = ft_strdup(*(words + 1))))
return (-1);
return (0);
}
@@ -42,8 +42,8 @@ int8_t
{
if (!(*words) || !(*(words + 1)) || (*(words + 2)))
return (-1);
- ft_memdel((void**)&clist->ea_tex_path);
- if (!(clist->ea_tex_path = ft_strdup(*(words + 1))))
+ ft_memdel((void**)&clist->mlist->ea_tex_path);
+ if (!(clist->mlist->ea_tex_path = ft_strdup(*(words + 1))))
return (-1);
return (0);
}
@@ -53,8 +53,8 @@ int8_t
{
if (!(*words) || !(*(words + 1)) || (*(words + 2)))
return (-1);
- ft_memdel((void**)&clist->we_tex_path);
- if (!(clist->we_tex_path = ft_strdup(*(words + 1))))
+ ft_memdel((void**)&clist->mlist->we_tex_path);
+ if (!(clist->mlist->we_tex_path = ft_strdup(*(words + 1))))
return (-1);
return (0);
}
diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c
index d56f40c..6754923 100644
--- a/src/ft_init_lists.c
+++ b/src/ft_init_lists.c
@@ -72,25 +72,10 @@ static t_cub
if (!(clist = (t_cub*)malloc(sizeof(t_cub))))
return (NULL);
- if (!(clist->no_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
- !(clist->so_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
- !(clist->ea_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
- !(clist->we_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
- !(clist->sprite_path = (char*)ft_calloc(1, sizeof(char))) ||
- !(clist->mapl = (char*)ft_calloc(1, sizeof(char))) ||
- !(clist->map = (char**)ft_calloc(2, sizeof(char*))) ||
- !(clist->map[0] = (char*)ft_calloc(1, sizeof(char))) ||
- !(clist->plist = ft_init_player()))
+ if (!(clist->plist = ft_init_player()) ||
+ !(clist->mlist = ft_init_map()))
return (NULL);
- clist->map[1] = 0;
- clist->map_w = 0;
- clist->map_h = 0;
- clist->x_step = 0;
- clist->y_step = 0;
- clist->line_chk = 0;
- clist->map_start = 0;
clist->minimap = 0;
- clist->isspawn = 0;
clist->f_rgb = ft_init_rgb();
clist->c_rgb = ft_init_rgb();
clist->rlist = ft_init_s_ray();
diff --git a/src/ft_init_map.c b/src/ft_init_map.c
new file mode 100644
index 0000000..0bbae5e
--- /dev/null
+++ b/src/ft_init_map.c
@@ -0,0 +1,31 @@
+#include <libft.h>
+#include <cub3d.h>
+#include <stdlib.h>
+
+t_map
+ *ft_init_map(void)
+{
+ t_map *mlist;
+
+ if (!(mlist = (t_map*)malloc(sizeof(t_map))))
+ return (NULL);
+ if (!(mlist->no_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
+ !(mlist->so_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
+ !(mlist->ea_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
+ !(mlist->we_tex_path = (char*)ft_calloc(1, sizeof(char))) ||
+ !(mlist->sprite_path = (char*)ft_calloc(1, sizeof(char))) ||
+ !(mlist->mapl = (char*)ft_calloc(1, sizeof(char))) ||
+ !(mlist->map = (char**)ft_calloc(2, sizeof(char*))) ||
+ !(mlist->map[0] = (char*)ft_calloc(1, sizeof(char))))
+ return (NULL);
+ mlist->map[1] = 0;
+ mlist->map_w = 0;
+ mlist->map_h = 0;
+ mlist->x_step = 0;
+ mlist->y_step = 0;
+ mlist->line_chk = 0;
+ mlist->map_start = 0;
+ mlist->isspawn = 0;
+ mlist->scale = 0;
+ return (mlist);
+}
diff --git a/src/ft_key_events.c b/src/ft_key_events.c
index 40f211a..a08a534 100644
--- a/src/ft_key_events.c
+++ b/src/ft_key_events.c
@@ -60,6 +60,7 @@ int
ft_key_event(int keycode, t_cub *clist)
{
t_player *pl;
+ t_map *ml;
int8_t (*fun_ptr[4])(t_cub*);
const int16_t tmp_code = keycode;
@@ -75,13 +76,14 @@ int
(tmp_code == 3) ? (keycode = INT16_MAX) : 0;
(tmp_code == 4) ? (keycode = INT16_MAX) : 0;
pl = clist->plist;
+ ml = clist->mlist;
if (keycode <= 3)
{
(*fun_ptr[keycode])(clist);
(pl->pos_y < 0.4) ? (pl->pos_y = 0.4) : 0;
(pl->pos_x < 0.4) ? (pl->pos_x = 0.4) : 0;
- (pl->pos_y > clist->map_h - 1.4) ? (pl->pos_y = clist->map_h - 1.4) : 0;
- (pl->pos_x > clist->map_w - 1.4) ? (pl->pos_x = clist->map_w - 1.4) : 0;
+ (pl->pos_y > ml->map_h - 1.4) ? (pl->pos_y = ml->map_h - 1.4) : 0;
+ (pl->pos_x > ml->map_w - 1.4) ? (pl->pos_x = ml->map_w - 1.4) : 0;
ft_draw_scene(clist);
return (0);
}
diff --git a/src/ft_map_error.c b/src/ft_map_error.c
index 1adc34b..0fc073a 100644
--- a/src/ft_map_error.c
+++ b/src/ft_map_error.c
@@ -20,6 +20,6 @@ int
{
ft_dprintf(STDERR_FILENO, "Error\n");
ft_dprintf(STDERR_FILENO,
- "\033[1;31mMap error: line %zu\033[0m\n", clist->line_chk);
+ "\033[1;31mMap error: line %zu\033[0m\n", clist->mlist->line_chk);
return (ft_exit(4, clist));
}
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c
index a2c3b82..4b66d0c 100644
--- a/src/ft_parse_map.c
+++ b/src/ft_parse_map.c
@@ -47,16 +47,18 @@ static void
static void
ft_check_map_last_line(t_cub *clist)
{
+ t_map *ml;
size_t i;
size_t j;
i = 0;
- while (clist->map[i])
+ ml = clist->mlist;
+ while (ml->map[i])
i++;
j = 0;
- while (clist->map[i - 1][j])
+ while (ml->map[i - 1][j])
{
- if (clist->map[i - 1][j] != '1' && clist->map[i - 1][j] != '\0')
+ if (ml->map[i - 1][j] != '1' && ml->map[i - 1][j] != '\0')
ft_map_error(clist);
j++;
}
@@ -76,7 +78,7 @@ static int8_t
char **words;
int ret;
- clist->line_chk += 1;
+ clist->mlist->line_chk += 1;
if ((ret = get_next_line(fd, &line)) < 0)
return (ft_map_error(clist));
if (ret == 0)
diff --git a/src/ft_print_list.c b/src/ft_print_list.c
index 6c2b702..314a4ec 100644
--- a/src/ft_print_list.c
+++ b/src/ft_print_list.c
@@ -21,21 +21,21 @@ void
ft_printf("x size ----- [%d]\n", clist->wlist->x_size);
ft_printf("y size ----- [%d]\n", clist->wlist->y_size);
- ft_printf("North ------ [%s]\n", clist->no_tex_path);
- ft_printf("South ------ [%s]\n", clist->so_tex_path);
- ft_printf("West ------- [%s]\n", clist->we_tex_path);
- ft_printf("East ------- [%s]\n", clist->ea_tex_path);
- ft_printf("Sprite ----- [%s]\n", clist->sprite_path);
+ ft_printf("North ------ [%s]\n", clist->mlist->no_tex_path);
+ ft_printf("South ------ [%s]\n", clist->mlist->so_tex_path);
+ ft_printf("West ------- [%s]\n", clist->mlist->we_tex_path);
+ ft_printf("East ------- [%s]\n", clist->mlist->ea_tex_path);
+ ft_printf("Sprite ----- [%s]\n", clist->mlist->sprite_path);
ft_printf("F color ---- [%d]\n", ft_rgb_to_hex(clist->f_rgb));
ft_printf("C color ---- [%d]\n", ft_rgb_to_hex(clist->c_rgb));
i = 0;
ft_printf("Map\n----\n");
- while (clist->map[i])
+ while (clist->mlist->map[i])
{
- ft_printf("%2zu -- [%s]\n", i + 1, clist->map[i]);
+ ft_printf("%2zu -- [%s]\n", i + 1, clist->mlist->map[i]);
i++;
}
- ft_printf("Map width -- [%zu]\n", clist->map_w);
- ft_printf("2D scale --- [%hhu]\n", clist->scale);
+ ft_printf("Map width -- [%zu]\n", clist->mlist->map_w);
+ ft_printf("2D scale --- [%hhu]\n", clist->mlist->scale);
ft_printf("----------------------\n");
}
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index 8aa4dbe..c0b55c4 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -21,10 +21,10 @@ ft_initray(t_cub *cl, uint16_t i)
ft_detect(cl);
if (cl->rlist.side == 0)
cl->rlist.wall_dist = (cl->rlist.sqx - cl->rlist.x_ray_pos +
- (1 - cl->x_step) / 2) / cl->rlist.x_ray_dir;
+ (1 - cl->mlist->x_step) / 2) / cl->rlist.x_ray_dir;
else
cl->rlist.wall_dist = (cl->rlist.sqy - cl->rlist.y_ray_pos +
- (1 - cl->y_step) / 2) / cl->rlist.y_ray_dir;
+ (1 - cl->mlist->y_step) / 2) / cl->rlist.y_ray_dir;
}
void
diff --git a/src/ft_select_get.c b/src/ft_select_get.c
index 76f424d..9c2bcbf 100644
--- a/src/ft_select_get.c
+++ b/src/ft_select_get.c
@@ -23,15 +23,15 @@ static int8_t
return (12);
if (ret == 0 && (clist->wlist->x_size != 0 || clist->wlist->y_size != 0))
return (-1);
- else if (ret == 1 && (clist->no_tex_path[0]))
+ else if (ret == 1 && (clist->mlist->no_tex_path[0]))
return (-1);
- else if (ret == 2 && (clist->so_tex_path[0]))
+ else if (ret == 2 && (clist->mlist->so_tex_path[0]))
return (-1);
- else if (ret == 3 && (clist->ea_tex_path[0]))
+ else if (ret == 3 && (clist->mlist->ea_tex_path[0]))
return (-1);
- else if (ret == 4 && (clist->we_tex_path[0]))
+ else if (ret == 4 && (clist->mlist->we_tex_path[0]))
return (-1);
- else if (ret == 5 && (clist->sprite_path[0]))
+ else if (ret == 5 && (clist->mlist->sprite_path[0]))
return (-1);
else if (ret == 6 && ((clist->f_rgb.r != -1) || (clist->f_rgb.g != -1)
|| (clist->f_rgb.b != -1)))
diff --git a/src/ft_set_minimap_scale.c b/src/ft_set_minimap_scale.c
index 0f79d6e..cd3424c 100644
--- a/src/ft_set_minimap_scale.c
+++ b/src/ft_set_minimap_scale.c
@@ -16,9 +16,12 @@
void
ft_set_minimap_scale(t_cub *clist)
{
- ((clist->scale = (clist->wlist->x_size / (uint16_t)clist->map_w) - 1) < 1)
- ? (clist->scale = 1) : 0;
- (clist->wlist->y_size < (clist->map_h * clist->scale)) ? (clist->scale =
- (clist->wlist->y_size / (uint16_t)clist->map_h) - 1) : 0;
- (clist->scale >= 10) ? (clist->scale /= 4) : 0;
+ t_map *ml;
+
+ ml = clist->mlist;
+ ((ml->scale = (clist->wlist->x_size / (uint16_t)ml->map_w) - 1) < 1)
+ ? (ml->scale = 1) : 0;
+ (clist->wlist->y_size < (ml->map_h * ml->scale)) ? (ml->scale =
+ (clist->wlist->y_size / (uint16_t)ml->map_h) - 1) : 0;
+ (ml->scale >= 10) ? (ml->scale /= 4) : 0;
}