1 // Copyright (C) 2004 John Farrell
2 //
3 //  This program is free software; you can redistribute it and/or modify
4 //  it under the terms of the GNU General Public License as published by
5 //  the Free Software Foundation; either version 3 of the License, or
6 //  (at your option) any later version.
7 //
8 //  This program is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 //  GNU Library General Public License for more details.
12 //
13 //  You should have received a copy of the GNU General Public License
14 //  along with this program; if not, write to the Free Software
15 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 //  02110-1301, USA.
17 
18 #include "AICityInfo.h"
19 #include "Threatlist.h"
20 #include "Threat.h"
21 #include "city.h"
22 
23 //#define debug(x) {std::cerr<<__FILE__<<": "<<__LINE__<<": "<<x<<std::flush<<std::endl;}
24 #define debug(x)
25 
AICityInfo(City * c)26 AICityInfo::AICityInfo(City *c)
27     :d_danger(0), d_reinforcements(0), d_city(c)
28 {
29     d_threats = new Threatlist();
30     d_num_defenders = d_city->countDefenders();
31 }
32 
~AICityInfo()33 AICityInfo::~AICityInfo()
34 {
35     // the threats in the threatlist do not belong to us
36     d_threats->clear();
37     delete d_threats;
38 }
39 
addThreat(float dangerFromThisThreat,Threat * threat)40 void AICityInfo::addThreat(float dangerFromThisThreat, Threat *threat)
41 {
42     this->d_danger += dangerFromThisThreat;
43     this->d_threats->push_back(threat);
44 }
45 
46