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

Last change on this file since 80 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: 2.4 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_SOLVEMAP_BREADTH_HH
10#define G1_SOLVEMAP_BREADTH_HH
11
12#include "arch.hh"
13#include "solvemap.hh"
14#include <string.h>
15
16class g1_block_map_class;
17class g1_breadth_first_map_solver_class : public g1_map_solver_class
18{
19protected:
20  w16 wx, wy;
21
22  w8 *solve_map;
23  g1_block_map_class *block;
24
25  // Breadth first Queue
26  enum { queue_length=22500 };
27  w32 cnx[queue_length], cny[queue_length], cnl[queue_length];
28  w32 head,tail;
29
30  void clear_queue() { head = tail = 0; }
31
32  i4_bool add_cell(w32 x,w32 y,w8 d, w32 length);
33  i4_bool get_next_cell(w32 &x,w32 &y, w32 &length);
34
35  void clear_solve()
36  //{{{
37  {
38    memset(solve_map, 0, wx*wy);
39  }
40  //}}}
41
42public:
43  enum { VISITED=16, OK=32 };
44
45  w16 width() { return wx; }
46  w16 height() { return wy; }
47
48  g1_breadth_first_map_solver_class() : solve_map(0) {}
49  g1_breadth_first_map_solver_class(g1_block_map_class *_block) : solve_map(0)
50  { set_block_map(_block); }
51  ~g1_breadth_first_map_solver_class();
52
53  // Solve Map Accessors
54  void visit(int x, int y) { solve_map[y*wx+x] |= VISITED; }
55  void unvisit(int x, int y) { solve_map[y*wx+x] &= ~VISITED; }
56  i4_bool is_visited(int x, int y) { return (solve_map[y*wx+x] & VISITED)!=0; }
57
58  void ok(int x, int y) { solve_map[y*wx+x] |= OK; }
59  void unok(int x, int y) { solve_map[y*wx+x] &= ~OK; }
60  i4_bool is_ok(int x, int y) { return (solve_map[y*wx+x] & OK)!=0; }
61
62  w8 solve_dir(int x, int y) { return solve_map[y*wx+x]&0xf; }
63  void set_solve_dir(int x, int y, w8 dir)
64  //{{{
65  {
66    solve_map[y*wx+x] = (solve_map[y*wx+x]&0xf0) | (dir&0xf);
67  }
68  //}}}
69
70  virtual void set_block_map(g1_block_map_class *_block);
71  virtual i4_bool path_solve(w32 startx, w32 starty, w32 destx, w32 desty, w8 size, w8 grade,
72                             i4_float *point, w16 &points);
73};
74
75#endif
76
77//{{{ Emacs Locals
78// Local Variables:
79// folded-file: t
80// End:
81//}}}
Note: See TracBrowser for help on using the repository browser.