2 * Copyright (C) 2003-2010 Neverball authors
4 * NEVERBALL is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
17 #include "game_proxy.h"
21 static Queue cmd_queue;
24 * Enqueue SRC in the game's command queue.
26 void game_proxy_enq(const union cmd *src)
31 * Create the queue. This is done only once during the life time
32 * of the program. For simplicity's sake, the queue is never
37 cmd_queue = queue_new();
40 * Add a copy of the command to the end of the queue.
43 if ((dst = malloc(sizeof (*dst))))
46 queue_enq(cmd_queue, dst);
51 * Dequeue and return the head element in the game's command queue.
52 * The element must be freed after use.
54 union cmd *game_proxy_deq(void)
56 return cmd_queue ? queue_deq(cmd_queue) : NULL;
60 * Clear the entire queue.
62 void game_proxy_clr(void)
66 while ((cmdp = game_proxy_deq()))