From f7d90f4a0abc90f267054342e42ac366ed0c37d8 Mon Sep 17 00:00:00 2001 From: Spoike Date: Sun, 23 Oct 2005 17:57:20 +0000 Subject: [PATCH] Fixed some nq server issues git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1537 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/server/sv_send.c | 136 +++++++++++++++++++++------------------- engine/server/sv_user.c | 21 ++++++- 2 files changed, 89 insertions(+), 68 deletions(-) diff --git a/engine/server/sv_send.c b/engine/server/sv_send.c index b00a1a7fc..9977fe978 100644 --- a/engine/server/sv_send.c +++ b/engine/server/sv_send.c @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -142,7 +142,7 @@ void VARGS Con_Printf (const char *fmt, ...) va_start (argptr,fmt); _vsnprintf (msg,sizeof(msg)-1, fmt,argptr); va_end (argptr); - + // add to redirected message if (sv_redirected) { @@ -169,7 +169,7 @@ void Con_TPrintf (translation_t stringnum, ...) va_start (argptr,stringnum); _vsnprintf (msg,sizeof(msg)-1, fmt,argptr); va_end (argptr); - + if (strlen (msg) + strlen(outputbuf) > sizeof(outputbuf) - 1) SV_FlushRedirect (); strcat (outputbuf, msg); @@ -204,7 +204,7 @@ void Con_DPrintf (char *fmt, ...) va_start (argptr,fmt); _vsnprintf (msg,sizeof(msg)-1, fmt,argptr); va_end (argptr); - + // add to redirected message if (sv_redirected) { @@ -274,10 +274,10 @@ void VARGS SV_ClientPrintf (client_t *cl, int level, char *fmt, ...) { va_list argptr; char string[1024]; - + if (level < cl->messagelevel) return; - + va_start (argptr,fmt); _vsnprintf (string,sizeof(string)-1, fmt,argptr); va_end (argptr); @@ -304,10 +304,10 @@ void VARGS SV_ClientTPrintf (client_t *cl, int level, translation_t stringnum, . va_list argptr; char string[1024]; char *fmt = languagetext[stringnum][cl->language]; - + if (level < cl->messagelevel) return; - + va_start (argptr,stringnum); _vsnprintf (string,sizeof(string)-1, fmt,argptr); va_end (argptr); @@ -389,7 +389,7 @@ void VARGS SV_BroadcastTPrintf (int level, translation_t stringnum, ...) if(strlen(string) >= sizeof(string)) Sys_Error("SV_BroadcastPrintf: Buffer stomped\n"); - + Sys_Printf ("%s", string); // print to the console for (i=0, cl = svs.clients ; iv->dmg_take); for (i=0 ; i<3 ; i++) MSG_WriteCoord (msg, other->v->origin[i] + 0.5*(other->v->mins[i] + other->v->maxs[i])); - + ent->v->dmg_take = 0; ent->v->dmg_save = 0; } @@ -1037,7 +1037,7 @@ void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg) if (ent->v->view_ofs[2] != DEFAULT_VIEWHEIGHT) bits |= SU_VIEWHEIGHT; - + // if (ent->v->idealpitch) // bits |= SU_IDEALPITCH; @@ -1049,16 +1049,16 @@ void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg) // items = (int)ent->v->items | ((int)val->_float << 23); // else items = (int)ent->v->items | ((int)pr_global_struct->serverflags << 28); - + bits |= SU_ITEMS; - + if ( (int)ent->v->flags & FL_ONGROUND) bits |= SU_ONGROUND; - + if ( ent->v->waterlevel >= 2) bits |= SU_INWATER; - + for (i=0 ; i<3 ; i++) { // if (ent->v->punchangle[i]) @@ -1066,7 +1066,7 @@ void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg) if (ent->v->velocity[i]) bits |= (SU_VELOCITY1<v->weaponframe) bits |= SU_WEAPONFRAME; @@ -1120,15 +1120,15 @@ void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg) } if (bits & SU_WEAPON) MSG_WriteByte (msg, SV_ModelIndex(ent->v->weaponmodel + svprogfuncs->stringtable)); - + MSG_WriteShort (msg, ent->v->health); MSG_WriteByte (msg, ent->v->currentammo); MSG_WriteByte (msg, ent->v->ammo_shells); MSG_WriteByte (msg, ent->v->ammo_nails); MSG_WriteByte (msg, ent->v->ammo_rockets); MSG_WriteByte (msg, ent->v->ammo_cells); - - //if (other && other->v->weapon) + + //if (other && other->v->weapon) //MSG_WriteByte (msg, other->v->weapon); //else //{ @@ -1238,7 +1238,7 @@ void SV_UpdateClientStats (client_t *client, int pnum) ent = client->edict; memset (stats, 0, sizeof(stats)); - + // if we are a spectator and we are tracking a player, we get his stats // so our status bar reflects his if (client->spectator && client->spec_track > 0) @@ -1276,7 +1276,7 @@ void SV_UpdateClientStats (client_t *client, int pnum) stats[STAT_ITEMS] = (int)ent->v->items | ((int)pr_global_struct->serverflags << 28); stats[STAT_VIEWHEIGHT] = ent->v->view_ofs[2]; -#ifdef PEXT_VIEW2 +#ifdef PEXT_VIEW2 if (ent->v->view2) stats[STAT_VIEW2] = NUM_FOR_EDICT(svprogfuncs, PROG_TO_EDICT(svprogfuncs, ent->v->view2)); else @@ -1336,7 +1336,7 @@ void SV_UpdateClientStats (client_t *client, int pnum) } else #endif - + if (pnum) { if (stats[i] >=0 && stats[i] <= 255) @@ -1467,7 +1467,7 @@ client_t *SV_SplitClientDest(client_t *client, qbyte first, int size) ClientReliableWrite_Begin (client, first, size); return client; } -} +} /* ======================= SV_UpdateToReliableMessages @@ -1498,7 +1498,7 @@ void SV_UpdateToReliableMessages (void) MSG_WriteByte (&sv.reliable_datagram, i); MSG_WriteString (&sv.reliable_datagram, "topcolor"); MSG_WriteString (&sv.reliable_datagram, Info_ValueForKey(host_client->userinfo, "topcolor")); - + MSG_WriteByte (&sv.reliable_datagram, svc_setinfo); MSG_WriteByte (&sv.reliable_datagram, i); MSG_WriteString (&sv.reliable_datagram, "bottomcolor"); @@ -1589,7 +1589,7 @@ void SV_UpdateToReliableMessages (void) extern cvar_t sv_gravity; // maxspeed/entgravity changes ent = host_client->edict; - + newval = ent->v->gravity*sv_gravity.value; if (progstype != PROG_QW) { @@ -1599,8 +1599,12 @@ void SV_UpdateToReliableMessages (void) if (host_client->entgravity != newval) { - sp = SV_SplitClientDest(host_client, svc_entgravity, 5); - ClientReliableWrite_Float(sp, newval/movevars.gravity); //lie to the client in a cunning way + if (ISQWCLIENT(host_client)) + { + Con_Printf("svc_entgravity\n"); + sp = SV_SplitClientDest(host_client, svc_entgravity, 5); + ClientReliableWrite_Float(sp, newval/movevars.gravity); //lie to the client in a cunning way + } host_client->entgravity = newval; } newval = ent->v->maxspeed; @@ -1617,29 +1621,31 @@ void SV_UpdateToReliableMessages (void) #endif if (host_client->maxspeed != newval) { //MSVC can really suck at times (optimiser bug) - - if (host_client->controller) - { //this is a slave client. - //find the right number and send. - int pnum = 0; - client_t *sp; - for (sp = host_client->controller; sp; sp = sp->controlled) - { - if (sp == host_client) - break; - pnum++; - } - sp = host_client->controller; - - ClientReliableWrite_Begin (sp, svc_choosesplitclient, 7); - ClientReliableWrite_Byte (sp, pnum); - ClientReliableWrite_Byte (sp, svc_maxspeed); - ClientReliableWrite_Float(sp, newval); - } - else + if (ISQWCLIENT(host_client)) { - ClientReliableWrite_Begin(host_client, svc_maxspeed, 5); - ClientReliableWrite_Float(host_client, newval); + if (host_client->controller) + { //this is a slave client. + //find the right number and send. + int pnum = 0; + client_t *sp; + for (sp = host_client->controller; sp; sp = sp->controlled) + { + if (sp == host_client) + break; + pnum++; + } + sp = host_client->controller; + + ClientReliableWrite_Begin (sp, svc_choosesplitclient, 7); + ClientReliableWrite_Byte (sp, pnum); + ClientReliableWrite_Byte (sp, svc_maxspeed); + ClientReliableWrite_Float(sp, newval); + } + else + { + ClientReliableWrite_Begin(host_client, svc_maxspeed, 5); + ClientReliableWrite_Float(host_client, newval); + } } host_client->maxspeed = newval; } @@ -1716,13 +1722,13 @@ void SV_UpdateToReliableMessages (void) } } - SZ_Clear (&sv.reliable_datagram); + SZ_Clear (&sv.reliable_datagram); SZ_Clear (&sv.datagram); #ifdef NQPROT SZ_Clear (&sv.nqreliable_datagram); SZ_Clear (&sv.nqdatagram); #endif - SZ_Clear (&sv.q2reliable_datagram); + SZ_Clear (&sv.q2reliable_datagram); SZ_Clear (&sv.q2datagram); } @@ -1818,7 +1824,7 @@ void SV_SendClientMessages (void) // it'll fit SZ_Write(&c->netchan.message, c->backbuf_data[0], c->backbuf_size[0]); - + //move along, move along for (j = 1; j < c->num_backbuf; j++) { @@ -1880,7 +1886,7 @@ void SV_SendClientMessages (void) SV_SendClientDatagram (c); else Netchan_Transmit (&c->netchan, 0, NULL, SV_RateForClient(c)); // just update reliable - + } SV_CleanupEnts(); @@ -1946,7 +1952,7 @@ void SV_SendMVDMessage(void) msg.cursize = 0; msg.allowoverflow = true; msg.overflowed = false; - + for (i=0, c = svs.clients ; istate != cs_spawned) @@ -1967,7 +1973,7 @@ void SV_SendMVDMessage(void) stats[STAT_ROCKETS] = ent->v->ammo_rockets; stats[STAT_CELLS] = ent->v->ammo_cells; stats[STAT_ACTIVEWEAPON] = ent->v->weapon; - + // stuff the sigil bits into the high bits of items for sbar stats[STAT_ITEMS] = (int)ent->v->items | ((int)pr_global_struct->serverflags << 28); @@ -2040,7 +2046,7 @@ void SV_SendMessagesToAll (void) for (i=0, c = svs.clients ; istate) // FIXME: should this only send to active? c->send_message = true; - + SV_SendClientMessages (); } diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index cad2bfc68..998b515bc 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -2963,6 +2963,7 @@ ucmd_t ucmdsq2[] = { }; #endif +extern ucmd_t nqucmds[]; /* ================== SV_ExecuteUserCommand @@ -3001,6 +3002,9 @@ void SV_ExecuteUserCommand (char *s, qboolean fromQC) u = ucmdsq2; else #endif + if (ISNQCLIENT(host_client)) + u = nqucmds; + else u=ucmds; for ( ; u->name ; u++) @@ -3100,6 +3104,9 @@ void SVNQ_Spawn_f (void) // send all current light styles for (i=0 ; i= MAX_STANDARDLIGHTSTYLES && host_client->protocol != SCP_DARKPLACES7) + break; //dp7 clients support more lightstyles. + ClientReliableWrite_Begin (host_client, svc_lightstyle, 3 + (sv.lightstyles[i] ? strlen(sv.lightstyles[i]) : 1)); ClientReliableWrite_Byte (host_client, (char)i); @@ -3459,6 +3466,7 @@ ucmd_t nqucmds[] = {"ban", NULL}, {"vote", SV_Vote_f}, + {"setinfo", SV_SetInfo_f}, {"playermodel", NULL}, {"playerskin", NULL}, {"rate", SV_Rate_f}, @@ -3469,7 +3477,7 @@ ucmd_t nqucmds[] = {NULL, NULL} }; - +/* void SVNQ_ExecuteUserCommand (char *s) { client_t *oldhost = host_client; @@ -3484,7 +3492,7 @@ void SVNQ_ExecuteUserCommand (char *s) { if (!strcmp (Cmd_Argv(0), u->name) ) { - if (/*!fromQC && */!u->noqchandling) + if (/ *!fromQC && * /!u->noqchandling) if (PR_UserCmd(s)) { host_client = oldhost; @@ -3512,6 +3520,7 @@ void SVNQ_ExecuteUserCommand (char *s) if (!u->name) Con_Printf("%s tried to \"%s\"\n", host_client->name, s); } +*/ #endif @@ -4677,6 +4686,9 @@ void SVQ2_ExecuteClientMessage (client_t *cl) s = MSG_ReadString (); SV_ExecuteUserCommand (s, false); + host_client = cl; + sv_player = cl->edict; + if (cl->state == cs_zombie) return; // disconnect command break; @@ -4862,7 +4874,10 @@ void SVNQ_ExecuteClientMessage (client_t *cl) case clc_stringcmd: s = MSG_ReadString (); - SVNQ_ExecuteUserCommand (s); + SV_ExecuteUserCommand (s, false); + + host_client = cl; + sv_player = cl->edict; break; }