aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_get_screen_size.c
blob: 67037de4b4f23974439e87a44eccc048f7e7dcbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_get_screen_size.c                               :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: joelecle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/02/14 17:28:47 by joelecle          #+#    #+#             */
/*   Updated: 2020/02/14 17:28:47 by joelecle         ###   ########lyon.fr   */
/*                                                                            */
/* ************************************************************************** */

#include <libft.h>
#include <cub3d.h>

int8_t
	ft_get_screen_size(t_win *wlist)
{
	char	**words;

	if (!(words = ft_split(FT_SCR_SIZE, 'x')))
		return (-1);
	if (!(*words + 0) || !(*(words + 1)) || (*(words + 2)))
		return (-1);
	wlist->x_max_size = ft_atoi(words[0]);
	wlist->y_max_size = ft_atoi(words[1]);
	if (wlist->x_size > wlist->x_max_size)
		wlist->x_size = wlist->x_max_size;
	if (wlist->y_size > wlist->y_max_size)
		wlist->y_size = wlist->y_max_size;
	return (ft_free_words(words));
}