LODDefs.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. ** Command & Conquer Renegade(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. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : W3DView *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/W3DView/LODDefs.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 3/03/99 7:26p $*
  29. * *
  30. * $Revision:: 2 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef __LODDEFS_H
  36. #define __LODDEFS_H
  37. ////////////////////////////////////////////////////////////////////////////
  38. //
  39. // Data types
  40. //
  41. typedef enum
  42. {
  43. TYPE_COMMANDO = 0,
  44. TYPE_G,
  45. TYPE_COUNT
  46. } LOD_NAMING_TYPE;
  47. ////////////////////////////////////////////////////////////////////////////
  48. //
  49. // Inline functions
  50. //
  51. __inline bool Is_LOD_Name_Valid (LPCTSTR name, LOD_NAMING_TYPE &type)
  52. {
  53. bool retval = false;
  54. // Does this name fit with the format expected?
  55. LPCTSTR last_2_chars = name + (::lstrlen (name)-2);
  56. if (((last_2_chars[0] == 'L') || (last_2_chars[0] == 'l')) &&
  57. ((last_2_chars[1] >= '0') && (last_2_chars[1] <= '9'))) {
  58. type = TYPE_COMMANDO;
  59. retval = true;
  60. } else if ((last_2_chars[1] >= 'a' && last_2_chars[1] <= 'z') ||
  61. (last_2_chars[1] >= 'A' && last_2_chars[1] <= 'Z')) {
  62. type = TYPE_G;
  63. retval = true;
  64. }
  65. return retval;
  66. }
  67. __inline bool Is_Model_Part_of_LOD (LPCTSTR name, LPCTSTR base, LOD_NAMING_TYPE &type)
  68. {
  69. // Assume failure
  70. bool retval = false;
  71. // Does the name start with the base?
  72. if (::strstr (name, base) == name) {
  73. // Get the remaining characters in the name (after the base)
  74. LPCTSTR extension = name + ::lstrlen (base);
  75. // What naming convention are we using?
  76. if (type == TYPE_COMMANDO) {
  77. if (((extension[0] == 'L') || (extension[0] == 'l')) &&
  78. ((extension[1] >= '0') && (extension[1] <= '9'))) {
  79. retval = (extension[2] == 0);
  80. }
  81. } else if (type == TYPE_G) {
  82. if ((extension[0] >= 'a' && extension[0] <= 'z') ||
  83. (extension[0] >= 'A' && extension[0] <= 'Z')) {
  84. retval = (extension[1] == 0);
  85. }
  86. }
  87. }
  88. // Return the true/false result ccde
  89. return retval;
  90. }
  91. #endif //__LODDEFS_H