LCOV - code coverage report
Current view: top level - source/simulation2/components - ICmpCommandQueue.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 2 2 100.0 %
Date: 2023-01-19 00:18:29 Functions: 3 4 75.0 %

          Line data    Source code
       1             : /* Copyright (C) 2020 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             : 
      21             : #include "simulation2/system/Interface.h"
      22             : 
      23             : #include "simulation2/helpers/SimulationCommand.h"
      24             : 
      25             : #include <vector>
      26             : 
      27             : /**
      28             :  * Command queue, for sending orders to entities.
      29             :  * Each command is associated with a player ID (who triggered the command, in some sense)
      30             :  * and an arbitrary script value.
      31             :  *
      32             :  * Commands can be added to the local queue at any time, and will all be executed at the start
      33             :  * of the next turn. (This will typically be used by AI scripts.)
      34             :  *
      35             :  * Alternatively, commands can be sent to the networking system, and they will be executed
      36             :  * at the start of some later turn by all players simultaneously. (This will typically be
      37             :  * used for user inputs.)
      38             :  */
      39          12 : class ICmpCommandQueue : public IComponent
      40             : {
      41             : public:
      42             :     /**
      43             :      * Pushes a new command onto the local queue. @p cmd does not need to be rooted.
      44             :      */
      45             :     virtual void PushLocalCommand(player_id_t player, JS::HandleValue cmd) = 0;
      46             : 
      47             :     /**
      48             :      * Send a command associated with the current player to the networking system.
      49             :      */
      50             :     virtual void PostNetworkCommand(JS::HandleValue cmd) = 0;
      51             : 
      52             :     /**
      53             :      * Calls the ProcessCommand(player, cmd) global script function for each command in the
      54             :      * local queue and in @p commands, and empties the local queue.
      55             :      */
      56             :     virtual void FlushTurn(const std::vector<SimulationCommand>& commands) = 0;
      57             : 
      58         117 :     DECLARE_INTERFACE_TYPE(CommandQueue)
      59             : };
      60             : 
      61             : #endif // INCLUDED_ICMPCOMMANDQUEUE

Generated by: LCOV version 1.13