- Main Page
- Classes
- Files

- File List
- File Members

# E:/uas2/Server/cNPCModels.h

Go to the documentation of this file.

    00001 /*
    00002 * This file is part of UAS2.
    00003 *
    00004 * UAS2 is free software; you can redistribute it and/or modify
    00005 * it under the terms of the GNU General Public License as published by
    00006 * the Free Software Foundation; either version 2 of the License, or
    00007 * (at your option) any later version.
    00008 *
    00009 * UAS2 is distributed in the hope that it will be useful,
    00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012 * GNU General Public License for more details.
    00013
    00014 * You should have received a copy of the GNU General Public License
    00015 * along with UASv1; if not, write to the Free Software
    00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00017 */
    00018
    00025 #ifndef CNPCMODELS_H__
    00026 #define CNPCMODELS_H__
    00027
    00028 #include "shared.h"
    00029
    00030 #define NPC_MODEL_TABLE_SIZE 2000
    00031
    00032 class cNPCModels
    00033 {
    00034         friend class cMasterServer;
    00035 public:
    00036         cNPCModels( DWORD dwModelID, BOOL fAddToHash = TRUE )
    00037                         :       m_dwModelID( dwModelID ),
    00038                                 m_pcPrev                ( NULL ),
    00039                                 m_pcNext                ( NULL )
    00040         {
    00041                 if( fAddToHash )
    00042                 Hash_Add( this );
    00043         }
    00044         virtual ~cNPCModels()
    00045         {
    00046                 if ( m_pcPrev ) m_pcPrev->m_pcNext = m_pcNext;
    00047                 else                    m_lpcHashTable[m_dwModelID] = m_pcNext;
    00048                 if ( m_pcNext ) m_pcNext->m_pcPrev = m_pcPrev;
    00049         }
    00050
    00051         static inline void Hash_Load( )
    00052         {
    00053                 ZeroMemory( m_lpcHashTable, sizeof( m_lpcHashTable ) );
    00054         }
    00055
    00056         static inline cNPCModels *Hash_New( DWORD& dwModelID )
    00057         {
    00058                 cNPCModels *pcModel = Hash_Find( dwModelID );
    00059                 if ( pcModel )
    00060                         return pcModel;
    00061
    00062                 return new cNPCModels( dwModelID ) ;
    00063         }
    00064
    00065         static void             Hash_Erase      ( );
    00066         static void             Hash_Remove     ( cNPCModels *pcModel );
    00067         static cNPCModels       *FindModel      ( DWORD dwModelID );
    00068
    00069
    00070         std::string             m_strName;
    00071         std::string             m_strDescription;
    00072
    00073         WORD                    m_wPaletteCode;
    00074
    00075         DWORD                   m_dwModelID;
    00076
    00077         float                   m_flScale;
    00078
    00079         // Model Vectors
    00080         BYTE                    m_bPaletteChange;
    00081         DWORD                   m_wPaletteVector;
    00082         sPaletteChange  m_vectorPal[255];
    00083
    00084         BYTE                    m_bTextureChange;
    00085         DWORD                   m_wTextureVector;
    00086         sTextureChange  m_vectorTex[255];
    00087
    00088         BYTE                    m_bModelChange;
    00089         DWORD                   m_wModelVector;
    00090         sModelChange    m_vectorMod[255];
    00091
    00092         WORD                    m_wModel;
    00093         WORD                    m_wIcon;
    00094         DWORD                   m_dwModelNumber;
    00095
    00096         cAnimates               m_cAnimations;
    00097
    00098         cNPCModels                      *m_pcNext;
    00099         cNPCModels                      *m_pcPrev;
    00100         std::list< cNPCModels * >       m_lstNPCModels;
    00101
    00102 private:
    00103         static cNPCModels *m_lpcHashTable[NPC_MODEL_TABLE_SIZE];
    00104
    00105         static inline Hash_Add( cNPCModels *pcModels )
    00106         {
    00107                 const DWORD dwModelID = pcModels->m_dwModelID;
    00108                 if ( !m_lpcHashTable[dwModelID] )
    00109                         m_lpcHashTable[dwModelID] = pcModels;
    00110                 else
    00111                 {
    00112                         pcModels->m_pcNext      =       m_lpcHashTable[dwModelID];
    00113                         m_lpcHashTable[dwModelID]->m_pcPrev     = pcModels;
    00114                         m_lpcHashTable[dwModelID]                       = pcModels;
    00115                 }
    00116         }
    00117
    00118         static inline cNPCModels *Hash_Find( DWORD& dwModelID )
    00119         {
    00120                 const DWORD dwModel = dwModelID;
    00121                 cNPCModels *pcModels = m_lpcHashTable[dwModel];
    00122                 while ( pcModels )
    00123                 {
    00124                         if ( pcModels->CompareModel( dwModelID ) )      return pcModels;
    00125                         else
    00126                                 pcModels = pcModels->m_pcNext;
    00127                 }
    00128                 return NULL;
    00129         }
    00130
    00131         inline BOOL CompareModel( DWORD& dwModelID )
    00132         {
    00133                 if ( dwModelID == m_dwModelID )
    00134                         return true;
    00135                 else
    00136                         return false;
    00137         }
    00138 };
    00139
    00140 #endif