From eceb37aa64d2286ab181768aefbab470de17f257 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Sat, 1 Nov 2014 17:47:29 +1300 Subject: [PATCH] Added recordmap for recording demos from console recordmap Starts a new game from the specified map recording to the specified filename --- src/d_event.h | 1 + src/d_main.cpp | 1 + src/doomstat.h | 2 ++ src/g_game.cpp | 16 ++++++++++++++++ src/g_level.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+) diff --git a/src/d_event.h b/src/d_event.h index 5bd4b02e05..7a9b48eb88 100644 --- a/src/d_event.h +++ b/src/d_event.h @@ -61,6 +61,7 @@ typedef enum ga_loadlevel, ga_newgame, ga_newgame2, + ga_recordgame, ga_loadgame, ga_loadgamehidecon, ga_loadgameplaydemo, diff --git a/src/d_main.cpp b/src/d_main.cpp index 79c8990855..e08b1539e3 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -1338,6 +1338,7 @@ CCMD (endgame) { gameaction = ga_fullconsole; demosequence = -1; + G_CheckDemoStatus(); } } diff --git a/src/doomstat.h b/src/doomstat.h index 92ab5b8f82..1559609f11 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -136,6 +136,8 @@ extern int consoleplayer; // Disable save/end game? extern bool usergame; +extern FString newdemoname; +extern FString newdemomap; extern bool demoplayback; extern bool demorecording; extern int demover; diff --git a/src/g_game.cpp b/src/g_game.cpp index 8419fc017c..1ea1c6b68d 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -162,6 +162,8 @@ int consoleplayer; // player taking events int gametic; CVAR(Bool, demo_compress, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +FString newdemoname; +FString newdemomap; FString demoname; bool demorecording; bool demoplayback; @@ -1048,6 +1050,10 @@ void G_Ticker () case ga_loadlevel: G_DoLoadLevel (-1, false); break; + case ga_recordgame: + G_CheckDemoStatus(); + G_RecordDemo(newdemoname); + G_BeginRecording(newdemomap); case ga_newgame2: // Silence GCC (see above) case ga_newgame: G_DoNewGame (); @@ -2434,6 +2440,16 @@ void G_DeferedPlayDemo (const char *name) CCMD (playdemo) { + if (netgame) + { + Printf("End your current netgame first!"); + return; + } + if (demorecording) + { + Printf("End your current demo first!"); + return; + } if (argv.argc() > 1) { G_DeferedPlayDemo (argv[1]); diff --git a/src/g_level.cpp b/src/g_level.cpp index f21a1dfe5f..2a2d6471a9 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -199,6 +199,46 @@ CCMD (map) // //========================================================================== +CCMD(recordmap) +{ + if (netgame) + { + Printf("You cannot record a new game while in a netgame."); + return; + } + if (argv.argc() > 2) + { + try + { + if (!P_CheckMapData(argv[2])) + { + Printf("No map %s\n", argv[2]); + } + else + { + G_DeferedInitNew(argv[2]); + gameaction = ga_recordgame; + newdemoname = argv[1]; + newdemomap = argv[2]; + } + } + catch (CRecoverableError &error) + { + if (error.GetMessage()) + Printf("%s", error.GetMessage()); + } + } + else + { + Printf("Usage: recordmap \n"); + } +} + +//========================================================================== +// +// +//========================================================================== + CCMD (open) { if (netgame)