MemFileFest.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program 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. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // MemFileFest.cpp
  19. // Project: Nostril (aka Postal)
  20. //
  21. // History:
  22. // 09/12/97 JMI Started.
  23. //
  24. // 09/12/97 JMI Added SHAREWARE_RELEASE files.
  25. //
  26. // 09/12/97 JMI Now only the end of the requested resource name has to
  27. // match the full embedded file's name.
  28. //
  29. // 09/17/97 MJR Renamed to the more-correct ONLINE_DEMO_RELEASE.
  30. //
  31. // 06/24/01 MJR Got rid of alternate CompUSA level.
  32. //
  33. //////////////////////////////////////////////////////////////////////////////
  34. //
  35. // Manages a group of memory resources that represent disk files. Currently
  36. // used for .RLM files to limit the usefulness of crippleware demos.
  37. //
  38. //////////////////////////////////////////////////////////////////////////////
  39. #include "RSPiX.h"
  40. #include "CompileOptions.h"
  41. #include "MemFileFest.h"
  42. //////////////////////////////////////////////////////////////////////////////
  43. // Macros.
  44. //////////////////////////////////////////////////////////////////////////////
  45. #define NUM_ELEMENTS(a) (sizeof(a) / sizeof(a[0]) )
  46. //////////////////////////////////////////////////////////////////////////////
  47. // Typedefs.
  48. //////////////////////////////////////////////////////////////////////////////
  49. //////////////////////////////////////////////////////////////////////////////
  50. // Variables.
  51. //////////////////////////////////////////////////////////////////////////////
  52. // Only compile this hefty chunk of shit if we're only allowing specific realm
  53. #if defined(ENABLE_PLAY_SPECIFIC_REALMS_ONLY)
  54. #include "GConsite.h"
  55. #include "EConsite.h"
  56. #include "MConsite.h"
  57. #include "HConsite.h"
  58. #include "PConsite.h"
  59. FATEntry ms_memdisk[] =
  60. {
  61. { pszCheckPtGConsite, au8CheckPtGConsite, sizeof(au8CheckPtGConsite), },
  62. { pszEConsite, au8EConsite, sizeof(au8EConsite), },
  63. { pszMConsite, au8MConsite, sizeof(au8MConsite), },
  64. { pszHConsite, au8HConsite, sizeof(au8HConsite), },
  65. { pszPConsite, au8PConsite, sizeof(au8PConsite), },
  66. };
  67. //////////////////////////////////////////////////////////////////////////////
  68. // Functions.
  69. //////////////////////////////////////////////////////////////////////////////
  70. //////////////////////////////////////////////////////////////////////////////
  71. // Given a filename, open an RFile to the corresponding resource data.
  72. //////////////////////////////////////////////////////////////////////////////
  73. extern short GetMemFileResource( // Returns 0 on successful open.
  74. const char* pszResName, // In: Res filename.
  75. RFile::Endian endian, // In: Endian nature for RFile.
  76. RFile* pfile) // In: File to open with.
  77. {
  78. short sRes = 1; // Assume failure for simplicity.
  79. ASSERT(pfile);
  80. ASSERT(pszResName);
  81. short sIndex;
  82. bool bFound;
  83. long lReqResNameLen = strlen(pszResName);
  84. for (sIndex = 0, bFound = false; sIndex < NUM_ELEMENTS(ms_memdisk) && bFound == false; sIndex++)
  85. {
  86. long lEmbeddedResNameLen = strlen(ms_memdisk[sIndex].pszResName);
  87. // If the requested name is long enough . . .
  88. if (lReqResNameLen >= lEmbeddedResNameLen)
  89. {
  90. // If this is the specified res name (the specified name only has to
  91. // match from the end back lEmbeddedResNameLen characters) . . .
  92. if (rspStricmp(pszResName + lReqResNameLen - lEmbeddedResNameLen, ms_memdisk[sIndex].pszResName) == 0)
  93. {
  94. // Found it.
  95. bFound = true;
  96. // Open the resource data . . .
  97. sRes = pfile->Open(ms_memdisk[sIndex].pau8Res, ms_memdisk[sIndex].lResSize, endian);
  98. }
  99. }
  100. }
  101. return sRes;
  102. }
  103. #endif // ENABLE_PLAY_SPECIFIC_REALMS_ONLY
  104. //////////////////////////////////////////////////////////////////////////////
  105. // EOF
  106. //////////////////////////////////////////////////////////////////////////////