Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

terraintype.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           terraintype.h  -  description
00003                              -------------------
00004     begin                : Fri Jul 27 2001
00005     copyright            : (C) 2001 by Martin Bickel
00006     email                : bickel@asc-hq.org
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef terraintypeH
00019  #define terraintypeH
00020 
00021  #include "graphics/surface.h"
00022  #include "typen.h"
00023  #include "mapitemtype.h"
00024 
00025  class OverviewMapImage;
00026 
00028  const int terrainPropertyNum = 38;
00029 
00030 
00032  class TerrainBits : public BitSet {
00033   public:
00034    void setInt ( int terrain1 = 0, int terrain2 = 0 );
00035    void read ( tnstream& stream );
00036    void write ( tnstream& stream ) const;
00037  };
00038 
00040  class TerrainAccess {
00041     public:
00042        TerrainAccess ( void ) ;
00043 
00045        TerrainBits  terrain;
00046 
00048        TerrainBits  terrainreq;
00049 
00051        TerrainBits  terrainnot;
00052 
00054        TerrainBits  terrainkill;
00055 
00060        int accessible ( const TerrainBits& bts ) const;
00061 
00062        void read ( tnstream& stream );
00063        void write ( tnstream& stream ) const;
00064        void runTextIO ( PropertyContainer& pc );
00065 
00066  };
00067 
00068 
00069  typedef class TerrainType* pterraintype;
00070 
00072  class TerrainType : public MapItemType, public LoadableItemType {
00073     public:
00074       int                id;
00075 
00077       vector<int> secondaryIDs;
00078 
00079       int                getID() const { return id; };
00080       ASCString          name;
00081       ASCString          getName() const { return name; };
00082       
00083       class MoveMalus: public vector<int> {
00084          public: MoveMalus();
00085            #ifdef _vector_at_broken_
00086             int& at(size_t pos) { return operator[](pos); };
00087             const int& at(size_t pos) const { return operator[](pos); };
00088            #endif
00089             // void read ( tnstream& stream ) { read ( stream, -1 ); };
00090             void read ( tnstream& stream, int defaultValue, int moveMalusCount = -1 );
00091             void write ( tnstream& stream ) const;
00092       };
00093 
00094       class  Weather: public LoadableItemType {
00096           OverviewMapImage* quickView;
00097         public:
00099           Surface        image;
00100 
00102           int            defensebonus;
00103 
00105           int            attackbonus;
00106 
00108           int            basicjamming;
00109 
00111           TerrainType::MoveMalus   move_malus;
00112 
00114           void           paint ( Surface& s, SPoint pos );
00115           
00116           
00118           int            bi_pict;
00119 
00121           TerrainBits    art;
00122 
00124           TerrainType*   terraintype;
00125 
00126           const OverviewMapImage* getQuickView();
00127 
00128           Weather ( TerrainType* base ) : quickView ( NULL ), terraintype ( base ) {};
00129           ~Weather();
00130           void runTextIO ( PropertyContainer& pc );
00131           void read ( tnstream& stream );
00132           void read ( tnstream& stream, int version );
00133           void write ( tnstream& stream ) const;
00134           int getMemoryFootprint() const;
00135       };
00136      Weather*           weather[cwettertypennum];
00137 
00138      TerrainType();
00139      void runTextIO ( PropertyContainer& pc );
00140      void read ( tnstream& stream );
00141      void write ( tnstream& stream ) const;
00142      int getMemoryFootprint() const;
00143      ~TerrainType();
00144  };
00145 
00146 
00147  extern const char*  terrainProperty[]  ;
00148 
00149  enum TerrainBitTypes { cbwater0 ,
00150                      cbwater1 ,
00151                      cbwater2 ,
00152                      cbwater3 ,
00153                      cbwater ,
00154                      cbstreet ,
00155                      cbrailroad ,
00156                      cbbuildingentry ,
00157                      cbharbour ,
00158                      cbrunway ,
00159                      cbpipeline ,
00160                      cbpowerline ,
00161                      cbfahrspur ,
00162                      cbfestland ,
00163                      cbsnow1 ,
00164                      cbsnow2 ,
00165                      cbhillside ,
00166                      cbsmallrocks ,
00167                      cblargerocks ,
00168                      cbfrozenwater,
00169                      cbicebreaking,
00170                      cbriver };
00171 
00172  TerrainBits getTerrainBitType ( TerrainBitTypes tbt );
00173 
00174 
00175 #endif

Generated on Tue Jun 24 01:27:53 2008 for Advanced Strategic Command by  doxygen 1.4.2