/[enigma]/enigma/src/enigma.hh
ViewVC logotype

Diff of /enigma/src/enigma.hh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by dheck, Sun Mar 23 17:25:09 2003 UTC revision 1.8 by reallysoft, Sat May 3 07:16:34 2003 UTC
# Line 5  Line 5 
5   * modify it under the terms of the GNU General Public License   * modify it under the terms of the GNU General Public License
6   * as published by the Free Software Foundation; either version 2   * as published by the Free Software Foundation; either version 2
7   * of the License, or (at your option) any later version.   * of the License, or (at your option) any later version.
8   *     *
9   * This program is distributed in the hope that it will be useful,   * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.   * GNU General Public License for more details.
13   *     *
14   * You should have received a copy of the GNU General Public License along   * You should have received a copy of the GNU General Public License along
15   * with this program; if not, write to the Free Software Foundation, Inc.,   * with this program; if not, write to the Free Software Foundation, Inc.,
16   * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.   * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
# Line 37  Line 37 
37  #include <iosfwd>  #include <iosfwd>
38    
39  /*  /*
40  ** Import symbols from other namespaces  ** Import symbols from other namespaces
41  */  */
42  namespace enigma  namespace enigma
43  {  {
# Line 69  namespace enigma Line 69  namespace enigma
69  //======================================================================  //======================================================================
70  namespace enigma  namespace enigma
71  {  {
72      enum Direction {      enum Direction {
73          NODIR = -1,          NODIR = -1,
74          NORTH = 3,          NORTH = 3,
75          EAST = 2,          EAST = 2,
76          SOUTH = 1,          SOUTH = 1,
77          WEST = 0,          WEST = 0,
78      };      };
79    
80      Direction reverse(Direction d);      Direction reverse(Direction d);
81      string to_suffix(Direction d);      Direction rotate_clockwise(Direction d);
82        string    to_suffix(Direction d);
83    
84      enum DirectionBits {      enum DirectionBits {
85          NODIRBIT = 0,          NODIRBIT = 0,
# Line 115  namespace enigma Line 117  namespace enigma
117    
118          void assign(double d) { clear(); type=DOUBLE; val.dval=d; }          void assign(double d) { clear(); type=DOUBLE; val.dval=d; }
119          void assign(const char* s);          void assign(const char* s);
120        
121          Type    get_type() const { return type; }          Type    get_type() const { return type; }
122          double  get_double() const throw();          double  get_double() const throw();
123          const char* get_string() const throw();          const char* get_string() const throw();
# Line 131  namespace enigma Line 133  namespace enigma
133    
134      px::Buffer& operator<<(px::Buffer& buf, const Value& val);      px::Buffer& operator<<(px::Buffer& buf, const Value& val);
135      px::Buffer& operator>>(px::Buffer& buf, Value& val);      px::Buffer& operator>>(px::Buffer& buf, Value& val);
136        
137      std::ostream& operator<<(std::ostream& os, const Value& val);      std::ostream& operator<<(std::ostream& os, const Value& val);
138    
139      bool        to_bool(const Value &v);      bool        to_bool(const Value &v);
# Line 172  namespace enigma Line 174  namespace enigma
174      struct GridPos {      struct GridPos {
175          int x, y;          int x, y;
176          explicit GridPos(int xx=0, int yy=0) : x(xx), y(yy) {}          explicit GridPos(int xx=0, int yy=0) : x(xx), y(yy) {}
177            explicit GridPos(const px::V2& p) : x(static_cast<int>(p[0])), y(static_cast<int>(p[1])) {}
178    
179          void move(Direction dir);          void move(Direction dir);
180          bool operator==(GridPos b) const { return (x==b.x && y==b.y); }          bool operator==(GridPos b) const { return (x==b.x && y==b.y); }
# Line 179  namespace enigma Line 182  namespace enigma
182      };      };
183    
184      inline void GridPos::move(Direction dir) {      inline void GridPos::move(Direction dir) {
185          switch(dir) {          switch(dir) {
186          case NORTH: y--; break; case SOUTH: y++; break;          case NORTH: y--; break; case SOUTH: y++; break;
187          case EAST: x++; break; case WEST: x--; break;          case EAST: x++; break; case WEST: x--; break;
188          case NODIR: break;          case NODIR: break;
189          }          }
190      }      }
191        
192      inline GridPos move(GridPos p, Direction dir) {      inline GridPos move(GridPos p, Direction dir) {
193          GridPos tmp = p;          GridPos tmp = p;
194          tmp.move(dir);          tmp.move(dir);
195          return tmp;          return tmp;
196      }      }
197    
198      inline px::V2 to_vec(GridPos p) {      inline px::V2 to_vec(GridPos p) {
199          return px::V2(p.x, p.y);          return px::V2(p.x, p.y);
200      }      }
201        
202      inline bool operator< (GridPos a, GridPos b) {      inline bool operator< (GridPos a, GridPos b) {
203          return ((a.y<<16) + a.x) < ((b.y<<16) + b.x);          return ((a.y<<16) + a.x) < ((b.y<<16) + b.x);
204      }      }
# Line 219  namespace enigma Line 222  namespace enigma
222          GridLoc(GridLayer l,GridPos p) : pos(p), layer(l) {}          GridLoc(GridLayer l,GridPos p) : pos(p), layer(l) {}
223      };      };
224    
225      /*      /*
226       * Output stream for logging messages       * Output stream for logging messages
227       */       */
228      extern std::ostream Log;      extern std::ostream Log;
# Line 231  namespace enigma Line 234  namespace enigma
234    
235      /* Find a file named `filename' in one of the Enigma data      /* Find a file named `filename' in one of the Enigma data
236         directories.  The filename may include subdirectory names.         directories.  The filename may include subdirectory names.
237          
238         FindDataFile("graphics/bomb.png")         FindDataFile("graphics/bomb.png")
239         -> "/usr/local/share/enigma/graphics/bomb.png"         -> "/usr/local/share/enigma/graphics/bomb.png"
240         or "/home/user/.enigma/graphics/bomb.png"         or "/home/user/.enigma/graphics/bomb.png"
241      */      */
242      string FindDataFile(const string &filename);      string FindDataFile(const string &filename);
243      string FindDataFile(const string &path, const string &filename);      string FindDataFile(const string &path, const string &filename);
244      std::list <string> FindDataFiles(const string &path, const string &filename);      std::list <string> FindDataFiles(const string &path, const string &filename);
245        
246      bool FindFile (const string &fname, string &dst_fname);      bool FindFile (const string &fname, string &dst_fname);
247    
248  //----------------------------------------  //----------------------------------------

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26