Main Page | Class List | File List | Class Members | File Members

CountryFilter Class Reference

Exported interface to the HL2 Engine. More...

#include <CountryFilter.h>

Collaboration diagram for CountryFilter:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CountryFilter ()
 ~CountryFilter ()
virtual bool Load (CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory)
 Our entry point into the program.
virtual void Unload (void)
 Called on unload.
virtual const char * GetPluginDescription (void)
 Return the plugin name.
virtual void Pause (void)
 We pause operations here.
virtual void UnPause (void)
 Unpause operations here.
virtual void LevelInit (char const *pMapName)
 Called on level init.
virtual void ServerActivate (edict_t *pEdictList, int edictCount, int clientMax)
 Called when the server activates.
virtual void LevelShutdown (void)
 Called on map end.
virtual void GameFrame (bool simulating)
 Called each game "tick", but only when clients are in game.
virtual PLUGIN_RESULT ClientConnect (bool *bAllowConnect, edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
 Called when a client connects.
virtual void ClientDisconnect (edict_t *pEntity)
 Called when a client disconnects.
virtual void ClientActive (edict_t *pEntity)
 Called when a client is active.
virtual void ClientPutInServer (edict_t *pEntity, char const *playername)
 Called when a client is put in the server.
virtual void ClientSettingsChanged (edict_t *pEntity)
 Called when a client's settings change.
virtual PLUGIN_RESULT ClientCommand (edict_t *pEntity)
 Called when a client executes a command.
virtual PLUGIN_RESULT NetworkIDValidated (const char *pszUserName, const char *pszNetworkID)
 Called when a player's Network ID is validated.
virtual void SetCommandClient (int index)
 Sets the last player who used a command.
virtual void FireGameEvent (KeyValues *event)

Public Attributes

int m_ClCommandIndex
 Last client index.

Private Member Functions

PLUGIN_RESULT handleStatusCommand (edict_t *pEntity)
PLUGIN_RESULT handleCountryByAddrCommand (edict_t *pEntity)
PLUGIN_RESULT handleTestGeoIPCommand (edict_t *pEntity)
bool handlePlayerSayEvent (KeyValues *event)
bool isMessageExcludeFrom (const char *countryCode) const
bool isAllowConnect (const char *countryCode) const
const char * idToCountry (int countryId) const
int getPlayerCountryId (int playerIndex) const
bool setPlayerCountryId (int playerIndex, int countryId)
bool initPlayerCountryIdList (int clientMax)
const char * getPlayerOriginalName (int playerIndex) const
bool setPlayerOriginalName (int playerIndex, const char *name)
bool initPlayerOriginalNameList (int clientMax)
bool printCountryStatus (edict_t *pEntity, bool isChat)
bool testGeoIP (edict_t *pEntity)
edict_t * getPlayerEdictByIndex (int playerIndex)
edict_t * getPlayerEdictByUserID (int userID)
IPlayerInfo * getPlayerInfoByEdict (edict_t *pPlayerEdict)
IPlayerInfo * getPlayerInfoByIndex (int playerIndex)
IPlayerInfo * getPlayerInfoByUserID (int userID)
int getPlayerCount ()
bool clientSendChatMessage (edict_t *pEntity, const char *msg)
bool clientSendAllChatMessage (const char *msg)

Static Private Member Functions

static bool isValidSteamId (const char *steamId)
static bool isBOTSteamId (const char *steamId)
static size_t indexOf (const char *s1, const char *s2, size_t begin=0)
static bool substring (const char *src, size_t begin, size_t end, char *dst)

Private Attributes

IPlayerInfoManager * m_PlayerInfoManager
 Player info manager.
ICvar * m_CvarFactory
 Cvar manager.
bool m_Loaded
 Have we loaded already?
CPluginConVarAccessorm_pConVarAccessor
 Our copy of the cvar manager.
IVEngineServer * m_IVEngine
 Our copy of the engine server.
IEffects * m_IEffects
 IEffects interface.
IEngineSound * m_IEngineSound
 IEngineSound interface.
IGameEventManager * m_GameEventManager
 game events interface
IServerPluginHelpers * m_Helpers
 plugin helpers
bool m_Paused
 Are we paused?
bool m_Initialized
 Are we initialized?
int m_ClientMax
 Max clients.
GeoIPWrapperm_giw
CUtlVector< int > m_playerCountryIdList
char m_playerOriginalNameList [64][256]

Classes

class  CPluginConVarAccessor

Detailed Description

Exported interface to the HL2 Engine.

Definition at line 64 of file CountryFilter.h.


Constructor & Destructor Documentation

CountryFilter::CountryFilter  ) 
 

