Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MAPSQUARE_WALKABLE_H_
00027 #define MAPSQUARE_WALKABLE_H_
00028
00029 #include "fileops.h"
00030 #include "drawable.h"
00031 #include <vector>
00032
00033
00034
00035
00036
00037
00038 const u_int16 MAPSQUARE_SIZE = 20;
00039
00040
00041
00042
00043
00044 #define ALL_WALKABLE 15
00045
00046
00047
00048
00049
00050 #define WALKABLE_SOUTH 1
00051
00052
00053
00054
00055
00056 #define WALKABLE_NORTH 2
00057
00058
00059
00060
00061
00062 #define WALKABLE_EAST 4
00063
00064
00065
00066
00067
00068 #define WALKABLE_WEST 8
00069
00070
00071
00072
00073
00074 #define NONE_WALKABLE 0
00075
00076
00077
00078
00079
00080
00081
00082 class mapsquare_walkable
00083 {
00084 public:
00085
00086
00087
00088
00089
00090 mapsquare_walkable();
00091
00092
00093
00094
00095
00096
00097
00098
00099 s_int8 get (igzstream& file);
00100
00101
00102
00103
00104
00105
00106
00107
00108 s_int8 put (ogzstream& file) const;
00109
00110
00111
00112
00113
00114
00115
00116 bool is_walkable_west () const
00117 {
00118 return walkable & WALKABLE_WEST;
00119 }
00120
00121
00122
00123
00124
00125
00126
00127 bool is_walkable_east () const
00128 {
00129 return walkable & WALKABLE_EAST;
00130 }
00131
00132
00133
00134
00135
00136
00137
00138 bool is_walkable_north () const
00139 {
00140 return walkable & WALKABLE_NORTH;
00141 }
00142
00143
00144
00145
00146
00147
00148
00149 bool is_walkable_south () const
00150 {
00151 return walkable & WALKABLE_SOUTH;
00152 }
00153
00154
00155
00156
00157
00158
00159 void set_walkable_west (bool w)
00160 {
00161 if (!w)
00162 walkable &= (ALL_WALKABLE - WALKABLE_WEST);
00163 else
00164 walkable |= WALKABLE_WEST;
00165 }
00166
00167
00168
00169
00170
00171
00172 void set_walkable_east (bool w)
00173 {
00174 if (!w)
00175 walkable &= (ALL_WALKABLE - WALKABLE_EAST);
00176 else
00177 walkable |= WALKABLE_EAST;
00178 }
00179
00180
00181
00182
00183
00184
00185 void set_walkable_north (bool w)
00186 {
00187 if (!w)
00188 walkable &= (ALL_WALKABLE - WALKABLE_NORTH);
00189 else
00190 walkable |= WALKABLE_NORTH;
00191 }
00192
00193
00194
00195
00196
00197
00198 void set_walkable_south (bool w)
00199 {
00200 if (!w)
00201 walkable &= (ALL_WALKABLE - WALKABLE_SOUTH);
00202 else
00203 walkable |= WALKABLE_SOUTH;
00204 }
00205
00206
00207
00208
00209
00210
00211 u_int8 get_walkable () const
00212 {
00213 return walkable;
00214 }
00215
00216
00217
00218
00219
00220
00221 void set_walkable (u_int8 w)
00222 {
00223 walkable = w;
00224 }
00225
00226 private:
00227 u_int8 walkable;
00228 };
00229
00230
00231
00232
00233
00234
00235 class mapsquare_walkable_area : public drawable
00236 {
00237 public:
00238
00239
00240
00241
00242 mapsquare_walkable_area ();
00243
00244
00245
00246
00247
00248 ~mapsquare_walkable_area ();
00249
00250
00251
00252
00253
00254 void clear ();
00255
00256 virtual void draw (s_int16 x, s_int16 y, const drawing_area * da_opt = NULL,
00257 surface * target = NULL) const = 0;
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271 u_int16 area_length () const
00272 {
00273 return area.size ();
00274 }
00275
00276
00277
00278
00279
00280
00281
00282 u_int16 area_height () const
00283 {
00284 if (area.size ()) return area[0].size ();
00285 else return 0;
00286 }
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296 mapsquare_walkable * get_square (u_int16 x, u_int16 y) const
00297 {
00298 return &(area[x][y]);
00299 }
00300
00301
00302
00303
00304
00305
00306
00307 void resize_area (u_int16 nl, u_int16 nh);
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324 u_int16 base_x () const
00325 {
00326 return basex;
00327 }
00328
00329
00330
00331
00332
00333
00334
00335 u_int16 base_y () const
00336 {
00337 return basey;
00338 }
00339
00340
00341
00342
00343
00344
00345
00346 void set_base (u_int16 nx, u_int16 ny);
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356 s_int8 get (igzstream & file);
00357
00358
00359
00360
00361
00362
00363
00364 s_int8 put (ogzstream & file) const;
00365
00366 #ifndef SWIG
00367
00368
00369
00370
00371
00372
00373 mapsquare_walkable_area & operator = (const mapsquare_walkable_area & mo);
00374 #endif
00375
00376
00377
00378
00379
00380
00381 void copy (const mapsquare_walkable_area& src)
00382 {
00383 *this = src;
00384 }
00385
00386 private:
00387
00388
00389
00390
00391 mapsquare_walkable_area (const mapsquare_walkable_area & src);
00392
00393 mutable vector <vector<mapsquare_walkable> > area;
00394
00395 u_int16 basex;
00396 u_int16 basey;
00397 };
00398
00399 #endif