// Store the message of the day in memory.char *gMOTD = ((char *)-1); // initialized at startup as bad pointercvar_t *motdfile;void ClientPrintMOTD (edict_t *ent){ FILE *in; char motdPath[MAX_QPATH + 1]; int c; int motdBytes; char *here; // If the MOTD hasn't been loaded, do so. if (gMOTD == ((char *)-1)) { // Generate the path to the MOTD file. if (gamedir == NULL || motdfile == NULL || !gamedir->string[0] || !motdfile->string[0]) { gMOTD = NULL; // null pointer means we'll never try again return; } sprintf (motdPath, "./%s/%s", gamedir->string, motdfile->string); // Open the file. in = fopen (motdPath, "rt"); if (in == NULL) { gi.dprintf("Opening MOTD file failed, error: %i.\n", errno); gMOTD = NULL; return; } // Count the number of bytes in the file. motdBytes = 0; while ((c = fgetc (in)), c != EOF) motdBytes++; // Make space for that many bytes. gMOTD = gi.TagMalloc (motdBytes + 1, TAG_GAME); gi.dprintf("Allocating %i bytes for MOTD\n", motdBytes +1); // Now read the MOTD in for real. Null-terminate the string. fclose (in); in = fopen (motdPath, "rt"); here = gMOTD; //extra pointer for writing into gMOTD while ((c = fgetc (in)), c != EOF) { *here = c; here++; motdBytes--; } *here = '\0'; // If anything went wrong, warn the console. if (motdBytes != 0) gi.dprintf ("MOTD error: off by %d bytes", motdBytes); } if (gMOTD != NULL) // If a MOTD was successfully loaded, print it. gi.centerprintf (ent, "%s", gMOTD); return;}
motdfile = gi.cvar ("motdfile", "motd.txt", 0);
extern cvar_t *motdfile;
/*=====================ClientBeginDeathmatchA client has just connected to the server in deathmatchmode, so clear everything out before starting them.=====================*/void ClientBeginDeathmatch (edict_t *ent){ G_InitEdict (ent); InitClientResp (ent->client); // locate ent at a spawn point PutClientInServer (ent); if (level.intermissiontime) MoveClientToIntermission (ent); else { // send effect gi.WriteByte (svc_muzzleflash); gi.WriteShort (ent-g_edicts); gi.WriteByte (MZ_LOGIN); gi.multicast (ent->s.origin, MULTICAST_PVS); gi.bprintf (PRINT_HIGH, "%s entered the game\n", ent->client->pers.netname); } ClientPrintMOTD(ent); // make sure all view stuff is valid ClientEndServerFrame (ent); return;}