00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #if !defined(AFX_CMAGICMODELS_H__F2C9124C_F6F0_4FCD_B4FC_1C85BE6113E1__INCLUDED_)
00020 #define AFX_CMAGICMODELS_H__F2C9124C_F6F0_4FCD_B4FC_1C85BE6113E1__INCLUDED_
00021
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025 #include <winsock2.h>
00026 #include "shared.h"
00027 #define MAGIC_MODEL_TABLE_SIZE 1000
00028
00029 class cMagicModels
00030 {
00031 friend class cMasterServer;
00032
00033 public:
00034 cMagicModels( DWORD dwSpellID, BOOL fAddToHash = TRUE )
00035 : m_dwSpellID( dwSpellID ),
00036 m_pcPrev ( NULL ),
00037 m_pcNext ( NULL )
00038 {
00039 m_dwModelNumber = 0x0L;
00040 m_dwFlags1 = 0x0000FB85;
00041 m_wParticle = 0x0000;
00042 m_wSoundSet = 0x0000;
00043 m_flScale = 1.0f;
00044 m_wModel = 0x0000;
00045 m_wIcon = 0x0000;
00046 m_wAssociatedSpell = 0x0000;
00047
00048 if( fAddToHash )
00049 Hash_Add( this );
00050 }
00051
00052 virtual ~cMagicModels()
00053 {
00054 if ( m_pcPrev ) m_pcPrev->m_pcNext = m_pcNext;
00055 else m_lpcHashTable[m_dwSpellID] = m_pcNext;
00056 if ( m_pcNext ) m_pcNext->m_pcPrev = m_pcPrev;
00057 }
00058
00059 static inline void Hash_Load( )
00060 {
00061 ZeroMemory( m_lpcHashTable, sizeof( m_lpcHashTable ) );
00062 }
00063
00064 static inline cMagicModels *Hash_New( DWORD& dwSpellID )
00065 {
00066 cMagicModels *pcModel = Hash_Find( dwSpellID );
00067 if ( pcModel )
00068 return pcModel;
00069
00070 return new cMagicModels( dwSpellID ) ;
00071 }
00072
00073 static void Hash_Erase ( );
00074 static void Hash_Remove ( cMagicModels *pcModel );
00075 static cMagicModels *FindModel ( DWORD dwSpellID );
00076
00077
00078 std::string m_strName;
00079 DWORD m_dwSpellID;
00080 DWORD m_dwModelNumber;
00081 WORD m_wPortalMode;
00082 WORD m_wUnknown_1;
00083 WORD m_wModel;
00084 WORD m_wIcon;
00085 WORD m_wParticle;
00086 WORD m_wSoundSet;
00087 DWORD m_dwFlags1;
00088 float m_flScale;
00089 DWORD m_dwMedGrey;
00090 DWORD m_dwBlueGrey;
00091 WORD m_wAssociatedSpell;
00092
00093 cMagicModels *m_pcNext;
00094 cMagicModels *m_pcPrev;
00095 std::list< cMagicModels * > m_lstModels;
00096
00097 private:
00098 static cMagicModels *m_lpcHashTable[MAGIC_MODEL_TABLE_SIZE];
00099
00100 static inline Hash_Add( cMagicModels *pcModels )
00101 {
00102 const DWORD dwSpellID = pcModels->m_dwSpellID;
00103 if ( !m_lpcHashTable[dwSpellID] )
00104 m_lpcHashTable[dwSpellID] = pcModels;
00105 else
00106 {
00107 pcModels->m_pcNext = m_lpcHashTable[dwSpellID];
00108 m_lpcHashTable[dwSpellID]->m_pcPrev = pcModels;
00109 m_lpcHashTable[dwSpellID] = pcModels;
00110 }
00111 }
00112
00113
00114 static inline cMagicModels *Hash_Find( DWORD& dwSpellID )
00115 {
00116 const DWORD dwModel = dwSpellID;
00117 cMagicModels *pcModels = m_lpcHashTable[dwModel];
00118 while ( pcModels )
00119 {
00120 if ( pcModels->CompareModel( dwSpellID ) ) return pcModels;
00121 else
00122 pcModels = pcModels->m_pcNext;
00123 }
00124 return NULL;
00125 }
00126
00127 inline BOOL CompareModel( DWORD& dwSpellID )
00128 {
00129 if ( dwSpellID == m_dwSpellID )
00130 return true;
00131 else
00132 return false;
00133 }
00134 };
00135
00136 #endif // !defined(AFX_CMAGICMODELS_H__F2C9124C_F6F0_4FCD_B4FC_1C85BE6113E1__INCLUDED_)