Skip to content

Commit

Permalink
Implemented optional CVar sv_tags for sets a string defining the "gam…
Browse files Browse the repository at this point in the history
…etags" for this server to allows users/scripts to filter in the matchmaking/server-browser interfaces based on the value
  • Loading branch information
s1lentq committed Jan 18, 2024
1 parent f29d6c5 commit 76cbd2c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
<li>sv_rehlds_local_gametime <1|0> // A feature of local gametime which decrease "lags" if you run same map for a long time. Default: 0
<li>sv_use_entity_file // Use custom entity file for a map. Path to an entity file will be "maps/[map name].ent". 0 - use original entities. 1 - use .ent files from maps directory. 2 - use .ent files from maps directory and create new .ent file if not exist.
<li>sv_usercmd_custom_random_seed // When enabled server will populate an additional random seed independent of the client. Default: 0
<li>sv_tags <comma-delimited string list of tags> // Sets a string defining the "gametags" for this server, this is optional, but if it is set it allows users/scripts to filter in the matchmaking/server-browser interfaces based on the value. Default: ""
</ul>
</details>

Expand Down
1 change: 1 addition & 0 deletions rehlds/engine/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ extern cvar_t sv_visiblemaxplayers;
extern cvar_t sv_downloadurl;
extern cvar_t sv_allow_dlfile;
extern cvar_t sv_version;
extern cvar_t sv_tags;
#ifdef REHLDS_FIXES
extern cvar_t sv_echo_unknown_cmd;
extern cvar_t sv_auto_precache_sounds_in_models;
Expand Down
3 changes: 3 additions & 0 deletions rehlds/engine/sv_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ cvar_t sv_version = { "sv_version", "", FCVAR_SERVER, 0.0f, NULL };
cvar_t sv_version = {"sv_version", "", 0, 0.0f, NULL};
#endif

cvar_t sv_tags = { "sv_tags", "", 0, 0.0f, NULL };

cvar_t sv_rcon_minfailures = { "sv_rcon_minfailures", "5", 0, 0.0f, NULL };
cvar_t sv_rcon_maxfailures = { "sv_rcon_maxfailures", "10", 0, 0.0f, NULL };
cvar_t sv_rcon_minfailuretime = { "sv_rcon_minfailuretime", "30", 0, 0.0f, NULL };
Expand Down Expand Up @@ -8258,6 +8260,7 @@ void SV_Init(void)
Cvar_RegisterVariable(&sv_version);
Cvar_RegisterVariable(&sv_allow_dlfile);
#ifdef REHLDS_FIXES
Cvar_RegisterVariable(&sv_tags);
Cvar_RegisterVariable(&sv_force_ent_intersection);
Cvar_RegisterVariable(&sv_echo_unknown_cmd);
Cvar_RegisterVariable(&sv_auto_precache_sounds_in_models);
Expand Down
21 changes: 21 additions & 0 deletions rehlds/engine/sv_steam3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ CSteam3Server::CSteam3Server() :
m_CallbackLogonFailure(this, &CSteam3Server::OnLogonFailure),
m_SteamIDGS(1, 0, k_EUniverseInvalid, k_EAccountTypeInvalid)
{
#ifdef REHLDS_FIXES
m_GameTagsData[0] = '\0';
#endif

m_bHasActivePlayers = false;
m_bWantToBeSecure = false;
m_bLanOnly = false;
Expand Down Expand Up @@ -499,6 +503,21 @@ void CSteam3Server::RunFrame()
}
}

void CSteam3Server::UpdateGameTags()
{
#ifdef REHLDS_FIXES
if (!sv_tags.string[0])
return;

if (m_GameTagsData[0] && !Q_stricmp(m_GameTagsData, sv_tags.string))
return;

Q_strlcpy(m_GameTagsData, sv_tags.string);
Q_strlwr(m_GameTagsData);
CRehldsPlatformHolder::get()->SteamGameServer()->SetGameTags(m_GameTagsData);
#endif
}

void CSteam3Server::SendUpdatedServerDetails()
{
int botCount = 0;
Expand All @@ -521,6 +540,8 @@ void CSteam3Server::SendUpdatedServerDetails()
CRehldsPlatformHolder::get()->SteamGameServer()->SetBotPlayerCount(botCount);
CRehldsPlatformHolder::get()->SteamGameServer()->SetServerName(Cvar_VariableString("hostname"));
CRehldsPlatformHolder::get()->SteamGameServer()->SetMapName(g_psv.name);

UpdateGameTags();
}

void CSteam3Client::Shutdown()
Expand Down
7 changes: 7 additions & 0 deletions rehlds/engine/sv_steam3.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class CSteam3
bool InitModule();
};

#define MAX_STEAM_TAGS_LENGTH 128 // Steam doesn't send tags string more than 128 bytes

class CSteam3Server: public CSteam3
{
public:
Expand All @@ -71,6 +73,10 @@ class CSteam3Server: public CSteam3
bool m_bLanOnly;
CSteamID m_SteamIDGS;

#ifdef REHLDS_FIXES
char m_GameTagsData[MAX_STEAM_TAGS_LENGTH];
#endif

public:

NOBODY void SetServerType();
Expand All @@ -96,6 +102,7 @@ class CSteam3Server: public CSteam3
void NotifyOfLevelChange(bool bForce);
void RunFrame();
void SendUpdatedServerDetails();
void UpdateGameTags();
};

class CSteam3Client: public CSteam3
Expand Down
2 changes: 2 additions & 0 deletions rehlds/rehlds/structSizeCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ void check_size() {
void checkSizesStatic() {
CHECK_TYPE_SIZE(client_t, 0x5018, 0x4EF4);
CHECK_TYPE_SIZE(userfilter_t, 0x20, 0x18);
#ifndef REHLDS_FIXES
CHECK_TYPE_SIZE(CSteam3Server, 0x90, 0xA8);
#endif
}

0 comments on commit 76cbd2c

Please sign in to comment.