mapfield.h

Go to the documentation of this file.
00001 
00002 /***************************************************************************
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  *                                                                         *
00009  ***************************************************************************/
00010 
00011 
00012 #ifndef mapfieldH
00013  #define mapfieldH
00014 
00015  #include <vector>
00016 
00017  #include "typen.h"
00018  #include "vehicle.h"
00019  #include "basestrm.h"
00020  #include "explosivemines.h"
00021  
00022  
00023 class Context;
00024 
00026 class  MapField {
00027     GameMap* gamemap;
00028     void init();
00029   protected:
00030     MapField (  );
00031     friend class GameMap;
00032   public:
00033     MapField ( GameMap* gamemap_ );
00034     void operator= ( const MapField& f );
00035 
00036     void setMap ( GameMap* gamemap_ ) { gamemap = gamemap_; };
00037     GameMap* getMap() const { return gamemap; };
00038 
00040     TerrainType::Weather* typ;
00041     
00043     const TerrainType* getTerrainType() const;
00044     
00045     
00047     void changeTerrainType( const TerrainType* terrain );
00048     
00049 
00053     char         fuel, material;
00054 
00055     int getMineralMaterial() const;
00056     int getMineralFuel() const;
00057     
00058     void setMineralMaterial( int material );
00059     void setMineralFuel( int fuel );
00060    
00062     Uint16       visible;
00063 
00065     int          viewbonus;
00066 
00067 
00069 
00070     union  {
00071       struct {
00072         char         temp;
00073         char         temp2;
00074       }a;
00075       Uint16 tempw;
00076     };
00077     int          temp3;
00078     int          temp4;
00080 
00081     Vehicle*     vehicle;
00082     
00084     Vehicle*     secondvehicle;
00085     
00086     inline Vehicle* getVehicle() const {
00087          if ( secondvehicle )
00088             return secondvehicle;
00089          else
00090             return vehicle;
00091       }
00092 
00093     
00094     Building*    building;
00095 
00096     struct Resourceview {
00097       Resourceview ( void );
00098       void setview( int player, int material, int fuel );
00099       void resetview( int player );
00100       char    visible;      // BM
00101       char    fuelvisible[8];
00102       char    materialvisible[8];
00103     };
00104 
00106     Resourceview*  resourceview;
00107 
00108     typedef list<Mine> MineContainer;
00109     MineContainer mines;
00110 
00112     Mine& getMine ( int n );
00113 
00114 
00115     typedef vector< ::Object> ObjectContainer;
00116     ObjectContainer objects;
00117 
00119     class ObjectRemovalStrategy {
00120        public:
00121           virtual void removeObject( MapField* fld, const ObjectType* obj ) = 0;
00122           virtual ~ObjectRemovalStrategy() {};
00123     };
00124     
00125     
00132     bool addobject ( const ObjectType* obj, int dir = -1, bool force = false, ObjectRemovalStrategy* objectRemovalStrategy = NULL );
00133 
00139     bool removeObject ( const ObjectType* obj, bool force = false, ObjectRemovalStrategy* objectRemovalStrategy = NULL );
00140 
00142     void sortobjects ( void );
00143 
00145     Object* checkForObject ( const ObjectType*  o );
00146 
00147 
00149     TerrainBits  bdt;
00150 
00152     int connection;
00153 
00154 
00156     void deleteeverything ( void );
00157 
00158    
00160     void setparams ( ObjectRemovalStrategy* objectRemovalStrategy );
00161     
00163     void setparams (  );
00164 
00166     int getdefensebonus ( void );
00167 
00169     int getattackbonus  ( void );
00170 
00172     int getWeather();
00173     void setWeather( int weather );
00174 
00175     ASCString getName();
00176     
00178     int getjamming ( void );
00179     int getmovemalus ( const Vehicle* veh );
00180     int getmovemalus ( int type );
00181 
00183     int mineattacks ( const Vehicle* veh );
00184 
00186     int mineowner ( void );
00187 
00189     bool unitHere ( const Vehicle* veh );
00190 
00192     ContainerBase* getContainer();
00193     const ContainerBase* getContainer() const;
00194 
00195     
00197     Building* getBuildingEntrance();
00198     
00200     void removeBuilding();
00201     
00203     void removeUnit();
00204     
00206     bool  putmine ( int owner, MineTypes typ, int strength );
00207 
00211     void  removemine ( int num ); 
00212 
00213     void endRound( int turn );
00214 
00216     struct View {
00217       int view;
00218       int jamming;
00219       char mine, satellite, sonar, direct;
00220     } view[8];
00221 
00226    void setVisibility ( VisibilityStates valtoset, int actplayer );
00227 
00228    VisibilityStates getVisibility( int actplayer ) {
00229        return VisibilityStates((visible >> (2*actplayer)) & 3);
00230    };
00231 
00232    static void resetView( GameMap* gamemap, int playersToReset );
00233 
00234     int getx();
00235     int gety();
00236     MapCoordinate getPosition();
00237 
00238     int getMemoryFootprint() const;
00239 
00240     ~MapField();
00241   private:
00242     TerrainType::MoveMalus __movemalus;
00243 };
00244 
00245 
00246 
00247 
00248 
00249 #endif
00250 

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