Definition at line 59 of file CountryFilter.cpp.

References m_Initialized, m_Loaded, and m_Paused.

CountryFilter::~CountryFilter  ) 
 

Definition at line 66 of file CountryFilter.cpp.

References m_Initialized, m_Loaded, and m_Paused.


Member Function Documentation

void CountryFilter::ClientActive edict_t *  pEntity  )  [virtual]
 

Called when a client is active.

This is the last client hook forwarded before Disconnect

Parameters:
pEntity Edict of the player

Definition at line 149 of file CountryFilter.cpp.

PLUGIN_RESULT CountryFilter::ClientCommand edict_t *  pEntity  )  [virtual]
 

Called when a client executes a command.

Parameters:
pEntity Edict of the player
Returns:
Whether to supercede the GameDLL or not

Definition at line 153 of file CountryFilter.cpp.

References g_StatusCommandAlias, handleCountryByAddrCommand(), handleStatusCommand(), handleTestGeoIPCommand(), and m_IVEngine.

PLUGIN_RESULT CountryFilter::ClientConnect bool *  bAllowConnect,
edict_t *  pEntity,
const char *  pszName,
const char *  pszAddress,
char *  reject,
int  maxrejectlen
[virtual]
 

Called when a client connects.

Parameters:
bAllowConnect Change this to block connecting
pEntity The player's edict
pszName The player's name
pszAddress The player's network address
reject String buffer to store a reject reason in
maxrejectlen Maximum size of the reject string buffer
Returns:
Whether to supercede the GameDLL or not.

Definition at line 210 of file CountryFilter.cpp.

References clientSendAllChatMessage(), COUNTRYFILTER_TMP_BUFFER_LENGTH, g_AllowMessage, g_CountryTag, g_DenyMessage, g_ForceChangeName, GeoIPWrapper::getIdByAddr(), idToCountry(), GeoIPWrapper::idToCountryCode(), indexOf(), isAllowConnect(), isMessageExcludeFrom(), m_giw, m_IVEngine, setPlayerCountryId(), setPlayerOriginalName(), and substring().

void CountryFilter::ClientDisconnect edict_t *  pEntity  )  [virtual]
 

Called when a client disconnects.

Parameters:
pEntity Edict of the player

Definition at line 265 of file CountryFilter.cpp.

References g_ForceChangeName, getPlayerOriginalName(), m_IVEngine, setPlayerCountryId(), and setPlayerOriginalName().

void CountryFilter::ClientPutInServer edict_t *  pEntity,
char const *  playername
[virtual]
 

Called when a client is put in the server.

Parameters:
pEntity Edict of the player
playername String containing the name of the player

Definition at line 277 of file CountryFilter.cpp.

bool CountryFilter::clientSendAllChatMessage const char *  msg  )  [private]
 

Definition at line 685 of file CountryFilter.cpp.

References clientSendChatMessage(), getPlayerEdictByIndex(), getPlayerInfoByEdict(), isBOTSteamId(), isValidSteamId(), and m_ClientMax.

Referenced by ClientConnect().

bool CountryFilter::clientSendChatMessage edict_t *  pEntity,
const char *  msg
[private]
 

Definition at line 672 of file CountryFilter.cpp.

References MRecipientFilter::AddPlayerByIndex(), m_IVEngine, and m_PlayerInfoManager.

Referenced by clientSendAllChatMessage(), and printCountryStatus().

void CountryFilter::ClientSettingsChanged edict_t *  pEntity  )  [virtual]
 

Called when a client's settings change.

Parameters:
pEntity Edict of the player

Definition at line 281 of file CountryFilter.cpp.

void CountryFilter::FireGameEvent KeyValues *  event  )  [virtual]
 

Definition at line 351 of file CountryFilter.cpp.

References COUNTRYFILTER_TMP_BUFFER_LENGTH, g_CountryTag, g_ForceChangeName, getPlayerCountryId(), getPlayerEdictByUserID(), getPlayerOriginalName(), handlePlayerSayEvent(), GeoIPWrapper::idToCountryCode(), indexOf(), m_IVEngine, and setPlayerOriginalName().

void CountryFilter::GameFrame bool  simulating  )  [virtual]
 

Called each game "tick", but only when clients are in game.

Parameters:
simulating Unknown

Definition at line 299 of file CountryFilter.cpp.

References m_Initialized, and m_Paused.

int CountryFilter::getPlayerCount  )  [private]
 

Definition at line 466 of file CountryFilter.cpp.

References getPlayerInfoByIndex(), isBOTSteamId(), isValidSteamId(), and m_ClientMax.

