vfxshape.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //---------------------------------------------------------------------------
  2. //
  3. // vfxshape.cpp - This file contains the header for the new shape engine
  4. //
  5. //---------------------------------------------------------------------------//
  6. // Copyright (C) Microsoft Corporation. All rights reserved. //
  7. //===========================================================================//
  8. //---------------------------------------------------------------------------
  9. // Include files
  10. #ifndef MCLIB_H
  11. #include "mclib.h"
  12. #endif
  13. #ifndef VFXSHAPE_H
  14. #include "vfxshape.h"
  15. #endif
  16. #ifndef SPRTMGR_H
  17. #include "sprtmgr.h"
  18. #endif
  19. #ifndef APPRTYPE_H
  20. #include "apprtype.h"
  21. #endif
  22. //---------------------------------------------------------------------------
  23. // Statics
  24. #define HEADER_OFFSET 8
  25. //****************************************************************************
  26. //
  27. // class Shape member functions
  28. //
  29. //****************************************************************************
  30. void Shape::destroy (void)
  31. {
  32. //----------------------------------------------------------------
  33. //-- First, tell our owner that we've gone away.
  34. //-- Owner simply NULLs the corresponding entry in its shapeList.
  35. if (owner)
  36. {
  37. owner->removeShape(this);
  38. }
  39. //----------------------------------------------------
  40. // The header points to the start of the memory block
  41. // all other pointer are internal to that block and do
  42. // NOT need to be deleted. Please don't delete them
  43. // or the heap will fatal out!
  44. if (stupidHeader)
  45. spriteManager->freeShapeRAM(stupidHeader);
  46. else
  47. spriteManager->freeShapeRAM(frameList);
  48. frameList = NULL;
  49. }
  50. #define STUPID_OFFSET 6
  51. //----------------------------------------------------------------------------
  52. long Shape::init (MemoryPtr fileBlock, AppearanceTypePtr myOwner, long shapeSize)
  53. {
  54. //-----------------------------------------------------------------
  55. // Everything in the below comment is a LIE!!!
  56. //
  57. // The entire shape is now stored in a NewShape FSY shape file.
  58. // The entire shape file is loaded as the .FSY file and all info
  59. // is stored in the file format itself. This solves all of the
  60. // crazy malloc issues previously associated with the sprites.
  61. //
  62. // Truth begins here.
  63. // This is simply the data holder for ALL shape types in the game EXCEPT mechs.
  64. if ((*(int*)fileBlock!=*(int*)"1.10"))
  65. {
  66. stupidHeader = fileBlock;
  67. frameList = fileBlock + STUPID_OFFSET; //You can talk to GDoren about this one!!!
  68. }
  69. else
  70. {
  71. stupidHeader = NULL;
  72. frameList = fileBlock;
  73. }
  74. long numFrames = VFX_shape_count(frameList);
  75. if (!numFrames)
  76. {
  77. return(-1); //There are no frames, this shape is NULL!!
  78. }
  79. owner = myOwner;
  80. if (numFrames)
  81. {
  82. long *testOffset = (long *)(frameList + 8);
  83. if (*testOffset >= shapeSize)
  84. {
  85. frameList = NULL;
  86. return(-3);
  87. }
  88. long minOffset = 8 + (numFrames * 8); //The first shape MUST be this far in or WRONG
  89. if (minOffset != *testOffset)
  90. {
  91. frameList = NULL;
  92. return(-4);
  93. }
  94. }
  95. return(NO_ERR);
  96. }
  97. //----------------------------------------------------------------------------