~ubuntu-branches/ubuntu/saucy/lordsawar/saucy

« back to all changes in this revision

Viewing changes to src/FogMap.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Barry deFreese
  • Date: 2008-12-20 13:52:12 UTC
  • mfrom: (1.1.6 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20081220135212-noeb2w3y98ebo7o9
Tags: 0.1.4-1
[ Barry deFreese ]
* New upstream release.
* Move 0.0.8-2.1 changelog entry to correct point in changelog.
* Make lordsawar-data suggest lordsawar.
* Update my e-mail address.
* Add build-depends on intltool, uuid-dev, and libboost-dev.
* Don't install locales since there are no translations currently.
* Add simple man page for new lordsawar-pbm binary.
* Drop gcc4.3 patches as they have been fixed upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include <sstream>
20
20
 
21
21
#include "FogMap.h"
 
22
#include "SightMap.h"
22
23
 
23
24
#include "playerlist.h"
24
25
#include "xmlhelper.h"
25
26
#include "GameScenarioOptions.h"
26
27
 
 
28
std::string FogMap::d_tag = "fogmap";
 
29
 
27
30
using namespace std;
28
31
 
29
32
//#define debug(x) {std::cerr<<__FILE__<<": "<<__LINE__<<": "<<x<<std::endl<<flush;}
95
98
{
96
99
    bool retval = true;
97
100
 
98
 
    retval &= helper->openTag("fogmap");
 
101
    retval &= helper->openTag(FogMap::d_tag);
99
102
    retval &= helper->saveData("width", d_width);
100
103
    retval &= helper->saveData("height", d_height);
101
104
 
123
126
 
124
127
void FogMap::alterFogRadius(Vector<int> pt, int radius, FogType new_type)
125
128
{
 
129
    // this doesn't draw a circle, it draws a square
 
130
    // it isn't a bug, except for being badly named
126
131
    int x = pt.x - radius;
127
132
    int y = pt.y - radius;
128
133
    int size = 2 * radius + 1;
152
157
    }
153
158
}
154
159
 
 
160
bool FogMap::isCompletelyObscuredFogTile(Vector<int> pos)
 
161
{
 
162
  bool foggyTile;
 
163
  for (int i = pos.x - 1; i <= pos.x + 1; i++)
 
164
    for (int j = pos.y - 1; j <= pos.y + 1; j++)
 
165
      {
 
166
        foggyTile = false;
 
167
        if (i == pos.x && j == pos.y)
 
168
          continue;
 
169
        if (i < 0 || j < 0 || 
 
170
            i >= FogMap::getWidth() || j >= FogMap::getHeight())
 
171
          foggyTile = true;
 
172
        else
 
173
          {
 
174
            Vector<int> pos = Vector<int>(i, j);
 
175
            foggyTile = FogMap::isFogged(pos, Playerlist::getActiveplayer());
 
176
          }
 
177
        if (foggyTile == false)
 
178
          return false;
 
179
      }
 
180
  return true;
 
181
}
 
182
 
155
183
bool FogMap::isLoneFogTile(Vector<int> pos)
156
184
{
157
185
  bool west_open = false;
193
221
    }
194
222
}
195
223
 
196
 
bool FogMap::isFogged(Vector <int> pos)
 
224
bool FogMap::isFogged(Vector <int> pos, Player *player)
197
225
{
198
226
  //is this tile visible, or not?
199
 
  FogMap *fogmap = Playerlist::getActiveplayer()->getFogMap();
 
227
  FogMap *fogmap = player->getFogMap();
200
228
  if (fogmap->getFogTile(pos) == FogMap::CLOSED)
201
229
    return true;
202
 
  if (Playerlist::getActiveplayer())
203
 
    if (Playerlist::getActiveplayer()->getType() != Player::HUMAN &&
 
230
  if (player)
 
231
    if (player->getType() != Player::HUMAN &&
204
232
        GameScenarioOptions::s_hidden_map == true)
205
233
      return true;
206
234
                
209
237
 
210
238
  return false;
211
239
}
 
240
 
 
241
void FogMap::alterFog(SightMap *sightmap)
 
242
{
 
243
  return alterFogRectangle(sightmap->pos, sightmap->h, sightmap->w, OPEN);
 
244
}
212
245
// End of file