Tremulous Forum

Mods => Mod Releases => Non-Gameplay Changing => Topic started by: Amanieu on October 03, 2008, 10:22:15 pm

Title: Amanieu's server-side demo mod
Post by: Amanieu on October 03, 2008, 10:22:15 pm
Server-side demos allow a server to record a complete game to a file and then play it back later. Recording and playback are both done on the server. When a demo is being played, every player on the server will be forced into the spectators team. They will be able to spectate all players which were recorded in the demo.

Now, to set up server-side demos on your server, you need 2 things: A patched game.qvm, and a tremded with server-demo support.
So far, only tremfusion and fsm-trem have server-side demo support. You will need to use one of these two in order to have server-side demos.
I have provided a patched version of Lakitu7's qvm with server-side demo support, but the patch can be applied to any other qvm.

Lakitu7's qvm with server-side demos (http://patches.mercenariesguild.net/index.php?getfile=858)
Patch (http://patches.mercenariesguild.net/index.php?getfile=859)

Cvars:
sv_autodemo: Set to 1 to automatically record a demo at the start of each map
sv_demostate: Current demo state: 0 = none, 1 = playing, 2 = recording
sv_democlients: Must be >= to the value of sv_maxclients used when recording a demo in order to play it

Commands:
demo_record <name>: Records a demo
demo_stoprecord: Stops recording a demo
demo_play <name>: Plays a demo
demo_stop: Stops playing a demo

If you would like admins to be able to record and play demos, you can make commands in admin.dat by following this tutorial (http://www.mercenariesguild.net/component/option,com_openwiki/Itemid,12/id,making_tjw_admin_commands/lang,en/)
Title: Re: Amanieu's server-side demo mod
Post by: David on October 04, 2008, 01:40:24 am
Nice.
Whats the status on client playback?
Where are the files stored, what format, and how big are they?  (And does it record when the server is empty?)
Title: Re: Amanieu's server-side demo mod
Post by: SlackerLinux on October 04, 2008, 01:57:28 am
Nice.
Whats the status on client playback?
Where are the files stored, what format, and how big are they?  (And does it record when the server is empty?)
client playback is nonexistant
and itll record anything thats happening when you issue the command so if the servers empty and you tell it to record it will. there not too big ive got a few min demos and there only 300-500 kb not much at all their stored in ~/.tremulous/base/svdemos
Title: Re: Amanieu's server-side demo mod
Post by: Sap on October 04, 2008, 03:54:06 am
I think this is a great addition and will be especially helpful in analyzing scrims , just like they do in a real world professional game  .
Title: Re: Amanieu's server-side demo mod
Post by: David on October 04, 2008, 11:05:31 am
I was meaning does sv_autodemo record empty games?
And 300-500 for a few mins?  Thats still ~72MB per server per day.  Not masses but it'll add up fast.
Title: Re: Amanieu's server-side demo mod
Post by: Amanieu on October 04, 2008, 12:50:40 pm
sv_autodemo will record empty games, but the demos will take almost no space at all.

It is possible to have client-side playback, all you need is a client and game.qvm that supports it. The tremfusion client supports it, and tremfusion-base.pk3 comes with the patched version of Lakitu7's qvm.
Title: Re: Amanieu's server-side demo mod
Post by: remember on October 08, 2008, 06:53:53 pm
Hi,

When i want to play a demo with this qvm i need to set sv_democlients >= to the value of sv_maxclients.
So, is it possible to modify this (nice) patch in order to do it automaticly?

After playing a demo the value of sv_maxclients changed.
For example, before playing a demo sv_maxclients=15 and sv_democlients=15 and there is only one player recorded in the demo, then, when the demo is finished sv_maxclients=16.
So, is it possible to restore the first value of sv_maxclients ... automaticly ?

I am a bad programmer but i am very curious.
In the file 'sv_demo.c' in the source of Tremfusion, the line after ' Cbuf_AddText(va("devmap %s\ndelay 20000 %s\n", s, Cmd_Cmd())); ' (SV_DemoStartPlayback) is ' SV_DemoStopPlayback(); ' => Why?
And the line before ' #ifdef DEDICATED ' (SV_DemoStopPlayback) is ' if (sv.demoState != DS_PLAYBACK) ' , but 2 lines before ' Cvar_SetValue("sv_demoState", DS_NONE); ' => So sv_demoState is always != DS_PLAYBACK , no?

Please, don't flame me with my bad english and my lack of programmation but anyway your patch is very nice and very useful i think, so THANK YOU Amanieu.

Title: Re: Amanieu's server-side demo mod
Post by: Amanieu on October 09, 2008, 12:12:45 am
When i want to play a demo with this qvm i need to set sv_democlients >= to the value of sv_maxclients.
So, is it possible to modify this (nice) patch in order to do it automaticly?

After playing a demo the value of sv_maxclients changed.
For example, before playing a demo sv_maxclients=15 and sv_democlients=15 and there is only one player recorded in the demo, then, when the demo is finished sv_maxclients=16.
So, is it possible to restore the first value of sv_maxclients ... automaticly ?
Yes, I'll do that. But the patch in the patch tracker is a little old, it's hard for me to keep it up-to-date all the time. The most recent version will always be in tremfusion.

I am a bad programmer but i am very curious.
In the file 'sv_demo.c' in the source of Tremfusion, the line after ' Cbuf_AddText(va("devmap %s\ndelay 20000 %s\n", s, Cmd_Cmd())); ' (SV_DemoStartPlayback) is ' SV_DemoStopPlayback(); ' => Why?
And the line before ' #ifdef DEDICATED ' (SV_DemoStopPlayback) is ' if (sv.demoState != DS_PLAYBACK) ' , but 2 lines before ' Cvar_SetValue("sv_demoState", DS_NONE); ' => So sv_demoState is always != DS_PLAYBACK , no?
So the map doesn't restart if it failed to start the demo.
Title: Re: Amanieu's server-side demo mod
Post by: rotacak on October 09, 2008, 07:12:58 pm
This is very good thing, server demo. But I think there is one problem and that is harddisk size :-) If all games will be recorded.

Is possible to add feature like this?: sv_max_demo_files = 50 And that will allow only last 50 demos recorded. Older will be automaticaly deleted.

Also good thing would be some administration for this. For example when is someone banned, then admin is noticed and that demo have to be deleted by admin, not automatically.

What do you think?
Title: Re: Amanieu's server-side demo mod
Post by: David on October 09, 2008, 07:19:30 pm
Use log-rotate, or a simple shell script.
No need to add bloat when there are tools to do it already.
Title: Re: Amanieu's server-side demo mod
Post by: Amanieu on October 09, 2008, 11:46:37 pm
I fixed some bugs and added support for recording stage changes. Here is the updated qvm with the patch:
Lakitu7's qvm with server-side demos (http://patches.mercenariesguild.net/index.php?getfile=858)
Patch (http://patches.mercenariesguild.net/index.php?getfile=859)

I also added automatic maxclients and democlients changing to tremfusion, it will be in the next release.