Code Section Question


(dvldrmmr) #1

I have a quick question about this code section:

// broadcast the death event to everyone
ent = G_TempEntity( self->r.currentOrigin, EV_OBITUARY );
ent->s.eventParm = meansOfDeath;
ent->s.otherEntityNum = self->s.number;
ent->s.otherEntityNum2 = killer;
ent->r.svFlags = SVF_BROADCAST;	// send to everyone

It’s in g_combat.c, function player_die. I know what the code is doing (sending a death msg, duh), but my question is when is it sent to the client? Is it sent immediately by the last line?

ent->r.svFlags = SVF_BROADCAST

Any help appreciated.


(SCDS_reyalP) #2

It is sent on the next snapshot, like everything else. Perhaps that wasn’t what you were asking ?

Remember that the engine itself has direct access to the entity array, and takes care of that sort of thing, after G_RunFrame.

I assume SVF_BROADCAST just does what the comment says :smiley:


(dvldrmmr) #3

It is sent on the next snapshot, like everything else.

That explains it lol.

Remember that the engine itself has direct access to the entity array, and takes care of that sort of thing, after G_RunFrame

Ah G_RunFrame. Hadn’t looked there… Thanks.


(SCDS_reyalP) #4

It is worth looking through g_main.c:vmMain to get an idea of the overall flow of things.
GAME_CLIENT_THINK handles client usercommands (which come in at a variable rate, depending on network, client settings, and FPS). This is responsible for most of the things clients do (like moving and shooting)
GAME_RUN_FRAME runs sv_fps times per second. It runs the non player entities (movers, missiles etc) as well as tidying up the clients next set of snapshots, and various other periodic things.
GAME_CLIENT_COMMAND handles commands from clients (like vsays, /callvote, /players)

A look through q_shared.h g_public.h and g_local.h is also a good idea.


(dvldrmmr) #5

I’ve looked through the header files, but never really looked at g_main.c very indepth. Thanks for the info!!