source: golgotha/src/golg/player.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 12 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.6 KB
RevLine 
[80]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 __PLAYER_HH
10#define __PLAYER_HH
11
12#include "g1_object.hh"
13#include "g1_limits.hh"
14#include "player_type.hh"
15#include "memory/array.hh"
16#include "init/init.hh"
17#include "lisp/li_optr.hh"
18#include "reference.hh"
19#include "objs/stank.hh"
20
21class g1_map_class;
22class g1_map_piece_class;
23class g1_player_piece_class;
24struct i4_pixel_format;
25class r1_render_api_class;
26class g1_team_api_class;
27class g1_team_api_definition_class;
28class g1_border_frame_class;
29class g1_takeover_pad_class;
30class g1_path_object_class;          // objs/path_object.hh
31
32class g1_player_info_class
33{
34public:
35  friend class g1_team_api_class;
36
37private:
38  g1_player_type player_num;
39  g1_team_api_class *ai;
40  g1_team_type team;
41
42  // I want g1_player manager to call init_colors and new game on each player
43  friend class g1_player_manager_class; 
44  void init_colors(w32 player_num, const i4_pixel_format *fmt);
45  void new_game(g1_player_type num);
46  void think();
47
48  int &num_points();
49  int &num_stank_deaths();
50 
51  g1_typed_reference_class<g1_player_piece_class> commander;
52 
53public:
54  i4_bool continue_wait;
55
56  int &num_stank_lives();
57  li_object_pointer vars;
58
59  float kill_ratio();
60 
61  g1_team_type get_team() const { return team; }
62 
63  li_class *get_vars() { return (li_class *)vars.get(); }
64  void set_vars(li_class *v) { vars=(li_object *)v; }
65
66  int supertank_upgrade_level;
67  void calc_upgrade_level();
68
69  g1_model_ref team_flag;
70  int refresh_money;
71  int &money();
72  int &income_rate();
73  float &damage_multiplier();
74
75
76  i4_array<w32> owned_objects;
77  void remove_object(w32 global_id);
78  void add_object(w32 global_id);
79 
80
81  g1_player_info_class();   
82
83  g1_team_api_class *get_ai() const { return ai; }
84  void set_ai(g1_team_api_class *ai);
85
86  g1_player_type get_player_num() const { return player_num; }
87
88  g1_player_piece_class* get_commander() { return commander.get(); }
89
90  void set_commander(g1_player_piece_class *who) { commander=who; }
91
92  i4_bool load(g1_loader_class *fp);
93  void save(g1_saver_class *fp);
94
95  w16 vehicle_pal[256]; 
96
97  i4_color map_player_building;
98  i4_color map_player_color;
99  i4_color map_attacking_player_color; 
100  i4_color map_select_player_color; 
101
102  // next pad and location on pad to build objects
103  int next_pad;
104  int next_location;
105
106
107 
108  void supertank_died(g1_object_class *killer);
109  void add_points(int points);
110 
111  void allow_building(g1_object_type type,
112                      int cost,
113                      int sfx_to_play_when_built,
114                      i4_image_class *normal_button_image,
115                      i4_image_class *active_button_image,
116                      i4_image_class *pressed_button_image);
117};
118
119class g1_player_manager_class : i4_init_class
120{
121  g1_player_info_class *list[G1_MAX_PLAYERS];
122  const char *default_ai;
123public:
124  g1_player_type local_player;
125
126  g1_player_manager_class();
127
128  void show_message(const i4_const_str &message, w32 color, int player_for);
129
130  // set the name of the default computer ai
131  void set_default_ai(const char *ai);
132
133
134  // the player on the local machine
135  g1_player_info_class *get_local()
136  {
137    return list[local_player];
138  }
139
140  g1_player_info_class *get(g1_player_type player)
141  {
142    if (player>=G1_MAX_PLAYERS)
143      player=g1_default_player;
144
145    return list[player];
146  }
147
148  void save(g1_saver_class *fp)
149  {
150    for (w32 i=0;i<G1_MAX_PLAYERS;i++)
151      list[i]->save(fp);
152  }
153
154  i4_bool load(g1_loader_class *fp)
155  {
156    i4_bool ret=i4_T;
157    for (w32 i=0;i<G1_MAX_PLAYERS;i++)
158      ret=(i4_bool)(ret & list[i]->load(fp));
159    return ret;
160  }
161
162  void init_colors(const i4_pixel_format *fmt, r1_render_api_class *api);
163
164  void new_game()
165  {   
166    for (w32 i=0; i<G1_MAX_PLAYERS; i++)
167      list[i]->new_game((g1_player_type)i);
168  }
169
170  void think()
171  {
172    for (w32 i=0; i<G1_MAX_PLAYERS; i++)
173      list[i]->think();
174  }
175
176  void recalc_from_map(g1_map_class *map);
177
178  virtual void init();
179  virtual void uninit();
180
181  // for unloading dll AIs
182  void unload_ai(g1_team_api_definition_class *definer);
183};
184
185extern g1_player_manager_class g1_player_man;
186
187#endif
188
189
Note: See TracBrowser for help on using the repository browser.