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    void appendToString( ASCString& text ) const;
00039  };
00040 
00042  class TerrainAccess {
00043     public:
00044        TerrainAccess ( void ) ;
00045 
00047        TerrainBits  terrain;
00048 
00050        TerrainBits  terrainreq;
00051 
00053        TerrainBits  terrainnot;
00054 
00056        TerrainBits  terrainkill;
00057 
00062        int accessible ( const TerrainBits& bts ) const;
00063 
00064        void read ( tnstream& stream );
00065        void write ( tnstream& stream ) const;
00066        void runTextIO ( PropertyContainer& pc );
00067 
00068        ASCString toString( bool brief  = true) const;
00069  };
00070 
00071 
00072  typedef class TerrainType* pterraintype;
00073 
00075  class TerrainType : public MapItemType, public LoadableItemType {
00076     public:
00077       int                id;
00078 
00080       vector<int> secondaryIDs;
00081 
00082       int                getID() const { return id; };
00083       ASCString          name;
00084       ASCString          getName() const { return name; };
00085       
00086       class MoveMalus: public vector<int> {
00087          public: MoveMalus();
00088            #ifdef _vector_at_broken_
00089             int& at(size_t pos) { return operator[](pos); };
00090             const int& at(size_t pos) const { return operator[](pos); };
00091            #endif
00092             // void read ( tnstream& stream ) { read ( stream, -1 ); };
00093             void read ( tnstream& stream, int defaultValue, int moveMalusCount = -1 );
00094             void write ( tnstream& stream ) const;
00095       };
00096 
00097       class  Weather: public LoadableItemType {
00099           OverviewMapImage* quickView;
00100           ASCString originalImageFilename;
00101         public:
00103           Surface        image;
00104 
00106           int            defensebonus;
00107 
00109           int            attackbonus;
00110 
00112           int            basicjamming;
00113 
00115           TerrainType::MoveMalus   move_malus;
00116 
00118           void           paint ( Surface& s, SPoint pos );
00119           
00120           
00122           int            bi_pict;
00123 
00125           TerrainBits    art;
00126 
00128           TerrainType*   terraintype;
00129 
00130           const OverviewMapImage* getQuickView();
00131 
00132           Weather ( TerrainType* base ) : quickView ( NULL ), terraintype ( base ) {};
00133           ~Weather();
00134           void runTextIO ( PropertyContainer& pc );
00135           void read ( tnstream& stream );
00136           void read ( tnstream& stream, int version );
00137           void write ( tnstream& stream ) const;
00138           int getMemoryFootprint() const;
00139       };
00140      Weather*           weather[cwettertypennum];
00141 
00142      TerrainType();
00143      void runTextIO ( PropertyContainer& pc );
00144      void read ( tnstream& stream );
00145      void write ( tnstream& stream ) const;
00146      int getMemoryFootprint() const;
00147      ~TerrainType();
00148  };
00149 
00150 
00151  extern const char*  terrainProperty[]  ;
00152 
00153  enum TerrainBitTypes { cbwater0 ,
00154                      cbwater1 ,
00155                      cbwater2 ,
00156                      cbwater3 ,
00157                      cbwater ,
00158                      cbstreet ,
00159                      cbrailroad ,
00160                      cbbuildingentry ,
00161                      cbharbour ,
00162                      cbrunway ,
00163                      cbpipeline ,
00164                      cbpowerline ,
00165                      cbfahrspur ,
00166                      cbfestland ,
00167                      cbsnow1 ,
00168                      cbsnow2 ,
00169                      cbhillside ,
00170                      cbsmallrocks ,
00171                      cblargerocks ,
00172                      cbfrozenwater,
00173                      cbicebreaking,
00174                      cbriver };
00175 
00176  TerrainBits getTerrainBitType ( TerrainBitTypes tbt );
00177 
00178 
00179 #endif

Generated on Mon May 21 01:26:38 2012 for Advanced Strategic Command by  doxygen 1.5.1