Pyrogenesis  trunk
ICmpCommandQueue.h
Go to the documentation of this file.
1 /* Copyright (C) 2010 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_ICMPCOMMANDQUEUE
19 #define INCLUDED_ICMPCOMMANDQUEUE
20 
22 
24 
25 /**
26  * Command queue, for sending orders to entities.
27  * Each command is associated with a player ID (who triggered the command, in some sense)
28  * and an arbitrary script value.
29  *
30  * Commands can be added to the local queue at any time, and will all be executed at the start
31  * of the next turn. (This will typically be used by AI scripts.)
32  *
33  * Alternatively, commands can be sent to the networking system, and they will be executed
34  * at the start of some later turn by all players simultaneously. (This will typically be
35  * used for user inputs.)
36  */
38 {
39 public:
40  /**
41  * Pushes a new command onto the local queue. @p cmd does not need to be rooted.
42  */
43  virtual void PushLocalCommand(player_id_t player, JS::HandleValue cmd) = 0;
44 
45  /**
46  * Send a command associated with the current player to the networking system.
47  */
48  virtual void PostNetworkCommand(JS::HandleValue cmd) = 0;
49 
50  /**
51  * Calls the ProcessCommand(player, cmd) global script function for each command in the
52  * local queue and in @p commands, and empties the local queue.
53  */
54  virtual void FlushTurn(const std::vector<SimulationCommand>& commands) = 0;
55 
56  DECLARE_INTERFACE_TYPE(CommandQueue)
57 };
58 
59 #endif // INCLUDED_ICMPCOMMANDQUEUE
Definition: IComponent.h:33
virtual void FlushTurn(const std::vector< SimulationCommand > &commands)=0
Calls the ProcessCommand(player, cmd) global script function for each command in the local queue and ...
virtual void PostNetworkCommand(JS::HandleValue cmd)=0
Send a command associated with the current player to the networking system.
int32_t player_id_t
valid player IDs are non-negative (see ICmpOwnership)
Definition: Player.h:24
Command queue, for sending orders to entities.
Definition: ICmpCommandQueue.h:37
#define DECLARE_INTERFACE_TYPE(iname)
Definition: Interface.h:23
virtual void PushLocalCommand(player_id_t player, JS::HandleValue cmd)=0
Pushes a new command onto the local queue.