diff --git a/README.md b/README.md
index 0bcb7b8..f9756ed 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
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
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.
sv_usercmd_custom_random_seed // When enabled server will populate an additional random seed independent of the client. Default: 0
+sv_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: ""
diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h
index e22b889..c59332e 100644
--- a/rehlds/engine/server.h
+++ b/rehlds/engine/server.h
@@ -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;
diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp
index d3e1ff7..59d3588 100644
--- a/rehlds/engine/sv_main.cpp
+++ b/rehlds/engine/sv_main.cpp
@@ -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 };
@@ -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);
diff --git a/rehlds/engine/sv_steam3.cpp b/rehlds/engine/sv_steam3.cpp
index ad288fa..8cd18a6 100644
--- a/rehlds/engine/sv_steam3.cpp
+++ b/rehlds/engine/sv_steam3.cpp
@@ -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;
@@ -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;
@@ -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()
diff --git a/rehlds/engine/sv_steam3.h b/rehlds/engine/sv_steam3.h
index 1aa2e51..3238dc8 100644
--- a/rehlds/engine/sv_steam3.h
+++ b/rehlds/engine/sv_steam3.h
@@ -54,6 +54,8 @@ protected:
bool InitModule();
};
+#define MAX_STEAM_TAGS_LENGTH 128 // Steam doesn't send tags string more than 128 bytes
+
class CSteam3Server: public CSteam3
{
public:
@@ -71,6 +73,10 @@ protected:
bool m_bLanOnly;
CSteamID m_SteamIDGS;
+#ifdef REHLDS_FIXES
+ char m_GameTagsData[MAX_STEAM_TAGS_LENGTH];
+#endif
+
public:
NOBODY void SetServerType();
@@ -96,6 +102,7 @@ public:
void NotifyOfLevelChange(bool bForce);
void RunFrame();
void SendUpdatedServerDetails();
+ void UpdateGameTags();
};
class CSteam3Client: public CSteam3
diff --git a/rehlds/rehlds/structSizeCheck.cpp b/rehlds/rehlds/structSizeCheck.cpp
index 18cb3db..259787c 100644
--- a/rehlds/rehlds/structSizeCheck.cpp
+++ b/rehlds/rehlds/structSizeCheck.cpp
@@ -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
}