aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-03 20:26:03 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-03 20:26:03 +0100
commit3d5d770c0f43f9b4cfe59dc694f78b18803a7872 (patch)
treeae25b98e1dd04a82d9b44aea0649e4df5cd6dc45 /src
parentNow better handling (diff)
download42-cub3d-3d5d770c0f43f9b4cfe59dc694f78b18803a7872.tar.gz
42-cub3d-3d5d770c0f43f9b4cfe59dc694f78b18803a7872.tar.bz2
42-cub3d-3d5d770c0f43f9b4cfe59dc694f78b18803a7872.tar.xz
42-cub3d-3d5d770c0f43f9b4cfe59dc694f78b18803a7872.tar.zst
42-cub3d-3d5d770c0f43f9b4cfe59dc694f78b18803a7872.zip
Changing stuff
Diffstat (limited to 'src')
-rw-r--r--src/ft_check_map_line.c12
-rw-r--r--src/ft_get_map.c4
-rw-r--r--src/ft_music.c3
-rw-r--r--src/ft_parse_map.c18
-rw-r--r--src/ft_select_get.c2
5 files changed, 30 insertions, 9 deletions
diff --git a/src/ft_check_map_line.c b/src/ft_check_map_line.c
index a3e60f5..c5b4cdc 100644
--- a/src/ft_check_map_line.c
+++ b/src/ft_check_map_line.c
@@ -20,21 +20,21 @@ static int8_t
{
if (!ft_ischarset("012NSEWL ", line[i]))
{
- ft_sprintf(clist->errmsg, "%s", FT_ERR_ILL_MAP);
+ ft_sprintf(clist->errmsg, FT_ERR_ILL_MAP);
return (-1);
}
if (ft_ischarset("NSEW", line[i]))
clist->mlist.isspawn += 1;
if (clist->mlist.isspawn > 1)
{
- ft_sprintf(clist->errmsg, "%s", FT_ERR_MULT_SPAWN);
+ ft_sprintf(clist->errmsg, FT_ERR_MULT_SPAWN);
return (-1);
}
if (line[i] == 'L')
clist->mlist.isnlvl += 1;
if (clist->mlist.isnlvl > 1)
{
- ft_sprintf(clist->errmsg, "%s", FT_ERR_MULT_NLVL);
+ ft_sprintf(clist->errmsg, FT_ERR_MULT_NLVL);
return (-1);
}
return (0);
@@ -45,7 +45,7 @@ static int8_t
{
if (!ft_ischarset("1 ", line[i]))
{
- ft_sprintf(clist->errmsg, "%s", FT_ERR_ILL_MAP);
+ ft_sprintf(clist->errmsg, FT_ERR_MAP_WALLS);
return (-1);
}
return (0);
@@ -73,7 +73,7 @@ static int8_t
{
if (line[0] != '1' || line[i - 1] != '1')
{
- ft_sprintf(clist->errmsg, "%s", FT_ERR_ILL_ENTRY);
+ ft_sprintf(clist->errmsg, FT_ERR_MAP_WALLS);
return (-1);
}
return (0);
@@ -102,7 +102,7 @@ int8_t
return (-1);
if (ft_get_line_len(line) != clist->mlist.map_w)
{
- ft_sprintf(clist->errmsg, "%s", FT_ERR_MAP_LEN);
+ ft_sprintf(clist->errmsg, FT_ERR_MAP_LEN);
return (-1);
}
return (0);
diff --git a/src/ft_get_map.c b/src/ft_get_map.c
index 60bcee0..fb8e0f2 100644
--- a/src/ft_get_map.c
+++ b/src/ft_get_map.c
@@ -54,7 +54,7 @@ static int8_t
((clist->mlist.map_w + 1) * i) * sizeof(char),
((clist->mlist.map_w + 1) * (i + 1)) * sizeof(char))))
{
- ft_sprintf(clist->errmsg, "%s", FT_ERR_ALLOCATE);
+ ft_sprintf(clist->errmsg, FT_ERR_ALLOCATE);
return (-1);
}
ft_linecpy(line, clist->mlist.mapl, (clist->mlist.map_w + 1) * i);
@@ -103,6 +103,8 @@ int
if (!line[0] || ft_check_map_line(line, 0, clist) < 0
|| ft_cat_mapl(line, i, clist) < 0)
{
+ if (!line[0])
+ ft_sprintf(clist->errmsg, FT_ERR_MAP_EMPL);
ft_memdel((void**)&line);
return (-1);
}
diff --git a/src/ft_music.c b/src/ft_music.c
index f3369bd..7688f57 100644
--- a/src/ft_music.c
+++ b/src/ft_music.c
@@ -23,6 +23,7 @@ void
cl = (t_cub *)vargp;
cl->isoldmus = 1;
- system(cl->mlist.music_cmd);
+ while (1)
+ system(cl->mlist.music_cmd);
return (NULL);
}
diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c
index e54b53c..256d131 100644
--- a/src/ft_parse_map.c
+++ b/src/ft_parse_map.c
@@ -61,7 +61,9 @@ static int8_t
ft_memdel((void**)&line);
return (ft_parse_it(fd, clist));
}
- if (!ft_ischarset("RNSEWFCLM1\0", line[0])
+ if (ft_ischarset("1 ", line[0]))
+ return ((ft_get_map_first_line(line, clist) < 0) ? (-1) : (12));
+ if (!ft_ischarset("RNSEWFCLM\0", line[0])
|| !(words = ft_split(line, ' ')))
return (ft_error_here(FT_ERR_ILL_ENTRY, line, clist));
if ((ret = ft_select_get(words, clist)) == 12)
@@ -78,6 +80,19 @@ static void
ft_exit(FT_RET_NO_MAP, clist);
}
+static void
+ ft_print_map(t_map *ml)
+{
+ size_t i;
+
+ i = 0;
+ while (ml->map[i])
+ {
+ ft_printf("[%s]\n", ml->map[i]);
+ i++;
+ }
+}
+
void
ft_parse_map(const char *map_path, t_cub *clist)
{
@@ -101,6 +116,7 @@ void
ft_get_nlvl_pos(&clist->mlist);
ft_check_missing(clist);
ft_set_minimap_scale(clist);
+ ft_print_map(&clist->mlist);
clist->currlvl += 1;
close(fd);
}
diff --git a/src/ft_select_get.c b/src/ft_select_get.c
index 124c208..c73ed06 100644
--- a/src/ft_select_get.c
+++ b/src/ft_select_get.c
@@ -74,6 +74,8 @@ static int8_t
ft_sprintf(ref[9], "LT");
ft_sprintf(ref[10], "MU");
ft_sprintf(ref[11], "");
+ if (words[0][0] == ' ' || words[0][0] == '1')
+ return (12);
ret = 0;
while (ft_strncmp(words[0], ref[ret], 3) && ref[ret][0])
ret++;