[go: up one dir, main page]

File: fltmngr.h

package info (click to toggle)
sabre 0.2.3-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 4,876 kB
  • ctags: 5,106
  • sloc: cpp: 25,581; ansic: 7,439; sh: 2,063; makefile: 92
file content (193 lines) | stat: -rw-r--r-- 4,584 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*
    SABRE Fighter Plane Simulator 
    Copyright (c) 1997 Dan Hammer
    Portions Donated By Antti Barck

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 1, or (at your option)
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/******************************************************
 * fltmngr.h                                          *
 ******************************************************/
#ifndef __fltmngr_h
#define __fltmngr_h

#ifndef __flight_h
#include "flight.h"
#endif

#ifndef __pilot_h
#include "pilot.h"
#endif

class Flight_Node
{
public:
  Flight *flight;
  Flight_ZViewer *viewer;
  Pilot          *pilot;
  int            user_node;
  int            user_auto;
  int            target_node;
  int            view_node;
  Flight_Specs   **specs;
  Z_Node_Manager **z_managers;
  Pilot_Params   **pilot_params;
  Weapons_Manager    &wpm;
  Weapon_Instance *wi;
  int             n_weaps;
  char           handle[17];
  Landing_Report	lr;
  Flight_Node(Flight_Specs **spcs, Z_Node_Manager **zm,
	      Pilot_Params **prms, Weapons_Manager &wp)
    :specs(spcs),
    z_managers(zm),
    pilot_params(prms),
    wpm(wp)
    {
      flight = NULL;
      viewer = NULL;
      pilot = NULL;
      wi = NULL;
      user_node = 0;
      user_auto = 0;
      n_weaps = 0;
      view_node = 0;
      target_node = -1;
    }

  ~Flight_Node()
    {
      if (pilot)
	delete pilot;
      if (viewer)
	delete viewer;
      if (flight)
	delete flight;
      if (wi)
	delete [] wi;
    }

  friend istream &operator >>(istream &, Flight_Node &);
  void read(istream &);

  void start()
    {
      if (pilot && flight->controls.autopilot)
	pilot->start();
      if (flight)
	flight->start();
    }

  void pause()
    {
      if (flight)
	flight->pause();
      if (pilot && flight->controls.autopilot)
	pilot->pause();
    }

  void update(Unguided_Manager *um = NULL);
  void add_draw_list(DrawList &, Port_3D &);
};

class Flight_Manager
{
public:
  Flight_Specs   **specs;
  int            n_specs;
  Z_Node_Manager **z_managers;
  int            n_managers;
  Pilot_Params   **p_params;
  int            n_pparams;
  Weapons_Manager wm;
  Flight_Node    **flight_nodes;
  int            n_flights;
  int            view_node;

  int            v_4_flag;
  int            v_4_node;
  Port_3D        v_4_port;

  Flight_Manager()
    {
      n_specs = n_managers = n_pparams = n_flights = 0;
      specs = NULL;
      z_managers = NULL;
      p_params = NULL;
      flight_nodes = NULL;
      view_node = 0;
      v_4_flag = 0;
      v_4_node = -1;
    }

  ~Flight_Manager();
  int read_file(char *);
  friend istream &operator >>(istream &, Flight_Manager &);
  void read(istream &);
  void update(Unguided_Manager *um = NULL);
  void start();
  void pause();
  void add_draw_list(DrawList &, Port_3D &);
  void set_flight_view(Port_3D &);
  int select_next_target(int);
  void set_view_node(int);
  Flight_Node *get_node(int n)
    {
      if (n >= 0 && n < n_flights)
	return (flight_nodes[n]);
      else
	return NULL;
    }
  Flight_Node & get_view_node()
    { return *flight_nodes[view_node]; }
  Port_3D & get_view_port()
    { return flight_nodes[view_node]->flight->state.flight_port; }
  Flight & get_view_flight()
    { return *(flight_nodes[view_node]->flight); }
  Flight *get_flight(int i)
    {
      if (i < n_flights && i >= 0)
	return (flight_nodes[i]->flight);
      else
	return (NULL);
    }
  Pilot *get_pilot(int i)
    {
      if (i < n_flights && i >= 0)
	return (flight_nodes[i]->pilot);
      else
	return (NULL);
    }
  Flight_ZViewer & get_view_viewer()
    { return *(flight_nodes[view_node]->viewer); }
  Flight_ZViewer *get_viewer(int i)
    {
      if (i < n_flights && i >= 0)
	return (flight_nodes[i]->viewer);
      else
	return NULL;
    }
  WayPoint *get_way_point(int i)
    {
      if (i < WayPoint::n_waypoints && i >= 0)
	return (WayPoint::gwaypoints[i]);
      else
	return NULL;
    }
  void readNodeFile(char *);
  void readNodes(istream &is);
};

#endif