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

cModels.cpp 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 cModels.cpp
  19. * Implements the cModels class.
  20. *
  21. * Author: G70mb2
  22. */
  23. #include "cModels.h"
  24. #ifdef _DEBUG
  25. #undef THIS_FILE
  26. static char THIS_FILE[]=__FILE__;
  27. #define new DEBUG_NEW
  28. #endif
  29. #define MONSTER_MODEL_TABLE_SIZE 3000
  30. cModels *cModels::m_lpcHashTable[MONSTER_MODEL_TABLE_SIZE];
  31. /**
  32. * Erases all models from the model hash list.
  33. */
  34. void cModels::Hash_Erase()
  35. {
  36. cModels *pcModels, *pcPrevModel;
  37. for ( int i = 0; i < MONSTER_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 model from the model hash list.
  50. *
  51. *
  52. * @param *pcModel - A pointer to the model to be removed.
  53. */
  54. void cModels::Hash_Remove( cModels *pcModel )
  55. {
  56. SAFEDELETE( pcModel )
  57. }
  58. /**
  59. * Finds a model.
  60. *
  61. * This function is called when a particular model needs to be found.
  62. * The search is performed by searching for the model's model ID.
  63. *
  64. * @param dwModelID - The model's model ID.
  65. *
  66. * @return *cModels - A pointer to the model.
  67. */
  68. cModels *cModels::FindModel( DWORD dwModelID )
  69. {
  70. cModels *pcModel;
  71. for ( int i = 0; i < MONSTER_MODEL_TABLE_SIZE; ++i )
  72. {
  73. pcModel = m_lpcHashTable[i];
  74. while ( pcModel )
  75. {
  76. if ( pcModel->m_dwModelID )
  77. {
  78. if ( dwModelID == pcModel->m_dwModelID )
  79. return pcModel;
  80. }
  81. pcModel = pcModel->m_pcNext;
  82. }
  83. }
  84. return NULL;
  85. }