w3dexclusionlist.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: /Commando/Code/ww3d2/w3dexclusionlist.cpp 1 12/12/02 3:36p Greg_h $ */
  19. /***********************************************************************************************
  20. *** Confidential - Westwood Studios ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Commando / G 3D Library *
  24. * *
  25. * $Archive:: /Commando/Code/ww3d2/w3dexclusionlist.cpp $*
  26. * *
  27. * Author:: Greg_h *
  28. * *
  29. * $Modtime:: 12/12/02 10:04a $*
  30. * *
  31. * $Revision:: 1 $*
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #include "w3dexclusionlist.h"
  37. #include "proto.h"
  38. #include "htree.h"
  39. #include "hanim.h"
  40. W3DExclusionListClass::W3DExclusionListClass(const DynamicVectorClass<StringClass> & names) :
  41. Names(names)
  42. {
  43. for (int i=0; i<Names.Count(); i++) {
  44. NameHash.Insert(Names[i],i);
  45. }
  46. }
  47. W3DExclusionListClass::~W3DExclusionListClass(void)
  48. {
  49. NameHash.Remove_All();
  50. }
  51. bool W3DExclusionListClass::Is_Excluded(PrototypeClass * proto) const
  52. {
  53. StringClass copy = proto->Get_Name();
  54. char * root_name = copy.Peek_Buffer();
  55. // don't preserve munged prototypes
  56. if (strchr(root_name,'#') != NULL) {
  57. return false;
  58. }
  59. // chop off the sub-object name if present (
  60. char * tmp = strchr(root_name,'.');
  61. if (tmp != NULL) {
  62. *tmp = 0;
  63. }
  64. return Is_Excluded(root_name);
  65. }
  66. bool W3DExclusionListClass::Is_Excluded(HTreeClass * htree) const
  67. {
  68. // plain old name...
  69. return Is_Excluded(htree->Get_Name());
  70. }
  71. bool W3DExclusionListClass::Is_Excluded(HAnimClass * hanim) const
  72. {
  73. // For HAnims, the name to check is the one trailing the '.'
  74. StringClass copy = hanim->Get_Name();
  75. char * root_name = copy.Peek_Buffer();
  76. char * tmp = strchr(root_name,'.');
  77. if (tmp) {
  78. return Is_Excluded(tmp + 1);
  79. } else {
  80. return false; // should never happen...
  81. }
  82. }
  83. bool W3DExclusionListClass::Is_Excluded(const char * root_name) const
  84. {
  85. return NameHash.Exists(StringClass(root_name));
  86. }