source: golgotha/src/golg/objs/path_object.hh

Last change on this file was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 4.2 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#ifndef G1_PATH_OBJECT_HH
10#define G1_PATH_OBJECT_HH
11
12#include "g1_object.hh"
13#include "memory/array.hh"
14#include "global_id.hh"
15
16class g1_map_piece_class;
17
18class g1_path_object_class : public g1_object_class
19{
20public:
21  enum { MAX_LINKS=8 };
22  enum bridge_status_type { NOT_BRIDGABLE,
23                            HAS_BRIDGE,
24                            NO_BRIDGE };
25  bridge_status_type get_bridge_status();
26  int bomb_warning_level();
27
28  // vehicles should use this to determine which path to follow
29  w32 last_selected_tick[G1_MAX_TEAMS];
30  g1_path_object_class *next;  // maintains a list of path objects in the level
31 
32  class link_class
33  {
34  public:
35    g1_id_ref object, path;
36
37    g1_object_class *get_object() const { return object.get(); }
38    g1_path_object_class *get_path() const { return g1_path_object_class::cast(path.get()); }
39  };
40  i4_array<link_class> link;
41  int link_index[G1_MAX_TEAMS+1];
42
43  virtual void validate();
44  virtual void save(g1_saver_class *fp);
45  g1_path_object_class(g1_object_type id, g1_loader_class *fp);   
46  virtual i4_bool occupy_location();
47  virtual void unoccupy_location();
48
49  virtual void draw(g1_draw_context_class *context);
50  virtual void editor_draw(g1_draw_context_class *context);
51  virtual void think() {} 
52  virtual i4_float occupancy_radius() const { return 0; }
53  virtual li_object *message(li_symbol *message_name,
54                             li_object *message_params,
55                             li_environment *env);
56
57  int total_links(g1_team_type team) const { return link_index[team+1] - link_index[team]; }
58  g1_path_object_class *get_link(g1_team_type team, int index) const
59  { return link[link_index[team] + index].get_path(); }
60  g1_object_class *get_object_link(g1_team_type team, int index) const
61  { return link[link_index[team] + index].get_object(); }
62
63  g1_path_object_class *get_recent_link(g1_team_type team, g1_path_object_class *last_used);
64 
65  int get_path_index(g1_team_type team, g1_path_object_class *obj) const;
66  int get_path_index(g1_path_object_class *obj) const;
67  int get_object_index(g1_object_class *obj) const;
68
69  i4_bool remove_link(g1_team_type type, g1_path_object_class *o);
70  void add_link(g1_team_type type, g1_path_object_class *o);
71
72  virtual void request_remove();
73
74  int total_controlled_objects();
75  g1_object_class *get_controlled_object(int object_num);
76  void add_controlled_object(g1_object_class *o);
77
78  static g1_path_object_class *cast(g1_object_class *obj)
79  //{{{
80  {
81    if (!obj || !(obj->get_type()->get_flag(g1_object_definition_class::TO_PATH_OBJECT)))
82      return 0;
83    return (g1_path_object_class *) obj;
84  }
85  //}}}
86
87  // returns the total destinations found (banks & etc that are attached to the path)
88  // uses "this" as the starting point
89  int find_path_destinations(g1_object_class **list,
90                             int list_size,               // max buffer size
91                             g1_team_type type);             // ALLY or ENEMY
92
93  int find_path(g1_team_type type, g1_path_object_class *dest,
94                g1_path_object_class **stack, int stack_size);
95
96  // this find path doesn't use a destination it follows most recently clicked nodes
97  int find_path(g1_team_type type, g1_path_object_class **stack, int stack_size);
98
99  void change_player_num(int new_player_num);
100 
101  g1_path_object_class* find_next(g1_team_type type, g1_path_object_class *dest);
102};
103
104
105// this maintains a list of path_objects that are on the current_map
106extern i4_isl_list<g1_path_object_class> g1_path_object_list;
107
108void g1_calc_path_object_colors();
109
110#endif
111
112//{{{ Emacs Locals
113// Local Variables:
114// folded-file: t
115// End:
116//}}}
Note: See TracBrowser for help on using the repository browser.