intra to gitea

This commit is contained in:
root
2025-11-15 22:16:13 +00:00
parent 0c0d28ab36
commit 50b45e597f
27 changed files with 888 additions and 624 deletions
+53 -46
View File
@@ -25,57 +25,64 @@
// "111111111111",
// NULL
// };
static const char *demo_map[] = {
"111111111111",
"100000000001",
"100000000001",
"100000000001",
"100000001111",
"100000000001",
"100000000001", /* N = start dir nord, on l'ignore ici (juste info) */
"100000000001",
"111111111111",
NULL
};
// static const char *demo_map[] = {
// "111111111111",
// "100000000001",
// "100000000001",
// "100000000001",
// "100000001111",
// "100000000001",
// "100000000001", /* N = start dir nord, on l'ignore ici (juste info) */
// "100000000001",
// "111111111111",
// NULL
// };
int world_init_demo(t_world *w)
{
int h = 0;
while (demo_map[h])
h++;
w->h = h;
w->w = 0;
for (int i = 0; i < h; i++)
{
int len = 0;
while (demo_map[i][len]) len++;
if (len > w->w) w->w = len;
}
w->grid = (char **)malloc(sizeof(char *) * (h + 1));
if (!w->grid) return (1);
for (int y = 0; y < h; y++)
{
w->grid[y] = (char *)malloc(w->w + 1);
if (!w->grid[y]) return (1);
for (int x = 0; x < w->w; x++)
{
char c = demo_map[y][x];
if (c == 0) c = '1';
if (c == 'N' || c == 'S' || c == 'E' || c == 'W')
c = '0';
w->grid[y][x] = c;
}
w->grid[y][w->w] = '\0';
}
w->grid[h] = NULL;
return (0);
}
// int world_init_demo(t_world *w)
// {
// int h = 0;
// while (demo_map[h])
// h++;
// w->h = h;
// w->w = 0;
// for (int i = 0; i < h; i++)
// {
// int len = 0;
// while (demo_map[i][len]) len++;
// if (len > w->w) w->w = len;
// }
// w->grid = (char **)malloc(sizeof(char *) * (h + 1));
// if (!w->grid) return (1);
// for (int y = 0; y < h; y++)
// {
// w->grid[y] = (char *)malloc(w->w + 1);
// if (!w->grid[y]) return (1);
// for (int x = 0; x < w->w; x++)
// {
// char c = demo_map[y][x];
// if (c == 0) c = '1';
// if (c == 'N' || c == 'S' || c == 'E' || c == 'W')
// c = '0';
// w->grid[y][x] = c;
// }
// w->grid[y][w->w] = '\0';
// }
// w->grid[h] = NULL;
// return (0);
// }
void world_free(t_world *w)
{
if (!w->grid) return ;
for (int y = 0; y < w->h; y++)
int y;
if (!w->grid)
return ;
y = 0;
while (y < w->h)
{
free(w->grid[y]);
y++;
}
free(w->grid);
w->grid = NULL;
}