Clone of UAS2 @ https://github.com/drudgedance/uas2

cMagicModels.cpp 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * This file is part of UAS2.
  3. *
  4. * UAS2 is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * UAS2 is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. * You should have received a copy of the GNU General Public License
  14. * along with UASv1; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. /**
  18. * @file cMagicModels.cpp
  19. * Implements functionality for the cMagicModels class.
  20. *
  21. * Author: G70mb2
  22. */
  23. #include "cMagicModels.h"
  24. #ifdef _DEBUG
  25. #undef THIS_FILE
  26. static char THIS_FILE[]=__FILE__;
  27. #define new DEBUG_NEW
  28. #endif
  29. #define MAGIC_MODEL_TABLE_SIZE 1000
  30. cMagicModels *cMagicModels::m_lpcHashTable[MAGIC_MODEL_TABLE_SIZE];
  31. /**
  32. * Removes all magic models from the magic model hash list.
  33. */
  34. void cMagicModels::Hash_Erase()
  35. {
  36. cMagicModels *pcModels, *pcPrevModel;
  37. for ( int i = 0; i < MAGIC_MODEL_TABLE_SIZE; ++i )
  38. {
  39. pcModels = m_lpcHashTable[i];
  40. while ( pcModels )
  41. {
  42. pcPrevModel = pcModels;
  43. pcModels = pcModels->m_pcNext;
  44. Hash_Remove( pcPrevModel );
  45. }
  46. }
  47. }
  48. /**
  49. * Removes a magic model from the magic model hash list.
  50. *
  51. * @param *pcModel - A pointer to the magic model to be removed.
  52. */
  53. void cMagicModels::Hash_Remove( cMagicModels *pcModel )
  54. {
  55. SAFEDELETE( pcModel )
  56. }
  57. /**
  58. * Finds a magic model.
  59. *
  60. * This function is called when a particular magic model needs to be found.
  61. * The search is performed by searching for the magic model's spell ID.
  62. *
  63. * @param dwSpellID - The magic model's spell ID.
  64. *
  65. * @return *cMagicModels - A pointer to the magic model.
  66. */
  67. cMagicModels *cMagicModels::FindModel( DWORD dwSpellID )
  68. {
  69. cMagicModels *pcModel;
  70. for ( int i = 0; i < MAGIC_MODEL_TABLE_SIZE; ++i )
  71. {
  72. pcModel = m_lpcHashTable[i];
  73. while ( pcModel )
  74. {
  75. if ( pcModel->m_dwSpellID )
  76. {
  77. if ( dwSpellID == pcModel->m_dwSpellID )
  78. return pcModel;
  79. }
  80. pcModel = pcModel->m_pcNext;
  81. }
  82. }
  83. return NULL;
  84. }