int CountryFilter::getPlayerCountryId int  playerIndex  )  const [private]
 

Definition at line 527 of file CountryFilter.cpp.

References m_playerCountryIdList.

Referenced by FireGameEvent(), and printCountryStatus().

edict_t * CountryFilter::getPlayerEdictByIndex int  playerIndex  )  [private]
 

Definition at line 419 of file CountryFilter.cpp.

References m_ClientMax, and m_IVEngine.

Referenced by clientSendAllChatMessage(), getPlayerEdictByUserID(), getPlayerInfoByIndex(), and printCountryStatus().

edict_t * CountryFilter::getPlayerEdictByUserID int  userID  )  [private]
 

Definition at line 430 of file CountryFilter.cpp.

References getPlayerEdictByIndex(), getPlayerInfoByEdict(), and m_ClientMax.

Referenced by FireGameEvent(), and handlePlayerSayEvent().

IPlayerInfo * CountryFilter::getPlayerInfoByEdict edict_t *  pPlayerEdict  )  [private]
 

Definition at line 442 of file CountryFilter.cpp.

References m_PlayerInfoManager.

Referenced by clientSendAllChatMessage(), getPlayerEdictByUserID(), getPlayerInfoByIndex(), and printCountryStatus().

IPlayerInfo * CountryFilter::getPlayerInfoByIndex int  playerIndex  )  [private]
 

Definition at line 449 of file CountryFilter.cpp.

References getPlayerEdictByIndex(), and getPlayerInfoByEdict().

Referenced by getPlayerCount(), and getPlayerInfoByUserID().

IPlayerInfo * CountryFilter::getPlayerInfoByUserID int  userID  )  [private]
 

Definition at line 455 of file CountryFilter.cpp.

References getPlayerInfoByIndex(), and m_ClientMax.

const char * CountryFilter::getPlayerOriginalName int  playerIndex  )  const [private]
 

Definition at line 532 of file CountryFilter.cpp.

References m_playerOriginalNameList.

Referenced by ClientDisconnect(), and FireGameEvent().

const char * CountryFilter::GetPluginDescription void   )  [virtual]
 

Return the plugin name.

Returns:
String describing the plugin

Definition at line 305 of file CountryFilter.cpp.

PLUGIN_RESULT CountryFilter::handleCountryByAddrCommand edict_t *  pEntity  )  [private]
 

Definition at line 178 of file CountryFilter.cpp.

References COUNTRYFILTER_TMP_BUFFER_LENGTH, GeoIPWrapper::getIdByAddr(), idToCountry(), m_giw, and m_IVEngine.

Referenced by ClientCommand().

bool CountryFilter::handlePlayerSayEvent KeyValues *  event  )  [private]
 

Definition at line 387 of file CountryFilter.cpp.

References g_StatusCommandAlias, getPlayerEdictByUserID(), and printCountryStatus().

Referenced by FireGameEvent().

PLUGIN_RESULT CountryFilter::handleStatusCommand edict_t *  pEntity  )  [private]
 

Definition at line 173 of file CountryFilter.cpp.

References printCountryStatus().

Referenced by ClientCommand().

PLUGIN_RESULT CountryFilter::handleTestGeoIPCommand edict_t *  pEntity  )  [private]
 

Definition at line 203 of file CountryFilter.cpp.

References testGeoIP().

Referenced by ClientCommand().

const char * CountryFilter::idToCountry int  countryId  )  const [private]
 

Definition at line 515 of file CountryFilter.cpp.

References g_CountryPrintMode, GeoIPWrapper::idToCountryCode(), GeoIPWrapper::idToCountryCode3(), and GeoIPWrapper::idToCountryName().

Referenced by ClientConnect(), handleCountryByAddrCommand(), and printCountryStatus().

size_t CountryFilter::indexOf const char *  s1,
const char *  s2,
size_t  begin = 0
[static, private]
 

Definition at line 713 of file CountryFilter.cpp.

Referenced by ClientConnect(), FireGameEvent(), isAllowConnect(), and isMessageExcludeFrom().

bool CountryFilter::initPlayerCountryIdList int  clientMax  )  [private]
 

Definition at line 557 of file CountryFilter.cpp.

References m_playerCountryIdList, and setPlayerCountryId().

Referenced by ServerActivate().

bool CountryFilter::initPlayerOriginalNameList int  clientMax  )  [private]
 

Definition at line 567 of file CountryFilter.cpp.

References setPlayerOriginalName().

Referenced by ServerActivate().

bool CountryFilter::isAllowConnect const char *  countryCode  )  const [private]
 

Definition at line 491 of file CountryFilter.cpp.

References g_AllowFrom, g_DenyFrom, g_Order, and indexOf().

