diff --git a/src/mastersrv/master.c b/src/mastersrv/master.c
index 7f476c17ce1a2f7c825a21e96eeb62268074bb8b..9745694cef8c88a08005f5833e314cfab92d8298 100644 (file)
--- a/src/mastersrv/master.c
+++ b/src/mastersrv/master.c
#define LC_MS_LIST "\nSent server list to %x:%u (ver. %s).\n"
#define LC_MS_DIE "\nD2DF master server shutting down...\n"
#define LC_MS_CONN "\nIncoming connection from %x:%u...\n"
+#define LC_MS_MOTD "\nMOTD: %s\n"
+#define LC_MS_URGENT "\nURGENT: %s\n"
+#define MS_URGENT_FILE "urgent.txt"
+#define MS_MOTD_FILE "motd.txt"
struct ms_server_s {
enet_uint8 used;
typedef struct ms_server_s ms_server;
const char ms_game_ver[] = "0.63";
+char ms_motd[256] = "";
+char ms_urgent[256] = "";
+
int ms_port = 25660;
int ms_timeout = 100000;
}
-enet_uint8 b_read_uint8 (enet_uint8 buf[], size_t *pos) {
+int d_readtextfile (const char *fname, char *buf, size_t max) {
+ FILE *f = fopen(fname, "r");
+ if (f) {
+ fgets(buf, max, f);
+ fclose(f);
+ return 0;
+ }
+ return 1;
+}
+
+
+enet_uint8 b_read_uint8 (enet_uint8 buf[], size_t *pos) {
return buf[(*pos)++];
}
printf(LC_MS_INIT, ms_port);
+ d_readtextfile(MS_MOTD_FILE, ms_motd, sizeof(ms_motd));
+ d_readtextfile(MS_URGENT_FILE, ms_urgent, sizeof(ms_urgent));
+
+ if (ms_motd[0]) printf(LC_MS_MOTD, ms_motd);
+ if (ms_urgent[0]) printf(LC_MS_URGENT, ms_urgent);
+
for (int i = 0; i < NET_MAXCLIENTS; ++i) ms_peers[i] = NULL;
for (int i = 0; i < MS_MAXSRVS; ++i) {
// TODO: check if this client is outdated (?) and send back new verstring
// for now just write the same shit back
b_write_dstring(b_send, &b_write, clientver);
+ // write the motd and urgent message
+ b_write_dstring(b_send, &b_write, ms_motd);
+ b_write_dstring(b_send, &b_write, ms_urgent);
}
ENetPacket *p = enet_packet_create(b_send, b_write, ENET_PACKET_FLAG_RELIABLE);