FS2_Open
Open source remastering of the Freespace 2 engine
objectdock.h
Go to the documentation of this file.
1 /*
2  * Created by Ian "Goober5000" Warfield for the FreeSpace2 Source Code Project.
3  * You may not sell or otherwise commercially exploit the source or things you
4  * create based on the source.
5  */
6 
7 
8 
9 #ifndef _OBJECT_DOCK_H
10 #define _OBJECT_DOCK_H
11 
12 #include "globalincs/globals.h"
13 #include "globalincs/pstypes.h"
14 
15 class object;
16 
17 // info for each docked object
18 typedef struct dock_instance {
19  dock_instance *next; // next item in list
20 
21  int dockpoint_used; // index into polymodel->docking_bays[]
22  object *docked_objp; // object that is docked to me
24 
25 // class used when a function must be evaluated for all docked objects
26 // (it's a class because it has a constructor)
28 {
29 public:
30 
31  // Set this to true when the function should return early.
33 
34  // The following were originally unions, but it became necessary to use structs
35  // for certain functions that need to maintain two or more values.
36  struct {
37  double double_value;
38  object* objp_value;
41  float float_value;
42  int int_value;
43  bool bool_value;
44  char char_value;
46 
47 
48  // constructor to initialize everything to 0
49  // (This used to memset the entire class (which at the time was a struct) to 0, but that hosed the function address table. Fortunately, by the time the constructor
50  // was called, the address table wasn't needed any more! It's now revised because it's best to keep the code robust in case of future unanticipated changes.)
52  : early_return_condition(false)
53  {
54  memset(&parameter_variables, 0, sizeof(parameter_variables));
55  memset(&maintained_variables, 0, sizeof(maintained_variables));
56  }
57 };
58 
60 {
64 };
65 
66 
67 // get the first object in objp's dock list
68 object *dock_get_first_docked_object(object *objp);
69 
70 // check whether objp is part of a docked pair
72 
73 // count objects directly docked to objp
75 
76 // count objects directly or indirectly docked with objp
78 
79 // check whether other_objp is directly docked to objp
80 bool dock_check_find_direct_docked_object(object *objp, object *other_objp);
81 
82 // check whether other_objp is directly or indirectly docked to objp
83 bool dock_check_find_docked_object(object *objp, object *other_objp);
84 
85 // find the object occupying objp's specified dockpoint
86 object *dock_find_object_at_dockpoint(object *objp, int dockpoint);
87 
88 // find objp's dockpoint being occupied by other_objp
89 int dock_find_dockpoint_used_by_object(object *objp, object *other_objp);
90 
91 // calculate the center of all docked objects (returned in dest)
92 void dock_calc_docked_center(vec3d *dest, object *objp);
93 
94 // calculate the center of mass of all docked objects (returned in dest)
95 // currently the game assumes the center of mass is the center of an object; this will need to
96 // be fixed eventually (though this function does weight the object masses properly)
97 void dock_calc_docked_center_of_mass(vec3d *dest, object *objp);
98 
99 // sum the masses of all directly or indirectly docked ships
100 float dock_calc_total_docked_mass(object *objp);
101 
102 // calculate cross-sectional radius of a set of docked models
104 
105 // *insert sophomoric jokes here*
106 // The semilatus rectum is analagous to the radius, but restricted to one dimension (whereas the radius
107 // covers two dimensions). It is half of the latus rectum. More information can be found in Wikipedia
108 // or in any math textbook. :p
110 
111 // calculate the overall forward speed of the entire docked mass
112 float dock_calc_docked_fspeed(object *objp);
113 
114 // calculate the overall speed of the entire docked mass
115 float dock_calc_docked_speed(object *objp);
116 
117 // Überfunction for evaluating all objects that could possibly be docked to objp. This will
118 // call "function" for each docked object. The function should store its intermediate and
119 // return values in the dock_function_info class.
120 void dock_evaluate_all_docked_objects(object *objp, dock_function_info *infop, void (*function)(object *, dock_function_info *));
121 
122 // moves all docked objects; called only from obj_move_all in object.cpp
123 void dock_move_docked_objects(object *objp);
124 
125 // add objp1 and objp2 to each others' dock lists; currently only called by ai_do_objects_docked_stuff
126 void dock_dock_objects(object *objp1, int dockpoint1, object *objp2, int dockpoint2);
127 
128 // remove objp1 and objp2 from each others' dock lists; currently only called by ai_do_objects_undocked_stuff
129 void dock_undock_objects(object *objp1, object *objp2);
130 
131 // free the entire dock list without undocking anything; should only be used on object cleanup
132 void dock_free_dock_list(object *objp);
133 
134 #endif // _OBJECT_DOCK_H
void dock_dock_objects(object *objp1, int dockpoint1, object *objp2, int dockpoint2)
Definition: objectdock.cpp:602
int dock_count_direct_docked_objects(object *objp)
Definition: objectdock.cpp:77
float dock_calc_max_semilatus_rectum_parallel_to_axis(object *objp, axis_type axis)
Definition: objectdock.cpp:211
vec3d * vecp_value2
Definition: objectdock.h:40
object * dock_get_first_docked_object(object *objp)
Definition: objectdock.cpp:47
Definition: pstypes.h:88
int dockpoint_used
Definition: objectdock.h:21
dock_instance * next
Definition: objectdock.h:19
float dock_calc_docked_fspeed(object *objp)
Definition: objectdock.cpp:261
float dock_calc_max_cross_sectional_radius_perpendicular_to_axis(object *objp, axis_type axis)
Definition: objectdock.cpp:161
object * objp
Definition: lua.cpp:3105
vec3d * vecp_value
Definition: objectdock.h:39
bool dock_check_find_docked_object(object *objp, object *other_objp)
Definition: objectdock.cpp:96
int dock_find_dockpoint_used_by_object(object *objp, object *other_objp)
Definition: objectdock.cpp:116
bool early_return_condition
Definition: objectdock.h:32
bool dock_check_find_direct_docked_object(object *objp, object *other_objp)
Definition: objectdock.cpp:91
void dock_move_docked_objects(object *objp)
Definition: objectdock.cpp:371
Definition: object.h:141
struct dock_instance dock_instance
bool dock_check_docked_one_on_one(object *objp)
Definition: objectdock.cpp:56
void dock_free_dock_list(object *objp)
Definition: objectdock.cpp:725
void dock_undock_objects(object *objp1, object *objp2)
Definition: objectdock.cpp:621
struct dock_function_info::@258 parameter_variables
struct dock_function_info::@258 maintained_variables
object * objp_value
Definition: objectdock.h:38
void dock_calc_docked_center(vec3d *dest, object *objp)
Definition: objectdock.cpp:126
object * docked_objp
Definition: objectdock.h:22
float dock_calc_docked_speed(object *objp)
Definition: objectdock.cpp:269
void dock_calc_docked_center_of_mass(vec3d *dest, object *objp)
Definition: objectdock.cpp:139
void dock_evaluate_all_docked_objects(object *objp, dock_function_info *infop, void(*function)(object *, dock_function_info *))
Definition: objectdock.cpp:285
float dock_calc_total_docked_mass(object *objp)
Definition: objectdock.cpp:152
false
Definition: lua.cpp:6789
object * dock_find_object_at_dockpoint(object *objp, int dockpoint)
Definition: objectdock.cpp:106
int dock_count_total_docked_objects(object *objp)
Definition: objectdock.cpp:82
axis_type
Definition: objectdock.h:59