diff --git a/qw/source/sv_ents.c b/qw/source/sv_ents.c index 591420d70..cfeb5d62f 100644 --- a/qw/source/sv_ents.c +++ b/qw/source/sv_ents.c @@ -99,7 +99,7 @@ SV_AddToFatPVS (vec3_t org, mnode_t *node) Calculates a PVS that is the inclusive or of all leafs within 8 pixels of the given point. */ -static byte * +static byte * SV_FatPVS (vec3_t org) { fatbytes = (sv.worldmodel->numleafs + 31) >> 3; @@ -457,12 +457,15 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte *pvs, if (cl->spectator) continue; - // ignore if not touching a PV leaf - for (i = 0; i < ent->num_leafs; i++) - if (pvs[ent->leafnums[i] >> 3] & (1 << (ent->leafnums[i] & 7))) - break; - if (i == ent->num_leafs) - continue; // not visible + if (pvs) { + // ignore if not touching a PV leaf + for (i = 0; i < ent->num_leafs; i++) + if (pvs[ent->leafnums[i] >> 3] + & (1 << (ent->leafnums[i] & 7))) + break; + if (i == ent->num_leafs) + continue; // not visible + } } pflags = PF_MSEC | PF_COMMAND; @@ -606,7 +609,7 @@ SV_WritePlayersToClient (client_t *client, edict_t *clent, byte *pvs, void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean recorder) { - byte *pvs; + byte *pvs = 0; int e, i, num_edicts, mpe_moaned = 0; int max_packet_entities = MAX_PACKET_ENTITIES; vec3_t org; @@ -620,11 +623,10 @@ SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean recorder) // find the client's PVS clent = client->edict; - pvs = 0; if (!recorder) { VectorAdd (SVvector (clent, origin), SVvector (clent, view_ofs), org); pvs = SV_FatPVS (org); - } else { + } else if (!sv_demoNoVis->int_val) { client_t *cl; max_packet_entities = MAX_DEMO_PACKET_ENTITIES; @@ -668,7 +670,7 @@ SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean recorder) || !*PR_GetString (&sv_pr_state, SVstring (ent, model))) continue; - if (!sv_demoNoVis->int_val || !recorder) { + if (pvs) { // ignore if not touching a PV leaf for (i = 0; i < ent->num_leafs; i++) if (pvs[ent->leafnums[i] >> 3] & (1 << (ent->leafnums[i] & 7))) diff --git a/qw/source/sv_send.c b/qw/source/sv_send.c index 427a63328..2e698e59c 100644 --- a/qw/source/sv_send.c +++ b/qw/source/sv_send.c @@ -829,11 +829,9 @@ SV_SendDemoMessage (void) if (!sv.demorecording) return; - if (sv_demoPings->value) { - if (sv.time - demo.pingtime > sv_demoPings->value) { - SV_DemoPings (); - demo.pingtime = sv.time; - } + if (sv_demoPings->value && sv.time - demo.pingtime > sv_demoPings->value) { + SV_DemoPings (); + demo.pingtime = sv.time; } @@ -866,7 +864,7 @@ SV_SendDemoMessage (void) msg.overflowed = false; for (i = 0, c = svs.clients; i < MAX_CLIENTS; i++, c++) { - if (c->state != cs_spawned) + if (c->state != cs_spawned && c->state != cs_server) continue; // datagrams only go to spawned if (c->spectator) @@ -914,6 +912,8 @@ SV_SendDemoMessage (void) demo.frames[demo.parsecount & DEMO_FRAMES_MASK].time = demo.time = sv.time; // that's a backup of 3sec in 20fps, should be enough + // FIXME make this framerate dependent. + // eg. sv_fps->int_val * sv_packetdelay->float_val if (demo.parsecount - demo.lastwritten > 60) { SV_DemoWritePackets (1); }