callofduty4x / CoD4x_Server

Extended Call of Duty 4 server
https://cod4x.ovh
GNU Affero General Public License v3.0
335 stars 121 forks source link

Demo Recording Filename #401

Closed matt-alton closed 1 year ago

matt-alton commented 1 year ago

Hello,

I would like to enable demo recording across all my servers however, I have always found the filenames to be of little use. My servers are using cod4x style player ID numbers. The demo recordings name the files as demo__0000.dm_1. The issue I have is if a player is not using a steam copy the demos are named demo_0_0000.dm_1 making it impossible to associate a demo with a player.

I have looked at src/svdemo.c and, due to my unfamiliarity with CoD4 cl variables, I cannot work out if modifying the filename is as simple as changing a variable to use a playerid instead of a streamid. My end goal is to have the files named as demo_0000.dm_1 and then I can easily associate a demo to a player.

Can anyone offer any assistance with this?

Regards, Matt.

Iswenzz commented 1 year ago

hi, you can use exec("record <client> <demoname>"); in GSC and make the demoname the player ID

matt-alton commented 1 year ago

@Iswenzz thanks for the suggestion. How would I implement this so it works?

I tried the following in player.gsx as part of a welcome message block but it appears to have had no effect. No errors logged either.

    exec( "record " + self.name + " demo_" + self.clientid + "_" );

Regards, Matt.

matt-alton commented 1 year ago

@Iswenzz I've since managed to work out where the variable is set and have created a PR with the very simple change.

Iswenzz commented 1 year ago

You should use the client number instead of name, and the Pr doesn't seem to make sense, it's a steam ID function

matt-alton commented 1 year ago

Hmm I see your point. This likely needs to check a dvar to check what type of ID is being used or a conditional statement to fallback to codguid if steamid is null. The code at present is hardcoded to only use the steamid in the autorecord filename.

https://github.com/callofduty4x/CoD4x_Server/blob/master/src/sv_client.c#L1212-L1220

    SV_SApiSteamIDToString(client->steamid, psti, sizeof(psti));

    //It was never intended to make a new demo for each fast_restart.
    //SV_SpawnServer() stops the demo and cleans the name which did not happen here which resulted in strange naming bug
    if(sv_autodemorecord->boolean && !client->demorecording && (client->netchan.remoteAddress.type == NA_IP || client->netchan.remoteAddress.type == NA_IP6))
    {
        SV_RecordClient(client, va("demo_%s_", psti));
    }
Iswenzz commented 1 year ago

Ye a fallback sounds good