File: viewcalculation.h

package info (click to toggle)
asc 2.6.1.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 81,740 kB
  • sloc: cpp: 158,704; sh: 11,544; ansic: 6,736; makefile: 604; perl: 138
file content (132 lines) | stat: -rw-r--r-- 7,154 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/***************************************************************************
                          viewcalculation.h  -  description
                             -------------------
    begin                : Thu Oct 5 2000
    copyright            : (C) 2000 by Martin Bickel
    email                : bickel@asc-hq.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/


#ifndef viewcalculationH
 #define viewcalculationH

 #include "actions/context.h"
 #include "typen.h"
 #include "mapalgorithms.h"
 #include "gamemap.h"

  class tcomputeview : public SearchFields {
                protected:
                      int actView;
                      int player;
                      int mode;
                      int height;
                      bool rangeJamming;
                      int baseJammingMultiplier; // in 1/100

                      int sonar,satellitenview,minenview;
                      int        viewdist;
                      int        jamdist;
                      virtual void  initviewcalculation( int view, int jamming, int sx, int sy, int _mode, int _height   );   // mode: +1 = add view  ;  -1 = remove view
                      virtual void  testfield ( const MapCoordinate& mc );

                public:
                      tcomputeview ( GameMap* _actmap ) : SearchFields ( _actmap ), rangeJamming ( true ), baseJammingMultiplier(100) { actView = _actmap->getPlayerView(); };
                 };

  class tcomputevehicleview : public tcomputeview {
                           public:
                               tcomputevehicleview ( GameMap* gamemap ) : tcomputeview ( gamemap ) {};
                               void          init( const Vehicle* eht, int _mode  );   // mode: +1 = add view  ;  -1 = remove view );
                           };

  class tcomputebuildingview : public tcomputeview  {
                              const Building*         building;
                           public:
                              tcomputebuildingview ( GameMap* gamemap ) : tcomputeview ( gamemap ) {};
                              void              init( const Building*    bld, int _mode );
                           };

  /** completely computes the view
      \param gamemap  the map that the view is generated on
      \param player_fieldcount_mask bitmapped variable containing the players for whom the changed fields are calculated
      \param disableShareView sharing the view between different players is disabled. 
      \returns the number of fields that have a changed visibility for the given players. If nothing changes, the map must not be displayed again after the view calculation
  */
  extern int computeview( GameMap* gamemap, int player_fieldcount_mask = 0, bool disableShareView = false, const Context* context = NULL );

  /** evaluates the view on a given field and saves it for that field. Calls #calcvisibilityfield for the calculation
      Radar and jamming values must have already been applied to the field! 
      \param gamemap the map that contains field
      \param fld    the field to evaluate
      \param player the player that the view is calculated for
      \param add    a bitmapped variable containing the players that share their view with player
      \param initial the initial visibility of the map when starting the game.
  */
  extern int evaluatevisibilityfield ( GameMap* gamemap, MapField* fld, int player, int add, int initial );

  /** evaluates the view on the whole map.
      Radar and jamming values must have already been applied to the field! 
      \param gamemap the map that the view is calculated of
      \param player_fieldcount_mask determines, which players should be counted when the view has changed
      \param disableShareView sharing the view between different players is disabled. 
      \returns the number of fields which have a changed visibility status
  */
  extern int  evaluateviewcalculation ( GameMap* gamemap, int player_fieldcount_mask = 0, bool disableShareView = false, const Context* context = NULL );

  /** evaluates the view on a part of the map.
      Radar and jamming values must have already been applied to the field! 
      \param gamemap the map that the view is calculated of
      \param pos  the central position around which the view is calculated
      \param distance the radius of the circle around pos in which the view is evaluated. 
                      The view is calculated in AT LEAST this circle, in reality it is a rectangle containing this circle.
                      This is not the number of fields, but the distance in points (with 10 points = 1 field) 
      \param player_fieldcount_mask determines, which players should be counted when the view has changed
      \param disableShareView sharing the view between different players is disabled. 
      \returns the number of fields which have a changed visibility status
  */
  extern int  evaluateviewcalculation ( GameMap* gamemap, const MapCoordinate& pos, int distance, int player_fieldcount_mask = 0, bool disableShareView = false, const Context* context = NULL );

  /** calculates the view on a given field.
      Radar and jamming values must have already been applied to the field! 
      \param gamemap the map that contains field
      \param fld    the field to evaluate
      \param player the player that the view is calculated for
      \param add    a bitmapped variable containing the players that share their view with player
      \param initial the initial visibility of the map when starting the game.
      \param additionalEnemyJamming if > 0 run an WhatIf analysis and don't save the result
   */
  extern VisibilityStates calcvisibilityfield ( GameMap* gamemap, MapField* fld, int player, int add, int initial, int additionalEnemyJamming );

  
  // extern VisibilityStates fieldVisibility  ( tfield* pe, int player, GameMap* gamemap, int additionalEnemyJamming );
  extern int getPlayersWithSharedViewMask( int player, GameMap* gamemap );
  
  extern sigc::signal<void> buildingSeen;

  class RecalculateAreaView {
     MapCoordinate position;
     int range;
     GameMap* gamemap; 
     bool active;

     void removeFieldView( const MapCoordinate& pos );
     void addFieldView( const MapCoordinate& pos );
     const Context* context;
   public:
      RecalculateAreaView( GameMap* gamemap, const MapCoordinate& pos, int range, const Context* context );
      void removeView();
      void addView();
      ~RecalculateAreaView();
  };

#endif