aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-25 18:46:15 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-25 18:46:15 +0100
commit58b408a130b2bec0d401b43d77ded34c9a8d34f9 (patch)
tree9eb665f259a98a834a777272b2683a0cb2bc5a57
parentMerge branch 'better_m_s' (diff)
download42-cub3d-58b408a130b2bec0d401b43d77ded34c9a8d34f9.tar.gz
42-cub3d-58b408a130b2bec0d401b43d77ded34c9a8d34f9.tar.bz2
42-cub3d-58b408a130b2bec0d401b43d77ded34c9a8d34f9.tar.xz
42-cub3d-58b408a130b2bec0d401b43d77ded34c9a8d34f9.tar.zst
42-cub3d-58b408a130b2bec0d401b43d77ded34c9a8d34f9.zip
Fixed sprite parse
Diffstat (limited to '')
-rw-r--r--inc/cub3d_defines.h1
-rw-r--r--map/lvl_four.cub2
-rw-r--r--map/map_one.cub20
-rw-r--r--src/ft_get_map.c7
-rw-r--r--src/ft_get_sprite.c2
-rw-r--r--src/ft_tex_sprites_extra_init.c1
6 files changed, 21 insertions, 12 deletions
diff --git a/inc/cub3d_defines.h b/inc/cub3d_defines.h
index 4ef2391..76c0fc5 100644
--- a/inc/cub3d_defines.h
+++ b/inc/cub3d_defines.h
@@ -231,6 +231,7 @@ enum
# define FT_ERR_RD_MUSIC "could not find music file"
# define FT_ERR_RD_TRAP "could not find trap texture file"
# define FT_ERR_WR_BMP "could not export to bmp"
+# define FT_ERR_UNDEF_SPRITE "undefined sprite"
# define FT_ERR_TOO_MUCH_HEALS "too much heal packs, limit is 64"
# define FT_ERR_TOO_MUCH_TRAPS "too much traps, limit is 512"
# define FT_ERR_TOO_MUCH_W_ONE "too much weapon one, limit is 1"
diff --git a/map/lvl_four.cub b/map/lvl_four.cub
index 4399923..2694723 100644
--- a/map/lvl_four.cub
+++ b/map/lvl_four.cub
@@ -25,7 +25,7 @@ L ./map/lvl_five.cub
101 1L1
101 11T11
101111111111111110111
- 100000000000@11000TT11
+ 1000000@1111111000TT11
10111111111111101111111
101 1+000000000+1
101 11111T111111011
diff --git a/map/map_one.cub b/map/map_one.cub
index a627cf2..e7395cb 100644
--- a/map/map_one.cub
+++ b/map/map_one.cub
@@ -1,4 +1,4 @@
-R 1280 1024
+R 1600 1024
NO ./media/img/tex/wood_wall_1.xpm
SO ./media/img/tex/wood_wall_1.xpm
@@ -11,18 +11,22 @@ F ./media/img/tex/parquet.xpm
S ./media/img/sprites/pillar.xpm
S3 ./media/img/sprites/pylon.xpm
S4 ./media/img/sprites/hey.xpm
+S5 ./media/img/sprites/hey.xpm
+S6 ./media/img/sprites/hey.xpm
+S7 ./media/img/sprites/hey.xpm
+S8 ./media/img/sprites/hey.xpm
T ./media/img/sprites/spikes.xpm
SH 2
- 11111111111111111111
-1111111111110000000000000000001
-1000000000000000000000000000001
-10000E0000000203040506070809001
-1000000000000000000000000000001
-1001000000000000000000000000001
-1011000001110000011111111111111
+ 1111111111111111111
+111111111111000000000000000001
+100000000000000000000000000001
+10000E000000020304050607000001
+100000000000000000000000000001
+1001000000T0000000000000000001
+10110+0+0111000001111111111111
111111111111110011
1000001 100001
1001001 100001
diff --git a/src/ft_get_map.c b/src/ft_get_map.c
index 4cb4941..d2f0a31 100644
--- a/src/ft_get_map.c
+++ b/src/ft_get_map.c
@@ -17,7 +17,7 @@
#include <stdint.h>
static void
- ft_linecpy(char *line, char *mapl, size_t start)
+ ft_linecpy(char *line, char *mapl, size_t start, t_cub *cl)
{
size_t i;
size_t j;
@@ -29,6 +29,9 @@ static void
while (i < slen && line[i])
{
mapl[j] = line[i];
+ if (mapl[j] - 48 > 2 && mapl[j] - 48 < 10
+ && mapl[j] - 48 > cl->mlist.topsp)
+ ft_error(FT_RET_MAP_ERR, FT_ERR_UNDEF_SPRITE, cl);
i++;
j++;
}
@@ -47,7 +50,7 @@ static int8_t
return (-1);
}
ft_linecpy(line, clist->mlist.mapl,
- clist->mlist.mapl_len);
+ clist->mlist.mapl_len, clist);
clist->mlist.mapl_len += ft_strlen(line) + 1;
return (0);
}
diff --git a/src/ft_get_sprite.c b/src/ft_get_sprite.c
index 05b13b2..9e84e93 100644
--- a/src/ft_get_sprite.c
+++ b/src/ft_get_sprite.c
@@ -46,6 +46,8 @@ static int8_t
return (-1);
i++;
}
+ if (i + 2 > clist->mlist.topsp)
+ clist->mlist.topsp = i + 2;
return (0);
}
diff --git a/src/ft_tex_sprites_extra_init.c b/src/ft_tex_sprites_extra_init.c
index 9ff7612..84684be 100644
--- a/src/ft_tex_sprites_extra_init.c
+++ b/src/ft_tex_sprites_extra_init.c
@@ -31,5 +31,4 @@ void
&cl->tlist[i + 7].endian);
i++;
}
- cl->mlist.topsp = i + 1;
}