Adonthell  0.4
mapsquare_walkable.cc
Go to the documentation of this file.
1 /*
2  $Id: mapsquare_walkable.cc,v 1.3 2002/09/28 17:21:50 ksterker Exp $
3 
4  Copyright (C) 2001 Alexandre Courbot
5  Part of the Adonthell Project http://adonthell.linuxgames.com
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 /**
16  * @file mapsquare_walkable.cc
17  * @author Alexandre Courbot <alexandrecourbot@linuxgames.com>
18  *
19  * @brief Defines the mapsquare_walkable and mapsquare_walkable_area classes.
20  *
21  *
22  */
23 
24 #include "mapsquare_walkable.h"
25 
27 {
29 }
30 
32 {
33  walkable << file;
34  return 0;
35 }
36 
38 {
39  walkable >> file;
40  return 0;
41 }
42 
44 {
45  basex = 0;
46  basey = 0;
47 }
48 
50 {
51 }
52 
54 {
55  area.clear ();
56 
57  basex = 0;
58  basey = 0;
59 }
60 
62 {
63  vector <vector<mapsquare_walkable> >::iterator it;
64  vector <mapsquare_walkable>::iterator jt;
65  u_int16 t_length, t_height;
66  u_int16 basex_, basey_;
67 
68  // Get the area size.
69  t_length << file;
70  t_height << file;
71  resize_area (t_length, t_height);
72 
73  // Load the area.
74  for (it = area.begin (); it != area.end (); it++)
75  for (jt = it->begin (); jt < it->end (); jt++)
76  jt->get (file);
77 
78  // Load the base square information.
79  basex_ << file;
80  basey_ << file;
81  set_base (basex_, basey_);
82 
83  return 0;
84 }
85 
87 {
88  vector <vector<mapsquare_walkable> >::iterator it;
89  vector <mapsquare_walkable>::iterator jt;
90 
91  // Put the area size.
92  area_length () >> file;
93  area_height () >> file;
94 
95  // Save the area.
96  for (it = area.begin (); it != area.end (); it++)
97  for (jt = it->begin (); jt < it->end (); jt++)
98  jt->put (file);
99 
100  // Save the base square information.
101  base_x () >> file;
102  base_y () >> file;
103 
104  return 0;
105 }
106 
108 {
109  vector <vector<mapsquare_walkable> >::iterator i;
110 
111  area.resize (nl);
112  for (i = area.begin (); i != area.end (); i++)
113  i->resize (nh);
114 
115  set_length (nl * MAPSQUARE_SIZE);
116  set_height (nh * MAPSQUARE_SIZE);
117 }
118 
120 {
121  basex = nx;
122  basey = ny;
123 }
124 
126 {
127  u_int16 i, j;
128 
129  // Clear everything.
130  clear ();
131 
132  (drawable&) (*this) = (drawable&) src;
133 
134  // Copy the area.
135  resize_area (src.area_length (), src.area_height ());
136  for (i = 0; i < src.area_length (); i++)
137  for (j = 0; j < src.area_height (); j++)
138  area[i][j] = src.area[i][j];
139 
140  // Copy the base square information.
141  set_base (src.base_x (), src.base_y ());
142 
143  return *this;
144 }