scexplosionevent.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/scexplosionevent.cpp $*
  25. * *
  26. * $Author:: Byon_g $*
  27. * *
  28. * $Modtime:: 1/09/02 3:13p $*
  29. * *
  30. * $Revision:: 5 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "scexplosionevent.h"
  36. #include <stdio.h>
  37. #include <stdlib.h>
  38. #include "networkobjectfactory.h"
  39. #include "wwaudio.h"
  40. #include "matrix3d.h"
  41. #include "translatedb.h"
  42. #include "string_ids.h"
  43. #include "apppackettypes.h"
  44. #include "bitpackids.h"
  45. #include "explosion.h"
  46. #include "combat.h"
  47. DECLARE_NETWORKOBJECT_FACTORY(cScExplosionEvent, NETCLASSID_SCEXPLOSIONEVENT);
  48. //-----------------------------------------------------------------------------
  49. cScExplosionEvent::cScExplosionEvent(void)
  50. {
  51. DefID = 0;
  52. Position.Set(Vector3(0, 0, 0));
  53. OwnerID = 0;
  54. Set_App_Packet_Type(APPPACKETTYPE_SCEXPLOSIONEVENT);
  55. }
  56. //-----------------------------------------------------------------------------
  57. void
  58. cScExplosionEvent::Init(int def_id, const Vector3 & position, int owner_id, int victim_id )
  59. {
  60. WWASSERT(CombatManager::I_Am_Server());
  61. DefID = def_id;
  62. Position = position;
  63. OwnerID = owner_id;
  64. VictimID = victim_id;
  65. //
  66. // This skips the local client
  67. //
  68. Set_Object_Dirty_Bit(BIT_CREATION, true);
  69. // if (CombatManager::I_Am_Client())
  70. {
  71. Act();
  72. }
  73. }
  74. //-----------------------------------------------------------------------------
  75. void
  76. cScExplosionEvent::Act(void)
  77. {
  78. // WWASSERT(CombatManager::I_Am_Client());
  79. ExplosionManager::Explode( DefID, Position, OwnerID, VictimID );
  80. WWDEBUG_SAY(("cScExplosionEvent::Act: Def %d, at (%5.2f, %5.2f, %5.2f) Owner %d Victim %d\n",
  81. DefID, Position.X, Position.Y, Position.Z, OwnerID, VictimID ));
  82. Set_Delete_Pending();
  83. }
  84. //-----------------------------------------------------------------------------
  85. void
  86. cScExplosionEvent::Export_Creation(BitStreamClass & packet)
  87. {
  88. WWASSERT(CombatManager::I_Am_Server());
  89. NetworkObjectClass::Export_Creation(packet);
  90. packet.Add(DefID);
  91. packet.Add(Position.X, BITPACK_WORLD_POSITION_X);
  92. packet.Add(Position.Y, BITPACK_WORLD_POSITION_Y);
  93. packet.Add(Position.Z, BITPACK_WORLD_POSITION_Z);
  94. packet.Add(OwnerID);
  95. Set_Delete_Pending();
  96. }
  97. //-----------------------------------------------------------------------------
  98. void
  99. cScExplosionEvent::Import_Creation(BitStreamClass & packet)
  100. {
  101. WWASSERT(CombatManager::I_Am_Only_Client());
  102. NetworkObjectClass::Import_Creation(packet);
  103. packet.Get(DefID);
  104. packet.Get(Position.X, BITPACK_WORLD_POSITION_X);
  105. packet.Get(Position.Y, BITPACK_WORLD_POSITION_Y);
  106. packet.Get(Position.Z, BITPACK_WORLD_POSITION_Z);
  107. packet.Get(OwnerID);
  108. Act();
  109. }