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

« back to all changes in this revision

Viewing changes to src/maptile.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:
22
22
#include <stdlib.h>
23
23
#include <iostream>
24
24
#include "tileset.h"
 
25
#include "MapBackpack.h"
25
26
 
26
27
Maptile::Maptile(Tileset* tileSet, int x, int y, Uint32 type, TileStyle *tileStyle)
27
28
    :d_index(type), d_building(NONE) 
28
29
{
29
30
    d_tileSet = tileSet;
30
31
    d_tileStyle = tileStyle;
 
32
    d_backpack = new MapBackpack(Vector<int>(x,y));
31
33
}
32
34
 
33
35
Maptile::Maptile(Tileset* tileSet, int x, int y, Tile::Type type, TileStyle *tileStyle)
47
49
      }
48
50
    if (found == false)
49
51
      d_index = 0;
 
52
    d_backpack = new MapBackpack(Vector<int>(x,y));
50
53
}
51
54
 
52
55
Maptile::~Maptile()
53
56
{
54
 
    while (!d_items.empty())
55
 
    {
56
 
        delete (*d_items.begin());
57
 
        d_items.erase(d_items.begin());
58
 
    }
 
57
    delete d_backpack;
59
58
}
60
59
 
61
60
Uint32 Maptile::getMoves() const
83
82
    std::cerr << "MAPTILE: building = " << d_building << std::endl;
84
83
}    
85
84
 
86
 
void Maptile::addItem(Item* item, int position)
87
 
{
88
 
    if (position < 0)
89
 
    {
90
 
        d_items.push_back(item);
91
 
        return;
92
 
    }
93
 
 
94
 
    std::list<Item*>::iterator it;
95
 
    for (it = d_items.begin(); position > 0; position--, it++)
96
 
      ;
97
 
    d_items.insert(it, item);
98
 
}
99
 
 
100
 
void Maptile::removeItem(Item* item)
101
 
{
102
 
    std::list<Item*>::iterator it;
103
 
    for (it = d_items.begin(); it != d_items.end(); it++)
104
 
        if ((*it) == item)
105
 
        {
106
 
            d_items.erase(it);
107
 
            return;
108
 
        }
109
 
}
110
 
 
111
 
std::list<Item*> Maptile::getItems() const
112
 
{
113
 
    return d_items;
114
 
}
115
 
 
116
85
bool Maptile::isCityTerrain()
117
86
{
118
87
  if (getBuilding() != Maptile::CITY || getBuilding() != Maptile::RUIN ||