int main(int argc, const char *argv[]) { demoPlugin_t *dem; if (argc != 2) { fprintf(stderr, "Usage: <demo file>\n"); exit(EXIT_FAILURE); } demo_init_urt_411_plugin(); if (! CL_ParseDemo(argv[1], 0)) { fprintf(stderr, "Error operating on \"%s\"\n", argv[1]); exit(EXIT_FAILURE); } // Load a DLL if ((dem = demoPluginDynamicLoad("demo_dummy_" ARCH_STRING DLL_EXT)) == NULL) { debug_print("Failed to load the dummy plugin"); exit(EXIT_FAILURE); } printPluginSummary(dem); // Make sure we can run it several times. The registry should still be in tact. // // It should now run with both UrT and the dummy plugin for every callback. if (! CL_ParseDemo(argv[1], 0)) { fprintf(stderr, "Error operating on \"%s\"\n", argv[1]); exit(EXIT_FAILURE); } demoPluginFreeRegistry(); return 1; }
/** * @brief Usage: demo \<demoname\> */ void CL_PlayDemo_f(void) { char name[MAX_OSPATH], retry[MAX_OSPATH]; char *arg, *ext_test; int protocol, i; if (Cmd_Argc() != 2) { Com_FuncPrinf("playdemo <demoname>\n"); return; } // make sure a local server is killed Cvar_Set("sv_killserver", "1"); CL_Disconnect(qtrue); // open the demo file arg = Cmd_Argv(1); // check for an extension .DEMOEXT_?? (?? is protocol) ext_test = strrchr(arg, '.'); if (ext_test && !Q_stricmpn(ext_test + 1, DEMOEXT, ARRAY_LEN(DEMOEXT) - 1)) { protocol = atoi(ext_test + ARRAY_LEN(DEMOEXT)); for (i = 0; demo_protocols[i]; i++) { if (demo_protocols[i] == protocol) { break; } } if (demo_protocols[i] || protocol == PROTOCOL_VERSION) { Com_sprintf(name, sizeof(name), "demos/%s", arg); FS_FOpenFileRead(name, &clc.demofile, qtrue); } else { int len; Com_FuncPrinf("Protocol %d not supported for demos\n", protocol); len = ext_test - arg; if (len >= ARRAY_LEN(retry)) { len = ARRAY_LEN(retry) - 1; } Q_strncpyz(retry, arg, len + 1); retry[len] = '\0'; protocol = CL_WalkDemoExt(retry, name, &clc.demofile); } } else { protocol = CL_WalkDemoExt(arg, name, &clc.demofile); } if (!clc.demofile) { Com_FuncDrop("couldn't open %s", name); return; } Q_strncpyz(clc.demoName, arg, sizeof(clc.demoName)); Con_Close(); #if NEW_DEMOFUNC CL_AllocateDemoPoints(); CL_ParseDemo(); #endif cls.state = CA_CONNECTED; clc.demoplaying = qtrue; if (Cvar_VariableValue("cl_wavefilerecord")) { CL_WriteWaveOpen(); } Q_strncpyz(cls.servername, arg, sizeof(cls.servername)); // read demo messages until connected while (cls.state >= CA_CONNECTED && cls.state < CA_PRIMED) { CL_ReadDemoMessage(); } // don't get the first snapshot this frame, to prevent the long // time from the gamestate load from messing causing a time skip clc.firstDemoFrameSkipped = qfalse; }