From cea945ad5e8bde709e9425966ba16e222ebf8a0b Mon Sep 17 00:00:00 2001 From: Spoike Date: Wed, 20 Apr 2011 03:34:32 +0000 Subject: [PATCH] Fix Q2 server issues (broken predition, deltaing, gamecode cvar crashes, choke info). git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3773 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/server/q2game.h | 1 + engine/server/sv_init.c | 37 ++++++++++++++++++------------------- engine/server/sv_main.c | 12 ++++++++++-- engine/server/sv_phys.c | 2 -- engine/server/svq2_ents.c | 7 +++++-- engine/server/svq2_game.c | 14 ++++++++++---- 6 files changed, 44 insertions(+), 29 deletions(-) diff --git a/engine/server/q2game.h b/engine/server/q2game.h index d0b7d4ef8..75eec8a36 100644 --- a/engine/server/q2game.h +++ b/engine/server/q2game.h @@ -313,5 +313,6 @@ game_export_t *GetGameApi (game_import_t *import); extern game_export_t *ge; +extern int svq2_maxclients; #endif diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index 7cdae6146..5de610054 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -966,6 +966,23 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us if (newgametype != svs.gametype) { +#ifdef HLSERVER + if (newgametype != GT_HALFLIFE) + SVHL_ShutdownGame(); +#endif +#ifdef Q3SERVER + if (newgametype != GT_QUAKE3) + SVQ3_ShutdownGame(); +#endif +#ifdef Q2SERVER + if (newgametype != GT_QUAKE2) //we don't want the q2 stuff anymore. + SVQ2_ShutdownGameProgs (); +#endif +#ifdef VM_Q1 + if (newgametype != GT_Q1QVM) + Q1QVM_Shutdown(); +#endif + for (i=0 ; is.number = i+1; svs.clients[i].q2edict = q2ent; } - sv.allocated_client_slots = i; + sv.allocated_client_slots = svq2_maxclients; #endif break; case GT_QUAKE3: diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index fa8085fec..f69f35483 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -3206,7 +3206,10 @@ qboolean SV_ReadPackets (void) svs.stats.packets++; if (cl->state != cs_zombie) { - cl->send_message = true; // reply at end of frame + if (cl->send_message) + cl->chokecount++; + else + cl->send_message = true; // reply at end of frame #ifdef Q2SERVER if (cl->protocol == SCP_QUAKE2) @@ -3484,6 +3487,8 @@ void SV_Frame (void) start = Sys_DoubleTime (); svs.stats.idle += start - end; end = start; + + //qw qc uses this for newmis handling svs.framenum++; if (svs.framenum > 0x10000) svs.framenum = 0; @@ -3595,6 +3600,7 @@ void SV_MVDStream_Poll(void); } else { + isidle = idletime < 0.1; #ifdef VM_Q1 if (svs.gametype == GT_Q1QVM) { @@ -3607,8 +3613,10 @@ void SV_MVDStream_Poll(void); } } - if (!isidle || idletime > 0.1) + if (!isidle || idletime > 0.15) { + //this is the q2 frame number found in the q2 protocol. each packet should contain a new frame or interpolation gets confused + sv.framenum++; #ifdef SQL PR_SQLCycle(); diff --git a/engine/server/sv_phys.c b/engine/server/sv_phys.c index 2783672f3..39646cc3a 100644 --- a/engine/server/sv_phys.c +++ b/engine/server/sv_phys.c @@ -2029,8 +2029,6 @@ qboolean SV_Physics (void) host_frametime = sv_maxtic.value; sv.world.physicstime = sv.time; - - sv.framenum++; switch(svs.gametype) { #ifdef Q2SERVER diff --git a/engine/server/svq2_ents.c b/engine/server/svq2_ents.c index 72e4a4c0b..412a6e53c 100644 --- a/engine/server/svq2_ents.c +++ b/engine/server/svq2_ents.c @@ -570,8 +570,8 @@ void SV_WriteFrameToClient (client_t *client, sizebuf_t *msg) MSG_WriteByte (msg, svcq2_frame); MSG_WriteLong (msg, sv.framenum); MSG_WriteLong (msg, lastframe); // what we are delta'ing from - MSG_WriteByte (msg, 0);//client->surpressCount); // rate dropped packets -// client->surpressCount = 0; + MSG_WriteByte (msg, client->chokecount); // rate dropped packets + client->chokecount = 0; // send over the areabits MSG_WriteByte (msg, frame->areabytes); @@ -650,6 +650,9 @@ void SV_BuildClientFrame (client_t *client) // grab the current player_state_t frame->ps = clent->client->ps; + if (sv.paused) + frame->ps.pmove.pm_type = Q2PM_FREEZE; + sv.world.worldmodel->funcs.FatPVS(sv.world.worldmodel, org, clientpvs, sizeof(clientpvs), false); clientphs = CM_ClusterPHS (sv.world.worldmodel, clientcluster); diff --git a/engine/server/svq2_game.c b/engine/server/svq2_game.c index 93b6bcc64..73f05fb3d 100644 --- a/engine/server/svq2_game.c +++ b/engine/server/svq2_game.c @@ -9,14 +9,12 @@ qboolean SVQ2_InitGameProgs(void) } #else game_export_t *ge; - +int svq2_maxclients; void Sys_UnloadGame (void); void *Sys_GetGameAPI (void *parms); - - /* =============== PF_Unicast @@ -644,6 +642,7 @@ void SVQ2_InitWorld(void) qboolean SVQ2_InitGameProgs(void) { + extern cvar_t maxclients; volatile static game_import_t import; //volatile because msvc sucks if (COM_CheckParm("-noq2dll")) { @@ -748,9 +747,16 @@ qboolean SVQ2_InitGameProgs(void) return false; } + if (maxclients.value > MAX_CLIENTS) + Cvar_SetValue(&maxclients, MAX_CLIENTS); + + svq2_maxclients = maxclients.value; + maxclients.flags |= CVAR_LATCH; + deathmatch.flags |= CVAR_LATCH; + coop.flags |= CVAR_LATCH; + SVQ2_InitWorld(); ge->Init (); - return true; }