From 36f35cff78ae6dfffc6f6c72e626eaba9d2cccc0 Mon Sep 17 00:00:00 2001 From: Spoike Date: Sun, 10 Jun 2007 05:14:38 +0000 Subject: [PATCH] added gl_texturemode2d fixed an nq network message corruption bug with large reliables. CSQC is supported on the server with the DP7 protocol sv_listen_qw can be switched off leaving sv_listen_dp enabled in order to force DP to connect with a specific protocol. This needs to be improved, but works well enough for what it was added for. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2514 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/clq3defs.h | 2 +- engine/client/renderer.c | 3 ++ engine/common/bothdefs.h | 23 +++++++++++++- engine/common/net_chan.c | 14 ++++---- engine/common/net_wins.c | 4 +-- engine/common/protocol.h | 1 + engine/gl/gl_draw.c | 69 +++++++++++++++++++++++++++++++++------- engine/server/sv_ents.c | 5 ++- engine/server/sv_main.c | 41 +++++++++++++++++------- engine/server/sv_send.c | 27 +++++++++++++++- engine/server/sv_user.c | 20 ++++++++++-- 11 files changed, 171 insertions(+), 38 deletions(-) diff --git a/engine/client/clq3defs.h b/engine/client/clq3defs.h index 428dda204..ec5d8e85e 100644 --- a/engine/client/clq3defs.h +++ b/engine/client/clq3defs.h @@ -15,7 +15,7 @@ typedef struct { int entityNum; // entity the contacted surface is a part of } q3trace_t; -#define Q3_NOENCRYPT //a debugging property, makes it incompatable with q3 +//#define Q3_NOENCRYPT //a debugging property, makes it incompatable with q3 #define MAX_Q3_STATS 16 #define MAX_Q3_PERSISTANT 16 diff --git a/engine/client/renderer.c b/engine/client/renderer.c index 701cc6fe0..4fa66a38b 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -30,6 +30,7 @@ void SCR_Viewsize_Callback (struct cvar_s *var, char *oldvalue); void SCR_Fov_Callback (struct cvar_s *var, char *oldvalue); #if defined(RGLQUAKE) void GL_Texturemode_Callback (struct cvar_s *var, char *oldvalue); +void GL_Texturemode2d_Callback (struct cvar_s *var, char *oldvalue); void GL_Texture_Anisotropic_Filtering_Callback (struct cvar_s *var, char *oldvalue); #endif @@ -105,6 +106,7 @@ static cvar_t vid_desktopsettings = SCVARF("vid_desktopsettings", "0", CVAR_ARCH #if defined(RGLQUAKE) cvar_t gl_texturemode = SCVARFC("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE|CVAR_RENDERERCALLBACK, GL_Texturemode_Callback); +cvar_t gl_texturemode2d = SCVARFC("gl_texturemode2d", "GL_LINEAR", CVAR_ARCHIVE|CVAR_RENDERERCALLBACK, GL_Texturemode2d_Callback); cvar_t gl_texture_anisotropic_filtering = SCVARFC("gl_texture_anisotropic_filtering", "0", CVAR_ARCHIVE|CVAR_RENDERERCALLBACK, GL_Texture_Anisotropic_Filtering_Callback); cvar_t gl_conback = SCVARF("gl_conback", "", CVAR_RENDERERCALLBACK); cvar_t gl_font = SCVARF("gl_font", "", CVAR_RENDERERCALLBACK); @@ -354,6 +356,7 @@ void GLRenderer_Init(void) Cvar_Register (&r_drawdisk, GLRENDEREROPTIONS); Cvar_Register (&gl_texturemode, GLRENDEREROPTIONS); + Cvar_Register (&gl_texturemode2d, GLRENDEREROPTIONS); Cvar_Register (&gl_texture_anisotropic_filtering, GLRENDEREROPTIONS); Cvar_Register (&gl_savecompressedtex, GLRENDEREROPTIONS); Cvar_Register (&gl_compress, GLRENDEREROPTIONS); diff --git a/engine/common/bothdefs.h b/engine/common/bothdefs.h index b67fa3094..d4e1ae27e 100644 --- a/engine/common/bothdefs.h +++ b/engine/common/bothdefs.h @@ -444,7 +444,28 @@ STAT_H2_MAXHEALTH, STAT_H2_MAXMANA, STAT_H2_FLAGS, -MAX_CL_STATS = 128 +MAX_CL_STATS = 256 + + +#define STAT_MOVEVARS_WALLFRICTION 237 // DP +#define STAT_MOVEVARS_FRICTION 238 // DP +#define STAT_MOVEVARS_WATERFRICTION 239 // DP +#define STAT_MOVEVARS_TICRATE 240 // DP +#define STAT_MOVEVARS_TIMESCALE 241 // DP +#define STAT_MOVEVARS_GRAVITY 242 // DP +#define STAT_MOVEVARS_STOPSPEED 243 // DP +#define STAT_MOVEVARS_MAXSPEED 244 // DP +#define STAT_MOVEVARS_SPECTATORMAXSPEED 245 // DP +#define STAT_MOVEVARS_ACCELERATE 246 // DP +#define STAT_MOVEVARS_AIRACCELERATE 247 // DP +#define STAT_MOVEVARS_WATERACCELERATE 248 // DP +#define STAT_MOVEVARS_ENTGRAVITY 249 // DP +#define STAT_MOVEVARS_JUMPVELOCITY 250 // DP +#define STAT_MOVEVARS_EDGEFRICTION 251 // DP +#define STAT_MOVEVARS_MAXAIRSPEED 252 // DP +#define STAT_MOVEVARS_STEPHEIGHT 253 // DP +#define STAT_MOVEVARS_AIRACCEL_QW 254 // DP +#define STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION 255 // DP }; // diff --git a/engine/common/net_chan.c b/engine/common/net_chan.c index 683b128ae..56e114371 100644 --- a/engine/common/net_chan.c +++ b/engine/common/net_chan.c @@ -373,15 +373,17 @@ void Netchan_Transmit (netchan_t *chan, int length, qbyte *data, int rate) i = MAX_NQDATAGRAM; SZ_Write (&send, chan->reliable_buf+chan->reliable_start, i); - if (send.cursize + length < send.maxsize) - { //throw the unreliable packet into the same one as the reliable (but not sent reliably) - SZ_Write (&send, data, length); - length = 0; - } - if (chan->reliable_start+i == chan->reliable_length) + { + if (send.cursize + length < send.maxsize) + { //throw the unreliable packet into the same one as the reliable (but not sent reliably) + SZ_Write (&send, data, length); + length = 0; + } + *(int*)send_buf = BigLong(NETFLAG_DATA | NETFLAG_EOM | send.cursize); + } else *(int*)send_buf = BigLong(NETFLAG_DATA | send.cursize); NET_SendPacket (chan->sock, send.cursize, send.data, chan->remote_address); diff --git a/engine/common/net_wins.c b/engine/common/net_wins.c index ebd86b14c..8b0dc7680 100644 --- a/engine/common/net_wins.c +++ b/engine/common/net_wins.c @@ -80,7 +80,7 @@ extern cvar_t sv_port_ipx; extern cvar_t sv_port_tcp; #endif -extern cvar_t sv_public, sv_listen; +extern cvar_t sv_public, sv_listen_qw, sv_listen_nq, sv_listen_dp; static qboolean allowconnects = false; @@ -2092,7 +2092,7 @@ void NET_InitServer(void) int port; port = PORT_SERVER; - if (sv_listen.value) + if (sv_listen_nq.value || sv_listen_dp.value || sv_listen_qw.value) { allowconnects = true; diff --git a/engine/common/protocol.h b/engine/common/protocol.h index 25370139c..589a72bb8 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -259,6 +259,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define svcdp_precache 54 // [short] precacheindex [string] filename, precacheindex is + 0 for modelindex and +32768 for soundindex #define svcdp_spawnbaseline2 55 #define svcdp_entities 57 +#define svcdp_csqcentities 58 diff --git a/engine/gl/gl_draw.c b/engine/gl/gl_draw.c index dfdd7b673..b4269a41f 100644 --- a/engine/gl/gl_draw.c +++ b/engine/gl/gl_draw.c @@ -112,6 +112,7 @@ int gl_alpha_format = 4; int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST; int gl_filter_max = GL_LINEAR; +int gl_filter_max_2d = GL_LINEAR; int texels; @@ -143,6 +144,7 @@ static gltexture_t *gltextures; int scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH]; qbyte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH*BLOCK_HEIGHT]; qboolean scrap_dirty; +int scrap_usedcount; int scrap_texnum; // returns a texture number and the position inside it @@ -180,6 +182,9 @@ int Scrap_AllocBlock (int w, int h, int *x, int *y) for (i=0 ; istring ) ) + break; + if (!Q_strcasecmp (modes[i].altname, var->string ) ) + break; + } + if (i == sizeof(modes)/sizeof(modes[0])) + { + Con_Printf ("bad gl_texturemode name\n"); + return; + } + +// gl_filter_min = modes[i].minimize; + gl_filter_max_2d = modes[i].maximize; + + // change all the existing mipmap texture objects + for (glt=gltextures ; glt ; glt=glt->next) + { + if (!glt->mipmap) + { + GL_Bind (glt->texnum); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max_2d); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max_2d); + } + } + Scrap_Upload(); +} #ifdef Q3SHADERS #define FOG_TEXTURE_WIDTH 32 @@ -2927,8 +2972,8 @@ qboolean GL_UploadCompressed (qbyte *file, int *out_width, int *out_height, unsi } else { - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max_2d); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max_2d); } return true; } @@ -3109,8 +3154,8 @@ done: } else { - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max_2d); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max_2d); } } @@ -3319,8 +3364,8 @@ done: ; } else { - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max_2d); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max_2d); } } @@ -3512,8 +3557,8 @@ void GL_UploadBump(qbyte *data, int width, int height, qboolean mipmap, float bu } else { - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max_2d); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max_2d); } // if (gl_texturefilteranisotropic) @@ -3604,8 +3649,8 @@ done: ; } else { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max_2d); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max_2d); } } #endif diff --git a/engine/server/sv_ents.c b/engine/server/sv_ents.c index eac2ff524..c9701c89b 100644 --- a/engine/server/sv_ents.c +++ b/engine/server/sv_ents.c @@ -343,7 +343,10 @@ void SV_EmitCSQCUpdate(client_t *client, sizebuf_t *msg) if (!writtenheader) { writtenheader=true; - MSG_WriteByte(msg, svc_csqcentities); + if (client->protocol != SCP_QUAKEWORLD) + MSG_WriteByte(msg, svcdp_csqcentities); + else + MSG_WriteByte(msg, svc_csqcentities); } MSG_WriteShort(msg, ent->entnum); if (sv.csqcdebug) //optional extra. diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index a76b09650..4fbbde520 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -114,7 +114,9 @@ cvar_t allow_download_wads = SCVAR("allow_download_wads", "1"); cvar_t allow_download_configs = SCVAR("allow_download_configs", "0"); cvar_t sv_public = SCVAR("sv_public", "0"); -cvar_t sv_listen = SCVAR("sv_listen", "1"); +cvar_t sv_listen_qw = FCVAR("sv_listen_qw", "sv_listen", "1", 0); +cvar_t sv_listen_nq = SCVAR("sv_listen_nq", "0"); +cvar_t sv_listen_dp = SCVAR("sv_listen_dp", "1"); cvar_t sv_reportheartbeats = SCVAR("sv_reportheartbeats", "1"); cvar_t sv_highchars = SCVAR("sv_highchars", "1"); cvar_t sv_loadentfiles = SCVAR("sv_loadentfiles", "1"); @@ -1226,11 +1228,12 @@ void SVC_GetChallenge (void) } #endif } - Netchan_OutOfBand(NS_SERVER, net_from, over-buf, buf); + if (sv_listen_qw.value) + Netchan_OutOfBand(NS_SERVER, net_from, over-buf, buf); - if (sv_listen.value >= 2) + if (sv_listen_dp.value) { - //dp can respond to this (and fte won't get confused because the challenge will be wrong) + //dp (protocol6 upwards) can respond to this (and fte won't get confused because the challenge will be wrong) buf = va("challenge "DISTRIBUTION"%i", svs.challenges[i].challenge); Netchan_OutOfBand(NS_SERVER, net_from, strlen(buf)+1, buf); } @@ -1448,7 +1451,7 @@ client_t *SVC_DirectConnect(void) if (*(Cmd_Argv(0)+7) == '\\') { - if (sv_listen.value < 2) + if (!sv_listen_dp.value) return NULL; Q_strncpyz (userinfo[0], net_message.data + 11, sizeof(userinfo[0])-1); @@ -1461,7 +1464,14 @@ client_t *SVC_DirectConnect(void) //it's a darkplaces client. s = Info_ValueForKey(userinfo[0], "protocols"); - if (strstr(s, "DP7")) + if (sizeofcoord != 4) + { //we allow nq with sv_listen_nq 0... + //reason: dp is too similar for concerns about unsupported code, while the main reason why we disable nq is because of the lack of challenges + //(and no, this isn't a way to bypass invalid challenges) + protocol = SCP_NETQUAKE; + Con_Printf ("* DP without sv_bigcoords 1\n"); + } + else if (strstr(s, "DP7")) protocol = SCP_DARKPLACES7; else protocol = SCP_DARKPLACES6; @@ -1636,8 +1646,12 @@ client_t *SVC_DirectConnect(void) && ( cl->netchan.qport == qport || adr.port == cl->netchan.remote_address.port )) { - if (cl->state == cs_connected) { - Con_Printf("%s:dup connect\n", NET_AdrToString (adr)); + if (cl->state == cs_connected) + { + if (cl->protocol != protocol) + Con_Printf("%s: diff prot connect\n", NET_AdrToString (adr)); + else + Con_Printf("%s:dup connect\n", NET_AdrToString (adr)); nextuserid--; return NULL; } @@ -2351,7 +2365,7 @@ void SVNQ_ConnectionlessPacket(void) if (net_from.type == NA_LOOPBACK) return; - if (sv_listen.value < 2) + if (!sv_listen_nq.value) return; if (sv_bigcoords.value) return; //no, start using dp7 instead. @@ -3074,8 +3088,11 @@ void SV_InitLocal (void) Cvar_Register (&sv_resetparms, cvargroup_servercontrol); Cvar_Register (&sv_public, cvargroup_servercontrol); - Cvar_Register (&sv_listen, cvargroup_servercontrol); - sv_listen.restriction = RESTRICT_MAX; + Cvar_Register (&sv_listen_qw, cvargroup_servercontrol); + Cvar_Register (&sv_listen_nq, cvargroup_servercontrol); + Cvar_Register (&sv_listen_dp, cvargroup_servercontrol); + sv_listen_qw.restriction = RESTRICT_MAX; + #ifdef TCPCONNECT Cvar_Register (&sv_port_tcp, cvargroup_servercontrol); sv_port_tcp.restriction = RESTRICT_MAX; @@ -3368,7 +3385,7 @@ void Master_Heartbeat (void) NET_SendPacket (NS_SERVER, strlen(string), string, sv_masterlist[i].adr); break; case true: - if (sv_listen.value>=2) //set listen to 1 to allow qw connections, 2 to allow nq connections too. + if (sv_listen_dp.value) //set listen to 1 to allow qw connections, 2 to allow nq connections too. { if (sv_reportheartbeats.value) Con_Printf ("Sending heartbeat to %s\n", NET_AdrToString (sv_masterlist[i].adr)); diff --git a/engine/server/sv_send.c b/engine/server/sv_send.c index 5576a951b..c452a1171 100644 --- a/engine/server/sv_send.c +++ b/engine/server/sv_send.c @@ -29,6 +29,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define CHAN_ITEM 3 #define CHAN_BODY 4 +extern cvar_t sv_gravity, sv_friction, sv_waterfriction, sv_gamespeed, sv_stopspeed, sv_spectatormaxspeed, sv_accelerate, sv_airaccelerate, sv_wateraccelerate, sv_edgefriction; + /* ============================================================================= @@ -1303,6 +1305,30 @@ void SV_UpdateClientStats (client_t *client, int pnum) else stats[STAT_VIEWZOOM] = ent->v->viewzoom*255; + if (host_client->protocol == SCP_DARKPLACES7) + { + float *statsf = (float*)stats; +// statsf[STAT_MOVEVARS_WALLFRICTION] = sv_wall + statsf[STAT_MOVEVARS_FRICTION] = sv_friction.value; + statsf[STAT_MOVEVARS_WATERFRICTION] = sv_waterfriction.value; + statsf[STAT_MOVEVARS_TICRATE] = 72; + statsf[STAT_MOVEVARS_TIMESCALE] = sv_gamespeed.value; + statsf[STAT_MOVEVARS_GRAVITY] = sv_gravity.value; + statsf[STAT_MOVEVARS_STOPSPEED] = sv_stopspeed.value; + statsf[STAT_MOVEVARS_MAXSPEED] = host_client->maxspeed; + statsf[STAT_MOVEVARS_SPECTATORMAXSPEED] = sv_spectatormaxspeed.value; + statsf[STAT_MOVEVARS_ACCELERATE] = sv_accelerate.value; + statsf[STAT_MOVEVARS_AIRACCELERATE] = sv_airaccelerate.value; + statsf[STAT_MOVEVARS_WATERACCELERATE] = sv_wateraccelerate.value; + statsf[STAT_MOVEVARS_ENTGRAVITY] = host_client->entgravity; + statsf[STAT_MOVEVARS_JUMPVELOCITY] = 280;//sv_jumpvelocity.value; //bah + statsf[STAT_MOVEVARS_EDGEFRICTION] = sv_edgefriction.value; + statsf[STAT_MOVEVARS_MAXAIRSPEED] = host_client->maxspeed; + statsf[STAT_MOVEVARS_STEPHEIGHT] = 18; + statsf[STAT_MOVEVARS_AIRACCEL_QW] = 1; + statsf[STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION] = sv_gravity.value; + } + SV_UpdateQCStats(ent, stats); //dmw tweek for stats @@ -1601,7 +1627,6 @@ void SV_UpdateToReliableMessages (void) } { - extern cvar_t sv_gravity; // maxspeed/entgravity changes ent = host_client->edict; diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index ca8ee0121..41ac0c48a 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -343,6 +343,23 @@ void SVNQ_New_f (void) #endif MSG_WriteString (&host_client->netchan.message,message); + if (host_client->protocol == SCP_DARKPLACES7) + { + char *f; + f = COM_LoadTempFile("csprogs.dat"); + if (f) + { + MSG_WriteByte (&host_client->netchan.message, svc_stufftext); + MSG_WriteString (&host_client->netchan.message, va("csqc_progname %s\n", "csprogs.dat")); + MSG_WriteByte (&host_client->netchan.message, svc_stufftext); + MSG_WriteString (&host_client->netchan.message, va("csqc_progsize %i\n", com_filesize)); + MSG_WriteByte (&host_client->netchan.message, svc_stufftext); + MSG_WriteString (&host_client->netchan.message, va("csqc_progcrc %i\n", QCRC_Block(f, com_filesize))); + + host_client->csqcactive = true; + } + } + MSG_WriteByte (&host_client->netchan.message, svc_serverdata); switch(host_client->protocol) { @@ -382,7 +399,6 @@ void SVNQ_New_f (void) MSG_WriteString (&host_client->netchan.message, sv.strings.sound_precache[i]); MSG_WriteByte (&host_client->netchan.message, 0); - // send music MSG_WriteByte (&host_client->netchan.message, svc_cdtrack); MSG_WriteByte (&host_client->netchan.message, sv.edicts->v->sounds); @@ -4992,7 +5008,7 @@ void SVNQ_ReadClientMove (usercmd_t *move) move->sidemove = MSG_ReadShort (); move->upmove = MSG_ReadShort (); - move->msec=100; + move->msec=(1/72.0f)*1000;//MSG_ReadFloat; // read buttons if (host_client->protocol == SCP_DARKPLACES6 || host_client->protocol == SCP_DARKPLACES7)