Referenced by ClientConnect().

bool CountryFilter::isBOTSteamId const char *  steamId  )  [static, private]
 

Definition at line 708 of file CountryFilter.cpp.

Referenced by clientSendAllChatMessage(), getPlayerCount(), and printCountryStatus().

bool CountryFilter::isMessageExcludeFrom const char *  countryCode  )  const [private]
 

Definition at line 481 of file CountryFilter.cpp.

References g_MessageExcludeFrom, and indexOf().

Referenced by ClientConnect().

bool CountryFilter::isValidSteamId const char *  steamId  )  [static, private]
 

Definition at line 703 of file CountryFilter.cpp.

Referenced by clientSendAllChatMessage(), getPlayerCount(), and printCountryStatus().

void CountryFilter::LevelInit char const *  pMapName  )  [virtual]
 

Called on level init.

Parameters:
pMapName String containing map name

Definition at line 310 of file CountryFilter.cpp.

References m_GameEventManager, m_Initialized, and testGeoIP().

void CountryFilter::LevelShutdown void   )  [virtual]
 

Called on map end.

Definition at line 318 of file CountryFilter.cpp.

References m_GameEventManager, and m_Initialized.

bool CountryFilter::Load CreateInterfaceFn  interfaceFactory,
CreateInterfaceFn  gameServerFactory
[virtual]
 

Our entry point into the program.

Parameters:
interfaceFactory Interface Factory for the Engine
gameServerFactory Interface Factory for the GameDLL
Returns:
True on load success, false otherwise

Definition at line 73 of file CountryFilter.cpp.

References COUNTRYFILTER_PATH_SEPARATOR, COUNTRYFILTER_TMP_BUFFER_LENGTH, GEOIP_STANDARD, LOAD_EINTERFACE, LOAD_GINTERFACE, LOAD_INTERFACES_BEGIN, LOAD_INTERFACES_END, m_CvarFactory, m_GameEventManager, m_giw, m_Helpers, m_IEffects, m_IEngineSound, m_IVEngine, m_Loaded, m_pConVarAccessor, and m_PlayerInfoManager.

PLUGIN_RESULT CountryFilter::NetworkIDValidated const char *  pszUserName,
const char *  pszNetworkID
[virtual]
 

Called when a player's Network ID is validated.

This is fairly useless, as we can't match the username to an edict.

Parameters:
pszUserName String containing client username
pszNetworkID String containing client SteamID
Returns:
Whether to supercede the GameDLL or not

Definition at line 324 of file CountryFilter.cpp.

void CountryFilter::Pause void   )  [virtual]
 

We pause operations here.

Definition at line 329 of file CountryFilter.cpp.

References m_Paused.

bool CountryFilter::printCountryStatus edict_t *  pEntity,
bool  isChat
[private]
 

Definition at line 576 of file CountryFilter.cpp.

References clientSendChatMessage(), COUNTRYFILTER_TMP_BUFFER_LENGTH, getPlayerCountryId(), getPlayerEdictByIndex(), getPlayerInfoByEdict(), idToCountry(), isBOTSteamId(), isValidSteamId(), m_ClientMax, and m_IVEngine.

Referenced by handlePlayerSayEvent(), and handleStatusCommand().

void CountryFilter::ServerActivate edict_t *  pEdictList,
int  edictCount,
int  clientMax
[virtual]
 

Called when the server activates.

Parameters:
pEdictList Pointer to the edict_t linked list
edictCount The initial number of edicts
clientMax The max players the server can hold

Definition at line 334 of file CountryFilter.cpp.

References initPlayerCountryIdList(), initPlayerOriginalNameList(), and m_ClientMax.

void CountryFilter::SetCommandClient int  index  )  [virtual]
 

Sets the last player who used a command.

Parameters:
index Client index

Definition at line 341 of file CountryFilter.cpp.

References m_ClCommandIndex.

bool CountryFilter::setPlayerCountryId int  playerIndex,
int  countryId
[private]
 

Definition at line 537 of file CountryFilter.cpp.

References m_playerCountryIdList.

Referenced by ClientConnect(), ClientDisconnect(), and initPlayerCountryIdList().

bool CountryFilter::setPlayerOriginalName int  playerIndex,
const char *  name
[private]
 

Definition at line 547 of file CountryFilter.cpp.

References m_playerOriginalNameList.

Referenced by ClientConnect(), ClientDisconnect(), FireGameEvent(), and initPlayerOriginalNameList().

bool CountryFilter::substring const char *  src,
size_t  begin,
size_t  end,
char *  dst
[static, private]
 

Definition at line 726 of file CountryFilter.cpp.

