Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ out
/game/neo/mapsrc/*.prt
/game/neo/mapsrc/*.vmx

# Demos
*.dem

# MP3 Player
/game/neo/resource/mp3player_db.txt
/game/neo/resource/mp3settings.txt
Expand Down
39 changes: 38 additions & 1 deletion src/game/shared/neo/neo_gamerules.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "cbase.h"
#include "neo_gamerules.h"
#include "neo_version_info.h"
#include "neo_misc.h"
#include "in_buttons.h"
#include "ammodef.h"

Expand Down Expand Up @@ -28,7 +29,6 @@
#include "player_resource.h"
#include "inetchannelinfo.h"
#include "neo_dm_spawn.h"
#include "neo_misc.h"
#include "neo_game_config.h"
#include "nav_mesh.h"

Expand Down Expand Up @@ -138,6 +138,10 @@ ConVar sv_neo_pausematch_unpauseimmediate("sv_neo_pausematch_unpauseimmediate",
ConVar sv_neo_readyup_countdown("sv_neo_readyup_countdown", "5", FCVAR_REPLICATED, "Set the countdown from fully ready to start of match in seconds.", true, 0.0f, true, 120.0f);
ConVar sv_neo_ghost_spawn_bias("sv_neo_ghost_spawn_bias", "0", FCVAR_REPLICATED, "Spawn ghost in the same location as the previous round on odd-indexed rounds (Round 1 = index 0)", true, 0, true, 1);
ConVar sv_neo_juggernaut_spawn_bias("sv_neo_juggernaut_spawn_bias", "0", FCVAR_REPLICATED, "Spawn juggernaut in the same location as the previous round on odd-indexed rounds (Round 1 = index 0)", true, 0, true, 1);
ConVar sv_neo_client_autorecord("sv_neo_client_autorecord", "0", FCVAR_REPLICATED | FCVAR_DONTRECORD, "Record demos clientside", true, 0, true, 1);
#ifdef CLIENT_DLL
ConVar cl_neo_client_autorecord_allow("cl_neo_client_autorecord_allow", "1", FCVAR_ARCHIVE, "Allow servers to automatically record demos on the client", true, 0, true, 1);
#endif

static void neoSvCompCallback(IConVar* var, const char* pOldValue, float flOldValue)
{
Expand All @@ -148,6 +152,7 @@ static void neoSvCompCallback(IConVar* var, const char* pOldValue, float flOldVa
sv_neo_pausematch_enabled.SetValue(bCurrentValue);
sv_neo_ghost_spawn_bias.SetValue(bCurrentValue);
sv_neo_juggernaut_spawn_bias.SetValue(bCurrentValue);
sv_neo_client_autorecord.SetValue(bCurrentValue);
}

ConVar sv_neo_comp("sv_neo_comp", "0", FCVAR_REPLICATED, "Enables competitive gamerules", true, 0.f, true, 1.f
Expand All @@ -156,6 +161,8 @@ ConVar sv_neo_comp("sv_neo_comp", "0", FCVAR_REPLICATED, "Enables competitive ga
#endif // GAME_DLL
);

ConVar sv_neo_comp_name("sv_neo_comp_name", "", FCVAR_REPLICATED, "Name of the competition. Leave blank if unused.");

#ifdef CLIENT_DLL
extern ConVar snd_victory_volume;
void sndVictoryVolumeChangeCallback(IConVar* cvar [[maybe_unused]], const char* pOldVal [[maybe_unused]], float flOldVal [[maybe_unused]])
Expand Down Expand Up @@ -526,6 +533,7 @@ CNEORules::CNEORules()

ResetMapSessionCommon();
ListenForGameEvent("round_start");
ListenForGameEvent("game_end");

#ifdef GAME_DLL
weaponstay.InstallChangeCallback(CvarChanged_WeaponStay);
Expand Down Expand Up @@ -1589,6 +1597,13 @@ void CNEORules::SetWinningDMPlayer(CNEO_Player *pWinner)
}

GoToIntermission();

IGameEvent *event = gameeventmanager->CreateEvent("game_end");
if (event)
{
event->SetInt("winner", pWinner->GetUserID());
gameeventmanager->FireEvent(event);
}
}
#endif

Expand Down Expand Up @@ -1738,10 +1753,25 @@ void CNEORules::FireGameEvent(IGameEvent* event)
#ifdef CLIENT_DLL
engine->ClientCmd("r_cleardecals");
engine->ClientCmd("classmenu");

if (!engine->IsRecordingDemo() && sv_neo_client_autorecord.GetBool() && cl_neo_client_autorecord_allow.GetBool())
{
StartAutoClientRecording();
}
#endif
m_flNeoRoundStartTime = gpGlobals->curtime;
m_flNeoNextRoundStartTime = 0;
}

#ifdef CLIENT_DLL
if (Q_strcmp(type, "game_end") == 0)
{
if (sv_neo_client_autorecord.GetBool() && cl_neo_client_autorecord_allow.GetBool())
{
engine->StopDemoRecording();
}
}
#endif
}

#ifdef GAME_DLL
Expand Down Expand Up @@ -3544,6 +3574,13 @@ void CNEORules::SetWinningTeam(int team, int iWinReason, bool bForceMapReset, bo
{
GoToIntermission();
}

IGameEvent *event = gameeventmanager->CreateEvent("game_end");
if (event)
{
event->SetInt("winner", team);
gameeventmanager->FireEvent(event);
}
}
}
#endif
Expand Down
62 changes: 62 additions & 0 deletions src/game/shared/neo/neo_misc.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#include "neo_misc.h"

#ifdef CLIENT_DLL
#include "steamclientpublic.h"
#include "vgui/ISystem.h"
#include "tier3.h"
#include <filesystem.h>

extern ConVar sv_neo_comp_name;

#define DEMOS_DIRECTORY_NAME "demos"
#endif

[[nodiscard]] bool InRect(const vgui::IntRect &rect, const int x, const int y)
{
return IN_BETWEEN_EQ(rect.x0, x, rect.x1) && IN_BETWEEN_EQ(rect.y0, y, rect.y1);
Expand All @@ -22,3 +33,54 @@
{
return LoopAroundMinMax(iValue, 0, iSize - 1);
}

#ifdef CLIENT_DLL
void StartAutoClientRecording()
{
// SteamID
char steamSection[64];
const CSteamID steamID = GetSteamIDForPlayerIndex(GetLocalPlayerIndex());
if (steamID.IsValid())
{
auto accountID = steamID.GetAccountID();
V_snprintf(steamSection, sizeof(steamSection), "%d", accountID);
}
else
{
V_strncpy(steamSection, "nosteamid", sizeof(steamSection));
}

// Map name
char mapSection[256];
V_strncpy(mapSection, GameRules()->MapName(), sizeof(mapSection));

// Time and date
char timeSection[16];
int year, month, dayOfWeek, day, hour, minute, second;
g_pVGuiSystem->GetCurrentTimeAndDate(&year, &month, &dayOfWeek, &day, &hour, &minute, &second);
V_snprintf(timeSection, sizeof(timeSection), "%04d%02d%02d-%02d%02d", year, month, day, hour, minute);

// Competition name
char compSection[32];
V_strncpy(compSection, sv_neo_comp_name.GetString(), sizeof(compSection));

// Build the filename
char replayName[MAX_PATH];

if (compSection[0] != '\0')
{
V_snprintf(replayName, sizeof(replayName), "%s_%s_%s_%s", compSection, timeSection, mapSection, steamSection);
}
else
{
V_snprintf(replayName, sizeof(replayName), "%s_%s_%s", timeSection, mapSection, steamSection);
}

if (!g_pFullFileSystem->IsDirectory(DEMOS_DIRECTORY_NAME))
{
g_pFullFileSystem->CreateDirHierarchy(DEMOS_DIRECTORY_NAME);
}

engine->StartDemoRecording(replayName, DEMOS_DIRECTORY_NAME); // Start recording
}
#endif
4 changes: 4 additions & 0 deletions src/game/shared/neo/neo_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ struct SZWSZTexts
};
#define SZWSZ_INIT(STR) {.szStr = STR, .wszStr = L"" STR}
#define X_SZWSZ_INIT(STR) SZWSZ_INIT(STR)

#ifdef CLIENT_DLL
void StartAutoClientRecording();
#endif