source: golgotha/src/golg/map_cell.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: 5.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_MAP_CELL_HH
10#define G1_MAP_CELL_HH
11
12#include "arch.hh"
13#include "rotation.hh"
14#include "player_type.hh"
15#include "file/file.hh"
16#include "range.hh"
17#include "math/point.hh"
18#include "obj3d.hh"
19#include "g1_limits.hh"
20#include "math/point.hh"
21#include "f_tables.hh"
22#include "map_man.hh"
23
24class g1_object_class;
25class g1_solid_class;
26class g1_bullet_class;
27class g1_map_view_class;
28class i4_image_class;
29class g1_solid_class;
30class g1_saver_class;
31class g1_loader_class;
32class g1_path_manager_class;
33class g1_map_class;
34class g1_draw_context_class;
35class g1_object_chain_class;
36class i4_loader_class;
37class i4_saver_class;
38
39struct g1_visible_cell
40{
41  w8 x,y;
42};
43
44
45class g1_map_cell_class
46{
47public:
48  enum { NO_CRITICAL=0 };
49
50
51  g1_object_chain_class *object_list;  // lists of objects that are standing on this tile
52                                       
53  void add_object(g1_object_chain_class &c);
54  i4_bool remove_object(g1_object_chain_class &c);
55
56  //  g1_graph_node nearest_critical[G1_GRADE_LEVELS][2][G1_CRITICALS_PER_CELL];
57  // tells which critical points are near this cell
58  w16 scratch_x, scratch_y;
59
60  w16   type;     // index into an array of ground object types (see tile.hh)
61 
62  w16   flags;
63  w16   top_left_normal;        // 1-5-5-5  top bit indicates needs recalc
64  w16   bottom_right_normal;    // 1-5-5-5  top bit indicates needs recalc
65
66  void recalc_top_left(int cx, int cy);
67  void recalc_bottom_right(int cx, int cy);
68
69  void  get_top_left_normal(i4_3d_vector &v, int cx, int cy)
70  {
71    if (top_left_normal & 0x8000)
72      recalc_top_left(cx, cy);
73
74    v.x=g1_table_0_31_to_n1_1[(top_left_normal>>10)&31];
75    v.y=g1_table_0_31_to_n1_1[(top_left_normal>>5)&31];
76    v.z=g1_table_0_31_to_n1_1[(top_left_normal)&31];
77  }
78
79  void get_bottom_right_normal(i4_3d_vector &v, int cx, int cy)
80  {
81    if (bottom_right_normal & 0x8000)
82      recalc_bottom_right(cx, cy);
83
84    v.x=g1_table_0_31_to_n1_1[(bottom_right_normal>>10)&31];
85    v.y=g1_table_0_31_to_n1_1[(bottom_right_normal>>5)&31];
86    v.z=g1_table_0_31_to_n1_1[(bottom_right_normal)&31];
87  }
88
89
90  void  get_bottom_right_normal(float &x, float &y, float &z, int current_cell_offset);
91
92  enum
93  {   
94    FOGGED=             (1<<0),             // if fogged from local player's view
95    MIRRORED=           (1<<1),  // if building cell is mirrored across the x-axis
96
97    ROTATE_BITS=        (1<<2)|(1<<3),
98
99    IS_GROUND=          (1<<4),  // if this square doesn't block movement
100
101    RADAR_NEEDS_RESTORE= (1<<5),            // if this spot on radar has been drawn
102    RADAR_NEEDS_STACKED_RESTORE = (1<<6),   // if spot has been drawn more than once
103
104    PLANAR=1<<13,      // if surface is planar and can be drawn with one quad rather than 2 tri's
105    SCRATCH1=1<<14,
106    SCRATCH2=1<<15
107  };
108
109  enum { SAVED_FLAGS = FOGGED | MIRRORED | ROTATE_BITS };
110
111  void clear_restore_bits() { flags &= ~(RADAR_NEEDS_STACKED_RESTORE | RADAR_NEEDS_RESTORE); }
112  i4_bool mirrored() { return (i4_bool)flags & MIRRORED; }
113 
114
115//   g1_player_type owner()
116//   {
117//     w32 ret=(flags&OWNER_BITS)>>8;
118//     //if (ret==31) return g1_no_player;
119//     //else
120//     return ret;
121//   }
122
123//   void set_owner(g1_player_type player)
124//   {
125//     //if (player==g1_no_player)
126//     //  flags|=OWNER_BITS;
127//     //else
128//       flags=((flags & (~OWNER_BITS)) | (player<<8));
129//   }
130
131  void load_v2(i4_file_class *fp, w16 *tile_remap);   // version 2
132  void load_v3(i4_file_class *fp, w16 *tile_remap);   // version 3
133  void load_v4(i4_file_class *fp, w16 *tile_remap);   // version 4
134  void load_v5(i4_file_class *fp, w16 *tile_remap);   // version 5
135  void load_v6(i4_file_class *fp, w16 *tile_remap);   // version 6
136
137  void set_rotation(g1_rotation_type type) { flags=(flags & (~ROTATE_BITS))|(type<<2); }
138  g1_rotation_type get_rotation() { return (g1_rotation_type)((flags&ROTATE_BITS)>>2); }
139 
140  void init(w16 _type, g1_rotation_type rotation, i4_bool mirrored);
141
142  i4_bool is_blocking() const { return !(flags&IS_GROUND); }
143
144  void set_planar_flag(w8 h1, w8 h2, w8 h3, w8 h4)
145  {
146    if (h1==h2 && h2==h3 && h3==h4)
147      flags|=PLANAR;
148    else
149      flags&=~PLANAR;
150  }
151
152  i4_bool list_capable() { return i4_T; }
153
154  g1_object_chain_class *get_solid_list();
155  g1_object_chain_class *get_non_solid_list();
156  g1_object_chain_class *get_obj_list()  { return object_list; }
157
158  void unfog(int x, int y);
159};
160
161
162i4_bool g1_load_map_cells(g1_map_cell_class *list, int lsize,
163                          w16 *tile_remap, i4_loader_class *fp);
164
165void g1_save_map_cells(g1_map_cell_class *list, int lsize, i4_saver_class *fp);
166
167inline g1_map_cell_class *g1_get_cell(int x, int y)
168{
169  return g1_cells + y*g1_map_width + x;
170}
171
172#endif
Note: See TracBrowser for help on using the repository browser.