-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.c
153 lines (139 loc) · 3.91 KB
/
debug.c
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* debug.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yabdulha <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/15 14:25:27 by yabdulha #+# #+# */
/* Updated: 2018/10/24 15:32:09 by yabdulha ### ########.fr */
/* */
/* ************************************************************************** */
#include "filler.h"
//remove
#include <fcntl.h>
void debug(t_filler *data, char *line, char *msg)
{
FILE *fd = fopen("./debug", "a");
int i = 0;
t_co *tmp;
t_dist *d;
t_co *my;
/* if (msg)
fprintf(fd, "msg: %s, ", msg);
fprintf(fd, "line: %s\n", line);
fprintf(fd, "x: %d\n", data->max_x);
fprintf(fd, "y: %d\n", data->max_y);
while (i < (data->max_x) * (data->max_y))
{
if (i % data->max_x == 0)
fprintf(fd, "\n%3.3d ", i / data->max_x);
fprintf(fd, "%c", (data->map[i]) ? data->map[i] : '?');
i++;
}
fprintf(fd, "\n");
fprintf(fd, "player: %c\n", data->player);
fprintf(fd, "opponent: %c\n", data->opponent);
*/
fprintf(fd, "up: %d, down: %d, left: %d, right: %d\n", data->up, data->lo, data->le, data->ri);
tmp = data->square;
while (tmp)
{
fprintf(fd, "square point: %d %d\n", tmp->x, tmp->y);
tmp = tmp->next;
}
if (data->shortest)
fprintf(fd, "shortest: %d\n", data->shortest->dist);
d = data->dist;
while (d)
{
fprintf(fd, "distance: %d, me: %d %d enemy %d %d\n", d->dist, d->me->x, d->me->y, d->enemy->x, d->enemy->y);
d = d->next;
}
fprintf(fd, "\n");
my = data->my;
while (my)
{
fprintf(fd, "my point: %d %d\n", my->x, my->y);
my = my->next;
}
fprintf(fd, "-------------\n");
my = data->piece;
while (my)
{
fprintf(fd, "piece point: %d %d [%c]\n", my->x, my->y, my->c);
my = my->next;
}
fprintf(fd, "piece size: %d %d\n", data->piece_size->x, data->piece_size->y);
fclose(fd);
}
void output(char *msg)
{
FILE *fd = fopen("dot", "a");
if (msg)
fprintf(fd, "debug msg: %s\n", msg);
fclose(fd);
}
void output_c(char msg)
{
FILE *fd = fopen("dot", "a");
if (msg)
fprintf(fd, "debug msg: %c\n", msg);
fclose(fd);
}
void print(t_filler *data, char *line, char *msg)
{
int fd = open("/dev/ttys003", O_RDWR);
write(fd, "sasd\n", 5);
int i = 0;
t_co *tmp;
t_dist *d;
t_co *my;
t_co *piece;
if (msg)
dprintf(fd, "msg: %s, ", msg);
dprintf(fd, "line: %s\n", line);
dprintf(fd, "x: %d\n", data->max_x);
dprintf(fd, "y: %d\n", data->max_y);
while (i < (data->max_x) * (data->max_y))
{
if (i % data->max_x == 0)
dprintf(fd, "\n%3.3d ", i / data->max_x);
dprintf(fd, "%c", (data->map[i]) ? data->map[i] : '?');
i++;
}
dprintf(fd, "\n");
dprintf(fd, "player: %c\n", data->player);
dprintf(fd, "opponent: %c\n", data->opponent);
dprintf(fd, "up: %d, down: %d, left: %d, right: %d\n", data->up, data->lo, data->le, data->ri);
tmp = data->square;
while (tmp)
{
dprintf(fd, "square point: %d %d\n", tmp->x, tmp->y);
tmp = tmp->next;
}
if (data->shortest)
dprintf(fd, "shortest: %d\n", data->shortest->dist);
d = data->dist;
while (d)
{
dprintf(fd, "distance: %d, me: %d %d enemy %d %d\n", d->dist, d->me->x, d->me->y, d->enemy->x, d->enemy->y);
d = d->next;
}
dprintf(fd, "\n");
my = data->my;
while (my)
{
dprintf(fd, "my point: %d %d\n", my->x, my->y);
my = my->next;
}
dprintf(fd, "-------------\n");
my = data->piece;
while (my)
{
dprintf(fd, "piece point: %d %d [%c]\n", my->x, my->y, my->c);
my = my->next;
}
printf("-------------\n");
close(fd);
}