The list events handled simple switch block
170 | 6. |
|
---|
|
---|
Creating Client Events 171
That was nothing! I didn’t even break a sweat typing that, how about
you? Here, the list of events is handled in a simple switch block. And
as all good C programmers know, to add a new bit of code to a switch,
you use the case keyword. Here, you add a case for EV_LIGHTNINGARC,
which will call the new function CG_LightningArc, passing in two
para-meters. The first is position, which is a vector passed into
CG_EntityEvent, representing the location of the event, in its starting
place. The second parameter is es->origin2. es is a variable set at
the top of CG_EntityEvent, which points to cent->currentState. So
what is cent, you ask? cent is actually the other variable passed
into
CG_EntityEvent, and it is of type centity_t. Let’s take a look at what
that type of variable is.
The struct centity_t is declared at line 149 in cg_local.h:
qboolean currentValid; holds this entity
// true if cg.frame