Referenced by ClientConnect().

bool CountryFilter::testGeoIP edict_t *  pEntity  )  [private]
 

Definition at line 647 of file CountryFilter.cpp.

References COUNTRYFILTER_TMP_BUFFER_LENGTH, GeoIPWrapper::getIdByAddr(), GeoIPWrapper::idToCountryCode(), m_giw, and m_IVEngine.

Referenced by handleTestGeoIPCommand(), and LevelInit().

void CountryFilter::Unload void   )  [virtual]
 

Called on unload.

Definition at line 131 of file CountryFilter.cpp.

References m_GameEventManager, m_giw, m_Loaded, and m_pConVarAccessor.

void CountryFilter::UnPause void   )  [virtual]
 

Unpause operations here.

Definition at line 346 of file CountryFilter.cpp.

References m_Paused.


Member Data Documentation

int CountryFilter::m_ClCommandIndex
 

Last client index.

Definition at line 211 of file CountryFilter.h.

Referenced by SetCommandClient().

int CountryFilter::m_ClientMax [private]
 

Max clients.

Definition at line 249 of file CountryFilter.h.

Referenced by clientSendAllChatMessage(), getPlayerCount(), getPlayerEdictByIndex(), getPlayerEdictByUserID(), getPlayerInfoByUserID(), printCountryStatus(), and ServerActivate().

ICvar* CountryFilter::m_CvarFactory [private]
 

Cvar manager.

Definition at line 218 of file CountryFilter.h.

Referenced by Load(), and CountryFilter::CPluginConVarAccessor::RegisterConCommandBase().

IGameEventManager* CountryFilter::m_GameEventManager [private]
 

game events interface

Definition at line 236 of file CountryFilter.h.

Referenced by LevelInit(), LevelShutdown(), Load(), and Unload().

GeoIPWrapper* CountryFilter::m_giw [private]
 

Definition at line 251 of file CountryFilter.h.

Referenced by ClientConnect(), handleCountryByAddrCommand(), Load(), testGeoIP(), and Unload().

IServerPluginHelpers* CountryFilter::m_Helpers [private]
 

plugin helpers

Definition at line 239 of file CountryFilter.h.

Referenced by Load().

IEffects* CountryFilter::m_IEffects [private]
 

IEffects interface.

Definition at line 230 of file CountryFilter.h.

Referenced by Load().

IEngineSound* CountryFilter::m_IEngineSound [private]
 

IEngineSound interface.

Definition at line 233 of file CountryFilter.h.

Referenced by Load().

bool CountryFilter::m_Initialized [private]
 

Are we initialized?

Definition at line 246 of file CountryFilter.h.

Referenced by CountryFilter(), GameFrame(), LevelInit(), LevelShutdown(), and ~CountryFilter().

IVEngineServer* CountryFilter::m_IVEngine [private]
 

Our copy of the engine server.

Definition at line 227 of file CountryFilter.h.

Referenced by ClientCommand(), ClientConnect(), ClientDisconnect(), clientSendChatMessage(), FireGameEvent(), getPlayerEdictByIndex(), handleCountryByAddrCommand(), Load(), printCountryStatus(), and testGeoIP().

bool CountryFilter::m_Loaded [private]
 

Have we loaded already?

Definition at line 221 of file CountryFilter.h.

Referenced by CountryFilter(), Load(), Unload(), and ~CountryFilter().

bool CountryFilter::m_Paused [private]
 

Are we paused?

Definition at line 243 of file CountryFilter.h.

Referenced by CountryFilter(), GameFrame(), Pause(), UnPause(), and ~CountryFilter().

CPluginConVarAccessor* CountryFilter::m_pConVarAccessor [private]
 

Our copy of the cvar manager.

Definition at line 224 of file CountryFilter.h.

Referenced by Load(), and Unload().

CUtlVector<int> CountryFilter::m_playerCountryIdList [private]
 

Definition at line 253 of file CountryFilter.h.

Referenced by getPlayerCountryId(), initPlayerCountryIdList(), and setPlayerCountryId().

IPlayerInfoManager* CountryFilter::m_PlayerInfoManager [private]
 

Player info manager.

Definition at line 215 of file CountryFilter.h.

Referenced by clientSendChatMessage(), getPlayerInfoByEdict(), and Load().

char CountryFilter::m_playerOriginalNameList[64][256] [private]
 

Definition at line 254 of file CountryFilter.h.

Referenced by getPlayerOriginalName(), and setPlayerOriginalName().


The documentation for this class was generated from the following files:
Generated on Tue Jun 28 01:09:12 2005 for CountryFilter by  doxygen 1.4.3-20050623