2016-07-26 03:22:47 +03:00
|
|
|
#include "precompiled.h"
|
2016-07-04 09:07:29 +03:00
|
|
|
|
2017-01-13 03:00:23 +03:00
|
|
|
MPlayer::MPlayer() : m_isQueried(false)
|
2016-07-04 09:07:29 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mark a player as querying a client cvar and stores the cvar name
|
|
|
|
// meta_errno values:
|
2017-11-18 19:14:14 +03:00
|
|
|
// - ME_ARGUMENT cvar is nullptr
|
2017-05-09 19:31:09 +03:00
|
|
|
void MPlayer::set_cvar_query(const char* cvar)
|
2016-07-04 09:07:29 +03:00
|
|
|
{
|
2017-11-18 19:14:14 +03:00
|
|
|
// Do not allow nullptr as queried cvar since we use this as
|
2016-07-04 09:07:29 +03:00
|
|
|
// return value in is_querying_cvar as indication if a
|
|
|
|
// client cvar is queried.
|
2017-05-09 19:31:09 +03:00
|
|
|
if (!cvar) {
|
2016-07-04 09:07:29 +03:00
|
|
|
return;
|
|
|
|
}
|
2016-07-26 15:18:32 +03:00
|
|
|
|
2017-01-13 03:00:23 +03:00
|
|
|
m_isQueried = true;
|
2017-11-18 17:36:53 +03:00
|
|
|
Q_strlcpy(g_cvarName, cvar);
|
2016-07-04 09:07:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Unmark player as querying a client cvar
|
2017-05-09 19:31:09 +03:00
|
|
|
void MPlayer::clear_cvar_query(const char* cvar)
|
2016-07-04 09:07:29 +03:00
|
|
|
{
|
2017-01-13 03:00:23 +03:00
|
|
|
m_isQueried = false;
|
|
|
|
g_cvarName[0] = '\0';
|
2016-07-04 09:07:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check if a client cvar is queried for this player
|
2017-11-18 19:14:14 +03:00
|
|
|
// Returns nullptr if not
|
2016-07-04 09:07:29 +03:00
|
|
|
// or the name of the cvar.
|
2017-05-09 19:31:09 +03:00
|
|
|
const char* MPlayer::is_querying_cvar() const
|
2016-07-04 09:07:29 +03:00
|
|
|
{
|
2017-05-09 19:31:09 +03:00
|
|
|
if (m_isQueried) {
|
2017-01-13 03:00:23 +03:00
|
|
|
return g_cvarName;
|
2016-07-04 09:07:29 +03:00
|
|
|
}
|
2016-07-26 03:22:47 +03:00
|
|
|
|
2016-07-26 19:31:47 +03:00
|
|
|
return nullptr;
|
2016-07-04 09:07:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mark a player as querying a client cvar and stores the cvar name
|
|
|
|
// meta_errno values:
|
2017-11-18 19:14:14 +03:00
|
|
|
// - ME_ARGUMENT cvar is nullptr
|
2017-05-09 19:31:09 +03:00
|
|
|
void MPlayerList::set_player_cvar_query(const edict_t* pEntity, const char* cvar)
|
2016-07-04 09:07:29 +03:00
|
|
|
{
|
2016-07-26 15:18:32 +03:00
|
|
|
int indx = ENTINDEX(pEntity);
|
2017-11-18 19:14:14 +03:00
|
|
|
if (indx >= 1 && indx <= gpGlobals->maxClients) {
|
2017-01-13 03:00:23 +03:00
|
|
|
m_players[indx].set_cvar_query(cvar);
|
2017-11-18 19:14:14 +03:00
|
|
|
}
|
2016-07-04 09:07:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Unmark player as querying a client cvar
|
2017-05-09 19:31:09 +03:00
|
|
|
void MPlayerList::clear_player_cvar_query(const edict_t* pEntity, const char* cvar)
|
2016-07-04 09:07:29 +03:00
|
|
|
{
|
2016-07-26 15:18:32 +03:00
|
|
|
int indx = ENTINDEX(pEntity);
|
2017-11-18 19:14:14 +03:00
|
|
|
if (indx >= 1 && indx <= gpGlobals->maxClients) {
|
2017-01-13 03:00:23 +03:00
|
|
|
m_players[indx].clear_cvar_query(cvar);
|
2017-11-18 19:14:14 +03:00
|
|
|
}
|
2016-07-04 09:07:29 +03:00
|
|
|
}
|
|
|
|
|
2017-05-08 23:52:22 +03:00
|
|
|
void MPlayerList::clear_all_cvar_queries()
|
2016-07-04 09:07:29 +03:00
|
|
|
{
|
2017-05-09 19:31:09 +03:00
|
|
|
for (int indx = 1; indx <= gpGlobals->maxClients; indx++) {
|
2017-01-13 03:00:23 +03:00
|
|
|
m_players[indx].clear_cvar_query();
|
2016-07-04 09:07:29 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if a client cvar is queried for this player
|
2017-11-18 19:14:14 +03:00
|
|
|
// Returns nullptr if not
|
2016-07-04 09:07:29 +03:00
|
|
|
// or the name of the cvar.
|
|
|
|
// meta_errno values:
|
|
|
|
// - ME_NOTFOUND invalid entity
|
2017-05-09 19:31:09 +03:00
|
|
|
const char* MPlayerList::is_querying_cvar(const edict_t* pEntity) const
|
2016-07-04 09:07:29 +03:00
|
|
|
{
|
2016-07-26 15:18:32 +03:00
|
|
|
int indx = ENTINDEX(pEntity);
|
2017-11-18 19:14:14 +03:00
|
|
|
if (indx >= 1 && indx <= gpGlobals->maxClients) {
|
2017-01-13 03:00:23 +03:00
|
|
|
return m_players[indx].is_querying_cvar();
|
2017-11-18 19:14:14 +03:00
|
|
|
}
|
2016-07-26 03:22:47 +03:00
|
|
|
|
2017-11-18 19:14:14 +03:00
|
|
|
return nullptr;
|
2016-07-04 09:07:29 +03:00
|
|
|
}
|