#include "commands.h"
+static int chat(struct natstr *, struct natstr *, char *);
static int sendmessage(struct natstr *, struct natstr *, char *, int);
int
{
struct natstr *us;
struct natstr *to;
- char buf[1024]; /* UTF-8 */
int tocn;
us = getnatp(player->cnum);
}
}
- if (player->comtail[2]) {
- buf[0] = ':';
- buf[1] = ' ';
- strcpy(buf+2, player->comtail[2]);
- sendmessage(us, to, buf, 1);
- } else {
- sendmessage(us, to, "...", 1);
- while (ugetstring("> ", buf)) {
- if (*buf == '.')
- break;
- sendmessage(us, to, buf, 0);
- }
- sendmessage(us, to, "<EOT>", 0);
- }
- return RET_OK;
+ return chat(us, to, player->comtail[2]);
}
int
wall(void)
{
- struct natstr *us;
+ return chat(getnatp(player->cnum), NULL, player->comtail[1]);
+}
+
+/*
+ * Send flash message(s) from US to TO.
+ * Null TO broadcasts to all.
+ * MESSAGE is UTF-8. If it is null, prompt for messages interactively.
+ * Return RET_OK.
+ */
+static int
+chat(struct natstr *us, struct natstr *to, char *message)
+{
char buf[1024]; /* UTF-8 */
- us = getnatp(player->cnum);
- if (player->comtail[1]) {
+ if (message) {
buf[0] = ':';
buf[1] = ' ';
- strcpy(buf+2, player->comtail[1]);
- sendmessage(us, 0, buf, 1);
+ strcpy(buf+2, message);
+ sendmessage(us, to, buf, 1);
} else {
- sendmessage(us, 0, "...", 1);
+ sendmessage(us, to, "...", 1);
while (ugetstring("> ", buf)) {
if (*buf == '.')
break;
- sendmessage(us, 0, buf, 0);
+ sendmessage(us, to, buf, 0);
}
- sendmessage(us, 0, "<EOT>", 0);
+ sendmessage(us, to, "<EOT>", 0);
}
return RET_OK;
}