Advanced Strategic Command
contextutils.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Advanced Strategic Command; http://www.asc-hq.org
3  Copyright (C) 1994-2010 Martin Bickel
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; see the file COPYING. If not, write to the
17  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  Boston, MA 02111-1307 USA
19 */
20 
21 #include "contextutils.h"
22 #include "gamemap.h"
23 
24 
26 {
27  Context context;
28 
29  context.gamemap = gamemap;
30  context.actingPlayer = &gamemap->getPlayer( gamemap->actplayer );
31  context.parentAction = NULL;
32  context.display = &getDefaultMapDisplay();
33  context.viewingPlayer = gamemap->getPlayerView();
34  context.actionContainer = &gamemap->actions;
35  return context;
36 }
37 
39  : repDisplay( &getDefaultMapDisplay() )
40 {
41  context.display= &repDisplay;
42  context.gamemap = gamemap;
43  context.actingPlayer = &gamemap->getPlayer( gamemap->actplayer );
44  context.parentAction = NULL;
45  context.viewingPlayer = gamemap->getPlayerView();
46  context.actionContainer = &gamemap->actions;
47 }
48 
50  return context;
51 }
Context & getContext()
Player * actingPlayer
Definition: context.h:37
Player & getPlayer(PlayerID p)
Definition: gamemap.h:257
MapDisplayInterface & getDefaultMapDisplay()
Context createContext(GameMap *gamemap)
int getPlayerView() const
the player which is currently viewing the map.
Definition: gamemap.cpp:1007
ReplayContext(GameMap *gamemap)
GameAction * parentAction
Definition: context.h:38
Definition of THE central asc class: GameMap.
int viewingPlayer
Definition: context.h:40
signed char actplayer
the player who is currently making his moves (may be human or AI)
Definition: gamemap.h:232
MapDisplayInterface * display
Definition: context.h:39
GameMap * gamemap
Definition: context.h:36
ActionContainer * actionContainer
Definition: context.h:41
ActionContainer actions
Records all action that have been done for undo/redo purposes.
Definition: gamemap.h:390
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182