X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=cl_main.c;h=c55c543e3537e2d48470b840016e3148f56c5564;hb=HEAD;hp=6e385c8105942c68d82d9b59bf9dfb9c7849b94d;hpb=354208009f5868b5eb706c718f8bb066b77c37de;p=xonotic%2Fdarkplaces.git diff --git a/cl_main.c b/cl_main.c index 6e385c81..71443f14 100644 --- a/cl_main.c +++ b/cl_main.c @@ -37,6 +37,7 @@ cvar_t csqc_progcrc = {CF_CLIENT | CF_READONLY, "csqc_progcrc","-1","CRC of cspr cvar_t csqc_progsize = {CF_CLIENT | CF_READONLY, "csqc_progsize","-1","file size of csprogs.dat file to load (-1 is none), only used during level changes and then reset to -1"}; cvar_t csqc_usedemoprogs = {CF_CLIENT, "csqc_usedemoprogs","1","use csprogs stored in demos"}; cvar_t csqc_polygons_defaultmaterial_nocullface = {CF_CLIENT, "csqc_polygons_defaultmaterial_nocullface", "0", "use 'cull none' behavior in the default shader for rendering R_PolygonBegin - warning: enabling this is not consistent with FTEQW behavior on this feature"}; +cvar_t csqc_lowres = {CF_CLIENT, "csqc_lowres", "0", "make EXT_CSQC functions CSQC_UpdateView(), setproperty(), getproperty() use the virtual 2D resolution (FTEQW/QSS behaviour) instead of the real resolution (DP behaviour); this mode is always used for the CSQC_SIMPLE (aka hud-only) CSQC_DrawHud() parameters; see cvars vid_conheight and vid_conwidth"}; cvar_t cl_shownet = {CF_CLIENT, "cl_shownet","0","1 = print packet size, 2 = print packet message list"}; cvar_t cl_nolerp = {CF_CLIENT, "cl_nolerp", "0","network update smoothing"}; @@ -61,6 +62,7 @@ cvar_t freelook = {CF_CLIENT | CF_ARCHIVE, "freelook", "1","mouse controls pitch cvar_t cl_autodemo = {CF_CLIENT | CF_ARCHIVE, "cl_autodemo", "0", "records every game played, using the date/time and map name to name the demo file" }; cvar_t cl_autodemo_nameformat = {CF_CLIENT | CF_ARCHIVE, "cl_autodemo_nameformat", "autodemos/%Y-%m-%d_%H-%M", "The format of the cl_autodemo filename, followed by the map name (the date is encoded using strftime escapes)" }; cvar_t cl_autodemo_delete = {CF_CLIENT, "cl_autodemo_delete", "0", "Delete demos after recording. This is a bitmask, bit 1 gives the default, bit 0 the value for the current demo. Thus, the values are: 0 = disabled; 1 = delete current demo only; 2 = delete all demos except the current demo; 3 = delete all demos from now on" }; +cvar_t cl_startdemos = {CF_CLIENT | CF_ARCHIVE, "cl_startdemos", "1", "1 enables the `startdemos` loop used in Quake and some mods, 0 goes straight to the menu"}; cvar_t r_draweffects = {CF_CLIENT, "r_draweffects", "1","renders temporary sprite effects"}; @@ -257,7 +259,7 @@ void CL_SetInfo(const char *key, const char *value, qbool send, qbool allowstark MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd); MSG_WriteString(&cls.netcon->message, va(vabuf, sizeof(vabuf), "setinfo \"%s\" \"%s\"", key, value)); } - else if (!strcasecmp(key, "name")) + else if (!strcasecmp(key, "_cl_name") || !strcasecmp(key, "name")) { MSG_WriteByte(&cls.netcon->message, clc_stringcmd); MSG_WriteString(&cls.netcon->message, va(vabuf, sizeof(vabuf), "name \"%s\"", value)); @@ -439,6 +441,8 @@ void CL_DisconnectEx(qbool kicked, const char *fmt, ... ) MSG_WriteByte(&buf, clc_disconnect); if(cls.protocol == PROTOCOL_DARKPLACES8) MSG_WriteString(&buf, reason); + // DP8 TODO: write a simpler func that Sys_HandleCrash() calls + // to send a disconnect message indicating we crashed } NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000, 0, false); NetConn_SendUnreliableMessage(cls.netcon, &buf, cls.protocol, 10000, 0, false); @@ -447,10 +451,14 @@ void CL_DisconnectEx(qbool kicked, const char *fmt, ... ) NetConn_Close(cls.netcon); cls.netcon = NULL; - if(fmt) - Con_Printf("Disconnect: %s\n", reason); + + // It's possible for a server to disconnect a player with an empty reason + // which is checked here rather than above so we don't print "Disconnect by user". + if(fmt && reason[0] != '\0') + dpsnprintf(cl_connect_status, sizeof(cl_connect_status), "Disconnect: %s", reason); else - Con_Printf("Disconnected\n"); + dp_strlcpy(cl_connect_status, "Disconnected", sizeof(cl_connect_status)); + Con_Printf("%s\n", cl_connect_status); } cls.state = ca_disconnected; cl.islocalgame = false; @@ -492,7 +500,7 @@ static void CL_Reconnect_f(cmd_state_t *cmd) if (temp[0]) CL_EstablishConnection(temp, -1); else - Con_Printf("Reconnect to what server? (you have not connected to a server yet)\n"); + Con_Printf(CON_WARN "Reconnect to what server? (you have not connected to a server yet)\n"); return; } // if connected, do something based on protocol @@ -572,18 +580,13 @@ void CL_EstablishConnection(const char *address, int firstarg) if (Sys_CheckParm("-benchmark")) return; - // clear menu's connect error message -#ifdef CONFIG_MENU - M_Update_Return_Reason(""); -#endif - // make sure the client ports are open before attempting to connect NetConn_UpdateSockets(); if (LHNETADDRESS_FromString(&cls.connect_address, address, 26000) && (cls.connect_mysocket = NetConn_ChooseClientSocketForAddress(&cls.connect_address))) { cls.connect_trying = true; - cls.connect_remainingtries = 3; + cls.connect_remainingtries = 10; cls.connect_nextsendtime = 0; // only NOW, set connect_userinfo @@ -601,17 +604,13 @@ void CL_EstablishConnection(const char *address, int firstarg) *cls.connect_userinfo = 0; } -#ifdef CONFIG_MENU - M_Update_Return_Reason("Trying to connect..."); -#endif + dp_strlcpy(cl_connect_status, "Connect: pending...", sizeof(cl_connect_status)); SCR_BeginLoadingPlaque(false); } else { - Con_Print("Unable to find a suitable network socket to connect to server.\n"); -#ifdef CONFIG_MENU - M_Update_Return_Reason("No network"); -#endif + Con_Printf(CON_ERROR "Connect: failed, unable to find a network socket suitable to reach %s\n", address); + dp_strlcpy(cl_connect_status, "Connect: failed, no network", sizeof(cl_connect_status)); } } @@ -893,7 +892,7 @@ void CL_AllocLightFlash(entity_render_t *ent, matrix4x4_t *matrix, float radius, dl->die = 0; dl->cubemapname[0] = 0; if (cubemapname && cubemapname[0]) - strlcpy(dl->cubemapname, cubemapname, sizeof(dl->cubemapname)); + dp_strlcpy(dl->cubemapname, cubemapname, sizeof(dl->cubemapname)); dl->style = style; dl->shadow = shadowenable; dl->corona = corona; @@ -1175,6 +1174,7 @@ static void CL_UpdateNetworkEntity(entity_t *e, int recursionlimit, qbool interp // someone or watching a cutscene of some sort if (cl_nolerp.integer || cls.timedemo) interpolate = false; + if (e == cl.entities + cl.playerentity && cl.movement_predicted && (!cl.fixangle[1] || !cl.fixangle[0])) { VectorCopy(cl.movement_origin, origin); @@ -2093,7 +2093,7 @@ void CL_UpdateWorld(void) CL_UpdateViewModel(); // when csqc is loaded, it will call this in CSQC_UpdateView - if (!cl.csqc_loaded) + if (!CLVM_prog->loaded || CLVM_prog->flag & PRVM_CSQC_SIMPLE) { // clear the CL_Mesh_Scene() used for some engine effects CL_MeshEntities_Scene_Clear(); @@ -2162,7 +2162,7 @@ static void CL_Fog_HeightTexture_f(cmd_state_t *cmd) r_refdef.fog_end = atof(Cmd_Argv(cmd, 7)); r_refdef.fog_height = atof(Cmd_Argv(cmd, 8)); r_refdef.fog_fadedepth = atof(Cmd_Argv(cmd, 9)); - strlcpy(r_refdef.fog_height_texturename, Cmd_Argv(cmd, 10), sizeof(r_refdef.fog_height_texturename)); + dp_strlcpy(r_refdef.fog_height_texturename, Cmd_Argv(cmd, 10), sizeof(r_refdef.fog_height_texturename)); } @@ -2227,7 +2227,7 @@ void CL_Locs_FindLocationName(char *buffer, size_t buffersize, vec3_t point) cl_locnode_t *loc; loc = CL_Locs_FindNearest(point); if (loc) - strlcpy(buffer, loc->name, buffersize); + dp_strlcpy(buffer, loc->name, buffersize); else dpsnprintf(buffer, buffersize, "LOC=%.0f:%.0f:%.0f", point[0], point[1], point[2]); } @@ -2802,7 +2802,7 @@ void CL_StartVideo(void) extern cvar_t host_framerate; extern cvar_t host_speeds; -extern qbool serverlist_querystage; +extern uint8_t serverlist_querystage; double CL_Frame (double time) { static double clframetime; @@ -2857,7 +2857,7 @@ double CL_Frame (double time) // on some legacy systems, we need to sleep to keep input responsive if (cl_maxfps_alwayssleep.value > 0 && !cls.timedemo) - Sys_Sleep((int)bound(1, cl_maxfps_alwayssleep.value * 1000, 50000)); + Sys_Sleep(min(cl_maxfps_alwayssleep.value / 1000, 0.05)); } // apply slowmo scaling @@ -3119,6 +3119,7 @@ void CL_Init (void) Cmd_AddCommand(CF_CLIENT, "locs_save", CL_Locs_Save_f, "save .loc file for this map containing currently defined points and boxes"); Cvar_RegisterVariable(&csqc_polygons_defaultmaterial_nocullface); + Cvar_RegisterVariable(&csqc_lowres); Cvar_RegisterVariable (&cl_minfps); Cvar_RegisterVariable (&cl_minfps_fade);