123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- /*
- * This file is part of UAS2.
- *
- * UAS2 is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * UAS2 is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with UASv1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
- /**
- * @file cClient.cpp
- * Implements functionality for the cClient class.
- */
-
- #include "Client.h"
- #include "WorldManager.h"
-
- cClient *cClient::m_lpcHashTable[1020];
-
- /**
- * Erases all clients from the client hash list.
- */
- void cClient::Hash_Erase( )
- {
- cClient *pcClient, *pcPrevClient;
- for ( int i = 0; i < 1020; ++i )
- {
- pcClient = m_lpcHashTable[i];
- while ( pcClient )
- {
- pcPrevClient = pcClient;
- pcClient = pcClient->m_pcNext;
-
- Hash_Remove( pcPrevClient );
- }
- }
- }
-
- /**
- * Removes a client from the client hash list.
- *
- * This function is called when a client disconnects from the server.
- *
- * @param *pcClient - A pointer to the client to be removed.
- */
- void cClient::Hash_Remove( cClient *pcClient )
- {
- if ( pcClient->m_pcAvatar )
- {
- pcClient->m_pcAvatar->SaveToDB();
- cWorldManager::RemoveClient( pcClient );
- }
-
- SAFEDELETE( pcClient )
- }
-
- /**
- * Finds a client.
- *
- * This function is called when a particular client needs to be found.
- * The search is performed by searching for the client's avatar's GUID.
- *
- * @param dwGUID - The client's avatar's GUID.
- *
- * @return *cClient - A pointer to the client.
- */
- cClient *cClient::FindClient( DWORD dwGUID )
- {
- cClient *pcClient;
- for ( int i = 0; i < 1020; ++i )
- {
- pcClient = m_lpcHashTable[i];
- while ( pcClient )
- {
- if ( pcClient->m_pcAvatar )
- {
- if ( dwGUID == pcClient->m_pcAvatar->GetGUID( ) )
- return pcClient;
- }
- pcClient = pcClient->m_pcNext;
- }
- }
- return NULL;
- }
-
- /**
- * Finds a client.
- *
- * This function is called when a particular client needs to be found.
- * The search is performed by searching for the client's avatar's name.
- *
- * @param szName - The client's avatar's name.
- *
- * @return *cClient - A pointer to the client.
- */
- cClient *cClient::FindClient( char *szName )
- {
- cClient *pcClient;
- for ( int i = 0; i < 1020; ++i )
- {
- pcClient = m_lpcHashTable[i];
- while ( pcClient )
- {
- if ( pcClient->m_pcAvatar )
- {
- if ( !lstrcmpi( szName, pcClient->m_pcAvatar->TokenlessName( ) ) )
- return pcClient;
- }
- pcClient = pcClient->m_pcNext;
- }
- }
- return NULL;
- }
-
- /**
- * Finds an avatar.
- *
- * This function is called when a particular avatar needs to be found.
- * The search is performed by searching for the client's avatar's GUID.
- *
- * @param dwGUID - The client's avatar's GUID.
- *
- * @return *cAvatar - A pointer to the avatar.
- */
- cAvatar *cClient::FindAvatar( DWORD dwGUID )
- {
- cClient *pcClient;
- for ( int i = 0; i < 1020; ++i )
- {
- pcClient = m_lpcHashTable[i];
- while ( pcClient )
- {
- if ( pcClient->m_pcAvatar )
- {
- if ( dwGUID == pcClient->m_pcAvatar->GetGUID( ) )
- return pcClient->m_pcAvatar;
- }
- pcClient = pcClient->m_pcNext;
- }
- }
- return NULL;
- }
-
- /**
- * Finds an avatar.
- *
- * This function is called when a particular avatar needs to be found.
- * The search is performed by searching for the client's avatar's name.
- *
- * @param szName - The client's avatar's name.
- *
- * @return *cAvatar - A pointer to the avatar.
- */
- cAvatar *cClient::FindAvatar( char *szName )
- {
- cClient *pcClient;
- for ( int i = 0; i < 1020; ++i )
- {
- pcClient = m_lpcHashTable[i];
- while ( pcClient )
- {
- if ( pcClient->m_pcAvatar )
- {
- if ( !lstrcmpi( szName, pcClient->m_pcAvatar->TokenlessName( ) ) )
- return pcClient->m_pcAvatar;
- }
- pcClient = pcClient->m_pcNext;
- }
- }
- return NULL;
- }
|