scobeliskevent.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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/scobeliskevent.cpp $*
  25. * *
  26. * $Author:: Tom_s $*
  27. * *
  28. * $Modtime:: 1/04/02 7:23p $*
  29. * *
  30. * $Revision:: 1 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "scobeliskevent.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(cScObeliskEvent, NETCLASSID_SCOBELISKEVENT);
  48. //-----------------------------------------------------------------------------
  49. cScObeliskEvent::cScObeliskEvent(void)
  50. {
  51. DefID = 0;
  52. Position.Set(Vector3(0, 0, 0));
  53. OwnerID = 0;
  54. Set_App_Packet_Type(APPPACKETTYPE_SCOBELISKEVENT);
  55. }
  56. //-----------------------------------------------------------------------------
  57. void
  58. cScObeliskEvent::Init(int def_id, const Vector3 & position, int owner_id )
  59. {
  60. WWASSERT(CombatManager::I_Am_Server());
  61. DefID = def_id;
  62. Position = position;
  63. OwnerID = owner_id;
  64. //
  65. // This skips the local client
  66. //
  67. Set_Object_Dirty_Bit(BIT_CREATION, true);
  68. if (CombatManager::I_Am_Client())
  69. {
  70. Act();
  71. }
  72. }
  73. //-----------------------------------------------------------------------------
  74. void
  75. cScObeliskEvent::Act(void)
  76. {
  77. WWASSERT(CombatManager::I_Am_Client());
  78. ExplosionManager::Explode( DefID, Position, OwnerID );
  79. WWDEBUG_SAY(("cScObeliskEvent::Act: Def %d, at (%5.2f, %5.2f, %5.2f) Owner %d\n",
  80. DefID, Position.X, Position.Y, Position.Z, OwnerID ));
  81. Set_Delete_Pending();
  82. }
  83. //-----------------------------------------------------------------------------
  84. void
  85. cScObeliskEvent::Export_Creation(BitStreamClass & packet)
  86. {
  87. WWASSERT(CombatManager::I_Am_Server());
  88. NetworkObjectClass::Export_Creation(packet);
  89. packet.Add(DefID);
  90. packet.Add(Position.X, BITPACK_WORLD_POSITION_X);
  91. packet.Add(Position.Y, BITPACK_WORLD_POSITION_Y);
  92. packet.Add(Position.Z, BITPACK_WORLD_POSITION_Z);
  93. packet.Add(OwnerID);
  94. Set_Delete_Pending();
  95. }
  96. //-----------------------------------------------------------------------------
  97. void
  98. cScObeliskEvent::Import_Creation(BitStreamClass & packet)
  99. {
  100. WWASSERT(CombatManager::I_Am_Only_Client());
  101. NetworkObjectClass::Import_Creation(packet);
  102. packet.Get(DefID);
  103. packet.Get(Position.X, BITPACK_WORLD_POSITION_X);
  104. packet.Get(Position.Y, BITPACK_WORLD_POSITION_Y);
  105. packet.Get(Position.Z, BITPACK_WORLD_POSITION_Z);
  106. packet.Get(OwnerID);
  107. Act();
  108. }