1 /******************************************************************************
2  *  Warmux is a convivial mass murder game.
3  *  Copyright (C) 2001-2011 Warmux Team.
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18  ******************************************************************************
19  * Macros to manage teams.
20  *****************************************************************************/
21 
22 #ifndef TEAM_MACRO_H
23 #define TEAM_MACRO_H
24 //-----------------------------------------------------------------------------
25 #include "team/teams_list.h"
26 //-----------------------------------------------------------------------------
27 
28 // Boucle pour chaque team
29 #define FOR_EACH_TEAM(team) \
30   for (TeamsList::iterator team=GetTeamsList().playing_list.begin(), \
31        end_of_each_team = GetTeamsList().playing_list.end(); \
32        team != end_of_each_team; \
33        ++team)
34 
35 #define FOR_EACH_LIVING_AND_DEAD_CHARACTER(team, character) \
36   for (Team::iterator character = (*(team)).begin(), \
37        end_character = (*(team)).end(); \
38        character != end_character; \
39        ++character) \
40 
41 #define FOR_EACH_CHARACTER(team,character) \
42   FOR_EACH_LIVING_AND_DEAD_CHARACTER(team,character) \
43           if (!character -> IsGhost())
44 
45 #define FOR_EACH_LIVING_CHARACTER(team,character)    \
46   FOR_EACH_LIVING_AND_DEAD_CHARACTER(team,character) \
47           if (!character -> IsDead())
48 
49 #define FOR_ALL_LIVING_AND_DEAD_CHARACTER(team, character) \
50   FOR_EACH_TEAM(team) \
51   FOR_EACH_LIVING_AND_DEAD_CHARACTER(*team,character)
52 
53 #define FOR_ALL_CHARACTERS(team,character) \
54   FOR_EACH_TEAM(team) \
55           FOR_EACH_CHARACTER(*team,character)
56 
57 #define FOR_ALL_LIVING_CHARACTERS(team,character) \
58   FOR_EACH_TEAM(team) \
59   FOR_EACH_LIVING_CHARACTER(*team,character)
60 
61 #define FOR_ALL_LIVING_ENEMIES(shooter,team,character)        \
62   FOR_EACH_TEAM(team)                                        \
63     if (!(*team)->IsSameAs(shooter.GetTeam()))        \
64       FOR_EACH_LIVING_CHARACTER(*team,character)
65 
66 //-----------------------------------------------------------------------------
67 #endif
68