Factor player_output_some() out of pr_player(), upr_player()

This commit is contained in:
Markus Armbruster 2012-03-11 14:56:41 +01:00
parent 4d59881505
commit 7980465199

View file

@ -68,6 +68,7 @@
static void pr_player(struct player *pl, int id, char *buf); static void pr_player(struct player *pl, int id, char *buf);
static void upr_player(struct player *pl, int id, char *buf); static void upr_player(struct player *pl, int id, char *buf);
static void outid(struct player *pl, int n); static void outid(struct player *pl, int n);
static void player_output_some(void);
/* /*
* Print to current player similar to printf(). * Print to current player similar to printf().
@ -223,7 +224,6 @@ pr_player(struct player *pl, int id, char *buf)
char *p; char *p;
char *bp; char *bp;
int len; int len;
time_t deadline;
journal_output(pl, id, buf); journal_output(pl, id, buf);
@ -247,12 +247,8 @@ pr_player(struct player *pl, int id, char *buf)
} }
} }
if (player == pl) { if (player == pl)
deadline = (time_t)(pl->may_sleep == PLAYER_SLEEP_FREELY player_output_some();
? -1 : 0);
while (io_output_if_queue_long(pl->iop, deadline) > 0)
;
}
} }
/* /*
@ -268,7 +264,6 @@ upr_player(struct player *pl, int id, char *buf)
int standout = 0; int standout = 0;
char printbuf[2]; char printbuf[2];
char ch; char ch;
time_t deadline;
journal_output(pl, id, buf); journal_output(pl, id, buf);
@ -307,12 +302,8 @@ upr_player(struct player *pl, int id, char *buf)
} }
} }
if (player == pl) { if (player == pl)
deadline = (time_t)(pl->may_sleep == PLAYER_SLEEP_FREELY player_output_some();
? -1 : 0);
while (io_output_if_queue_long(pl->iop, deadline) > 0)
;
}
} }
/* /*
@ -337,6 +328,16 @@ outid(struct player *pl, int n)
pl->curid = n; pl->curid = n;
} }
static void
player_output_some(void)
{
time_t deadline;
deadline = (time_t)(player->may_sleep == PLAYER_SLEEP_FREELY ? -1 : 0);
while (io_output_if_queue_long(player->iop, deadline) > 0)
;
}
/* /*
* Send redirection request REDIR to the current player. * Send redirection request REDIR to the current player.
* REDIR is UTF-8, but non-ASCII characters can occur only if the * REDIR is UTF-8, but non-ASCII characters can occur only if the