16 #include "gb/GB_server.h" 17 #include "gb/buffers.h" 19 #include "gb/files_shl.h" 21 #include "gb/tweakables.h" 63 void post(
const char *origmsg,
int type) {
83 char *fixmsg = strdupa(origmsg);
86 for (p = fixmsg; *p; p++) {
94 if ((news_fd = fopen(telefl,
"a")) ==
nullptr) {
100 asprintf(&outbuf,
"%2d/%2d %02d:%02d:%02d %s",
current_tm->tm_mon + 1,
103 fprintf(news_fd,
"%s", outbuf);
105 newslength[type] += strlen(outbuf);
123 Race = races[recipient - 1];
125 if (Race->governor[j].active) push_telegram(recipient, j, msg);
139 const std::string &msg) {
143 bzero((
char *)telefl,
sizeof(telefl));
144 sprintf(telefl,
"%s.%d.%d",
TELEGRAMFL, recipient, gov);
146 if ((telegram_fd = fopen(telefl,
"a")) ==
nullptr)
147 if ((telegram_fd = fopen(telefl,
"w+")) ==
nullptr) {
154 fprintf(telegram_fd,
"%2d/%2d %02d:%02d:%02d %s\n", current_tm->tm_mon + 1,
155 current_tm->tm_mday, current_tm->tm_hour, current_tm->tm_min,
156 current_tm->tm_sec, msg.c_str());
177 player_t Playernum = g.player;
178 governor_t Governor = g.governor;
182 sprintf(telegram_file,
"%s.%d.%d",
TELEGRAMFL, Playernum, Governor);
185 g.out <<
"Telegrams:";
190 for (p = buf; *p; p++)
196 notify(Playernum, Governor, buf);
206 sprintf(buf,
"\nTelegram file %s non-existent.\n",
telegram_file);
207 notify(Playernum, Governor, buf);
232 sprintf(telegram_file,
"%s",
COMBATFL);
242 Race = races[Playernum - 1];
243 if (Race->governor[Governor].newspos[type] > newslength[type])
244 Race->governor[Governor].newspos[type] = 0;
246 fseek(teleg_read_fd, Race->governor[Governor].newspos[type] & LONG_MAX,
249 for (p = buf; *p; p++)
255 notify(Playernum, Governor, buf);
259 Race->governor[Governor].newspos[type] = newslength[type];
262 sprintf(buf,
"\nNews file %s non-existent.\n",
telegram_file);
263 notify(Playernum, Governor, buf);
273 std::string filename = std::string(
TELEGRAMFL) +
'.' +
274 std::to_string(g.player) +
'.' +
275 std::to_string(g.governor);
277 std::memset(&sbuf, 0,
sizeof(sbuf));
278 stat(filename.c_str(), &sbuf);
279 if (sbuf.st_size != 0) {
280 g.out <<
"You have telegram(s) waiting. Use 'read' to read them.\n";
void teleg_read(GameObj &g)
void post(const char *origmsg, int type)
void push_telegram_race(const player_t recipient, const std::string &msg)
static struct tm * current_tm
void news_read(int Playernum, int Governor, int type)
void check_for_telegrams(GameObj &g)
Check for telegrams and notify the player if there is any.
static FILE * teleg_read_fd
void push_telegram(const player_t recipient, const governor_t gov, const std::string &msg)
static char telegram_file[PATHLEN]
static struct stat telestat