norm: norming of parsing/ and source/cleanup.c
This commit is contained in:
parent
6f2677dde3
commit
d66e1ec615
10 changed files with 421 additions and 340 deletions
42
parsing/utils.c
Normal file
42
parsing/utils.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* utils.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/12/01 17:43:17 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/12/01 17:45:58 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cub3d_struct.h"
|
||||
|
||||
#include "ft_string.h"
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <stdio.h>
|
||||
|
||||
t_tile *c3_get_cell(t_tile *map, t_ipoint dimensions, t_ipoint pos)
|
||||
{
|
||||
if (pos.x < 0 || pos.y < 0 || pos.x >= dimensions.x
|
||||
|| pos.y >= dimensions.y)
|
||||
return (printf("runtime error: %s:%d (pos:%d,%d on dims:%d,%d)\n",
|
||||
__func__, __LINE__, pos.x, pos.y, dimensions.x, dimensions.y),
|
||||
NULL);
|
||||
return (map + (pos.y * dimensions.x + pos.x));
|
||||
}
|
||||
|
||||
bool is_identifier(const char *str, const char **id_str)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (id_str[i])
|
||||
{
|
||||
if (ft_strstart_with(str, id_str[i]))
|
||||
return (true);
|
||||
i++;
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue