// we need to declare some mouse variables here, because the menu system
// references them even when on a unix system.
-// these two are not intended to be set directly
-cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player"};
-cvar_t cl_color = {CVAR_SAVE, "_cl_color", "0"};
-cvar_t cl_pmodel = {CVAR_SAVE, "_cl_pmodel", "0"};
-
cvar_t cl_shownet = {0, "cl_shownet","0"};
cvar_t cl_nolerp = {0, "cl_nolerp", "0"};
cvar_t cl_noplayershadow = {CVAR_SAVE, "cl_noplayershadow", "0"};
-mempool_t *cl_scores_mempool;
mempool_t *cl_refdef_mempool;
mempool_t *cl_entities_mempool;
if (!sv.active)
Host_ClearMemory ();
- Mem_EmptyPool(cl_scores_mempool);
Mem_EmptyPool(cl_entities_mempool);
// wipe the entire cl structure
This is also called on Host_Error, so it shouldn't cause any errors
=====================
*/
-void CL_Disconnect (void)
+void CL_Disconnect(void)
{
if (cls.state == ca_dedicated)
return;
cl.worldmodel = NULL;
if (cls.demoplayback)
- CL_StopPlayback ();
- else if (cls.state == ca_connected)
+ CL_StopPlayback();
+ else if (cls.netcon)
{
if (cls.demorecording)
- CL_Stop_f ();
-
- Con_DPrintf ("Sending clc_disconnect\n");
- SZ_Clear (&cls.message);
- MSG_WriteByte (&cls.message, clc_disconnect);
- NET_SendUnreliableMessage (cls.netcon, &cls.message);
- SZ_Clear (&cls.message);
- NET_Close (cls.netcon);
- cls.state = ca_disconnected; // prevent this code from executing again during Host_ShutdownServer
+ CL_Stop_f();
+
+ Con_DPrintf("Sending clc_disconnect\n");
+ SZ_Clear(&cls.message);
+ MSG_WriteByte(&cls.message, clc_disconnect);
+ NetConn_SendUnreliableMessage(cls.netcon, &cls.message);
+ SZ_Clear(&cls.message);
+ NetConn_Close(cls.netcon);
+ cls.netcon = NULL;
// if running a local server, shut it down
if (sv.active)
+ {
+ // prevent this code from executing again during Host_ShutdownServer
+ cls.state = ca_disconnected;
Host_ShutdownServer(false);
+ }
}
cls.state = ca_disconnected;
=====================
CL_EstablishConnection
-Host should be either "local" or a net address to be passed on
+Host should be either "local" or a net address
=====================
*/
-void CL_EstablishConnection (char *host)
+void CL_EstablishConnection(const char *host)
{
if (cls.state == ca_dedicated)
return;
- if (cls.demoplayback)
- return;
+ // clear menu's connect error message
+ m_return_reason[0] = 0;
- CL_Disconnect ();
+ // stop demo loop in case this fails
+ cls.demonum = -1;
+ CL_Disconnect();
- cls.netcon = NET_Connect (host);
- if (!cls.netcon)
- Host_Error ("CL_Connect: connect failed\n");
- Con_DPrintf ("CL_EstablishConnection: connected to %s\n", host);
-
- cls.demonum = -1; // not in the demo loop now
- cls.state = ca_connected;
- cls.signon = 0; // need all the signon messages before playing
-
- CL_ClearState ();
+ if (LHNETADDRESS_FromString(&cls.connect_address, host, 26000) && (cls.connect_mysocket = NetConn_ChooseClientSocketForAddress(&cls.connect_address)))
+ {
+ cls.connect_trying = true;
+ cls.connect_remainingtries = 3;
+ cls.connect_nextsendtime = 0;
+ if (sv.active)
+ {
+ NetConn_ClientFrame();
+ NetConn_ServerFrame();
+ NetConn_ClientFrame();
+ NetConn_ServerFrame();
+ NetConn_ClientFrame();
+ NetConn_ServerFrame();
+ NetConn_ClientFrame();
+ NetConn_ServerFrame();
+ }
+ }
}
/*
//Con_Printf("dlight %i : %f %f %f : %f %f %f\n", i, org[0], org[1], org[2], red * radius, green * radius, blue * radius);
memset (dl, 0, sizeof(*dl));
dl->ent = ent;
- Mod_FindNonSolidLocation(org, dl->origin, cl.worldmodel, 6);
+ cl.worldmodel->FindNonSolidLocation(cl.worldmodel, org, dl->origin, 6);
//VectorCopy(org, dl->origin);
dl->radius = radius;
dl->color[0] = red;
rmeshstate_t m;
vec3_t beamdir, right, up, offset;
float length, t1, t2;
- memset(&m, 0, sizeof(m));
- m.blendfunc1 = GL_SRC_ALPHA;
- m.blendfunc2 = GL_ONE;
- if (r_lightningbeam_qmbtexture.integer && r_lightningbeamqmbtexture == NULL)
- r_lightningbeams_setupqmbtexture();
- if (!r_lightningbeam_qmbtexture.integer && r_lightningbeamtexture == NULL)
- r_lightningbeams_setuptexture();
- if (r_lightningbeam_qmbtexture.integer)
- m.tex[0] = R_GetTexture(r_lightningbeamqmbtexture);
- else
- m.tex[0] = R_GetTexture(r_lightningbeamtexture);
- R_Mesh_State(&m);
+
R_Mesh_Matrix(&r_identitymatrix);
// calculate beam direction (beamdir) vector and beam length
// (and realize that the whole polygon assembly orients itself to face
// the viewer)
- R_Mesh_GetSpace(12);
+ memset(&m, 0, sizeof(m));
+ if (r_lightningbeam_qmbtexture.integer)
+ m.tex[0] = R_GetTexture(r_lightningbeamqmbtexture);
+ else
+ m.tex[0] = R_GetTexture(r_lightningbeamtexture);
+ m.pointer_texcoord[0] = varray_texcoord2f[0];
+ R_Mesh_State_Texture(&m);
+
+ GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
+ GL_DepthMask(false);
+ GL_DepthTest(true);
+ if (r_lightningbeam_qmbtexture.integer && r_lightningbeamqmbtexture == NULL)
+ r_lightningbeams_setupqmbtexture();
+ if (!r_lightningbeam_qmbtexture.integer && r_lightningbeamtexture == NULL)
+ r_lightningbeams_setuptexture();
// polygon 1, verts 0-3
VectorScale(right, r_lightningbeam_thickness.value, offset);
- R_CalcLightningBeamPolygonVertex3f(varray_vertex3f, b->start, b->end, offset);
- R_CalcLightningBeamPolygonTexCoord2f(varray_texcoord2f[0], t1, t2);
-
+ R_CalcLightningBeamPolygonVertex3f(varray_vertex3f + 0, b->start, b->end, offset);
// polygon 2, verts 4-7
VectorAdd(right, up, offset);
VectorScale(offset, r_lightningbeam_thickness.value * 0.70710681f, offset);
R_CalcLightningBeamPolygonVertex3f(varray_vertex3f + 12, b->start, b->end, offset);
- R_CalcLightningBeamPolygonTexCoord2f(varray_texcoord2f[0] + 8, t1 + 0.33, t2 + 0.33);
-
// polygon 3, verts 8-11
VectorSubtract(right, up, offset);
VectorScale(offset, r_lightningbeam_thickness.value * 0.70710681f, offset);
R_CalcLightningBeamPolygonVertex3f(varray_vertex3f + 24, b->start, b->end, offset);
+ R_CalcLightningBeamPolygonTexCoord2f(varray_texcoord2f[0] + 0, t1, t2);
+ R_CalcLightningBeamPolygonTexCoord2f(varray_texcoord2f[0] + 8, t1 + 0.33, t2 + 0.33);
R_CalcLightningBeamPolygonTexCoord2f(varray_texcoord2f[0] + 16, t1 + 0.66, t2 + 0.66);
+ GL_VertexPointer(varray_vertex3f);
if (fogenabled)
{
// per vertex colors if fog is used
- GL_UseColorArray();
+ GL_ColorPointer(varray_color4f);
R_FogLightningBeam_Vertex3f_Color4f(varray_vertex3f, varray_color4f, 12, r_lightningbeam_color_red.value, r_lightningbeam_color_green.value, r_lightningbeam_color_blue.value, 1);
}
else
Read all incoming data from the server
===============
*/
-int CL_ReadFromServer (void)
+int CL_ReadFromServer(void)
{
- int ret, netshown;
-
- cl.oldtime = cl.time;
- cl.time += cl.frametime;
-
- netshown = false;
- do
- {
- ret = CL_GetMessage ();
- if (ret == -1)
- Host_Error ("CL_ReadFromServer: lost server connection");
- if (!ret)
- break;
-
- cl.last_received_message = realtime;
-
- if (cl_shownet.integer)
- netshown = true;
-
- CL_ParseServerMessage ();
- }
- while (ret && cls.state == ca_connected);
-
- if (netshown)
- Con_Printf ("\n");
+ CL_ReadDemoMessage();
r_refdef.numentities = 0;
cl_num_entities = 0;
if (cls.state == ca_connected && cls.signon == SIGNONS)
{
- CL_RelinkEntities ();
+ CL_RelinkEntities();
// run cgame code (which can add more entities)
CL_CGVM_Frame();
}
-//
-// bring the links up to date
-//
return 0;
}
CL_SendCmd
=================
*/
-void CL_SendCmd (void)
+void CL_SendCmd(void)
{
- usercmd_t cmd;
-
- if (cls.state != ca_connected)
- return;
+ usercmd_t cmd;
if (cls.signon == SIGNONS)
{
- // get basic movement from keyboard
- CL_BaseMove (&cmd);
+ // get basic movement from keyboard
+ CL_BaseMove(&cmd);
- IN_PreMove(); // OS independent code
+ // OS independent code
+ IN_PreMove();
- // allow mice or other external controllers to add to the move
- IN_Move (&cmd);
+ // allow mice or other external controllers to add to the move
+ IN_Move(&cmd);
- IN_PostMove(); // OS independent code
+ // OS independent code
+ IN_PostMove();
- // send the unreliable message
- CL_SendMove (&cmd);
+ // send the unreliable message
+ CL_SendMove(&cmd);
}
-#ifndef NOROUTINGFIX
- else if (cls.signon == 0 && !cls.demoplayback)
- {
- // LordHavoc: fix for NAT routing of netquake:
- // bounce back a clc_nop message to the newly allocated server port,
- // to establish a routing connection for incoming frames,
- // the server waits for this before sending anything
- if (realtime > cl.sendnoptime)
- {
- cl.sendnoptime = realtime + 3;
- Con_DPrintf("sending clc_nop to get server's attention\n");
- {
- sizebuf_t buf;
- qbyte data[128];
- buf.maxsize = 128;
- buf.cursize = 0;
- buf.data = data;
- MSG_WriteByte(&buf, clc_nop);
- if (NET_SendUnreliableMessage (cls.netcon, &buf) == -1)
- {
- Con_Printf ("CL_SendCmd: lost server connection\n");
- CL_Disconnect ();
- }
- }
- }
- }
-#endif
if (cls.demoplayback)
{
- SZ_Clear (&cls.message);
+ SZ_Clear(&cls.message);
return;
}
-// send the reliable message
- if (!cls.message.cursize)
- return; // no message at all
-
- if (!NET_CanSendMessage (cls.netcon))
+ // send the reliable message (forwarded commands) if there is one
+ if (cls.message.cursize && NetConn_CanSendMessage(cls.netcon))
{
- Con_DPrintf ("CL_WriteToServer: can't send\n");
if (developer.integer)
+ {
+ Con_Printf("CL_SendCmd: sending reliable message:\n");
SZ_HexDumpToConsole(&cls.message);
- return;
+ }
+ if (NetConn_SendReliableMessage(cls.netcon, &cls.message) == -1)
+ Host_Error("CL_WriteToServer: lost server connection");
+ SZ_Clear(&cls.message);
}
-
- if (NET_SendMessage (cls.netcon, &cls.message) == -1)
- Host_Error ("CL_WriteToServer: lost server connection");
-
- SZ_Clear (&cls.message);
}
// LordHavoc: pausedemo command
Con_Printf("Demo unpaused\n");
}
-/*
-======================
-CL_PModel_f
-LordHavoc: Intended for Nehahra, I personally think this is dumb, but Mindcrime won't listen.
-======================
-*/
-static void CL_PModel_f (void)
-{
- int i;
- eval_t *val;
-
- if (Cmd_Argc () == 1)
- {
- Con_Printf ("\"pmodel\" is \"%s\"\n", cl_pmodel.string);
- return;
- }
- i = atoi(Cmd_Argv(1));
-
- if (cmd_source == src_command)
- {
- if (cl_pmodel.integer == i)
- return;
- Cvar_SetValue ("_cl_pmodel", i);
- if (cls.state == ca_connected)
- Cmd_ForwardToServer ();
- return;
- }
-
- host_client->pmodel = i;
- if ((val = GETEDICTFIELDVALUE(EDICT_NUM(host_client->edictnumber), eval_pmodel)))
- val->_float = i;
-}
-
/*
======================
CL_Fog_f
*/
void CL_Init (void)
{
- cl_scores_mempool = Mem_AllocPool("client player info");
cl_entities_mempool = Mem_AllocPool("client entities");
cl_refdef_mempool = Mem_AllocPool("refdef");
//
// register our commands
//
- Cvar_RegisterVariable (&cl_name);
- Cvar_RegisterVariable (&cl_color);
- if (gamemode == GAME_NEHAHRA)
- Cvar_RegisterVariable (&cl_pmodel);
Cvar_RegisterVariable (&cl_upspeed);
Cvar_RegisterVariable (&cl_forwardspeed);
Cvar_RegisterVariable (&cl_backspeed);
// LordHavoc: added pausedemo
Cmd_AddCommand ("pausedemo", CL_PauseDemo_f);
- if (gamemode == GAME_NEHAHRA)
- Cmd_AddCommand ("pmodel", CL_PModel_f);
Cvar_RegisterVariable(&r_draweffects);
Cvar_RegisterVariable(&cl_explosions);