int cl_max_lightstyle;
int cl_max_brushmodel_entities;
int cl_activedlights;
+int cl_activeeffects;
+int cl_activebeams;
entity_t *cl_entities;
entity_t *cl_csqcentities; //[515]: csqc
void CL_ClearState(void)
{
int i;
+ entity_t *ent;
if (cl_entities) Mem_Free(cl_entities);cl_entities = NULL;
if (cl_csqcentities) Mem_Free(cl_csqcentities);cl_csqcentities = NULL; //[515]: csqc
if (cl_brushmodel_entities) Mem_Free(cl_brushmodel_entities);cl_brushmodel_entities = NULL;
if (cl.entitydatabase) EntityFrame_FreeDatabase(cl.entitydatabase);cl.entitydatabase = NULL;
if (cl.entitydatabase4) EntityFrame4_FreeDatabase(cl.entitydatabase4);cl.entitydatabase4 = NULL;
+ if (cl.entitydatabaseqw) EntityFrameQW_FreeDatabase(cl.entitydatabaseqw);cl.entitydatabaseqw = NULL;
if (cl.scores) Mem_Free(cl.scores);cl.scores = NULL;
if (!sv.active)
// wipe the entire cl structure
memset (&cl, 0, sizeof(cl));
+
+ S_StopAllSounds();
+
// reset the view zoom interpolation
cl.mviewzoom[0] = cl.mviewzoom[1] = 1;
cl_max_lightstyle = MAX_LIGHTSTYLES;
cl_max_brushmodel_entities = MAX_EDICTS;
cl_activedlights = 0;
+ cl_activeeffects = 0;
+ cl_activebeams = 0;
cl_entities = (entity_t *)Mem_Alloc(cl_mempool, cl_max_entities * sizeof(entity_t));
cl_csqcentities = (entity_t *)Mem_Alloc(cl_mempool, cl_max_csqcentities * sizeof(entity_t)); //[515]: csqc
VectorSet(cl_playercrouchmaxs, 16, 16, 24);
}
+ // disable until we get textures for it
+ R_ResetSkyBox();
+
+ ent = &cl_entities[0];
+ // entire entity array was cleared, so just fill in a few fields
+ ent->state_current.active = true;
+ ent->render.model = cl.worldmodel = NULL; // no world model yet
+ ent->render.scale = 1; // some of the renderer still relies on scale
+ ent->render.alpha = 1;
+ ent->render.colormap = -1; // no special coloring
+ ent->render.flags = RENDER_SHADOW | RENDER_LIGHT;
+ Matrix4x4_CreateFromQuakeEntity(&ent->render.matrix, 0, 0, 0, 0, 0, 0, 1);
+ Matrix4x4_Invert_Simple(&ent->render.inversematrix, &ent->render.matrix);
+ CL_BoundingBoxForEntity(&ent->render);
+
+ // noclip is turned off at start
+ noclip_anglehack = false;
+
+ // mark all frames invalid for delta
+ memset(cl.qw_deltasequence, -1, sizeof(cl.qw_deltasequence));
+
CL_Screen_NewMap();
CL_Particles_Clear();
CL_CGVM_Clear();
if (cls.demorecording)
CL_Stop_f();
- // send clc_disconnect 3 times to improve chances of server receiving
- // it (but it still fails sometimes)
- Con_DPrint("Sending clc_disconnect\n");
+ // send disconnect message 3 times to improve chances of server
+ // receiving it (but it still fails sometimes)
memset(&buf, 0, sizeof(buf));
buf.data = bufdata;
buf.maxsize = sizeof(bufdata);
- MSG_WriteByte(&buf, clc_disconnect);
+ if (cls.protocol == PROTOCOL_QUAKEWORLD)
+ {
+ Con_DPrint("Sending drop command\n");
+ MSG_WriteByte(&buf, qw_clc_stringcmd);
+ MSG_WriteString(&buf, "drop");
+ }
+ else
+ {
+ Con_DPrint("Sending clc_disconnect\n");
+ MSG_WriteByte(&buf, clc_disconnect);
+ }
NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol);
NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol);
NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol);
e->frame = 0;
e->frame1time = cl.time;
e->frame2time = cl.time;
+ cl_activeeffects = max(cl_activeeffects, i + 1);
break;
}
}
VectorSet(flag->render.colormod, 1, 1, 1);
// attach the flag to the player matrix
Matrix4x4_CreateFromQuakeEntity(&flagmatrix, -f, -22, 0, 0, 0, -45, 1);
- Matrix4x4_Concat(&flag->render.matrix, &flagmatrix, &player->render.matrix);
+ Matrix4x4_Concat(&flag->render.matrix, &player->render.matrix, &flagmatrix);
Matrix4x4_Invert_Simple(&flag->render.inversematrix, &flag->render.matrix);
R_LerpAnimation(&flag->render);
CL_BoundingBoxForEntity(&flag->render);
entity_t *ent = &cl_entities[0];
cl_brushmodel_entities[cl_num_brushmodel_entities++] = 0;
// FIXME: this should be done at load
- Matrix4x4_CreateIdentity(&ent->render.matrix);
- Matrix4x4_CreateIdentity(&ent->render.inversematrix);
+ ent->render.matrix = identitymatrix;
+ ent->render.inversematrix = identitymatrix;
R_LerpAnimation(&ent->render);
CL_BoundingBoxForEntity(&ent->render);
ent->render.flags = RENDER_SHADOW;
return;
// cl_brushmodel_entities[cl_num_brushmodel_entities++] = 0;
// FIXME: this should be done at load
- Matrix4x4_CreateIdentity(&ent->render.matrix);
- Matrix4x4_CreateIdentity(&ent->render.inversematrix);
+ ent->render.matrix = identitymatrix;
+ ent->render.inversematrix = identitymatrix;
R_LerpAnimation(&ent->render);
CL_BoundingBoxForEntity(&ent->render);
ent->render.flags = RENDER_SHADOW;
entity_t *ent;
float frame;
- for (i = 0, e = cl_effects;i < cl_max_effects;i++, e++)
+ for (i = 0, e = cl_effects;i < cl_activeeffects;i++, e++)
{
if (e->active)
{
if (intframe < 0 || intframe >= e->endframe)
{
memset(e, 0, sizeof(*e));
+ while (cl_activeeffects > 0 && !cl_effects[cl_activeeffects - 1].active)
+ cl_activeeffects--;
continue;
}
float forward;
matrix4x4_t tempmatrix;
- for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
+ while (cl_activebeams > 0 && !cl_beams[cl_activebeams - 1].model)
+ cl_activeeffects--;
+ for (i = 0, b = cl_beams;i < cl_activebeams;i++, b++)
{
- if (!b->model || b->endtime < cl.time)
+ if (!b->model)
+ continue;
+ if (b->endtime < cl.time)
+ {
+ b->model = NULL;
continue;
+ }
// if coming from the player, update the start position
//if (b->entity == cl.viewentity)
r_refdef.time = cl.time;
r_refdef.extraupdate = !r_speeds.integer;
r_refdef.numentities = 0;
- Matrix4x4_CreateIdentity(&r_refdef.viewentitymatrix);
+ r_refdef.viewentitymatrix = identitymatrix;
cl_num_brushmodel_entities = 0;
if (cls.state == ca_connected && cls.signon == SIGNONS)
CL_RelinkStaticEntities();
CL_RelinkBeams();
CL_RelinkEffects();
+ CL_RelinkQWNails();
}
else
csqc_frame = true;