1 // Copyright (C) 2004 John Farrell
2 // Copyright (C) 2004, 2005 Ulf Lorenz
3 // Copyright (C) 2004, 2006 Andrea Paternesi
4 // Copyright (C) 2007, 2009 Ben Asselstine
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Library General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
35 class Threatlist : public std::list<Threat*>
39 //! Default Constructor.
46 // Methods that operate on class data and modify the class.
48 //! Add a ruin as a threat
49 void addRuin(Ruin *ruin);
51 //! Adds a stack as a threat.
53 * If other threats posed by the owner of the stack are close by, they
54 * are merged to a single threat.
56 void addStack(Stack *stack);
58 //! Searches through the threat list and deletes the stack
59 void deleteStack(Stack* s);
61 //! deletes the stack in the threat list that has the given id.
62 void deleteStack(guint32 id);
64 // how much danger does this set of threats pose to the given city?
65 void findThreats(AICityInfo *info) const;
67 //! sort into a list of most dangerous first
70 //! sort into list by closest first
71 void sortByDistance(Vector<int> pos);
73 //! sort into a list with value divded by distance.
74 void sortByDistanceAndValue(Vector<int> pos);
76 //! Behaves like std::list::clear(), but frees pointers as well
79 //! Behaves like std::list::erase(), but frees pointers as well
80 iterator flErase(iterator object);
82 //! Behaves like std::list::remove(), but frees pointers as well
83 bool flRemove(Threat* object);
85 // Methods that operate on class data but do not modify the class
87 //! return some debugging information
88 string toString() const;
90 void changeOwnership(Player *old_owner, Player *new_owner);
94 static bool compareValue(const Threat *lhs, const Threat *rhs);
97 #endif // THREATLIST_H