added password support
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401166
This commit is contained in:
parent
9c44d29b23
commit
9ef04b07e7
@ -46,4 +46,10 @@
|
|||||||
* String to use as the silent chat trigger. Set an empty string to disable.
|
* String to use as the silent chat trigger. Set an empty string to disable.
|
||||||
*/
|
*/
|
||||||
"SilentChatTrigger" "/"
|
"SilentChatTrigger" "/"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Password setinfo key that clients must set. You must change this in order for
|
||||||
|
* passwords to work, for security reasons.
|
||||||
|
*/
|
||||||
|
"PassInfoVar" "_password"
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,23 @@ void PlayerManager::OnSourceModShutdown()
|
|||||||
delete [] m_Players;
|
delete [] m_Players;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigResult PlayerManager::OnSourceModConfigChanged(const char *key,
|
||||||
|
const char *value,
|
||||||
|
ConfigSource source,
|
||||||
|
char *error,
|
||||||
|
size_t maxlength)
|
||||||
|
{
|
||||||
|
if (strcmp(key, "PassInfoVar") == 0)
|
||||||
|
{
|
||||||
|
if (strcmp(value, "_password") != 0)
|
||||||
|
{
|
||||||
|
m_PassInfoVar.assign(value);
|
||||||
|
}
|
||||||
|
return ConfigResult_Accept;
|
||||||
|
}
|
||||||
|
return ConfigResult_Ignore;
|
||||||
|
}
|
||||||
|
|
||||||
void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
|
void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
|
||||||
{
|
{
|
||||||
if (m_FirstPass)
|
if (m_FirstPass)
|
||||||
@ -119,13 +136,18 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
|
|||||||
SM_ExecuteAllConfigs();
|
SM_ExecuteAllConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id)
|
bool PlayerManager::CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id)
|
||||||
{
|
{
|
||||||
const char *password = g_Admins.GetAdminPassword(id);
|
const char *password = g_Admins.GetAdminPassword(id);
|
||||||
if (password != NULL)
|
if (password != NULL)
|
||||||
{
|
{
|
||||||
|
if (m_PassInfoVar.size() < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Whoa... the user needs a password! */
|
/* Whoa... the user needs a password! */
|
||||||
const char *given = engine->GetClientConVarValue(index, "_password");
|
const char *given = engine->GetClientConVarValue(index, m_PassInfoVar.c_str());
|
||||||
if (!given || strcmp(given, password) != 0)
|
if (!given || strcmp(given, password) != 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -76,6 +76,7 @@ public: //SMGlobalClass
|
|||||||
void OnSourceModAllInitialized();
|
void OnSourceModAllInitialized();
|
||||||
void OnSourceModShutdown();
|
void OnSourceModShutdown();
|
||||||
void OnSourceModLevelEnd();
|
void OnSourceModLevelEnd();
|
||||||
|
ConfigResult OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength);
|
||||||
public:
|
public:
|
||||||
CPlayer *GetPlayerByIndex(int client) const;
|
CPlayer *GetPlayerByIndex(int client) const;
|
||||||
void RunAuthChecks();
|
void RunAuthChecks();
|
||||||
@ -108,6 +109,7 @@ public:
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
|
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
|
||||||
|
bool CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id);
|
||||||
private:
|
private:
|
||||||
List<IClientListener *> m_hooks;
|
List<IClientListener *> m_hooks;
|
||||||
IForward *m_clconnect;
|
IForward *m_clconnect;
|
||||||
@ -125,6 +127,7 @@ private:
|
|||||||
int m_PlayerCount;
|
int m_PlayerCount;
|
||||||
bool m_FirstPass;
|
bool m_FirstPass;
|
||||||
unsigned int *m_AuthQueue;
|
unsigned int *m_AuthQueue;
|
||||||
|
String m_PassInfoVar;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern PlayerManager g_Players;
|
extern PlayerManager g_Players;
|
||||||
|
Loading…
Reference in New Issue
Block a user