helper functions
このコミットが含まれているのは:
コミット
9b1b6ea5b6
23
uttt.c
23
uttt.c
|
@ -286,6 +286,29 @@ void ut_show_boards(const struct ut_state *state) {
|
|||
}
|
||||
}
|
||||
|
||||
int info_line; // set this to 21 and reset it on erase TODO
|
||||
void ut_info(const char *str)
|
||||
{
|
||||
mvaddstr(info_line, 0, str);
|
||||
info_line++;
|
||||
}
|
||||
|
||||
int readfill(int fd, char *x, size_t l)
|
||||
{
|
||||
while(l > 0)
|
||||
{
|
||||
int r = read(fd, x, l);
|
||||
if(r < 0)
|
||||
{
|
||||
if(errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {continue;}
|
||||
else {return 1;}
|
||||
}
|
||||
else if(r == 0) {return 2;}
|
||||
x += r; l -= r;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool getpos(const struct ut_state *state, int *x, int *y) {
|
||||
while (true) {
|
||||
printf("Place token %c at position x,y: ", state->player);
|
||||
|
|
読み込み中…
新しいイシューから参照