Subversion Repositories Games.Descent

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Portions of this file are copyright Rebirth contributors and licensed as
  3.  * described in COPYING.txt.
  4.  * Portions of this file are copyright Parallax Software and licensed
  5.  * according to the Parallax license below.
  6.  * See COPYING.txt for license details.
  7.  
  8. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  9. SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  10. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  11. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  12. IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  13. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  14. FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  15. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  16. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  17. COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  18. */
  19.  
  20. /*
  21.  *
  22.  * Header for cntrlcen.c
  23.  *
  24.  */
  25.  
  26. #pragma once
  27.  
  28. #include <physfs.h>
  29.  
  30. #ifdef __cplusplus
  31. #include "fwd-object.h"
  32. #include "pack.h"
  33. #include "fwd-segment.h"
  34. #include "fwd-window.h"
  35.  
  36. #include "fwd-partial_range.h"
  37.  
  38. struct control_center_triggers : public prohibit_void_ptr<control_center_triggers>
  39. {
  40.         enum {
  41.                 max_links = 10
  42.         };
  43.         uint16_t num_links;
  44.         std::array<segnum_t, max_links>   seg;
  45.         std::array<uint16_t, max_links>   side;
  46. };
  47.  
  48. extern control_center_triggers ControlCenterTriggers;
  49.  
  50. #ifdef dsx
  51. #include "vecmat.h"
  52. struct reactor {
  53. #if defined(DXX_BUILD_DESCENT_II)
  54.         int model_num;
  55. #endif
  56.         int n_guns;
  57.         /* Location of the gun on the reactor model */
  58.         std::array<vms_vector, MAX_CONTROLCEN_GUNS> gun_points;
  59.         /* Orientation of the gun on the reactor model */
  60.         std::array<vms_vector, MAX_CONTROLCEN_GUNS> gun_dirs;
  61. };
  62.  
  63. // fills in arrays gun_points & gun_dirs, returns the number of guns read
  64. void read_model_guns(const char *filename, reactor &);
  65.  
  66. namespace dsx {
  67. #if defined(DXX_BUILD_DESCENT_I)
  68. constexpr std::integral_constant<unsigned, 1> MAX_REACTORS{};
  69. constexpr std::integral_constant<unsigned, 1> Num_reactors{};
  70. #elif defined(DXX_BUILD_DESCENT_II)
  71. constexpr std::integral_constant<unsigned, 7> MAX_REACTORS{};
  72. #define DEFAULT_CONTROL_CENTER_EXPLOSION_TIME 30    // Note: Usually uses Alan_pavlish_reactor_times, but can be overridden in editor.
  73.  
  74. struct d_level_shared_control_center_state
  75. {
  76.         int Base_control_center_explosion_time;      // how long to blow up on insane
  77.         int Reactor_strength;
  78. };
  79.  
  80. extern d_level_shared_control_center_state LevelSharedControlCenterState;
  81.  
  82. extern unsigned Num_reactors;
  83.  
  84. /*
  85.  * reads n reactor structs from a PHYSFS_File
  86.  */
  87. void reactor_read_n(PHYSFS_File *fp, partial_range_t<reactor *> r);
  88. #endif
  89.  
  90. extern std::array<reactor, MAX_REACTORS> Reactors;
  91.  
  92. static inline int get_reactor_model_number(int id)
  93. {
  94. #if defined(DXX_BUILD_DESCENT_I)
  95.         return id;
  96. #elif defined(DXX_BUILD_DESCENT_II)
  97.         return Reactors[id].model_num;
  98. #endif
  99. }
  100.  
  101. static inline reactor &get_reactor_definition(int id)
  102. {
  103. #if defined(DXX_BUILD_DESCENT_I)
  104.         (void)id;
  105.         return Reactors[0];
  106. #elif defined(DXX_BUILD_DESCENT_II)
  107.         return Reactors[id];
  108. #endif
  109. }
  110.  
  111. // do whatever this thing does in a frame
  112. void do_controlcen_frame(vmobjptridx_t obj);
  113.  
  114. // Initialize control center for a level.
  115. // Call when a new level is started.
  116. void init_controlcen_for_level();
  117. void calc_controlcen_gun_point(object &obj);
  118.  
  119. void do_controlcen_destroyed_stuff(imobjidx_t objp);
  120. window_event_result do_controlcen_dead_frame();
  121. }
  122. #endif
  123.  
  124. /*
  125.  * reads n control_center_triggers structs from a PHYSFS_File
  126.  */
  127. void control_center_triggers_read(control_center_triggers *cct, PHYSFS_File *fp);
  128. void control_center_triggers_write(const control_center_triggers *cct, PHYSFS_File *fp);
  129.  
  130. #endif
  131.