UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
e_parse.cpp File Reference
#include "../../client.h"
#include "e_parse.h"
#include "e_main.h"
#include "../cl_localentity.h"
#include "../../cgame/cl_game.h"

Go to the source code of this file.

Data Structures

struct  evTimes_s
 

Typedefs

typedef struct evTimes_s evTimes_t
 

Functions

static void CL_LogEvent (const eventRegister_t *eventData)
 
void CL_BlockBattlescapeEvents (bool block)
 Adds the ability to block battlescape event execution until something other is finished. E.g. camera movement. More...
 
static bool CL_AreBattlescapeEventsBlocked (void)
 
static bool CL_CheckBattlescapeEvent (int now, void *data)
 Checks if a given battlescape event is ok to run now. Uses the check_func pointer in the event struct. More...
 
static void CL_NotifyBattlescapeEventDelay (int now, void *data, int delay)
 If we delayed the battlescape events due to event locking (e.g. le is locked or camera is locked), we have to advance the time for new events, too. Otherwise they might be scheduled before the just delayed events. More...
 
static bool CL_DelayBattlescapeEvent (int now, void *data)
 Checks if a given battlescape event should get delayed. More...
 
static void CL_ExecuteBattlescapeEvent (int now, void *data)
 
static void CL_FreeBattlescapeEvent (void *data)
 
static bool CL_FilterBattlescapeEvents (int when, event_func *func, event_check_func *check, void *data)
 
int CL_ClearBattlescapeEvents (void)
 
static int CL_GetEventTime (const event_t eType, dbuffer *msg, eventTiming_t *eventTiming)
 Calculates the time the event should get executed. If two events return the same time, they are going to be executed in the order the were parsed. More...
 
event_t CL_ParseEvent (dbuffer *msg)
 Called in case a svc_event was send via the network buffer. More...
 

Variables

cvar_tcl_log_battlescape_events
 

Detailed Description

Event format identifiers

id | type | length (bytes)

c | char | 1 b | byte | 1 s | short | 2 l | long | 4 p | pos | 6 (map boundaries - (-MAX_WORLD_WIDTH) - (MAX_WORLD_WIDTH)) g | gpos | 3 d | dir | 1 a | angle | 1 & | string | x ! | do not read the next id | 1

  • | pascal string type - SIZE+DATA, SIZE can be read from va_arg | 2 + sizeof(DATA)

Definition in file e_parse.cpp.

Typedef Documentation

typedef struct evTimes_s evTimes_t

Function Documentation

static bool CL_AreBattlescapeEventsBlocked ( void  )
static
Returns
if the client interrupts the event execution, this is true

Definition at line 95 of file e_parse.cpp.

References cl, and clientBattleScape_s::eventsBlocked.

Referenced by CL_CheckBattlescapeEvent(), and CL_DelayBattlescapeEvent().

void CL_BlockBattlescapeEvents ( bool  block)

Adds the ability to block battlescape event execution until something other is finished. E.g. camera movement.

Parameters
blocktrue to block the execution of other events until you unblock the event execution again, false to unblock the event execution.

Definition at line 83 of file e_parse.cpp.

References cl, Com_DPrintf(), DEBUG_EVENTSYS, and clientBattleScape_s::eventsBlocked.

Referenced by CL_CameraMove(), CL_CameraRoute(), and CL_ClearBattlescapeEvents().

static bool CL_CheckBattlescapeEvent ( int  now,
void data 
)
static

Checks if a given battlescape event is ok to run now. Uses the check_func pointer in the event struct.

Parameters
nowThe current time.
dataThe event to check.
Returns
true if it's ok to run or there is no check function, false otherwise.

Definition at line 107 of file e_parse.cpp.

References CL_AreBattlescapeEventsBlocked(), CL_GetEvent(), and eventRegister_s::eventCheck.

Referenced by CL_ParseEvent().

int CL_ClearBattlescapeEvents ( void  )
static bool CL_DelayBattlescapeEvent ( int  now,
void data 
)
static

Checks if a given battlescape event should get delayed.

Parameters
nowThe current time.
dataEvent structure pointer

Definition at line 156 of file e_parse.cpp.

References CL_AreBattlescapeEventsBlocked(), CL_GetEvent(), Com_DPrintf(), DEBUG_EVENTSYS, and eventRegister_s::name.

Referenced by CL_ParseEvent().

static void CL_ExecuteBattlescapeEvent ( int  now,
void data 
)
static
static bool CL_FilterBattlescapeEvents ( int  when,
event_func func,
event_check_func check,
void data 
)
static
Returns
true to keep the event, false to remove it from the queue

Definition at line 204 of file e_parse.cpp.

References CL_ExecuteBattlescapeEvent(), CL_GetEvent(), Com_Printf(), and eventRegister_s::name.

Referenced by CL_ClearBattlescapeEvents().

static void CL_FreeBattlescapeEvent ( void data)
static

Definition at line 194 of file e_parse.cpp.

References Mem_Free, and evTimes_s::msg.

Referenced by CL_ParseEvent().

static int CL_GetEventTime ( const event_t  eType,
dbuffer msg,
eventTiming_t eventTiming 
)
static

Calculates the time the event should get executed. If two events return the same time, they are going to be executed in the order the were parsed.

Parameters
[in]eTypeThe event type
[in,out]msgThe message buffer that can be modified to get the event time
[in,out]eventTimingThe delay data for the events
Returns
the time (in milliseconds) the event should be executed. This value is used to sort the event chain to determine which event must be executed at first. This value also ensures, that the events are executed in the correct order. E.g. impactTime is used to delay some events in case the projectile needs some time to reach its target.

Definition at line 234 of file e_parse.cpp.

References cl, CL_GetEvent(), Com_DPrintf(), DEBUG_EVENTSYS, eventTiming_s::impactTime, eventRegister_s::name, eventTiming_s::nextTime, eventTiming_s::shootTime, clientBattleScape_s::time, and eventRegister_s::timeCallback.

Referenced by CL_ParseEvent().

static void CL_NotifyBattlescapeEventDelay ( int  now,
void data,
int  delay 
)
static

If we delayed the battlescape events due to event locking (e.g. le is locked or camera is locked), we have to advance the time for new events, too. Otherwise they might be scheduled before the just delayed events.

Parameters
[in]now
[in]dataThe userdata that is passed to the function callback. In our case this is the eventTiming_t data
[in]delayThe milliseconds that the battlescape events were delayed and that we have to use to advance the eventTiming_t values.

Definition at line 131 of file e_parse.cpp.

References i, eventTiming_s::impactTime, leStep_s::lastMoveTime, LE_GetNextInUse(), LE_IsLivingActor(), leStep_s::next, eventTiming_s::nextTime, eventTiming_s::shootTime, le_s::stepIndex, and le_s::stepList.

Referenced by CL_ParseEvent().

Variable Documentation

cvar_t* cl_log_battlescape_events

Definition at line 47 of file e_parse.cpp.

Referenced by CL_InitLocal().