/* ====================== SV_Map_f handle a map <mapname> command from the console or progs. ====================== */ void SV_Map_f (void) { char expanded[MAX_QPATH]; qfile_t *f; if (Cmd_Argc() != 2) { Com_Printf ("map <mapname> : continue game on a new map\n"); return; } // check to make sure the level exists Q_snprintf (expanded, sizeof(expanded), "maps/%s.bsp", Cmd_Argv(1)); f = FS_Open (expanded, "rb", false, true); if (!f) return; FS_Close (f); if (sv.mvdrecording) SV_MVDStop_f(); NET_ServerConfig (true); if (!dedicated) CL_BeginLocalConnection (); SV_BroadcastCommand ("changing\n"); SV_SendMessagesToAll (); SV_SpawnServer (Cmd_Argv(1), !Q_stricmp(Cmd_Argv(0), "devmap")); SV_BroadcastCommand ("reconnect\n"); }
/* ==================== SV_WriteMVDMessage Dumps the current net message, prefixed by the length and view angles ==================== */ void SV_WriteMVDMessage (sizebuf_t *msg, int type, int to, float time) { int len, i, msec; byte c; static double prevtime; if (!sv.mvdrecording) return; msec = (time - prevtime)*1000; prevtime += msec*0.001; if (msec > 255) msec = 255; if (msec < 2) msec = 0; c = msec; DemoWrite(&c, sizeof(c)); if (demo.lasttype != type || demo.lastto != to) { demo.lasttype = type; demo.lastto = to; switch (demo.lasttype) { case dem_all: c = dem_all; DemoWrite (&c, sizeof(c)); break; case dem_multiple: c = dem_multiple; DemoWrite (&c, sizeof(c)); i = LittleLong(demo.lastto); DemoWrite (&i, sizeof(i)); break; case dem_single: case dem_stats: c = demo.lasttype + (demo.lastto << 3); DemoWrite (&c, sizeof(c)); break; default: SV_MVDStop_f (); Com_Printf("bad demo message type:%d", type); return; } } else { c = dem_read; DemoWrite (&c, sizeof(c)); } len = LittleLong (msg->cursize); DemoWrite (&len, 4); DemoWrite (msg->data, msg->cursize); DestFlush(false); }
void SV_MVDRemoveNum_f (void) { int num; char *val, *name; char path[MAX_OSPATH]; if (Cmd_Argc() != 2) { Com_Printf("rmdemonum <#>\n"); return; } val = Cmd_Argv(1); if ((num = atoi(val)) == 0 && val[0] != '0') { Com_Printf("rmdemonum <#>\n"); return; } name = SV_MVDNum(num); if (name != NULL) { if (sv.mvdrecording && !strcmp(name, demo.name)) SV_MVDStop_f(); Q_snprintf(path, MAX_OSPATH, "%s/%s/%s", fs_gamedir, sv_demoDir.string, name); if (!Sys_remove(path)) { Com_Printf("demo %s succesfully removed\n", name); } else Com_Printf("unable to remove demo %s\n", name); Sys_remove(SV_MVDName2Txt(path)); } else Com_Printf("invalid demo num\n"); }
void SV_MVDRemove_f (void) { char name[MAX_MVD_NAME], *ptr; char path[MAX_OSPATH]; int i; if (Cmd_Argc() != 2) { Com_Printf("rmdemo <demoname> - removes the demo\nrmdemo *<token> - removes demo with <token> in the name\nrmdemo * - removes all demos\n"); return; } ptr = Cmd_Argv(1); if (*ptr == '*') { dir_t dir; file_t *list; // remove all demos with specified token ptr++; dir = Sys_listdir(va("%s/%s", fs_gamedir, sv_demoDir.string), ".mvd", true); list = dir.files; for (i = 0;list->name[0]; list++) { if (strstr(list->name, ptr)) { if (sv.mvdrecording && !strcmp(list->name, demo.name)) SV_MVDStop_f(); // stop recording first; Q_snprintf(path, MAX_OSPATH, "%s/%s/%s", fs_gamedir, sv_demoDir.string, list->name); if (!Sys_remove(path)) { Com_Printf("removing %s...\n", list->name); i++; } Sys_remove(SV_MVDName2Txt(path)); } } if (i) { Com_Printf("%d demos removed\n", i); } else { Com_Printf("no matching found\n"); } return; } Q_strncpyz(name, Cmd_Argv(1), MAX_MVD_NAME); FS_DefaultExtension(name, ".mvd", sizeof(name)); Q_snprintf(path, MAX_OSPATH, "%s/%s/%s", fs_gamedir, sv_demoDir.string, name); if (sv.mvdrecording && !strcmp(name, demo.name)) SV_MVDStop_f(); if (!Sys_remove(path)) { Com_Printf("demo %s successfully removed\n", name); } else Com_Printf("unable to remove demo %s\n", name); Sys_remove(SV_MVDName2Txt(path)); }