physcontrol.cpp 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 : WWPhys *
  23. * *
  24. * $Archive:: /Commando/Code/wwphys/physcontrol.cpp $*
  25. * *
  26. * Author:: Greg Hjelstrom *
  27. * *
  28. * $Modtime:: 4/04/00 10:55a $*
  29. * *
  30. * $Revision:: 5 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "physcontrol.h"
  36. #include "chunkio.h"
  37. #include "wwdebug.h"
  38. enum
  39. {
  40. PHYSCONTROLLER_CHUNK_VARIABLES = 0x00000100,
  41. PHYSCONTROLLER_VARIABLE_MOVEVECTOR = 0x00,
  42. PHYSCONTROLLER_VARIABLE_TURNLEFT,
  43. };
  44. bool PhysControllerClass::Save(ChunkSaveClass & csave)
  45. {
  46. csave.Begin_Chunk(PHYSCONTROLLER_CHUNK_VARIABLES);
  47. WRITE_MICRO_CHUNK(csave,PHYSCONTROLLER_VARIABLE_MOVEVECTOR,MoveVector);
  48. WRITE_MICRO_CHUNK(csave,PHYSCONTROLLER_VARIABLE_TURNLEFT,TurnLeft);
  49. csave.End_Chunk();
  50. WWASSERT(WWMath::Is_Valid_Float(MoveVector.X));
  51. WWASSERT(WWMath::Is_Valid_Float(MoveVector.Y));
  52. WWASSERT(WWMath::Is_Valid_Float(MoveVector.Z));
  53. WWASSERT(WWMath::Is_Valid_Float(TurnLeft));
  54. return true;
  55. }
  56. bool PhysControllerClass::Load(ChunkLoadClass & cload)
  57. {
  58. while (cload.Open_Chunk()) {
  59. switch(cload.Cur_Chunk_ID())
  60. {
  61. case PHYSCONTROLLER_CHUNK_VARIABLES:
  62. while (cload.Open_Micro_Chunk()) {
  63. switch(cload.Cur_Micro_Chunk_ID()) {
  64. READ_MICRO_CHUNK(cload,PHYSCONTROLLER_VARIABLE_MOVEVECTOR,MoveVector);
  65. READ_MICRO_CHUNK(cload,PHYSCONTROLLER_VARIABLE_TURNLEFT,TurnLeft);
  66. }
  67. cload.Close_Micro_Chunk();
  68. }
  69. break;
  70. default:
  71. WWDEBUG_SAY(("Unhandled Chunk: 0x%X File: %s Line: %d\r\n",cload.Cur_Chunk_ID(),__FILE__,__LINE__));
  72. break;
  73. }
  74. cload.Close_Chunk();
  75. }
  76. WWASSERT(WWMath::Is_Valid_Float(MoveVector.X));
  77. WWASSERT(WWMath::Is_Valid_Float(MoveVector.Y));
  78. WWASSERT(WWMath::Is_Valid_Float(MoveVector.Z));
  79. WWASSERT(WWMath::Is_Valid_Float(TurnLeft));
  80. return true;
  81. }