1 /** 2 * @file 3 */ 4 5 /* 6 Copyright (C) 2002-2013 UFO: Alien Invasion. 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 17 See the GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 23 */ 24 25 #pragma once 26 27 class dbuffer; 28 29 /** @brief CL_ParseEvent timers and vars */ 30 typedef struct eventTiming_s { 31 int nextTime; /**< time when the next event should be executed */ 32 int shootTime; /**< time when the shoot was fired */ 33 int impactTime; /**< time when the shoot hits the target. This is used to delay some events in case the 34 * projectile needs some time to reach its target. */ 35 bool parsedDeath; /**< extra delay caused by death - @sa @c impactTime */ 36 bool parsedShot; /** delay as caused by shot */ 37 } eventTiming_t; 38 39 /** 40 * @brief Struct that defines one particular event with all its callbacks and data. 41 */ 42 typedef struct eventRegister_s { 43 /** 44 * @brief The type of this event 45 */ 46 const event_t type; 47 /** 48 * @brief the name of this event (e.g. for logs) 49 */ 50 const char* name; 51 /** 52 * @brief The format string that is used to write and parse this event 53 */ 54 const char* formatString; 55 /** 56 * @brief Callback that is executing the event 57 * @param self A pointer to this struct 58 * @param msg The buffer with the event data 59 */ 60 void (*eventCallback)(const struct eventRegister_s* self, dbuffer* msg); 61 /** 62 * @brief Callback that is returning the time that is needed to execute this event 63 * @param self A pointer to this struct 64 * @param msg The buffer with the event data 65 * @param eventTiming The delta time value 66 */ 67 int (*timeCallback)(const struct eventRegister_s* self, dbuffer* msg, eventTiming_t* eventTiming); 68 69 /** 70 * @brief Called to determine if this event is ok to run at this point. Should check any 71 * conflicts with other ongoing events (see @c LE_LOCKED ). 72 * @return @c true if OK to run, @c false if not. 73 */ 74 bool (*eventCheck)(const struct eventRegister_s* self, const dbuffer* msg); 75 } eventRegister_t; 76 77 const eventRegister_t* CL_GetEvent(const event_t eType); 78 int CL_GetNextTime(const eventRegister_t* event, eventTiming_t* eventTiming, int nextTime); 79 int CL_GetStepTime(const eventTiming_t* eventTiming, const le_t* le, int step); 80 const char* CL_ConvertSoundFromEvent(char* sound, size_t size); 81