/* ==================== CL_PlayDemo_f play [demoname] ==================== */ void CL_PlayDemo_f (void) { char name[MAX_QPATH]; int c; qboolean neg = false; qfile_t *f; if (Cmd_Argc() != 2) { Con_Print("play <demoname> : plays a demo\n"); return; } // open the demo file strlcpy (name, Cmd_Argv(1), sizeof (name)); FS_DefaultExtension (name, ".dem", sizeof (name)); f = FS_OpenVirtualFile(name, false); if (!f) { Con_Printf("ERROR: couldn't open %s.\n", name); cls.demonum = -1; // stop demo loop return; } cls.demostarting = true; // disconnect from server CL_Disconnect (); Host_ShutdownServer (); // update networking ports (this is mainly just needed at startup) NetConn_UpdateSockets(); cls.protocol = PROTOCOL_QUAKE; Con_Printf("Playing demo %s.\n", name); cls.demofile = f; strlcpy(cls.demoname, name, sizeof(cls.demoname)); cls.demoplayback = true; demoplayback = true; cls.state = ca_connected; cls.forcetrack = 0; while ((c = FS_Getc (cls.demofile)) != '\n') if (c == '-') neg = true; else cls.forcetrack = cls.forcetrack * 10 + (c - '0'); if (neg) cls.forcetrack = -cls.forcetrack; cls.demostarting = false; }
static void Key_History_Init(void) { qfile_t *historyfile; ConBuffer_Init(&history, HIST_TEXTSIZE, HIST_MAXLINES, zonemempool); // not necessary for mobile #ifndef DP_MOBILETOUCH historyfile = FS_OpenRealFile("darkplaces_history.txt", "rb", false); // rb to handle unix line endings on windows too if(historyfile) { char buf[MAX_INPUTLINE]; int bufpos; int c; bufpos = 0; for(;;) { c = FS_Getc(historyfile); if(c < 0 || c == 0 || c == '\r' || c == '\n') { if(bufpos > 0) { buf[bufpos] = 0; ConBuffer_AddLine(&history, buf, bufpos, 0); bufpos = 0; } if(c < 0) break; } else { if(bufpos < MAX_INPUTLINE - 1) buf[bufpos++] = c; } } FS_Close(historyfile); } #endif history_line = -1; }